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