2 Copyright (C) 2004 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __ardour_gtk_processor_box__
21 #define __ardour_gtk_processor_box__
26 #include <boost/function.hpp>
28 #include <gtkmm/box.h>
29 #include <gtkmm/eventbox.h>
30 #include <gtkmm/menu.h>
31 #include <gtkmm/scrolledwindow.h>
32 #include "gtkmm2ext/dndtreeview.h"
33 #include "gtkmm2ext/auto_spin.h"
34 #include "gtkmm2ext/click_box.h"
35 #include "gtkmm2ext/dndvbox.h"
36 #include "gtkmm2ext/pixfader.h"
38 #include "pbd/stateful.h"
39 #include "pbd/signals.h"
41 #include "ardour/types.h"
42 #include "ardour/ardour.h"
43 #include "ardour/plugin_insert.h"
44 #include "ardour/port_insert.h"
45 #include "ardour/processor.h"
46 #include "ardour/route.h"
47 #include "ardour/session_handle.h"
49 #include "pbd/fastlog.h"
51 #include "plugin_interest.h"
52 #include "io_selector.h"
55 #include "window_proxy.h"
57 class MotionController;
60 class RouteRedirectSelection;
77 /** A WindowProxy for Processor UI windows; it knows how to ask a ProcessorBox
78 * to create a UI window for a particular processor.
80 class ProcessorWindowProxy : public WindowProxy<Gtk::Window>
83 ProcessorWindowProxy (std::string const &, XMLNode const *, ProcessorBox *, boost::weak_ptr<ARDOUR::Processor>);
86 bool rc_configured () const {
90 boost::weak_ptr<ARDOUR::Processor> processor () const {
97 ProcessorBox* _processor_box;
98 boost::weak_ptr<ARDOUR::Processor> _processor;
101 class ProcessorEntry : public Gtkmm2ext::DnDVBoxChild, public sigc::trackable
104 ProcessorEntry (boost::shared_ptr<ARDOUR::Processor>, Width);
106 Gtk::EventBox& action_widget ();
107 Gtk::Widget& widget ();
108 std::string drag_text () const;
109 void set_visual_state (Gtk::StateType);
117 void set_position (Position);
118 boost::shared_ptr<ARDOUR::Processor> processor () const;
119 void set_enum_width (Width);
120 virtual void set_pixel_width (int) {}
128 void active_toggled ();
129 void processor_active_changed ();
130 void processor_property_changed (const PBD::PropertyChange&);
131 std::string name () const;
132 void setup_visuals ();
135 Gtk::EventBox _event_box;
138 Gtk::CheckButton _active;
139 boost::shared_ptr<ARDOUR::Processor> _processor;
141 Gtk::StateType _visual_state;
143 PBD::ScopedConnection active_connection;
144 PBD::ScopedConnection name_connection;
147 class SendProcessorEntry : public ProcessorEntry
150 SendProcessorEntry (boost::shared_ptr<ARDOUR::Send>, Width);
152 static void setup_slider_pix ();
154 void set_enum_width (Width, int);
155 void set_pixel_width (int);
159 void gain_adjusted ();
161 boost::shared_ptr<ARDOUR::Send> _send;
162 Gtk::Adjustment _adjustment;
163 Gtkmm2ext::HSliderController _fader;
164 bool _ignore_gain_change;
165 PBD::ScopedConnection send_gain_connection;
167 static Glib::RefPtr<Gdk::Pixbuf> _slider;
170 class ProcessorBox : public Gtk::HBox, public PluginInterestedObject, public ARDOUR::SessionHandlePtr
173 ProcessorBox (ARDOUR::Session*, boost::function<PluginSelector*()> get_plugin_selector,
174 RouteRedirectSelection&, MixerStrip* parent, bool owner_is_mixer = false);
177 void set_route (boost::shared_ptr<ARDOUR::Route>);
178 void set_width (Width);
182 void select_all_processors ();
183 void deselect_all_processors ();
184 void select_all_plugins ();
185 void select_all_inserts ();
186 void select_all_sends ();
188 Gtk::Window* get_processor_ui (boost::shared_ptr<ARDOUR::Processor>) const;
189 void toggle_edit_processor (boost::shared_ptr<ARDOUR::Processor>);
191 sigc::signal<void,boost::shared_ptr<ARDOUR::Processor> > ProcessorSelected;
192 sigc::signal<void,boost::shared_ptr<ARDOUR::Processor> > ProcessorUnselected;
194 static void register_actions();
198 /* prevent copy construction */
199 ProcessorBox (ProcessorBox const &);
201 boost::shared_ptr<ARDOUR::Route> _route;
202 MixerStrip* _parent_strip; // null if in RouteParamsUI
203 bool _owner_is_mixer;
205 PBD::ScopedConnectionList _mixer_strip_connections;
206 PBD::ScopedConnectionList _route_connections;
208 boost::function<PluginSelector*()> _get_plugin_selector;
210 boost::shared_ptr<ARDOUR::Processor> _processor_being_created;
212 ARDOUR::Placement _placement;
214 RouteRedirectSelection& _rr_selection;
216 void route_going_away ();
218 void selection_changed ();
220 Gtk::EventBox processor_eventbox;
221 Gtk::HBox processor_hpacker;
222 Gtkmm2ext::DnDVBox<ProcessorEntry> processor_display;
223 Gtk::ScrolledWindow processor_scroller;
225 void object_drop (Gtkmm2ext::DnDVBox<ProcessorEntry> *, ProcessorEntry *, Glib::RefPtr<Gdk::DragContext> const &);
229 Gtk::Menu *send_action_menu;
230 void build_send_action_menu ();
233 void show_send_controls ();
235 Gtk::Menu *processor_menu;
236 gint processor_menu_map_handler (GdkEventAny *ev);
237 Gtk::Menu * build_processor_menu ();
238 void build_processor_tooltip (Gtk::EventBox&, std::string);
239 void show_processor_menu (gint arg);
240 Gtk::Menu* build_possible_aux_menu();
242 void choose_aux (boost::weak_ptr<ARDOUR::Route>);
244 void send_io_finished (IOSelector::Result, boost::weak_ptr<ARDOUR::Processor>, IOSelectorWindow*);
245 void return_io_finished (IOSelector::Result, boost::weak_ptr<ARDOUR::Processor>, IOSelectorWindow*);
246 void choose_insert ();
247 void choose_plugin ();
248 bool use_plugins (const SelectedPlugins&);
250 bool no_processor_redisplay;
252 bool enter_notify (GdkEventCrossing *ev);
253 bool leave_notify (GdkEventCrossing *ev);
254 bool processor_key_press_event (GdkEventKey *);
255 bool processor_key_release_event (GdkEventKey *);
256 bool processor_button_press_event (GdkEventButton *, ProcessorEntry *);
257 bool processor_button_release_event (GdkEventButton *, ProcessorEntry *);
258 void redisplay_processors ();
259 void add_processor_to_display (boost::weak_ptr<ARDOUR::Processor>);
261 void report_failed_reorder ();
262 void route_processors_changed (ARDOUR::RouteProcessorChange);
264 void processors_reordered (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&, int*);
265 void compute_processor_sort_keys ();
267 void all_processors_active(bool state);
268 void all_plugins_active(bool state);
271 typedef std::vector<boost::shared_ptr<ARDOUR::Processor> > ProcSelection;
273 void cut_processors (const ProcSelection&);
274 void cut_processors ();
275 void copy_processors (const ProcSelection&);
276 void copy_processors ();
277 void delete_processors (const ProcSelection&);
278 void delete_processors ();
279 void paste_processors ();
280 void paste_processors (boost::shared_ptr<ARDOUR::Processor> before);
282 void delete_dragged_processors (const std::list<boost::shared_ptr<ARDOUR::Processor> >&);
283 void clear_processors ();
284 void clear_processors (ARDOUR::Placement);
285 void rename_processors ();
287 void for_selected_processors (void (ProcessorBox::*pmf)(boost::shared_ptr<ARDOUR::Processor>));
288 void get_selected_processors (ProcSelection&) const;
290 bool can_cut() const;
292 static Glib::RefPtr<Gtk::Action> cut_action;
293 static Glib::RefPtr<Gtk::Action> paste_action;
294 static Glib::RefPtr<Gtk::Action> rename_action;
295 static Glib::RefPtr<Gtk::Action> edit_action;
296 void paste_processor_state (const XMLNodeList&, boost::shared_ptr<ARDOUR::Processor>);
298 void activate_processor (boost::shared_ptr<ARDOUR::Processor>);
299 void deactivate_processor (boost::shared_ptr<ARDOUR::Processor>);
300 void hide_processor_editor (boost::shared_ptr<ARDOUR::Processor>);
301 void rename_processor (boost::shared_ptr<ARDOUR::Processor>);
303 gint idle_delete_processor (boost::weak_ptr<ARDOUR::Processor>);
305 void weird_plugin_dialog (ARDOUR::Plugin& p, ARDOUR::Route::ProcessorStreams streams);
306 void on_size_allocate (Gtk::Allocation &);
308 void setup_entry_positions ();
310 static ProcessorBox* _current_processor_box;
312 static void rb_choose_aux (boost::weak_ptr<ARDOUR::Route>);
313 static void rb_choose_plugin ();
314 static void rb_choose_insert ();
315 static void rb_choose_send ();
316 static void rb_clear ();
317 static void rb_clear_pre ();
318 static void rb_clear_post ();
319 static void rb_cut ();
320 static void rb_copy ();
321 static void rb_paste ();
322 static void rb_delete ();
323 static void rb_rename ();
324 static void rb_select_all ();
325 static void rb_deselect_all ();
326 static void rb_activate_all ();
327 static void rb_deactivate_all ();
328 static void rb_ab_plugins ();
329 static void rb_edit ();
331 void route_property_changed (const PBD::PropertyChange&);
332 std::string generate_processor_title (boost::shared_ptr<ARDOUR::PluginInsert> pi);
334 std::list<ProcessorWindowProxy*> _processor_window_proxies;
335 void set_processor_ui (boost::shared_ptr<ARDOUR::Processor>, Gtk::Window *);
336 void maybe_add_processor_to_ui_list (boost::weak_ptr<ARDOUR::Processor>);
338 bool one_processor_can_be_edited ();
339 bool processor_can_be_edited (boost::shared_ptr<ARDOUR::Processor>);
341 void mixer_strip_delivery_changed (boost::weak_ptr<ARDOUR::Delivery>);
344 #endif /* __ardour_gtk_processor_box__ */