Skip silent sources on session-archive -- fixes #7699
[ardour.git] / gtk2_ardour / route_time_axis.h
1 /*
2     Copyright (C) 2006 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_route_time_axis_h__
21 #define __ardour_route_time_axis_h__
22
23 #include <list>
24 #include <set>
25
26 #include <gtkmm/table.h>
27 #include <gtkmm/button.h>
28 #include <gtkmm/box.h>
29 #include <gtkmm/menu.h>
30 #include <gtkmm/menuitem.h>
31 #include <gtkmm/radiomenuitem.h>
32 #include <gtkmm/checkmenuitem.h>
33 #include <gtkmm/adjustment.h>
34
35 #include "widgets/ardour_button.h"
36
37 #include "ardour/playlist.h"
38 #include "ardour/types.h"
39
40 #include "ardour_dialog.h"
41 #include "route_ui.h"
42 #include "enums.h"
43 #include "stripable_time_axis.h"
44 #include "gain_meter.h"
45
46 namespace ARDOUR {
47         class Session;
48         class Region;
49         class RouteGroup;
50         class IOProcessor;
51         class Processor;
52         class Location;
53         class Playlist;
54 }
55
56 namespace ArdourCanvas {
57         class Rectangle;
58 }
59
60 class PublicEditor;
61 class RegionView;
62 class StreamView;
63 class Selection;
64 class RegionSelection;
65 class Selectable;
66 class AutomationTimeAxisView;
67 class AutomationLine;
68 class ProcessorAutomationLine;
69 class TimeSelection;
70 class RouteGroupMenu;
71 class ItemCounts;
72
73 class RouteTimeAxisView : public RouteUI, public StripableTimeAxisView
74 {
75 public:
76         RouteTimeAxisView (PublicEditor&, ARDOUR::Session*, ArdourCanvas::Canvas& canvas);
77         virtual ~RouteTimeAxisView ();
78
79         std::string name()  const;
80         Gdk::Color color () const;
81         bool marked_for_display () const;
82         bool set_marked_for_display (bool);
83
84         boost::shared_ptr<ARDOUR::Stripable> stripable() const { return RouteUI::stripable(); }
85
86         void set_route (boost::shared_ptr<ARDOUR::Route>);
87
88         void show_selection (TimeSelection&);
89         void set_button_names ();
90
91         void set_samples_per_pixel (double);
92         void set_height (uint32_t h, TrackHeightMode m = OnlySelf);
93         void show_timestretch (samplepos_t start, samplepos_t end, int layers, int layer);
94         void hide_timestretch ();
95         void selection_click (GdkEventButton*);
96         void set_selected_points (PointSelection&);
97         void set_selected_regionviews (RegionSelection&);
98         void get_selectables (ARDOUR::samplepos_t start, ARDOUR::samplepos_t end, double top, double bot, std::list<Selectable *>&, bool within = false);
99         void get_inverted_selectables (Selection&, std::list<Selectable*>&);
100         void set_layer_display (LayerDisplay d, bool apply_to_selection = false);
101         LayerDisplay layer_display () const;
102
103         boost::shared_ptr<ARDOUR::Region> find_next_region (samplepos_t pos, ARDOUR::RegionPoint, int32_t dir);
104         samplepos_t find_next_region_boundary (samplepos_t pos, int32_t dir);
105
106         /* Editing operations */
107         void cut_copy_clear (Selection&, Editing::CutCopyOp);
108         bool paste (ARDOUR::samplepos_t, const Selection&, PasteContext& ctx, const int32_t sub_num);
109         RegionView* combine_regions ();
110         void uncombine_regions ();
111         void uncombine_region (RegionView*);
112         void toggle_automation_track (const Evoral::Parameter& param);
113         void fade_range (TimeSelection&);
114
115         /* The editor calls these when mapping an operation across multiple tracks */
116         void use_new_playlist (bool prompt, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &, bool copy);
117         void clear_playlist ();
118
119         /* group playlist name resolving */
120         std::string resolve_new_group_playlist_name(std::string &, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
121
122         void build_playlist_menu ();
123
124         void add_underlay (StreamView*, bool update_xml = true);
125         void remove_underlay (StreamView*);
126         void build_underlay_menu(Gtk::Menu*);
127
128         int set_state (const XMLNode&, int version);
129
130         virtual Gtk::CheckMenuItem* automation_child_menu_item (Evoral::Parameter);
131
132         StreamView*         view() const { return _view; }
133         ARDOUR::RouteGroup* route_group() const;
134         boost::shared_ptr<ARDOUR::Playlist> playlist() const;
135
136         void fast_update ();
137         void hide_meter ();
138         void show_meter ();
139         void reset_meter ();
140         void clear_meter ();
141         void io_changed (ARDOUR::IOChange, void *);
142         void meter_changed ();
143         void effective_gain_display () { gm.effective_gain_display(); }
144
145         std::string state_id() const;
146
147 protected:
148         friend class StreamView;
149
150         struct ProcessorAutomationNode {
151                 Evoral::Parameter                         what;
152                 Gtk::CheckMenuItem*                       menu_item;
153                 boost::shared_ptr<AutomationTimeAxisView> view;
154                 RouteTimeAxisView&                        parent;
155
156                 ProcessorAutomationNode (Evoral::Parameter w, Gtk::CheckMenuItem* mitem, RouteTimeAxisView& p)
157                     : what (w), menu_item (mitem), parent (p) {}
158
159                 ~ProcessorAutomationNode ();
160         };
161
162         struct ProcessorAutomationInfo {
163                 boost::shared_ptr<ARDOUR::Processor> processor;
164                 bool                                 valid;
165                 Gtk::Menu*                           menu;
166                 std::vector<ProcessorAutomationNode*>     lines;
167
168                 ProcessorAutomationInfo (boost::shared_ptr<ARDOUR::Processor> i)
169                     : processor (i), valid (true), menu (0) {}
170
171                 ~ProcessorAutomationInfo ();
172         };
173
174
175         void update_diskstream_display ();
176
177         bool route_group_click  (GdkEventButton *);
178
179         virtual void processors_changed (ARDOUR::RouteProcessorChange);
180
181         virtual void add_processor_to_subplugin_menu (boost::weak_ptr<ARDOUR::Processor>);
182         void remove_processor_automation_node (ProcessorAutomationNode* pan);
183
184         void processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo*,
185                                          RouteTimeAxisView::ProcessorAutomationNode*);
186
187         void processor_automation_track_hidden (ProcessorAutomationNode*,
188                                                boost::shared_ptr<ARDOUR::Processor>);
189
190
191         ProcessorAutomationNode*
192         find_processor_automation_node (boost::shared_ptr<ARDOUR::Processor> i, Evoral::Parameter);
193
194         boost::shared_ptr<AutomationLine>
195         find_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> i, Evoral::Parameter);
196
197         void add_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> r, Evoral::Parameter);
198         void add_existing_processor_automation_curves (boost::weak_ptr<ARDOUR::Processor>);
199
200
201         void reset_processor_automation_curves ();
202
203         void take_name_changed (void *src);
204         void route_property_changed (const PBD::PropertyChange&);
205         bool name_entry_changed (std::string const&);
206
207         virtual void toggle_channel_selector () {}
208
209         void blink_rec_display (bool onoff);
210
211         virtual void label_view ();
212
213         virtual void build_automation_action_menu (bool);
214         virtual void append_extra_display_menu_items () {}
215         void         build_display_menu ();
216
217         void set_align_choice (Gtk::RadioMenuItem*, ARDOUR::AlignChoice, bool apply_to_selection = false);
218
219         bool         playlist_click (GdkEventButton *);
220         void         show_playlist_selector ();
221         void         playlist_changed ();
222
223         void rename_current_playlist ();
224
225         bool         automation_click (GdkEventButton *);
226
227         virtual void show_all_automation (bool apply_to_selection = false);
228         virtual void show_existing_automation (bool apply_to_selection = false);
229         virtual void hide_all_automation (bool apply_to_selection = false);
230
231         void timestretch (samplepos_t start, samplepos_t end);
232         void speed_changed ();
233         void map_frozen ();
234         void color_handler ();
235         void region_view_added (RegionView*);
236         void create_gain_automation_child (const Evoral::Parameter &, bool);
237         void create_trim_automation_child (const Evoral::Parameter &, bool);
238         void create_mute_automation_child (const Evoral::Parameter &, bool);
239         void setup_processor_menu_and_curves ();
240         void route_color_changed ();
241         bool can_edit_name() const;
242
243         StreamView*           _view;
244
245         Gtk::HBox   other_button_hbox;
246         Gtk::Table  button_table;
247         ArdourWidgets::ArdourButton route_group_button;
248         ArdourWidgets::ArdourButton playlist_button;
249         ArdourWidgets::ArdourButton automation_button;
250         ArdourWidgets::ArdourButton number_label;
251
252         Gtk::Menu           subplugin_menu;
253         Gtk::Menu*          automation_action_menu;
254         Gtk::MenuItem*      plugins_submenu_item;
255         RouteGroupMenu*     route_group_menu;
256         Gtk::Menu*          playlist_action_menu;
257         Gtk::MenuItem*      playlist_item;
258         Gtk::Menu*          mode_menu;
259         Gtk::Menu*          color_mode_menu;
260
261         virtual Gtk::Menu* build_color_mode_menu() { return 0; }
262
263         void use_playlist (Gtk::RadioMenuItem *item, boost::weak_ptr<ARDOUR::Playlist> wpl);
264
265         ArdourCanvas::Rectangle* timestretch_rect;
266
267         /** Information about all automatable processor parameters that apply to
268          *  this route.  The Amp processor is not included in this list.
269          */
270         std::list<ProcessorAutomationInfo*> processor_automation;
271
272         typedef std::vector<boost::shared_ptr<AutomationLine> > ProcessorAutomationCurves;
273         ProcessorAutomationCurves processor_automation_curves;
274         /** parameter -> menu item map for the plugin automation menu */
275         ParameterMenuMap _subplugin_menu_map;
276
277         void post_construct ();
278
279         GainMeterBase gm;
280
281         XMLNode* underlay_xml_node;
282         bool set_underlay_state();
283
284         typedef std::list<StreamView*> UnderlayList;
285         UnderlayList _underlay_streams;
286         typedef std::list<RouteTimeAxisView*> UnderlayMirrorList;
287         UnderlayMirrorList _underlay_mirrors;
288
289         bool _ignore_set_layer_display;
290
291 protected:
292         void update_pan_track_visibility ();
293
294         /** Ensure that we have the appropriate automation lanes for panners.
295          *
296          *  @param show true to show any new views that we create, otherwise false.
297          */
298         void ensure_pan_views (bool show = true);
299
300         std::list<boost::shared_ptr<AutomationTimeAxisView> > pan_tracks;
301         Gtk::CheckMenuItem* pan_automation_item;
302
303 private:
304
305         void remove_child (boost::shared_ptr<TimeAxisView>);
306         void update_playlist_tip ();
307         void parameter_changed (std::string const & p);
308         void update_track_number_visibility();
309
310         void drop_instrument_ref ();
311         void reread_midnam ();
312         PBD::ScopedConnectionList midnam_connection;
313 };
314
315 #endif /* __ardour_route_time_axis_h__ */