Fix track mode options to appear only once on audio tracks rather than twice. Fix...
[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_dialog.h"
42 #include "route_ui.h"
43 #include "enums.h"
44 #include "time_axis_view.h"
45 #include "canvas.h"
46 #include "gain_meter.h"
47
48 namespace ARDOUR {
49         class Session;
50         class Region;
51         class Diskstream;
52         class RouteGroup;
53         class IOProcessor;
54         class Processor;
55         class Location;
56         class Playlist;
57 }
58
59 class PublicEditor;
60 class RegionView;
61 class StreamView;
62 class Selection;
63 class RegionSelection;
64 class Selectable;
65 class AutomationTimeAxisView;
66 class AutomationLine;
67 class ProcessorAutomationLine;
68 class TimeSelection;
69 class RouteGroupMenu;
70
71 class RouteTimeAxisView : public RouteUI, public TimeAxisView
72 {
73 public:
74         RouteTimeAxisView (PublicEditor&, ARDOUR::Session*, boost::shared_ptr<ARDOUR::Route>, ArdourCanvas::Canvas& canvas);
75         virtual ~RouteTimeAxisView ();
76
77         void show_selection (TimeSelection&);
78         void set_button_names ();
79
80         void set_samples_per_unit (double);
81         void set_height (uint32_t h);
82         void show_timestretch (nframes_t start, nframes_t end);
83         void hide_timestretch ();
84         void selection_click (GdkEventButton*);
85         void set_selected_points (PointSelection&);
86         void set_selected_regionviews (RegionSelection&);
87         void get_selectables (nframes_t start, nframes_t end, double top, double bot, std::list<Selectable *>&);
88         void get_inverted_selectables (Selection&, std::list<Selectable*>&);
89         bool show_automation(Evoral::Parameter param);
90         void set_layer_display (LayerDisplay d);
91         LayerDisplay layer_display () const;
92
93         boost::shared_ptr<ARDOUR::Region> find_next_region (nframes_t pos, ARDOUR::RegionPoint, int32_t dir);
94         nframes64_t find_next_region_boundary (nframes64_t pos, int32_t dir);
95
96         /* Editing operations */
97         bool cut_copy_clear (Selection&, Editing::CutCopyOp);
98         bool paste (nframes_t, float times, Selection&, size_t nth);
99
100         TimeAxisView::Children get_child_list();
101
102         void toggle_automation_track (const Evoral::Parameter& param);
103
104         /* The editor calls these when mapping an operation across multiple tracks */
105         void use_new_playlist (bool prompt, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
106         void use_copy_playlist (bool prompt, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
107         void clear_playlist ();
108
109         /* group playlist name resolving */
110         std::string resolve_new_group_playlist_name(std::string &, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
111
112
113         void build_playlist_menu (Gtk::Menu *);
114
115         void add_underlay (StreamView*, bool update_xml = true);
116         void remove_underlay (StreamView*);
117         void build_underlay_menu(Gtk::Menu*);
118         
119         int set_state (const XMLNode&, int version);
120         
121         /* This is a bit nasty to expose :/ */
122         struct RouteAutomationNode {
123                 Evoral::Parameter                         param;
124                 Gtk::CheckMenuItem*                       menu_item;
125                 boost::shared_ptr<AutomationTimeAxisView> track;
126
127                 RouteAutomationNode (Evoral::Parameter par, Gtk::CheckMenuItem* mi, boost::shared_ptr<AutomationTimeAxisView> tr)
128                     : param (par), menu_item (mi), track (tr) {}
129         };
130
131         virtual void create_automation_child (const Evoral::Parameter& param, bool show) = 0;
132
133         /* make sure we get the right version of this */
134
135         XMLNode* get_automation_child_xml_node (Evoral::Parameter param) { return RouteUI::get_automation_child_xml_node (param); }
136
137         typedef std::map<Evoral::Parameter, RouteAutomationNode*> AutomationTracks;
138         AutomationTracks automation_tracks() { return _automation_tracks; }
139
140         boost::shared_ptr<AutomationTimeAxisView> automation_child(Evoral::Parameter param);
141
142         std::string         name() const;
143         StreamView*         view() const { return _view; }
144         ARDOUR::RouteGroup* route_group() const;
145         boost::shared_ptr<ARDOUR::Playlist> playlist() const;
146
147         void fast_update ();
148         void hide_meter ();
149         void show_meter ();
150         void reset_meter ();
151         void clear_meter ();
152         void io_changed (ARDOUR::IOChange, void *);
153         void meter_changed (void *);
154         void effective_gain_display () { gm.effective_gain_display(); }
155
156         static void setup_slider_pix ();
157
158 protected:
159         friend class StreamView;
160
161         struct ProcessorAutomationNode {
162                 Evoral::Parameter                         what;
163                 Gtk::CheckMenuItem*                       menu_item;
164                 boost::shared_ptr<AutomationTimeAxisView> view;
165                 RouteTimeAxisView&                        parent;
166
167             ProcessorAutomationNode (Evoral::Parameter w, Gtk::CheckMenuItem* mitem, RouteTimeAxisView& p)
168                     : what (w), menu_item (mitem), parent (p) {}
169
170             ~ProcessorAutomationNode ();
171         };
172
173         struct ProcessorAutomationInfo {
174             boost::shared_ptr<ARDOUR::Processor> processor;
175             bool                                 valid;
176             Gtk::Menu*                           menu;
177             std::vector<ProcessorAutomationNode*>     lines;
178
179             ProcessorAutomationInfo (boost::shared_ptr<ARDOUR::Processor> i)
180                     : processor (i), valid (true), menu (0) {}
181
182             ~ProcessorAutomationInfo ();
183         };
184
185
186         void diskstream_changed ();
187         void update_diskstream_display ();
188
189         gint edit_click  (GdkEventButton *);
190
191         void processors_changed (ARDOUR::RouteProcessorChange);
192
193         void add_processor_to_subplugin_menu (boost::weak_ptr<ARDOUR::Processor>);
194         void remove_processor_automation_node (ProcessorAutomationNode* pan);
195
196         void processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo*,
197                                          RouteTimeAxisView::ProcessorAutomationNode*);
198
199         void processor_automation_track_hidden (ProcessorAutomationNode*,
200                                                boost::shared_ptr<ARDOUR::Processor>);
201
202         void automation_track_hidden (Evoral::Parameter param);
203         
204         RouteAutomationNode* automation_track(Evoral::Parameter param);
205         RouteAutomationNode* automation_track(ARDOUR::AutomationType type);
206
207         ProcessorAutomationNode*
208         find_processor_automation_node (boost::shared_ptr<ARDOUR::Processor> i, Evoral::Parameter);
209
210         boost::shared_ptr<AutomationLine>
211         find_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> i, Evoral::Parameter);
212
213         void add_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> r, Evoral::Parameter);
214         void add_existing_processor_automation_curves (boost::weak_ptr<ARDOUR::Processor>);
215
216         void add_automation_child(Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show=true);
217
218         void reset_processor_automation_curves ();
219
220         void take_name_changed (void *src);
221         void route_property_changed (const PBD::PropertyChange&);
222         void name_entry_changed ();
223
224         void update_rec_display ();
225
226         virtual void label_view ();
227
228         void set_route_group_from_menu (ARDOUR::RouteGroup *);
229
230         void reset_samples_per_unit ();
231
232         void select_track_color();
233
234         virtual void build_automation_action_menu ();
235         virtual void append_extra_display_menu_items () {}
236         void         build_display_menu ();
237
238         void align_style_changed ();
239         void set_align_style (ARDOUR::AlignStyle);
240
241         void         playlist_click ();
242         void         show_playlist_selector ();
243         void         playlist_changed ();
244
245         void rename_current_playlist ();
246
247         void         automation_click ();
248         virtual void show_all_automation ();
249         virtual void show_existing_automation ();
250         virtual void hide_all_automation ();
251
252         void timestretch (nframes_t start, nframes_t end);
253
254         void visual_click ();
255         void hide_click ();
256
257         void speed_changed ();
258
259         void map_frozen ();
260
261         void color_handler ();
262
263         void region_view_added (RegionView*);
264
265         StreamView*           _view;
266         ArdourCanvas::Canvas& parent_canvas;
267         bool                  no_redraw;
268
269         Gtk::HBox   other_button_hbox;
270         Gtk::Table  button_table;
271         Gtk::Button processor_button;
272         Gtk::Button route_group_button;
273         Gtk::Button playlist_button;
274         Gtk::Button size_button;
275         Gtk::Button automation_button;
276         Gtk::Button hide_button;
277         Gtk::Button visual_button;
278
279         Gtk::Menu           subplugin_menu;
280         Gtk::Menu*          automation_action_menu;
281         Gtk::MenuItem*      plugins_submenu_item;
282         RouteGroupMenu*     route_group_menu;
283         Gtk::RadioMenuItem* align_existing_item;
284         Gtk::RadioMenuItem* align_capture_item;
285         Gtk::RadioMenuItem* normal_track_mode_item;
286         Gtk::RadioMenuItem* non_layered_track_mode_item;
287         Gtk::RadioMenuItem* destructive_track_mode_item;
288         Gtk::Menu*          playlist_menu;
289         Gtk::Menu*          playlist_action_menu;
290         Gtk::MenuItem*      playlist_item;
291         Gtk::Menu*          mode_menu;
292         Gtk::Menu*          color_mode_menu;
293
294         virtual Gtk::Menu* build_color_mode_menu() { return 0; }
295
296         void use_playlist (Gtk::RadioMenuItem *item, boost::weak_ptr<ARDOUR::Playlist> wpl);
297
298         ArdourCanvas::SimpleRect* timestretch_rect;
299
300         void set_track_mode (ARDOUR::TrackMode);
301         void _set_track_mode (ARDOUR::Track* track, ARDOUR::TrackMode mode, Gtk::RadioMenuItem* reset_item, Gtk::RadioMenuItem* reset_item_2);
302         void track_mode_changed ();
303
304         std::list<ProcessorAutomationInfo*> processor_automation;
305
306         typedef std::vector<boost::shared_ptr<AutomationLine> > ProcessorAutomationCurves;
307         ProcessorAutomationCurves processor_automation_curves;
308
309         // Set from XML so context menu automation buttons can be correctly initialized
310         std::set<Evoral::Parameter> _show_automation;
311
312         AutomationTracks _automation_tracks;
313
314         void post_construct ();
315
316         GainMeterBase gm;
317
318         static Glib::RefPtr<Gdk::Pixbuf> slider;
319
320         XMLNode* underlay_xml_node;
321         bool set_underlay_state();
322
323         typedef std::list<StreamView*> UnderlayList;
324         UnderlayList _underlay_streams;
325         typedef std::list<RouteTimeAxisView*> UnderlayMirrorList;
326         UnderlayMirrorList _underlay_mirrors;
327
328         bool _ignore_track_mode_change; ///< true to ignore track mode change signals
329 };
330
331 #endif /* __ardour_route_time_axis_h__ */
332