resolve merge with master (?)
[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 "canvas.h"
47 #include "gain_meter.h"
48
49 namespace ARDOUR {
50         class Session;
51         class Region;
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*, ArdourCanvas::Canvas& canvas);
75         virtual ~RouteTimeAxisView ();
76
77         void set_route (boost::shared_ptr<ARDOUR::Route>);
78
79         void show_selection (TimeSelection&);
80         void set_button_names ();
81
82         void set_samples_per_unit (double);
83         void set_height (uint32_t h);
84         void show_timestretch (framepos_t start, framepos_t end, int layers, int layer);
85         void hide_timestretch ();
86         void selection_click (GdkEventButton*);
87         void set_selected_points (PointSelection&);
88         void set_selected_regionviews (RegionSelection&);
89         void get_selectables (ARDOUR::framepos_t start, ARDOUR::framepos_t end, double top, double bot, std::list<Selectable *>&);
90         void get_inverted_selectables (Selection&, std::list<Selectable*>&);
91         void set_layer_display (LayerDisplay d, bool apply_to_selection = false);
92         LayerDisplay layer_display () const;
93
94         boost::shared_ptr<ARDOUR::Region> find_next_region (framepos_t pos, ARDOUR::RegionPoint, int32_t dir);
95         framepos_t find_next_region_boundary (framepos_t pos, int32_t dir);
96
97         /* Editing operations */
98         void cut_copy_clear (Selection&, Editing::CutCopyOp);
99         bool paste (ARDOUR::framepos_t, float times, Selection&, size_t nth);
100         RegionView* combine_regions ();
101         void uncombine_regions ();
102         void uncombine_region (RegionView*);
103         void toggle_automation_track (const Evoral::Parameter& param);
104
105         /* The editor calls these when mapping an operation across multiple tracks */
106         void use_new_playlist (bool prompt, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
107         void use_copy_playlist (bool prompt, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
108         void clear_playlist ();
109
110         /* group playlist name resolving */
111         std::string resolve_new_group_playlist_name(std::string &, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
112
113         void build_playlist_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         virtual void create_automation_child (const Evoral::Parameter& param, bool show) = 0;
122
123         typedef std::map<Evoral::Parameter, boost::shared_ptr<AutomationTimeAxisView> > AutomationTracks;
124         AutomationTracks automation_tracks() { return _automation_tracks; }
125
126         boost::shared_ptr<AutomationTimeAxisView> automation_child(Evoral::Parameter param);
127         virtual Gtk::CheckMenuItem* automation_child_menu_item (Evoral::Parameter);
128
129         std::string         name() const;
130         StreamView*         view() const { return _view; }
131         ARDOUR::RouteGroup* route_group() const;
132         boost::shared_ptr<ARDOUR::Playlist> playlist() const;
133
134         void fast_update ();
135         void hide_meter ();
136         void show_meter ();
137         void reset_meter ();
138         void clear_meter ();
139         void io_changed (ARDOUR::IOChange, void *);
140         void meter_changed ();
141         void effective_gain_display () { gm.effective_gain_display(); }
142
143         std::string state_id() const;
144
145 protected:
146         friend class StreamView;
147
148         struct ProcessorAutomationNode {
149                 Evoral::Parameter                         what;
150                 Gtk::CheckMenuItem*                       menu_item;
151                 boost::shared_ptr<AutomationTimeAxisView> view;
152                 RouteTimeAxisView&                        parent;
153
154             ProcessorAutomationNode (Evoral::Parameter w, Gtk::CheckMenuItem* mitem, RouteTimeAxisView& p)
155                     : what (w), menu_item (mitem), parent (p) {}
156
157             ~ProcessorAutomationNode ();
158         };
159
160         struct ProcessorAutomationInfo {
161             boost::shared_ptr<ARDOUR::Processor> processor;
162             bool                                 valid;
163             Gtk::Menu*                           menu;
164             std::vector<ProcessorAutomationNode*>     lines;
165
166             ProcessorAutomationInfo (boost::shared_ptr<ARDOUR::Processor> i)
167                     : processor (i), valid (true), menu (0) {}
168
169             ~ProcessorAutomationInfo ();
170         };
171
172
173         void update_diskstream_display ();
174
175         gint route_group_click  (GdkEventButton *);
176
177         void processors_changed (ARDOUR::RouteProcessorChange);
178
179         virtual void add_processor_to_subplugin_menu (boost::weak_ptr<ARDOUR::Processor>);
180         void remove_processor_automation_node (ProcessorAutomationNode* pan);
181
182         void processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo*,
183                                          RouteTimeAxisView::ProcessorAutomationNode*);
184
185         void processor_automation_track_hidden (ProcessorAutomationNode*,
186                                                boost::shared_ptr<ARDOUR::Processor>);
187
188         void automation_track_hidden (Evoral::Parameter param);
189
190         ProcessorAutomationNode*
191         find_processor_automation_node (boost::shared_ptr<ARDOUR::Processor> i, Evoral::Parameter);
192
193         boost::shared_ptr<AutomationLine>
194         find_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> i, Evoral::Parameter);
195
196         void add_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> r, Evoral::Parameter);
197         void add_existing_processor_automation_curves (boost::weak_ptr<ARDOUR::Processor>);
198
199         void add_automation_child(Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show=true);
200
201         void reset_processor_automation_curves ();
202
203         void take_name_changed (void *src);
204         void route_property_changed (const PBD::PropertyChange&);
205         void name_entry_changed ();
206
207         void update_rec_display ();
208
209         virtual void label_view ();
210
211         void reset_samples_per_unit ();
212         void horizontal_position_changed ();
213
214         virtual void build_automation_action_menu (bool);
215         virtual void append_extra_display_menu_items () {}
216         void         build_display_menu ();
217
218         void set_align_choice (Gtk::RadioMenuItem*, ARDOUR::AlignChoice, bool apply_to_selection = false);
219
220         void         playlist_click ();
221         void         show_playlist_selector ();
222         void         playlist_changed ();
223
224         void rename_current_playlist ();
225
226         void         automation_click ();
227
228         virtual void show_all_automation (bool apply_to_selection = false);
229         virtual void show_existing_automation (bool apply_to_selection = false);
230         virtual void hide_all_automation (bool apply_to_selection = false);
231
232         void timestretch (framepos_t start, framepos_t end);
233         void speed_changed ();
234         void map_frozen ();
235         void color_handler ();
236         void region_view_added (RegionView*);
237         void create_gain_automation_child (const Evoral::Parameter &, bool);
238         void setup_processor_menu_and_curves ();
239         void route_color_changed ();
240         bool can_edit_name() const;
241
242         boost::shared_ptr<AutomationTimeAxisView> gain_track;
243
244         StreamView*           _view;
245         ArdourCanvas::Canvas& parent_canvas;
246         bool                  no_redraw;
247
248         Gtk::HBox   other_button_hbox;
249         Gtk::Table  button_table;
250         ArdourButton route_group_button;
251         ArdourButton playlist_button;
252         ArdourButton automation_button;
253
254         Gtk::Menu           subplugin_menu;
255         Gtk::Menu*          automation_action_menu;
256         Gtk::MenuItem*      plugins_submenu_item;
257         RouteGroupMenu*     route_group_menu;
258         Gtk::Menu*          playlist_action_menu;
259         Gtk::MenuItem*      playlist_item;
260         Gtk::Menu*          mode_menu;
261         Gtk::Menu*          color_mode_menu;
262
263         virtual Gtk::Menu* build_color_mode_menu() { return 0; }
264
265         void use_playlist (Gtk::RadioMenuItem *item, boost::weak_ptr<ARDOUR::Playlist> wpl);
266
267         ArdourCanvas::SimpleRect* timestretch_rect;
268
269         void set_track_mode (ARDOUR::TrackMode, bool apply_to_selection = false);
270
271         /** Information about all automatable processor parameters that apply to
272          *  this route.  The Amp processor is not included in this list.
273          */
274         std::list<ProcessorAutomationInfo*> processor_automation;
275
276         typedef std::vector<boost::shared_ptr<AutomationLine> > ProcessorAutomationCurves;
277         ProcessorAutomationCurves processor_automation_curves;
278
279         AutomationTracks _automation_tracks;
280         typedef std::map<Evoral::Parameter, Gtk::CheckMenuItem*> ParameterMenuMap;
281         /** parameter -> menu item map for the main automation menu */
282         ParameterMenuMap _main_automation_menu_map;
283         /** parameter -> menu item map for the plugin automation menu */
284         ParameterMenuMap _subplugin_menu_map;
285
286         void post_construct ();
287
288         GainMeterBase gm;
289
290         XMLNode* underlay_xml_node;
291         bool set_underlay_state();
292
293         typedef std::list<StreamView*> UnderlayList;
294         UnderlayList _underlay_streams;
295         typedef std::list<RouteTimeAxisView*> UnderlayMirrorList;
296         UnderlayMirrorList _underlay_mirrors;
297
298         bool _ignore_set_layer_display;
299
300 private:
301
302         void remove_child (boost::shared_ptr<TimeAxisView>);
303         void update_playlist_tip ();
304 };
305
306 #endif /* __ardour_route_time_axis_h__ */
307