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