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