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