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