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