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