Plugin Order: remove from instant.xml and save to: plugin_metadata/plugin_order
[ardour.git] / gtk2_ardour / mixer_ui.h
1 /*
2     Copyright (C) 2000 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_mixer_ui_h__
21 #define __ardour_mixer_ui_h__
22
23 #include <list>
24
25 #include <gtkmm/box.h>
26 #include <gtkmm/scrolledwindow.h>
27 #include <gtkmm/eventbox.h>
28 #include <gtkmm/label.h>
29 #include <gtkmm/comboboxtext.h>
30 #include <gtkmm/button.h>
31 #include <gtkmm/frame.h>
32 #include <gtkmm/menu.h>
33 #include <gtkmm/treeview.h>
34 #include <gtkmm/treestore.h>
35 #include <gtkmm/liststore.h>
36
37 #include "pbd/stateful.h"
38 #include "pbd/signals.h"
39
40 #include "ardour/ardour.h"
41 #include "ardour/types.h"
42 #include "ardour/session_handle.h"
43 #include "ardour/plugin.h"
44 #include "ardour/plugin_manager.h"
45
46 #include <gtkmm2ext/bindings.h>
47 #include "gtkmm2ext/dndtreeview.h"
48 #include "gtkmm2ext/treeutils.h"
49
50 #include "widgets/pane.h"
51 #include "widgets/tabbable.h"
52
53 #include "axis_provider.h"
54 #include "enums.h"
55 #include "route_processor_selection.h"
56
57 namespace ARDOUR {
58         class Route;
59         class RouteGroup;
60         class VCA;
61 };
62
63 class AxisView;
64 class MixerStrip;
65 class PluginSelector;
66 class MixerGroupTabs;
67 class MonitorSection;
68 class VCAMasterStrip;
69
70 class PluginTreeStore : public Gtk::TreeStore
71 {
72 public:
73         static Glib::RefPtr<PluginTreeStore> create(const Gtk::TreeModelColumnRecord& columns) {
74                 return Glib::RefPtr<PluginTreeStore> (new PluginTreeStore (columns));
75         }
76
77 protected:
78         PluginTreeStore (const Gtk::TreeModelColumnRecord& columns) : Gtk::TreeStore (columns) {}
79         virtual bool row_draggable_vfunc (const Gtk::TreeModel::Path&) const { return true; }
80         virtual bool row_drop_possible_vfunc (const Gtk::TreeModel::Path&, const Gtk::SelectionData&) const;
81 };
82
83 class Mixer_UI : public ArdourWidgets::Tabbable, public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr, public AxisViewProvider
84 {
85 public:
86         static Mixer_UI* instance();
87         ~Mixer_UI();
88
89         Gtk::Window* use_own_window (bool and_fill_it);
90         void show_window ();
91
92         void set_session (ARDOUR::Session *);
93
94         PluginSelector* plugin_selector();
95
96         void  set_strip_width (Width, bool save = false);
97         Width get_strip_width () const { return _strip_width; }
98
99         XMLNode& get_state ();
100         int set_state (const XMLNode&, int /* version */);
101
102         void show_mixer_list (bool yn);
103         void show_monitor_section (bool);
104
105         void show_strip (MixerStrip *);
106         void hide_strip (MixerStrip *);
107
108         void maximise_mixer_space();
109         void restore_mixer_space();
110
111         MonitorSection* monitor_section() const { return _monitor_section; }
112
113         void deselect_all_strip_processors();
114         void delete_processors();
115         void select_none ();
116         void select_all_tracks ();
117
118         void do_vca_assign (boost::shared_ptr<ARDOUR::VCA>);
119         void do_vca_unassign (boost::shared_ptr<ARDOUR::VCA>);
120         void show_spill (boost::shared_ptr<ARDOUR::Stripable>);
121         bool showing_spill_for (boost::shared_ptr<ARDOUR::Stripable>) const;
122
123         sigc::signal1<void,boost::shared_ptr<ARDOUR::Stripable> > show_spill_change;
124
125         RouteProcessorSelection& selection() { return _selection; }
126
127         void show_editor_window () const;
128
129         void register_actions ();
130
131         void load_bindings ();
132         Gtkmm2ext::Bindings*  bindings;
133
134 protected:
135         void set_axis_targets_for_operation ();
136         ARDOUR::AutomationControlSet selected_gaincontrols ();
137
138 private:
139         Mixer_UI ();
140         static Mixer_UI*     _instance;
141         Gtk::VBox            _content;
142         Gtk::HBox             global_hpacker;
143         Gtk::VBox             global_vpacker;
144         Gtk::ScrolledWindow   scroller;
145         Gtk::EventBox         scroller_base;
146         Gtk::HBox             scroller_hpacker;
147         Gtk::VBox             mixer_scroller_vpacker;
148         Gtk::VBox             list_vpacker;
149         Gtk::Label            group_display_button_label;
150         Gtk::ScrolledWindow   track_display_scroller;
151         Gtk::ScrolledWindow   group_display_scroller;
152         Gtk::ScrolledWindow   favorite_plugins_scroller;
153         Gtk::VBox             group_display_vbox;
154         Gtk::Frame            track_display_frame;
155         Gtk::Frame            group_display_frame;
156         Gtk::Frame            favorite_plugins_frame;
157         Gtk::VBox             favorite_plugins_vbox;
158         Gtk::ComboBoxText     favorite_plugins_tag_combo;
159         ArdourWidgets::VPane  rhs_pane1;
160         ArdourWidgets::VPane  rhs_pane2;
161         ArdourWidgets::HPane  inner_pane;
162         Gtk::HBox             strip_packer;
163         Gtk::ScrolledWindow   vca_scroller;
164         Gtk::HBox             vca_hpacker;
165         Gtk::VBox             vca_vpacker;
166         Gtk::EventBox         vca_label_bar;
167         Gtk::Label            vca_label;
168         Gtk::EventBox         vca_scroller_base;
169         Gtk::HBox             out_packer;
170         ArdourWidgets::HPane  list_hpane;
171         Gtk::Button           add_button; // should really be an ArdourButton
172         Gtk::Button           add_vca_button;
173
174         MixerGroupTabs* _group_tabs;
175
176         bool on_scroll_event (GdkEventScroll*);
177
178         std::list<MixerStrip *> strips;
179
180         void scroller_drag_data_received (const Glib::RefPtr<Gdk::DragContext>&, int, int, const Gtk::SelectionData&, guint, guint);
181         bool strip_scroller_button_release (GdkEventButton*);
182         bool masters_scroller_button_release (GdkEventButton*);
183         void scroll_left ();
184         void scroll_right ();
185         void toggle_midi_input_active (bool flip_others);
186
187         void move_stripable_into_view (boost::shared_ptr<ARDOUR::Stripable>);
188
189         void add_stripables (ARDOUR::StripableList&);
190
191         void add_routes (ARDOUR::RouteList&);
192         void remove_strip (MixerStrip *);
193
194         void add_masters (ARDOUR::VCAList&);
195         void remove_master (VCAMasterStrip*);
196
197         MixerStrip* strip_by_route (boost::shared_ptr<ARDOUR::Route>) const;
198         MixerStrip* strip_by_stripable (boost::shared_ptr<ARDOUR::Stripable>) const;
199
200         AxisView* axis_view_by_stripable (boost::shared_ptr<ARDOUR::Stripable>) const;
201         AxisView* axis_view_by_control (boost::shared_ptr<ARDOUR::AutomationControl>) const;
202
203         gint start_updating ();
204         gint stop_updating ();
205
206         void session_going_away ();
207
208         sigc::connection fast_screen_update_connection;
209         void fast_update_strips ();
210
211         void track_name_changed (MixerStrip *);
212
213         void redisplay_track_list ();
214         void spill_redisplay (boost::shared_ptr<ARDOUR::VCA>);
215         bool no_track_list_redisplay;
216         bool track_display_button_press (GdkEventButton*);
217         void strip_width_changed ();
218
219         void track_list_delete (const Gtk::TreeModel::Path&);
220         void track_list_reorder (const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter, int* new_order);
221
222         void plugin_row_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column);
223         bool plugin_row_button_press (GdkEventButton*);
224         void popup_note_context_menu (GdkEventButton*);
225         void plugin_drop (const Glib::RefPtr<Gdk::DragContext>&, const Gtk::SelectionData& data);
226
227         enum ProcessorPosition {
228                 AddTop,
229                 AddPreFader,
230                 AddPostFader,
231                 AddBottom
232         };
233
234         void add_selected_processor (ProcessorPosition);
235         void add_favorite_processor (ARDOUR::PluginPresetPtr, ProcessorPosition);
236         void remove_selected_from_favorites ();
237         void delete_selected_preset ();
238         ARDOUR::PluginPresetPtr selected_plugin ();
239
240         void initial_track_display ();
241
242         void set_all_strips_visibility (bool yn);
243         void set_all_audio_midi_visibility (int, bool);
244         void track_visibility_changed (std::string const & path);
245         void update_track_visibility ();
246
247         void hide_all_routes ();
248         void show_all_routes ();
249         void show_all_audiobus ();
250         void hide_all_audiobus ();
251         void show_all_audiotracks();
252         void hide_all_audiotracks ();
253         void show_all_miditracks();
254         void hide_all_miditracks ();
255
256         bool in_group_row_change;
257
258         void group_selected (gint row, gint col, GdkEvent *ev);
259         void group_unselected (gint row, gint col, GdkEvent *ev);
260         void group_display_active_clicked();
261         void new_route_group ();
262         void remove_selected_route_group ();
263         void activate_all_route_groups ();
264         void disable_all_route_groups ();
265         void add_route_group (ARDOUR::RouteGroup *);
266         void route_groups_changed ();
267         void route_group_name_edit (const std::string&, const std::string&);
268         void route_group_row_change (const Gtk::TreeModel::Path& path,const Gtk::TreeModel::iterator& iter);
269         void route_group_row_deleted (Gtk::TreeModel::Path const &);
270
271         Gtk::Menu *track_menu;
272         void track_column_click (gint);
273         void build_track_menu ();
274
275         MonitorSection* _monitor_section;
276         PluginSelector    *_plugin_selector;
277
278         void stripable_property_changed (const PBD::PropertyChange& what_changed, boost::weak_ptr<ARDOUR::Stripable> ws);
279         void route_group_property_changed (ARDOUR::RouteGroup *, const PBD::PropertyChange &);
280
281         /* various treeviews */
282
283         struct StripableDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
284                 StripableDisplayModelColumns () {
285                         add (text);
286                         add (visible);
287                         add (stripable);
288                         add (strip);
289                 }
290                 Gtk::TreeModelColumn<bool>         visible;
291                 Gtk::TreeModelColumn<std::string>  text;
292                 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Stripable> > stripable;
293                 Gtk::TreeModelColumn<AxisView*>    strip;
294         };
295
296         struct GroupDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
297                 GroupDisplayModelColumns() {
298                         add (visible);
299                         add (text);
300                         add (group);
301                 }
302                 Gtk::TreeModelColumn<bool>            visible;
303                 Gtk::TreeModelColumn<std::string>         text;
304                 Gtk::TreeModelColumn<ARDOUR::RouteGroup*> group;
305         };
306
307         struct PluginsDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
308                 PluginsDisplayModelColumns() {
309                         add (name);
310                         add (plugin);
311                 }
312                 Gtk::TreeModelColumn<std::string> name;
313                 Gtk::TreeModelColumn<ARDOUR::PluginPresetPtr> plugin;
314         };
315
316         ARDOUR::PluginInfoList favorite_order;
317         std::map<std::string, bool> favorite_ui_state;
318
319         StripableDisplayModelColumns stripable_columns;
320         GroupDisplayModelColumns     group_columns;
321         PluginsDisplayModelColumns   favorite_plugins_columns;
322
323         Gtk::TreeView track_display;
324         Gtk::TreeView group_display;
325         Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr> favorite_plugins_display;
326
327         Glib::RefPtr<Gtk::ListStore> track_model;
328         Glib::RefPtr<Gtk::ListStore> group_model;
329         Glib::RefPtr<PluginTreeStore> favorite_plugins_model;
330
331         bool group_display_button_press (GdkEventButton*);
332         void group_display_selection_changed ();
333
334         bool strip_button_release_event (GdkEventButton*, MixerStrip*);
335         bool vca_button_release_event (GdkEventButton*, VCAMasterStrip*);
336
337         Width _strip_width;
338
339         void presentation_info_changed (PBD::PropertyChange const &);
340         void sync_treeview_from_presentation_info (PBD::PropertyChange const &);
341         void sync_presentation_info_from_treeview ();
342
343         bool ignore_reorder;
344
345         void parameter_changed (std::string const &);
346         void set_route_group_activation (ARDOUR::RouteGroup *, bool);
347
348         void setup_track_display ();
349         void new_track_or_bus ();
350
351         static const int32_t default_width = 478;
352         static const int32_t default_height = 765;
353
354         /** true if we are rebuilding the route group list, or clearing
355          * it during a session teardown.
356          */
357         bool _in_group_rebuild_or_clear;
358         bool _route_deletion_in_progress;
359
360         void update_title ();
361         MixerStrip* strip_by_x (int x);
362
363         friend class MixerGroupTabs;
364
365         void monitor_section_going_away ();
366
367         void monitor_section_attached ();
368         void monitor_section_detached ();
369
370         void store_current_favorite_order();
371         void refiller (ARDOUR::PluginInfoList& result, const ARDOUR::PluginInfoList& plugs);
372
373         void plugin_list_changed ();
374
375         void refill_favorite_plugins ();
376         void refill_tag_combo ();
377
378         void tag_combo_changed ();
379
380         void sync_treeview_from_favorite_order ();
381         void sync_treeview_favorite_ui_state (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&);
382         void save_favorite_ui_state (const Gtk::TreeModel::iterator& iter, const Gtk::TreeModel::Path& path);
383
384         /// true if we are in fullscreen mode
385         bool _maximised;
386
387         // true if mixer list is visible
388         bool _show_mixer_list;
389
390         bool _strip_selection_change_without_scroll;
391
392         mutable boost::weak_ptr<ARDOUR::Stripable> spilled_strip;
393
394         void escape ();
395
396         Gtkmm2ext::ActionMap myactions;
397         RouteProcessorSelection _selection;
398         AxisViewSelection _axis_targets;
399
400         void vca_assign (boost::shared_ptr<ARDOUR::VCA>);
401         void vca_unassign (boost::shared_ptr<ARDOUR::VCA>);
402
403         template<class T> void control_action (boost::shared_ptr<T> (ARDOUR::Stripable::*get_control)() const);
404         void solo_action ();
405         void mute_action ();
406         void rec_enable_action ();
407         void step_gain_up_action ();
408         void step_gain_down_action ();
409         void unity_gain_action ();
410
411         void copy_processors ();
412         void cut_processors ();
413         void paste_processors ();
414         void select_all_processors ();
415         void toggle_processors ();
416         void ab_plugins ();
417 };
418
419 #endif /* __ardour_mixer_ui_h__ */