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