add track/bus now allows specifying aux or direct bus role; processor box menus sort...
[ardour.git] / gtk2_ardour / processor_box.h
1 /*
2     Copyright (C) 2004 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19
20 #ifndef __ardour_gtk_processor_box__
21 #define __ardour_gtk_processor_box__
22
23 #include <vector>
24
25 #include <cmath>
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/dndtreeview.h>
34
35 #include "pbd/stateful.h"
36
37 #include "ardour/types.h"
38 #include "ardour/ardour.h"
39 #include "ardour/plugin_insert.h"
40 #include "ardour/port_insert.h"
41 #include "ardour/processor.h"
42 #include "ardour/route.h"
43
44 #include "pbd/fastlog.h"
45
46 #include "plugin_interest.h"
47 #include "io_selector.h"
48 #include "send_ui.h"
49 #include "enums.h"
50
51 class MotionController;
52 class PluginSelector;
53 class PluginUIWindow;
54 class RouteRedirectSelection;
55 class MixerStrip;
56
57 namespace ARDOUR {
58         class Connection;
59         class IO;
60         class Insert;
61         class Plugin;
62         class PluginInsert;
63         class PortInsert;
64         class Route;
65         class Send;
66         class Session;
67 }
68
69 class ProcessorBox : public Gtk::HBox, public PluginInterestedObject
70 {
71   public:
72         ProcessorBox (ARDOUR::Session&, sigc::slot<PluginSelector*> get_plugin_selector,
73                         RouteRedirectSelection&, MixerStrip* parent, bool owner_is_mixer = false);
74         ~ProcessorBox ();
75
76         void set_route (boost::shared_ptr<ARDOUR::Route>);
77         void set_width (Width);
78
79         void update();
80
81         void select_all_processors ();
82         void deselect_all_processors ();
83         void select_all_plugins ();
84         void select_all_inserts ();
85         void select_all_sends ();
86
87         sigc::signal<void,boost::shared_ptr<ARDOUR::Processor> > ProcessorSelected;
88         sigc::signal<void,boost::shared_ptr<ARDOUR::Processor> > ProcessorUnselected;
89
90         static void register_actions();
91
92   private:
93         boost::shared_ptr<ARDOUR::Route>  _route;
94         ARDOUR::Session &   _session;
95         MixerStrip*         _parent_strip; // null if in RouteParamsUI
96         bool                _owner_is_mixer;
97         bool                 ab_direction;
98         std::vector<sigc::connection> connections;
99
100         sigc::slot<PluginSelector*> _get_plugin_selector;
101
102         boost::shared_ptr<ARDOUR::Processor> _processor_being_created;
103
104         ARDOUR::Placement _placement;
105
106         RouteRedirectSelection& _rr_selection;
107
108         void route_going_away ();
109
110         struct ModelColumns : public Gtk::TreeModel::ColumnRecord {
111             ModelColumns () {
112                     add (text);
113                     add (processor);
114                     add (color);
115             }
116             Gtk::TreeModelColumn<std::string>       text;
117             Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Processor> > processor;
118             Gtk::TreeModelColumn<Gdk::Color>        color;
119         };
120
121         ModelColumns columns;
122         Glib::RefPtr<Gtk::ListStore> model;
123
124         void selection_changed ();
125
126         static bool get_colors;
127         static Gdk::Color* active_processor_color;
128         static Gdk::Color* inactive_processor_color;
129
130         Gtk::EventBox          processor_eventbox;
131         Gtk::HBox              processor_hpacker;
132         Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Processor> > processor_display;
133         Gtk::ScrolledWindow    processor_scroller;
134
135         void object_drop (const std::list<boost::shared_ptr<ARDOUR::Processor> >&, Gtk::TreeView*,
136                           int x, int y, Glib::RefPtr<Gdk::DragContext>& context);
137
138         Width _width;
139
140         Gtk::Menu *send_action_menu;
141         void build_send_action_menu ();
142
143         void new_send ();
144         void show_send_controls ();
145
146         Gtk::Menu *processor_menu;
147         gint processor_menu_map_handler (GdkEventAny *ev);
148         Gtk::Menu * build_processor_menu ();
149         void build_processor_tooltip (Gtk::EventBox&, std::string);
150         void show_processor_menu (gint arg);
151         Gtk::Menu* build_possible_aux_menu();
152
153         void choose_aux (boost::weak_ptr<ARDOUR::Route>);
154         void choose_send ();
155         void send_io_finished (IOSelector::Result, boost::weak_ptr<ARDOUR::Processor>, IOSelectorWindow*);
156         void choose_return ();
157         void return_io_finished (IOSelector::Result, boost::weak_ptr<ARDOUR::Processor>, IOSelectorWindow*);
158         void choose_insert ();
159         void choose_plugin ();
160         void use_plugins (const SelectedPlugins&);
161
162         bool no_processor_redisplay;
163         bool ignore_delete;
164
165         bool enter_notify (GdkEventCrossing *ev);
166         bool leave_notify (GdkEventCrossing *ev);
167         bool processor_key_press_event (GdkEventKey *);
168         bool processor_key_release_event (GdkEventKey *);
169         bool processor_button_press_event (GdkEventButton *);
170         bool processor_button_release_event (GdkEventButton *);
171         void redisplay_processors ();
172         void add_processor_to_display (boost::weak_ptr<ARDOUR::Processor>);
173         void row_deleted (const Gtk::TreeModel::Path& path);
174         void show_processor_active (boost::weak_ptr<ARDOUR::Processor>);
175         void show_processor_name (boost::weak_ptr<ARDOUR::Processor>);
176         std::string processor_name (boost::weak_ptr<ARDOUR::Processor>);
177
178         void remove_processor_gui (boost::shared_ptr<ARDOUR::Processor>);
179
180         void processors_reordered (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&, int*);
181         void compute_processor_sort_keys ();
182         std::vector<sigc::connection> processor_active_connections;
183         std::vector<sigc::connection> processor_name_connections;
184
185         bool processor_drag_in_progress;
186         void processor_drag_begin (GdkDragContext*);
187         void processor_drag_end (GdkDragContext*);
188         void all_processors_active(bool state);
189         void all_plugins_active(bool state);
190         void ab_plugins ();
191
192         typedef std::vector<boost::shared_ptr<ARDOUR::Processor> > ProcSelection;
193
194         void cut_processors (const ProcSelection&);
195         void cut_processors ();
196         void copy_processors (const ProcSelection&);
197         void copy_processors ();
198         void delete_processors (const ProcSelection&);
199         void delete_processors ();
200         void paste_processors ();
201         void paste_processors (boost::shared_ptr<ARDOUR::Processor> before);
202
203         void delete_dragged_processors (const std::list<boost::shared_ptr<ARDOUR::Processor> >&);
204         void clear_processors ();
205         void clear_processors (ARDOUR::Placement);
206         void rename_processors ();
207
208         void for_selected_processors (void (ProcessorBox::*pmf)(boost::shared_ptr<ARDOUR::Processor>));
209         void get_selected_processors (ProcSelection&);
210
211         static Glib::RefPtr<Gtk::Action> paste_action;
212         void paste_processor_state (const XMLNodeList&, boost::shared_ptr<ARDOUR::Processor>);
213
214         void activate_processor (boost::shared_ptr<ARDOUR::Processor>);
215         void deactivate_processor (boost::shared_ptr<ARDOUR::Processor>);
216         void edit_processor (boost::shared_ptr<ARDOUR::Processor>);
217         void hide_processor_editor (boost::shared_ptr<ARDOUR::Processor>);
218         void rename_processor (boost::shared_ptr<ARDOUR::Processor>);
219
220         gint idle_delete_processor (boost::weak_ptr<ARDOUR::Processor>);
221
222         void weird_plugin_dialog (ARDOUR::Plugin& p, ARDOUR::Route::ProcessorStreams streams);
223
224         static ProcessorBox* _current_processor_box;
225
226         static void rb_choose_aux (boost::weak_ptr<ARDOUR::Route>);
227         static void rb_choose_plugin ();
228         static void rb_choose_insert ();
229         static void rb_choose_send ();
230         static void rb_choose_return ();
231         static void rb_clear ();
232         static void rb_clear_pre ();
233         static void rb_clear_post ();
234         static void rb_cut ();
235         static void rb_copy ();
236         static void rb_paste ();
237         static void rb_delete ();
238         static void rb_rename ();
239         static void rb_select_all ();
240         static void rb_deselect_all ();
241         static void rb_activate ();
242         static void rb_deactivate ();
243         static void rb_activate_all ();
244         static void rb_deactivate_all ();
245         static void rb_ab_plugins ();
246         static void rb_edit ();
247
248         void route_name_changed ();
249         std::string generate_processor_title (boost::shared_ptr<ARDOUR::PluginInsert> pi);
250 };
251
252 #endif /* __ardour_gtk_processor_box__ */