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