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 <gtkmm/box.h>
27 #include <gtkmm/eventbox.h>
28 #include <gtkmm/menu.h>
29 #include <gtkmm/scrolledwindow.h>
30 #include <gtkmm2ext/dndtreeview.h>
31 #include <gtkmm2ext/auto_spin.h>
32 #include <gtkmm2ext/click_box.h>
33 #include <gtkmm2ext/dndvbox.h>
34 #include <gtkmm2ext/pixfader.h>
36 #include "pbd/stateful.h"
38 #include "ardour/types.h"
39 #include "ardour/ardour.h"
40 #include "ardour/plugin_insert.h"
41 #include "ardour/port_insert.h"
42 #include "ardour/processor.h"
43 #include "ardour/route.h"
45 #include "pbd/fastlog.h"
47 #include "plugin_interest.h"
48 #include "io_selector.h"
52 class MotionController;
55 class RouteRedirectSelection;
70 class ProcessorEntry : public Gtkmm2ext::DnDVBoxChild, public sigc::trackable
73 ProcessorEntry (boost::shared_ptr<ARDOUR::Processor>, Width);
75 Gtk::EventBox& action_widget ();
76 Gtk::Widget& widget ();
77 std::string drag_text () const;
78 boost::shared_ptr<ARDOUR::Processor> processor () const;
79 void set_enum_width (Width);
80 virtual void set_pixel_width (int) {}
88 void active_toggled ();
89 void processor_active_changed ();
90 void processor_name_changed ();
91 std::string name () const;
93 Gtk::EventBox _event_box;
96 Gtk::CheckButton _active;
97 boost::shared_ptr<ARDOUR::Processor> _processor;
101 class SendProcessorEntry : public ProcessorEntry
104 SendProcessorEntry (boost::shared_ptr<ARDOUR::Send>, Width);
106 static void setup_slider_pix ();
108 void set_enum_width (Width, int);
109 void set_pixel_width (int);
113 void gain_adjusted ();
115 boost::shared_ptr<ARDOUR::Send> _send;
116 Gtk::Adjustment _adjustment;
117 Gtkmm2ext::HSliderController _fader;
118 bool _ignore_gain_change;
120 static Glib::RefPtr<Gdk::Pixbuf> _slider;
123 class ProcessorBox : public Gtk::HBox, public PluginInterestedObject
126 ProcessorBox (ARDOUR::Session&, sigc::slot<PluginSelector*> get_plugin_selector,
127 RouteRedirectSelection&, MixerStrip* parent, bool owner_is_mixer = false);
130 void set_route (boost::shared_ptr<ARDOUR::Route>);
131 void set_width (Width);
135 void select_all_processors ();
136 void deselect_all_processors ();
137 void select_all_plugins ();
138 void select_all_inserts ();
139 void select_all_sends ();
141 sigc::signal<void,boost::shared_ptr<ARDOUR::Processor> > ProcessorSelected;
142 sigc::signal<void,boost::shared_ptr<ARDOUR::Processor> > ProcessorUnselected;
144 static void register_actions();
147 boost::shared_ptr<ARDOUR::Route> _route;
148 ARDOUR::Session & _session;
149 MixerStrip* _parent_strip; // null if in RouteParamsUI
150 bool _owner_is_mixer;
152 std::vector<sigc::connection> connections;
154 sigc::slot<PluginSelector*> _get_plugin_selector;
156 boost::shared_ptr<ARDOUR::Processor> _processor_being_created;
158 ARDOUR::Placement _placement;
160 RouteRedirectSelection& _rr_selection;
162 void route_going_away ();
164 void selection_changed ();
166 Gtk::EventBox processor_eventbox;
167 Gtk::HBox processor_hpacker;
168 Gtkmm2ext::DnDVBox<ProcessorEntry> processor_display;
169 Gtk::ScrolledWindow processor_scroller;
171 void object_drop (Gtkmm2ext::DnDVBox<ProcessorEntry> *, ProcessorEntry *, Glib::RefPtr<Gdk::DragContext> const &);
175 Gtk::Menu *send_action_menu;
176 void build_send_action_menu ();
179 void show_send_controls ();
181 Gtk::Menu *processor_menu;
182 gint processor_menu_map_handler (GdkEventAny *ev);
183 Gtk::Menu * build_processor_menu ();
184 void build_processor_tooltip (Gtk::EventBox&, std::string);
185 void show_processor_menu (gint arg);
186 Gtk::Menu* build_possible_aux_menu();
188 void choose_aux (boost::weak_ptr<ARDOUR::Route>);
190 void send_io_finished (IOSelector::Result, boost::weak_ptr<ARDOUR::Processor>, IOSelectorWindow*);
191 void return_io_finished (IOSelector::Result, boost::weak_ptr<ARDOUR::Processor>, IOSelectorWindow*);
192 void choose_insert ();
193 void choose_plugin ();
194 void use_plugins (const SelectedPlugins&);
196 bool no_processor_redisplay;
198 bool enter_notify (GdkEventCrossing *ev);
199 bool leave_notify (GdkEventCrossing *ev);
200 bool processor_key_press_event (GdkEventKey *);
201 bool processor_key_release_event (GdkEventKey *);
202 bool processor_button_press_event (GdkEventButton *, ProcessorEntry *);
203 bool processor_button_release_event (GdkEventButton *, ProcessorEntry *);
204 void redisplay_processors ();
205 void add_processor_to_display (boost::weak_ptr<ARDOUR::Processor>);
207 void route_processors_changed (ARDOUR::RouteProcessorChange);
209 void remove_processor_gui (boost::shared_ptr<ARDOUR::Processor>);
211 void processors_reordered (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&, int*);
212 void compute_processor_sort_keys ();
214 void all_processors_active(bool state);
215 void all_plugins_active(bool state);
218 typedef std::vector<boost::shared_ptr<ARDOUR::Processor> > ProcSelection;
220 void cut_processors (const ProcSelection&);
221 void cut_processors ();
222 void copy_processors (const ProcSelection&);
223 void copy_processors ();
224 void delete_processors (const ProcSelection&);
225 void delete_processors ();
226 void paste_processors ();
227 void paste_processors (boost::shared_ptr<ARDOUR::Processor> before);
229 void delete_dragged_processors (const std::list<boost::shared_ptr<ARDOUR::Processor> >&);
230 void clear_processors ();
231 void clear_processors (ARDOUR::Placement);
232 void rename_processors ();
234 void for_selected_processors (void (ProcessorBox::*pmf)(boost::shared_ptr<ARDOUR::Processor>));
235 void get_selected_processors (ProcSelection&);
237 static Glib::RefPtr<Gtk::Action> paste_action;
238 void paste_processor_state (const XMLNodeList&, boost::shared_ptr<ARDOUR::Processor>);
240 void activate_processor (boost::shared_ptr<ARDOUR::Processor>);
241 void deactivate_processor (boost::shared_ptr<ARDOUR::Processor>);
242 void edit_processor (boost::shared_ptr<ARDOUR::Processor>);
243 void hide_processor_editor (boost::shared_ptr<ARDOUR::Processor>);
244 void rename_processor (boost::shared_ptr<ARDOUR::Processor>);
246 gint idle_delete_processor (boost::weak_ptr<ARDOUR::Processor>);
248 void weird_plugin_dialog (ARDOUR::Plugin& p, ARDOUR::Route::ProcessorStreams streams);
249 void on_size_allocate (Gtk::Allocation &);
251 static ProcessorBox* _current_processor_box;
253 static void rb_choose_aux (boost::weak_ptr<ARDOUR::Route>);
254 static void rb_choose_plugin ();
255 static void rb_choose_insert ();
256 static void rb_choose_send ();
257 static void rb_clear ();
258 static void rb_clear_pre ();
259 static void rb_clear_post ();
260 static void rb_cut ();
261 static void rb_copy ();
262 static void rb_paste ();
263 static void rb_delete ();
264 static void rb_rename ();
265 static void rb_select_all ();
266 static void rb_deselect_all ();
267 static void rb_activate_all ();
268 static void rb_deactivate_all ();
269 static void rb_ab_plugins ();
270 static void rb_edit ();
272 void route_name_changed ();
273 std::string generate_processor_title (boost::shared_ptr<ARDOUR::PluginInsert> pi);
276 #endif /* __ardour_gtk_processor_box__ */