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