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