adjust plugin-UI height when toggling expanders
[ardour.git] / gtk2_ardour / editor_routes.h
1 /*
2     Copyright (C) 2009 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_gtk_editor_route_h__
21 #define __ardour_gtk_editor_route_h__
22
23 #include "pbd/signals.h"
24 #include "gtkmm2ext/widget_state.h"
25
26 #include "editor_component.h"
27
28 class VCATimeAxisView;
29
30 class EditorRoutes : public EditorComponent, public PBD::ScopedConnectionList, public ARDOUR::SessionHandlePtr
31 {
32 public:
33         EditorRoutes (Editor *);
34
35         void set_session (ARDOUR::Session *);
36
37         Gtk::Widget& widget () {
38                 return _scroller;
39         }
40
41         void move_selected_tracks (bool);
42         void show_track_in_display (TimeAxisView &);
43
44
45         void suspend_redisplay () {
46                 if (!_no_redisplay) {
47                         _no_redisplay = true;
48                         _redisplay_on_resume = false;
49                 }
50         }
51
52         void resume_redisplay () {
53                 _no_redisplay = false;
54                 if (_redisplay_on_resume) {
55                         redisplay ();
56                 }
57         }
58
59         void redisplay ();
60         void update_visibility ();
61         void time_axis_views_added (std::list<TimeAxisView*>);
62         void route_removed (TimeAxisView *);
63         void hide_track_in_display (TimeAxisView &);
64         std::list<TimeAxisView*> views () const;
65         void hide_all_tracks (bool);
66         void clear ();
67         void sync_presentation_info_from_treeview ();
68
69 private:
70         void initial_display ();
71         void redisplay_real ();
72         void on_input_active_changed (std::string const &);
73         void on_tv_rec_enable_changed (std::string const &);
74         void on_tv_rec_safe_toggled (std::string const &);
75         void on_tv_mute_enable_toggled (std::string const &);
76         void on_tv_solo_enable_toggled (std::string const &);
77         void on_tv_solo_isolate_toggled (std::string const &);
78         void on_tv_solo_safe_toggled (std::string const &);
79         void build_menu ();
80         void show_menu ();
81         void sync_treeview_from_presentation_info ();
82         void row_deleted (Gtk::TreeModel::Path const &);
83         void visible_changed (std::string const &);
84         void active_changed (std::string const &);
85         void reordered (Gtk::TreeModel::Path const &, Gtk::TreeModel::iterator const &, int *);
86         bool button_press (GdkEventButton *);
87         void route_property_changed (const PBD::PropertyChange&, boost::weak_ptr<ARDOUR::Stripable>);
88         void handle_gui_changes (std::string const &, void *);
89         bool idle_update_mute_rec_solo_etc ();
90         void update_rec_display ();
91         void update_mute_display ();
92         void update_solo_display ();
93         void update_solo_isolate_display ();
94         void update_solo_safe_display ();
95         void update_input_active_display ();
96         void update_active_display ();
97         void set_all_tracks_visibility (bool);
98         void set_all_audio_midi_visibility (int, bool);
99         void show_all_routes ();
100         void hide_all_routes ();
101         void show_all_audiotracks ();
102         void hide_all_audiotracks ();
103         void show_all_audiobus ();
104         void hide_all_audiobus ();
105         void show_all_miditracks ();
106         void hide_all_miditracks ();
107         void show_tracks_with_regions_at_playhead ();
108         void selection_changed ();
109
110         int plugin_setup (boost::shared_ptr<ARDOUR::Route>, boost::shared_ptr<ARDOUR::PluginInsert>, ARDOUR::Route::PluginSetupOptions);
111
112         void display_drag_data_received (
113                 Glib::RefPtr<Gdk::DragContext> const &, gint, gint, Gtk::SelectionData const &, guint, guint
114                 );
115
116         bool selection_filter (Glib::RefPtr<Gtk::TreeModel> const &, Gtk::TreeModel::Path const &, bool);
117         void name_edit (std::string const &, std::string const &);
118         void solo_changed_so_update_mute ();
119
120         struct ModelColumns : public Gtk::TreeModel::ColumnRecord {
121                 ModelColumns() {
122                         add (text);
123                         add (visible);
124                         add (rec_state);
125                         add (rec_safe);
126                         add (mute_state);
127                         add (solo_state);
128                         add (solo_visible);
129                         add (solo_isolate_state);
130                         add (solo_safe_state);
131                         add (is_track);
132                         add (tv);
133                         add (stripable);
134                         add (name_editable);
135                         add (is_input_active);
136                         add (is_midi);
137                         add (active);
138                 }
139
140                 Gtk::TreeModelColumn<std::string>    text;
141                 Gtk::TreeModelColumn<bool>           visible;
142                 Gtk::TreeModelColumn<uint32_t>       rec_state;
143                 Gtk::TreeModelColumn<uint32_t>       rec_safe;
144                 Gtk::TreeModelColumn<uint32_t>       mute_state;
145                 Gtk::TreeModelColumn<uint32_t>       solo_state;
146                 /** true if the solo buttons are visible for this route, otherwise false */
147                 Gtk::TreeModelColumn<bool>           solo_visible;
148                 Gtk::TreeModelColumn<uint32_t>       solo_isolate_state;
149                 Gtk::TreeModelColumn<uint32_t>       solo_safe_state;
150                 Gtk::TreeModelColumn<bool>           is_track;
151                 Gtk::TreeModelColumn<TimeAxisView*>  tv;
152                 Gtk::TreeModelColumn<boost::shared_ptr<ARDOUR::Stripable> >  stripable;
153                 Gtk::TreeModelColumn<bool>           name_editable;
154                 Gtk::TreeModelColumn<bool>           is_input_active;
155                 Gtk::TreeModelColumn<bool>           is_midi;
156                 Gtk::TreeModelColumn<bool>           active;
157         };
158
159         Gtk::ScrolledWindow _scroller;
160         Gtkmm2ext::DnDTreeView<boost::shared_ptr<ARDOUR::Route> > _display;
161         Glib::RefPtr<Gtk::ListStore> _model;
162         ModelColumns _columns;
163         int _name_column;
164         int _visible_column;
165         int _active_column;
166
167         bool _ignore_reorder;
168         bool _no_redisplay;
169         bool _adding_routes;
170         bool _route_deletion_in_progress;
171         bool _redisplay_on_resume;
172         volatile gint _redisplay_active;
173         volatile gint _queue_tv_update;
174
175         Gtk::Menu* _menu;
176         Gtk::Widget* old_focus;
177         uint32_t selection_countdown;
178         Gtk::CellEditable* name_editable;
179
180         bool key_press (GdkEventKey* ev);
181         bool focus_in (GdkEventFocus*);
182         bool focus_out (GdkEventFocus*);
183         bool enter_notify (GdkEventCrossing*);
184         bool leave_notify (GdkEventCrossing*);
185         void name_edit_started (Gtk::CellEditable*, const Glib::ustring&);
186
187         bool get_relevant_routes (boost::shared_ptr<ARDOUR::RouteList> rl);
188 };
189
190 #endif /* __ardour_gtk_editor_route_h__ */