Fixed bug where embedded sources did not correctly obey the BWF time stamp and would...
[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 RouteGroup;
52         class IOProcessor;
53         class Processor;
54         class Location;
55         class Playlist;
56 }
57
58 class PublicEditor;
59 class RegionView;
60 class StreamView;
61 class Selection;
62 class RegionSelection;
63 class Selectable;
64 class AutomationTimeAxisView;
65 class AutomationLine;
66 class ProcessorAutomationLine;
67 class TimeSelection;
68 class RouteGroupMenu;
69
70 class RouteTimeAxisView : public RouteUI, public TimeAxisView
71 {
72 public:
73         RouteTimeAxisView (PublicEditor&, ARDOUR::Session*, boost::shared_ptr<ARDOUR::Route>, ArdourCanvas::Canvas& canvas);
74         virtual ~RouteTimeAxisView ();
75
76         void show_selection (TimeSelection&);
77         void set_button_names ();
78
79         void set_samples_per_unit (double);
80         void set_height (uint32_t h);
81         void show_timestretch (framepos_t start, framepos_t end);
82         void hide_timestretch ();
83         void selection_click (GdkEventButton*);
84         void set_selected_points (PointSelection&);
85         void set_selected_regionviews (RegionSelection&);
86         void get_selectables (ARDOUR::framepos_t start, ARDOUR::framepos_t end, double top, double bot, std::list<Selectable *>&);
87         void get_inverted_selectables (Selection&, std::list<Selectable*>&);
88         void set_layer_display (LayerDisplay d, bool apply_to_selection = false);
89         LayerDisplay layer_display () const;
90
91         boost::shared_ptr<ARDOUR::Region> find_next_region (framepos_t pos, ARDOUR::RegionPoint, int32_t dir);
92         framepos_t find_next_region_boundary (framepos_t pos, int32_t dir);
93
94         /* Editing operations */
95         void cut_copy_clear (Selection&, Editing::CutCopyOp);
96         bool paste (ARDOUR::framepos_t, float times, Selection&, size_t nth);
97         RegionView* combine_regions ();
98         void uncombine_regions ();
99         void uncombine_region (RegionView*);
100         void toggle_automation_track (const Evoral::Parameter& param);
101
102         /* The editor calls these when mapping an operation across multiple tracks */
103         void use_new_playlist (bool prompt, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
104         void use_copy_playlist (bool prompt, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
105         void clear_playlist ();
106
107         /* group playlist name resolving */
108         std::string resolve_new_group_playlist_name(std::string &, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
109
110         void build_playlist_menu ();
111
112         void add_underlay (StreamView*, bool update_xml = true);
113         void remove_underlay (StreamView*);
114         void build_underlay_menu(Gtk::Menu*);
115
116         int set_state (const XMLNode&, int version);
117
118         virtual void create_automation_child (const Evoral::Parameter& param, bool show) = 0;
119
120         typedef std::map<Evoral::Parameter, boost::shared_ptr<AutomationTimeAxisView> > AutomationTracks;
121         AutomationTracks automation_tracks() { return _automation_tracks; }
122
123         boost::shared_ptr<AutomationTimeAxisView> automation_child(Evoral::Parameter param);
124         virtual Gtk::CheckMenuItem* automation_child_menu_item (Evoral::Parameter);
125
126         std::string         name() const;
127         StreamView*         view() const { return _view; }
128         ARDOUR::RouteGroup* route_group() const;
129         boost::shared_ptr<ARDOUR::Playlist> playlist() const;
130
131         void fast_update ();
132         void hide_meter ();
133         void show_meter ();
134         void reset_meter ();
135         void clear_meter ();
136         void io_changed (ARDOUR::IOChange, void *);
137         void meter_changed ();
138         void effective_gain_display () { gm.effective_gain_display(); }
139
140         static void setup_slider_pix ();
141
142 protected:
143         friend class StreamView;
144
145         struct ProcessorAutomationNode {
146                 Evoral::Parameter                         what;
147                 Gtk::CheckMenuItem*                       menu_item;
148                 boost::shared_ptr<AutomationTimeAxisView> view;
149                 RouteTimeAxisView&                        parent;
150
151             ProcessorAutomationNode (Evoral::Parameter w, Gtk::CheckMenuItem* mitem, RouteTimeAxisView& p)
152                     : what (w), menu_item (mitem), parent (p) {}
153
154             ~ProcessorAutomationNode ();
155         };
156
157         struct ProcessorAutomationInfo {
158             boost::shared_ptr<ARDOUR::Processor> processor;
159             bool                                 valid;
160             Gtk::Menu*                           menu;
161             std::vector<ProcessorAutomationNode*>     lines;
162
163             ProcessorAutomationInfo (boost::shared_ptr<ARDOUR::Processor> i)
164                     : processor (i), valid (true), menu (0) {}
165
166             ~ProcessorAutomationInfo ();
167         };
168
169
170         void update_diskstream_display ();
171
172         gint route_group_click  (GdkEventButton *);
173
174         void processors_changed (ARDOUR::RouteProcessorChange);
175
176         virtual void add_processor_to_subplugin_menu (boost::weak_ptr<ARDOUR::Processor>);
177         void remove_processor_automation_node (ProcessorAutomationNode* pan);
178
179         void processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo*,
180                                          RouteTimeAxisView::ProcessorAutomationNode*);
181
182         void processor_automation_track_hidden (ProcessorAutomationNode*,
183                                                boost::shared_ptr<ARDOUR::Processor>);
184
185         void automation_track_hidden (Evoral::Parameter param);
186
187         ProcessorAutomationNode*
188         find_processor_automation_node (boost::shared_ptr<ARDOUR::Processor> i, Evoral::Parameter);
189
190         boost::shared_ptr<AutomationLine>
191         find_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> i, Evoral::Parameter);
192
193         void add_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> r, Evoral::Parameter);
194         void add_existing_processor_automation_curves (boost::weak_ptr<ARDOUR::Processor>);
195
196         void add_automation_child(Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show=true);
197
198         void reset_processor_automation_curves ();
199
200         void take_name_changed (void *src);
201         void route_property_changed (const PBD::PropertyChange&);
202         void name_entry_changed ();
203
204         void update_rec_display ();
205
206         virtual void label_view ();
207
208         void reset_samples_per_unit ();
209         void horizontal_position_changed ();
210
211         void set_color (Gdk::Color const &);
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         void         playlist_click ();
220         void         show_playlist_selector ();
221         void         playlist_changed ();
222
223         void rename_current_playlist ();
224
225         void         automation_click ();
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 (framepos_t start, framepos_t end);
232
233         void speed_changed ();
234
235         void map_frozen ();
236
237         void color_handler ();
238
239         void region_view_added (RegionView*);
240
241         void create_gain_automation_child (const Evoral::Parameter &, bool);
242
243         boost::shared_ptr<AutomationTimeAxisView> gain_track;
244
245         StreamView*           _view;
246         ArdourCanvas::Canvas& parent_canvas;
247         bool                  no_redraw;
248
249         Gtk::HBox   other_button_hbox;
250         Gtk::Table  button_table;
251         Gtk::Button processor_button;
252         Gtk::Button route_group_button;
253         Gtk::Button playlist_button;
254         Gtk::Button automation_button;
255
256         Gtk::Menu           subplugin_menu;
257         Gtk::Menu*          automation_action_menu;
258         Gtk::MenuItem*      plugins_submenu_item;
259         RouteGroupMenu*     route_group_menu;
260         Gtk::Menu*          playlist_action_menu;
261         Gtk::MenuItem*      playlist_item;
262         Gtk::Menu*          mode_menu;
263         Gtk::Menu*          color_mode_menu;
264
265         virtual Gtk::Menu* build_color_mode_menu() { return 0; }
266
267         void use_playlist (Gtk::RadioMenuItem *item, boost::weak_ptr<ARDOUR::Playlist> wpl);
268
269         ArdourCanvas::SimpleRect* timestretch_rect;
270
271         void set_track_mode (ARDOUR::TrackMode, bool apply_to_selection = false);
272
273         std::list<ProcessorAutomationInfo*> processor_automation;
274
275         typedef std::vector<boost::shared_ptr<AutomationLine> > ProcessorAutomationCurves;
276         ProcessorAutomationCurves processor_automation_curves;
277
278         AutomationTracks _automation_tracks;
279         typedef std::map<Evoral::Parameter, Gtk::CheckMenuItem*> ParameterMenuMap;
280         /** parameter -> menu item map for the main automation menu */
281         ParameterMenuMap _main_automation_menu_map;
282         /** parameter -> menu item map for the plugin automation menu */
283         ParameterMenuMap _subplugin_menu_map;
284
285         void post_construct ();
286
287         GainMeterBase gm;
288
289         static Glib::RefPtr<Gdk::Pixbuf> slider;
290
291         XMLNode* underlay_xml_node;
292         bool set_underlay_state();
293
294         typedef std::list<StreamView*> UnderlayList;
295         UnderlayList _underlay_streams;
296         typedef std::list<RouteTimeAxisView*> UnderlayMirrorList;
297         UnderlayMirrorList _underlay_mirrors;
298
299         bool _ignore_track_mode_change; ///< true to ignore track mode change signals
300 };
301
302 #endif /* __ardour_route_time_axis_h__ */
303