key stroke (left/right arrow) and wheel (left/right, shift-down/up) scrolling in...
[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
35 #include <pbd/stateful.h>
36
37 #include <ardour/ardour.h>
38 #include <ardour/io.h>
39
40 #include "route_redirect_selection.h"
41 #include "enums.h"
42
43 namespace ARDOUR {
44         class Route;
45         class RouteGroup;
46         class Session;
47         class AudioDiskstream;
48 };
49
50 class MixerStrip;
51 class PluginSelector;
52
53 class Mixer_UI : public Gtk::Window
54 {
55   public:
56         Mixer_UI ();
57         ~Mixer_UI();
58
59         void connect_to_session (ARDOUR::Session *);
60         
61         PluginSelector&  plugin_selector() { return *_plugin_selector; }
62
63         void  set_strip_width (Width);
64         Width get_strip_width () const { return _strip_width; }
65
66         void unselect_strip_in_display (MixerStrip*);
67         void select_strip_in_display (MixerStrip*);
68
69         XMLNode& get_state (void);
70         int set_state (const XMLNode& );
71
72         void show_window ();
73         bool hide_window (GdkEventAny *ev);
74         void show_strip (MixerStrip *);
75         void hide_strip (MixerStrip *);
76
77         void ensure_float (Gtk::Window&);
78         void toggle_auto_rebinding ();
79         void set_auto_rebinding(bool);
80
81         RouteRedirectSelection& selection() { return _selection; }
82         
83         static const char* get_order_key();
84
85   private:
86         ARDOUR::Session         *session;
87
88         bool _visible;
89         
90         Gtk::HBox                global_hpacker;
91         Gtk::VBox                global_vpacker;
92         Gtk::ScrolledWindow      scroller;
93         Gtk::EventBox            scroller_base;
94         Gtk::HBox                scroller_hpacker;
95         Gtk::VBox                mixer_scroller_vpacker;
96         Gtk::VBox                list_vpacker;
97         Gtk::Label               group_display_button_label;
98         Gtk::Button              group_display_button;
99         Gtk::ScrolledWindow      track_display_scroller;
100         Gtk::ScrolledWindow      group_display_scroller;
101         Gtk::VBox                group_display_vbox;
102         Gtk::Frame               track_display_frame;
103         Gtk::Frame               group_display_frame;
104         Gtk::VPaned              rhs_pane1;
105         Gtk::HBox                strip_packer;
106         Gtk::HBox                out_packer;
107         Gtk::HPaned              list_hpane;
108
109         // for restoring window geometry.
110         int m_root_x, m_root_y, m_width, m_height;
111         
112         void set_window_pos_and_size ();
113         void get_window_pos_and_size ();
114
115         bool on_key_press_event (GdkEventKey*);
116         bool on_scroll_event (GdkEventScroll*);
117
118         void pane_allocation_handler (Gtk::Allocation&, Gtk::Paned*);
119         
120         list<MixerStrip *> strips;
121
122         bool strip_scroller_button_release (GdkEventButton*);
123         void scroll_left ();
124         void scroll_right ();
125
126         void add_strip (ARDOUR::Session::RouteList&);
127         void remove_strip (MixerStrip *);
128
129         void hide_all_strips (bool with_select);
130         void unselect_all_strips();
131         void select_all_strips ();
132         void unselect_all_audiotrack_strips ();
133         void select_all_audiotrack_strips ();
134         void unselect_all_audiobus_strips ();
135         void select_all_audiobus_strips ();
136
137         void auto_rebind_midi_controls ();
138         bool auto_rebinding;
139
140         void strip_select_op (bool audiotrack, bool select);
141         void select_strip_op (MixerStrip*, bool select);
142
143         void follow_strip_selection ();
144
145         gint start_updating ();
146         gint stop_updating ();
147
148         void disconnect_from_session ();
149         
150         sigc::connection fast_screen_update_connection;
151         void fast_update_strips ();
152
153         void track_name_changed (MixerStrip *);
154
155         void redisplay_track_list ();
156         bool no_track_list_redisplay;
157         bool track_display_button_press (GdkEventButton*);
158 #ifdef GTKOSX
159         void queue_draw_all_strips ();
160 #endif
161         
162         void track_list_change (const Gtk::TreeModel::Path&,const Gtk::TreeModel::iterator&);
163         void track_list_delete (const Gtk::TreeModel::Path&);
164         void track_list_reorder (const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter, int* new_order);
165
166         void initial_track_display ();
167         void show_track_list_menu ();
168
169         void set_all_strips_visibility (bool yn);
170         void set_all_audio_visibility (int tracks, bool yn);
171         
172         void hide_all_routes ();
173         void show_all_routes ();
174         void show_all_audiobus ();
175         void hide_all_audiobus ();
176         void show_all_audiotracks();
177         void hide_all_audiotracks ();
178
179         Gtk::Menu* mix_group_context_menu;
180         bool in_group_row_change;
181
182         void group_selected (gint row, gint col, GdkEvent *ev);
183         void group_unselected (gint row, gint col, GdkEvent *ev);
184         void group_display_active_clicked();
185         void new_mix_group ();
186         void remove_selected_mix_group ();
187         void build_mix_group_context_menu ();
188         void activate_all_mix_groups ();
189         void disable_all_mix_groups ();
190         void show_all_mix_groups ();
191         void hide_all_mix_groups ();
192         void add_mix_group (ARDOUR::RouteGroup *);
193         void mix_groups_changed ();
194         void mix_group_name_edit (const Glib::ustring&, const Glib::ustring&);
195         void mix_group_row_change (const Gtk::TreeModel::Path& path,const Gtk::TreeModel::iterator& iter);
196
197         Gtk::Menu *track_menu;
198         void track_column_click (gint);
199         void build_track_menu ();
200
201         PluginSelector    *_plugin_selector;
202
203         void strip_name_changed (void *src, MixerStrip *);
204
205         void group_flags_changed (void *src, ARDOUR::RouteGroup *);
206
207         /* various treeviews */
208         
209         struct TrackDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
210             TrackDisplayModelColumns () {
211                     add (text);
212                     add (visible);
213                     add (route);
214                     add (strip);
215             }
216             Gtk::TreeModelColumn<bool>           visible;
217             Gtk::TreeModelColumn<Glib::ustring>  text;
218             Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Route> > route;
219             Gtk::TreeModelColumn<MixerStrip*>    strip;
220         };
221
222         struct GroupDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
223             GroupDisplayModelColumns() { 
224                     add (active);
225                     add (visible);
226                     add (text);
227                     add (group);
228             }
229             Gtk::TreeModelColumn<bool>                active;
230             Gtk::TreeModelColumn<bool>  visible;
231             Gtk::TreeModelColumn<Glib::ustring>       text;
232             Gtk::TreeModelColumn<ARDOUR::RouteGroup*> group;
233         };
234
235         TrackDisplayModelColumns    track_columns;
236         GroupDisplayModelColumns    group_columns;
237
238         Gtk::TreeView track_display;
239         Gtk::TreeView group_display;
240
241         Glib::RefPtr<Gtk::ListStore> track_model;
242         Glib::RefPtr<Gtk::ListStore> group_model;
243
244         bool group_display_button_press (GdkEventButton*);
245         void group_display_selection_changed ();
246
247         bool strip_button_release_event (GdkEventButton*, MixerStrip*);
248
249         RouteRedirectSelection _selection;
250
251         Width _strip_width;
252
253         void sync_order_keys (const char *src);
254         bool strip_redisplay_does_not_reset_order_keys;
255         bool strip_redisplay_does_not_sync_order_keys;
256
257         static const int32_t default_width = 478;
258         static const int32_t default_height = 765;
259 };
260
261 #endif /* __ardour_mixer_ui_h__ */
262
263