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_width (Width);
87 void active_toggled ();
88 void processor_active_changed ();
89 void processor_name_changed ();
90 std::string name () const;
92 Gtk::EventBox _event_box;
95 Gtk::CheckButton _active;
96 boost::shared_ptr<ARDOUR::Processor> _processor;
100 class SendProcessorEntry : public ProcessorEntry
103 SendProcessorEntry (boost::shared_ptr<ARDOUR::Send>, Width);
105 static void setup_slider_pix ();
109 void gain_adjusted ();
111 boost::shared_ptr<ARDOUR::Send> _send;
112 Gtk::Adjustment _adjustment;
113 Gtkmm2ext::HSliderController _fader;
114 bool _ignore_gain_change;
116 static Glib::RefPtr<Gdk::Pixbuf> _slider;
119 class ProcessorBox : public Gtk::HBox, public PluginInterestedObject
122 ProcessorBox (ARDOUR::Session&, sigc::slot<PluginSelector*> get_plugin_selector,
123 RouteRedirectSelection&, MixerStrip* parent, bool owner_is_mixer = false);
126 void set_route (boost::shared_ptr<ARDOUR::Route>);
127 void set_width (Width);
131 void select_all_processors ();
132 void deselect_all_processors ();
133 void select_all_plugins ();
134 void select_all_inserts ();
135 void select_all_sends ();
137 sigc::signal<void,boost::shared_ptr<ARDOUR::Processor> > ProcessorSelected;
138 sigc::signal<void,boost::shared_ptr<ARDOUR::Processor> > ProcessorUnselected;
140 static void register_actions();
143 boost::shared_ptr<ARDOUR::Route> _route;
144 ARDOUR::Session & _session;
145 MixerStrip* _parent_strip; // null if in RouteParamsUI
146 bool _owner_is_mixer;
148 std::vector<sigc::connection> connections;
150 sigc::slot<PluginSelector*> _get_plugin_selector;
152 boost::shared_ptr<ARDOUR::Processor> _processor_being_created;
154 ARDOUR::Placement _placement;
156 RouteRedirectSelection& _rr_selection;
158 void route_going_away ();
160 void selection_changed ();
162 Gtk::EventBox processor_eventbox;
163 Gtk::HBox processor_hpacker;
164 Gtkmm2ext::DnDVBox<ProcessorEntry> processor_display;
165 Gtk::ScrolledWindow processor_scroller;
167 void object_drop (Gtkmm2ext::DnDVBox<ProcessorEntry> *, ProcessorEntry *, Glib::RefPtr<Gdk::DragContext> const &);
171 Gtk::Menu *send_action_menu;
172 void build_send_action_menu ();
175 void show_send_controls ();
177 Gtk::Menu *processor_menu;
178 gint processor_menu_map_handler (GdkEventAny *ev);
179 Gtk::Menu * build_processor_menu ();
180 void build_processor_tooltip (Gtk::EventBox&, std::string);
181 void show_processor_menu (gint arg);
182 Gtk::Menu* build_possible_aux_menu();
184 void choose_aux (boost::weak_ptr<ARDOUR::Route>);
186 void send_io_finished (IOSelector::Result, boost::weak_ptr<ARDOUR::Processor>, IOSelectorWindow*);
187 void return_io_finished (IOSelector::Result, boost::weak_ptr<ARDOUR::Processor>, IOSelectorWindow*);
188 void choose_insert ();
189 void choose_plugin ();
190 void use_plugins (const SelectedPlugins&);
192 bool no_processor_redisplay;
194 bool enter_notify (GdkEventCrossing *ev);
195 bool leave_notify (GdkEventCrossing *ev);
196 bool processor_key_press_event (GdkEventKey *);
197 bool processor_key_release_event (GdkEventKey *);
198 bool processor_button_press_event (GdkEventButton *, ProcessorEntry *);
199 bool processor_button_release_event (GdkEventButton *, ProcessorEntry *);
200 void redisplay_processors ();
201 void add_processor_to_display (boost::weak_ptr<ARDOUR::Processor>);
204 void remove_processor_gui (boost::shared_ptr<ARDOUR::Processor>);
206 void processors_reordered (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&, int*);
207 void compute_processor_sort_keys ();
209 void all_processors_active(bool state);
210 void all_plugins_active(bool state);
213 typedef std::vector<boost::shared_ptr<ARDOUR::Processor> > ProcSelection;
215 void cut_processors (const ProcSelection&);
216 void cut_processors ();
217 void copy_processors (const ProcSelection&);
218 void copy_processors ();
219 void delete_processors (const ProcSelection&);
220 void delete_processors ();
221 void paste_processors ();
222 void paste_processors (boost::shared_ptr<ARDOUR::Processor> before);
224 void delete_dragged_processors (const std::list<boost::shared_ptr<ARDOUR::Processor> >&);
225 void clear_processors ();
226 void clear_processors (ARDOUR::Placement);
227 void rename_processors ();
229 void for_selected_processors (void (ProcessorBox::*pmf)(boost::shared_ptr<ARDOUR::Processor>));
230 void get_selected_processors (ProcSelection&);
232 static Glib::RefPtr<Gtk::Action> paste_action;
233 void paste_processor_state (const XMLNodeList&, boost::shared_ptr<ARDOUR::Processor>);
235 void activate_processor (boost::shared_ptr<ARDOUR::Processor>);
236 void deactivate_processor (boost::shared_ptr<ARDOUR::Processor>);
237 void edit_processor (boost::shared_ptr<ARDOUR::Processor>);
238 void hide_processor_editor (boost::shared_ptr<ARDOUR::Processor>);
239 void rename_processor (boost::shared_ptr<ARDOUR::Processor>);
241 gint idle_delete_processor (boost::weak_ptr<ARDOUR::Processor>);
243 void weird_plugin_dialog (ARDOUR::Plugin& p, ARDOUR::Route::ProcessorStreams streams);
245 static ProcessorBox* _current_processor_box;
247 static void rb_choose_aux (boost::weak_ptr<ARDOUR::Route>);
248 static void rb_choose_plugin ();
249 static void rb_choose_insert ();
250 static void rb_choose_send ();
251 static void rb_clear ();
252 static void rb_clear_pre ();
253 static void rb_clear_post ();
254 static void rb_cut ();
255 static void rb_copy ();
256 static void rb_paste ();
257 static void rb_delete ();
258 static void rb_rename ();
259 static void rb_select_all ();
260 static void rb_deselect_all ();
261 static void rb_activate_all ();
262 static void rb_deactivate_all ();
263 static void rb_ab_plugins ();
264 static void rb_edit ();
266 void route_name_changed ();
267 std::string generate_processor_title (boost::shared_ptr<ARDOUR::PluginInsert> pi);
270 #endif /* __ardour_gtk_processor_box__ */