add mike start (linux dsp) to author list
[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/session_handle.h"
41
42 #include "enums.h"
43 #include "mixer_actor.h"
44
45 namespace ARDOUR {
46         class Route;
47         class RouteGroup;
48 };
49
50 class MixerStrip;
51 class PluginSelector;
52 class MixerGroupTabs;
53 class MonitorSection;
54
55 class Mixer_UI : public Gtk::Window, public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr, public MixerActor
56 {
57   public:
58         Mixer_UI ();
59         ~Mixer_UI();
60
61         void set_session (ARDOUR::Session *);
62
63         PluginSelector* plugin_selector();
64
65         void  set_strip_width (Width);
66         Width get_strip_width () const { return _strip_width; }
67
68         void unselect_strip_in_display (MixerStrip*);
69         void select_strip_in_display (MixerStrip*);
70
71         XMLNode& get_state (void);
72         int set_state (const XMLNode& );
73
74         void show_window ();
75         bool hide_window (GdkEventAny *ev);
76         void show_strip (MixerStrip *);
77         void hide_strip (MixerStrip *);
78
79         void ensure_float (Gtk::Window&);
80         void toggle_auto_rebinding ();
81         void set_auto_rebinding(bool);
82
83         MonitorSection* monitor_section() const { return _monitor_section; }
84
85   protected:
86         void set_route_targets_for_operation ();
87
88   private:
89         bool                                    _visible;
90
91         Gtk::HBox                               global_hpacker;
92         Gtk::VBox                               global_vpacker;
93         Gtk::ScrolledWindow             scroller;
94         Gtk::EventBox                   scroller_base;
95         Gtk::HBox                               scroller_hpacker;
96         Gtk::VBox                               mixer_scroller_vpacker;
97         Gtk::VBox                               list_vpacker;
98         Gtk::Label                              group_display_button_label;
99         Gtk::Button                             group_display_button;
100         Gtk::ScrolledWindow             track_display_scroller;
101         Gtk::ScrolledWindow             group_display_scroller;
102         Gtk::VBox                               group_display_vbox;
103         Gtk::Frame                              track_display_frame;
104         Gtk::Frame                              group_display_frame;
105         Gtk::VPaned                             rhs_pane1;
106         Gtk::HBox                               strip_packer;
107         Gtk::HBox                               out_packer;
108         Gtk::HPaned                             list_hpane;
109
110         MixerGroupTabs* _group_tabs;
111
112         // for restoring window geometry.
113         int m_root_x, m_root_y, m_width, m_height;
114
115         void set_window_pos_and_size ();
116         void get_window_pos_and_size ();
117
118         bool on_key_press_event (GdkEventKey*);
119         bool on_key_release_event (GdkEventKey*);
120         bool on_scroll_event (GdkEventScroll*);
121
122         void pane_allocation_handler (Gtk::Allocation&, Gtk::Paned*);
123
124         std::list<MixerStrip *> strips;
125
126         bool strip_scroller_button_release (GdkEventButton*);
127         void scroll_left ();
128         void scroll_right ();
129
130         void add_strip (ARDOUR::RouteList&);
131         void remove_strip (MixerStrip *);
132
133         MixerStrip* strip_by_route (boost::shared_ptr<ARDOUR::Route>);
134
135         void hide_all_strips (bool with_select);
136         void unselect_all_strips();
137         void select_all_strips ();
138         void unselect_all_audiotrack_strips ();
139         void select_all_audiotrack_strips ();
140         void unselect_all_audiobus_strips ();
141         void select_all_audiobus_strips ();
142
143         void auto_rebind_midi_controls ();
144         bool auto_rebinding;
145
146         void strip_select_op (bool audiotrack, bool select);
147         void select_strip_op (MixerStrip*, bool select);
148
149         void follow_strip_selection ();
150
151         gint start_updating ();
152         gint stop_updating ();
153
154         void session_going_away ();
155
156         sigc::connection fast_screen_update_connection;
157         void fast_update_strips ();
158
159         void track_name_changed (MixerStrip *);
160
161         void redisplay_track_list ();
162         bool no_track_list_redisplay;
163         bool track_display_button_press (GdkEventButton*);
164         void strip_width_changed ();
165
166         void track_list_change (const Gtk::TreeModel::Path&,const Gtk::TreeModel::iterator&);
167         void track_list_delete (const Gtk::TreeModel::Path&);
168         void track_list_reorder (const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter, int* new_order);
169
170         void initial_track_display ();
171         void show_track_list_menu ();
172
173         void set_all_strips_visibility (bool yn);
174         void set_all_audio_visibility (int tracks, bool yn);
175
176         void hide_all_routes ();
177         void show_all_routes ();
178         void show_all_audiobus ();
179         void hide_all_audiobus ();
180         void show_all_audiotracks();
181         void hide_all_audiotracks ();
182
183         bool in_group_row_change;
184
185         void group_selected (gint row, gint col, GdkEvent *ev);
186         void group_unselected (gint row, gint col, GdkEvent *ev);
187         void group_display_active_clicked();
188         void new_route_group ();
189         void remove_selected_route_group ();
190         void activate_all_route_groups ();
191         void disable_all_route_groups ();
192         void add_route_group (ARDOUR::RouteGroup *);
193         void route_groups_changed ();
194         void route_group_name_edit (const std::string&, const std::string&);
195         void route_group_row_change (const Gtk::TreeModel::Path& path,const Gtk::TreeModel::iterator& iter);
196         void route_group_row_deleted (Gtk::TreeModel::Path const &);
197
198         Gtk::Menu *track_menu;
199         void track_column_click (gint);
200         void build_track_menu ();
201
202         MonitorSection* _monitor_section;
203         PluginSelector    *_plugin_selector;
204
205         void strip_property_changed (const PBD::PropertyChange&, MixerStrip *);
206         void route_group_property_changed (ARDOUR::RouteGroup *, const PBD::PropertyChange &);
207
208         /* various treeviews */
209
210         struct TrackDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
211             TrackDisplayModelColumns () {
212                     add (text);
213                     add (visible);
214                     add (route);
215                     add (strip);
216             }
217             Gtk::TreeModelColumn<bool>           visible;
218             Gtk::TreeModelColumn<std::string>  text;
219             Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Route> > route;
220             Gtk::TreeModelColumn<MixerStrip*>    strip;
221         };
222
223         struct GroupDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
224             GroupDisplayModelColumns() {
225                     add (visible);
226                     add (text);
227                     add (group);
228             }
229             Gtk::TreeModelColumn<bool>                                  visible;
230             Gtk::TreeModelColumn<std::string>                   text;
231             Gtk::TreeModelColumn<ARDOUR::RouteGroup*>   group;
232         };
233
234         TrackDisplayModelColumns    track_columns;
235         GroupDisplayModelColumns    group_columns;
236
237         Gtk::TreeView track_display;
238         Gtk::TreeView group_display;
239
240         Glib::RefPtr<Gtk::ListStore> track_model;
241         Glib::RefPtr<Gtk::ListStore> group_model;
242
243         bool group_display_button_press (GdkEventButton*);
244         void group_display_selection_changed ();
245
246         bool strip_button_release_event (GdkEventButton*, MixerStrip*);
247
248         Width _strip_width;
249
250         void sync_order_keys (std::string const &);
251         bool strip_redisplay_does_not_reset_order_keys;
252         bool strip_redisplay_does_not_sync_order_keys;
253         bool ignore_sync;
254
255         void parameter_changed (std::string const &);
256         void set_route_group_activation (ARDOUR::RouteGroup *, bool);
257
258         void setup_track_display ();
259         void new_track_or_bus ();
260
261         static const int32_t default_width = 478;
262         static const int32_t default_height = 765;
263
264         /** true if we are rebuilding the route group list, or clearing
265             it during a session teardown.
266         */
267         bool _in_group_rebuild_or_clear;
268
269         void update_title ();
270         MixerStrip* strip_by_x (int x);
271
272         friend class MixerGroupTabs;
273 };
274
275 #endif /* __ardour_mixer_ui_h__ */
276
277