remove "New Return" menu option from processor box; make return toggle processor...
[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/dndvbox.h>
34 #include <gtkmm2ext/pixfader.h>
35
36 #include "pbd/stateful.h"
37
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"
44
45 #include "pbd/fastlog.h"
46
47 #include "plugin_interest.h"
48 #include "io_selector.h"
49 #include "send_ui.h"
50 #include "enums.h"
51
52 class MotionController;
53 class PluginSelector;
54 class PluginUIWindow;
55 class RouteRedirectSelection;
56 class MixerStrip;
57
58 namespace ARDOUR {
59         class Connection;
60         class IO;
61         class Insert;
62         class Plugin;
63         class PluginInsert;
64         class PortInsert;
65         class Route;
66         class Send;
67         class Session;
68 }
69
70 class ProcessorEntry : public Gtkmm2ext::DnDVBoxChild, public sigc::trackable
71 {
72 public:
73         ProcessorEntry (boost::shared_ptr<ARDOUR::Processor>, Width);
74
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);
80
81 protected:
82         
83         Gtk::VBox _vbox;
84         
85 private:
86
87         void active_toggled ();
88         void processor_active_changed ();
89         void processor_name_changed ();
90         std::string name () const;
91         
92         Gtk::EventBox _event_box;
93         Gtk::Label _name;
94         Gtk::HBox _hbox;
95         Gtk::CheckButton _active;
96         boost::shared_ptr<ARDOUR::Processor> _processor;
97         Width _width;
98 };
99
100 class SendProcessorEntry : public ProcessorEntry
101 {
102 public:
103         SendProcessorEntry (boost::shared_ptr<ARDOUR::Send>, Width);
104
105         static void setup_slider_pix ();
106
107 private:
108         void show_gain ();
109         void gain_adjusted ();
110         
111         boost::shared_ptr<ARDOUR::Send> _send;
112         Gtk::Adjustment _adjustment;
113         Gtkmm2ext::HSliderController _fader;
114         bool _ignore_gain_change;
115         
116         static Glib::RefPtr<Gdk::Pixbuf> _slider;
117 };
118
119 class ProcessorBox : public Gtk::HBox, public PluginInterestedObject
120 {
121   public:
122         ProcessorBox (ARDOUR::Session&, sigc::slot<PluginSelector*> get_plugin_selector,
123                         RouteRedirectSelection&, MixerStrip* parent, bool owner_is_mixer = false);
124         ~ProcessorBox ();
125
126         void set_route (boost::shared_ptr<ARDOUR::Route>);
127         void set_width (Width);
128
129         void update();
130
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 ();
136
137         sigc::signal<void,boost::shared_ptr<ARDOUR::Processor> > ProcessorSelected;
138         sigc::signal<void,boost::shared_ptr<ARDOUR::Processor> > ProcessorUnselected;
139
140         static void register_actions();
141
142   private:
143         boost::shared_ptr<ARDOUR::Route>  _route;
144         ARDOUR::Session &   _session;
145         MixerStrip*         _parent_strip; // null if in RouteParamsUI
146         bool                _owner_is_mixer;
147         bool                 ab_direction;
148         std::vector<sigc::connection> connections;
149
150         sigc::slot<PluginSelector*> _get_plugin_selector;
151
152         boost::shared_ptr<ARDOUR::Processor> _processor_being_created;
153
154         ARDOUR::Placement _placement;
155
156         RouteRedirectSelection& _rr_selection;
157
158         void route_going_away ();
159
160         void selection_changed ();
161
162         Gtk::EventBox          processor_eventbox;
163         Gtk::HBox              processor_hpacker;
164         Gtkmm2ext::DnDVBox<ProcessorEntry> processor_display;
165         Gtk::ScrolledWindow    processor_scroller;
166
167         void object_drop (Gtkmm2ext::DnDVBox<ProcessorEntry> *, ProcessorEntry *, Glib::RefPtr<Gdk::DragContext> const &);
168
169         Width _width;
170
171         Gtk::Menu *send_action_menu;
172         void build_send_action_menu ();
173
174         void new_send ();
175         void show_send_controls ();
176
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();
183
184         void choose_aux (boost::weak_ptr<ARDOUR::Route>);
185         void choose_send ();
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&);
191
192         bool no_processor_redisplay;
193
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>);
202         void reordered ();
203
204         void remove_processor_gui (boost::shared_ptr<ARDOUR::Processor>);
205
206         void processors_reordered (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&, int*);
207         void compute_processor_sort_keys ();
208
209         void all_processors_active(bool state);
210         void all_plugins_active(bool state);
211         void ab_plugins ();
212
213         typedef std::vector<boost::shared_ptr<ARDOUR::Processor> > ProcSelection;
214
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);
223
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 ();
228
229         void for_selected_processors (void (ProcessorBox::*pmf)(boost::shared_ptr<ARDOUR::Processor>));
230         void get_selected_processors (ProcSelection&);
231
232         static Glib::RefPtr<Gtk::Action> paste_action;
233         void paste_processor_state (const XMLNodeList&, boost::shared_ptr<ARDOUR::Processor>);
234
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>);
240
241         gint idle_delete_processor (boost::weak_ptr<ARDOUR::Processor>);
242
243         void weird_plugin_dialog (ARDOUR::Plugin& p, ARDOUR::Route::ProcessorStreams streams);
244
245         static ProcessorBox* _current_processor_box;
246
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 ();
265
266         void route_name_changed ();
267         std::string generate_processor_title (boost::shared_ptr<ARDOUR::PluginInsert> pi);
268 };
269
270 #endif /* __ardour_gtk_processor_box__ */