Remove some dead code. Clean up storage of automation axis menu
[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 (nframes_t start, nframes_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 (nframes_t start, nframes_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);
89         LayerDisplay layer_display () const;
90
91         boost::shared_ptr<ARDOUR::Region> find_next_region (nframes_t pos, ARDOUR::RegionPoint, int32_t dir);
92         nframes64_t find_next_region_boundary (nframes64_t pos, int32_t dir);
93
94         /* Editing operations */
95         bool cut_copy_clear (Selection&, Editing::CutCopyOp);
96         bool paste (nframes_t, float times, Selection&, size_t nth);
97
98         TimeAxisView::Children get_child_list();
99
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
111         void build_playlist_menu (Gtk::Menu *);
112
113         void add_underlay (StreamView*, bool update_xml = true);
114         void remove_underlay (StreamView*);
115         void build_underlay_menu(Gtk::Menu*);
116         
117         int set_state (const XMLNode&, int version);
118         
119         virtual void create_automation_child (const Evoral::Parameter& param, bool show) = 0;
120
121         /* make sure we get the right version of this */
122
123         XMLNode* get_automation_child_xml_node (Evoral::Parameter param) { return RouteUI::get_automation_child_xml_node (param); }
124
125         typedef std::map<Evoral::Parameter, boost::shared_ptr<AutomationTimeAxisView> > AutomationTracks;
126         AutomationTracks automation_tracks() { return _automation_tracks; }
127
128         boost::shared_ptr<AutomationTimeAxisView> automation_child(Evoral::Parameter param);
129         Gtk::CheckMenuItem* automation_child_menu_item (Evoral::Parameter);
130         
131         std::string         name() const;
132         StreamView*         view() const { return _view; }
133         ARDOUR::RouteGroup* route_group() const;
134         boost::shared_ptr<ARDOUR::Playlist> playlist() const;
135
136         void fast_update ();
137         void hide_meter ();
138         void show_meter ();
139         void reset_meter ();
140         void clear_meter ();
141         void io_changed (ARDOUR::IOChange, void *);
142         void meter_changed ();
143         void effective_gain_display () { gm.effective_gain_display(); }
144
145         static void setup_slider_pix ();
146
147 protected:
148         friend class StreamView;
149
150         struct ProcessorAutomationNode {
151                 Evoral::Parameter                         what;
152                 Gtk::CheckMenuItem*                       menu_item;
153                 boost::shared_ptr<AutomationTimeAxisView> view;
154                 RouteTimeAxisView&                        parent;
155
156             ProcessorAutomationNode (Evoral::Parameter w, Gtk::CheckMenuItem* mitem, RouteTimeAxisView& p)
157                     : what (w), menu_item (mitem), parent (p) {}
158
159             ~ProcessorAutomationNode ();
160         };
161
162         struct ProcessorAutomationInfo {
163             boost::shared_ptr<ARDOUR::Processor> processor;
164             bool                                 valid;
165             Gtk::Menu*                           menu;
166             std::vector<ProcessorAutomationNode*>     lines;
167
168             ProcessorAutomationInfo (boost::shared_ptr<ARDOUR::Processor> i)
169                     : processor (i), valid (true), menu (0) {}
170
171             ~ProcessorAutomationInfo ();
172         };
173
174
175         void update_diskstream_display ();
176
177         gint edit_click  (GdkEventButton *);
178
179         void processors_changed (ARDOUR::RouteProcessorChange);
180
181         void add_processor_to_subplugin_menu (boost::weak_ptr<ARDOUR::Processor>);
182         void remove_processor_automation_node (ProcessorAutomationNode* pan);
183
184         void processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo*,
185                                          RouteTimeAxisView::ProcessorAutomationNode*);
186
187         void processor_automation_track_hidden (ProcessorAutomationNode*,
188                                                boost::shared_ptr<ARDOUR::Processor>);
189
190         void automation_track_hidden (Evoral::Parameter param);
191         
192         ProcessorAutomationNode*
193         find_processor_automation_node (boost::shared_ptr<ARDOUR::Processor> i, Evoral::Parameter);
194
195         boost::shared_ptr<AutomationLine>
196         find_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> i, Evoral::Parameter);
197
198         void add_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> r, Evoral::Parameter);
199         void add_existing_processor_automation_curves (boost::weak_ptr<ARDOUR::Processor>);
200
201         void add_automation_child(Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show=true);
202
203         void reset_processor_automation_curves ();
204
205         void take_name_changed (void *src);
206         void route_property_changed (const PBD::PropertyChange&);
207         void name_entry_changed ();
208
209         void update_rec_display ();
210
211         virtual void label_view ();
212
213         void set_route_group_from_menu (ARDOUR::RouteGroup *);
214
215         void reset_samples_per_unit ();
216
217         void select_track_color();
218
219         virtual void build_automation_action_menu ();
220         virtual void append_extra_display_menu_items () {}
221         void         build_display_menu ();
222
223         void align_style_changed ();
224         void set_align_style (ARDOUR::AlignStyle);
225
226         void         playlist_click ();
227         void         show_playlist_selector ();
228         void         playlist_changed ();
229
230         void rename_current_playlist ();
231
232         void         automation_click ();
233         virtual void show_all_automation ();
234         virtual void show_existing_automation ();
235         virtual void hide_all_automation ();
236
237         void timestretch (nframes_t start, nframes_t end);
238
239         void speed_changed ();
240
241         void map_frozen ();
242
243         void color_handler ();
244
245         void region_view_added (RegionView*);
246
247         StreamView*           _view;
248         ArdourCanvas::Canvas& parent_canvas;
249         bool                  no_redraw;
250
251         Gtk::HBox   other_button_hbox;
252         Gtk::Table  button_table;
253         Gtk::Button processor_button;
254         Gtk::Button route_group_button;
255         Gtk::Button playlist_button;
256         Gtk::Button automation_button;
257
258         Gtk::Menu           subplugin_menu;
259         Gtk::Menu*          automation_action_menu;
260         Gtk::MenuItem*      plugins_submenu_item;
261         RouteGroupMenu*     route_group_menu;
262         Gtk::RadioMenuItem* align_existing_item;
263         Gtk::RadioMenuItem* align_capture_item;
264         Gtk::RadioMenuItem* normal_track_mode_item;
265         Gtk::RadioMenuItem* non_layered_track_mode_item;
266         Gtk::RadioMenuItem* destructive_track_mode_item;
267         Gtk::Menu*          playlist_menu;
268         Gtk::Menu*          playlist_action_menu;
269         Gtk::MenuItem*      playlist_item;
270         Gtk::Menu*          mode_menu;
271         Gtk::Menu*          color_mode_menu;
272
273         virtual Gtk::Menu* build_color_mode_menu() { return 0; }
274
275         void use_playlist (Gtk::RadioMenuItem *item, boost::weak_ptr<ARDOUR::Playlist> wpl);
276
277         ArdourCanvas::SimpleRect* timestretch_rect;
278
279         void set_track_mode (ARDOUR::TrackMode);
280         void _set_track_mode (ARDOUR::Track* track, ARDOUR::TrackMode mode, Gtk::RadioMenuItem* reset_item, Gtk::RadioMenuItem* reset_item_2);
281         void track_mode_changed ();
282
283         std::list<ProcessorAutomationInfo*> processor_automation;
284
285         typedef std::vector<boost::shared_ptr<AutomationLine> > ProcessorAutomationCurves;
286         ProcessorAutomationCurves processor_automation_curves;
287
288         AutomationTracks _automation_tracks;
289         typedef std::map<Evoral::Parameter, Gtk::CheckMenuItem*> ParameterMenuMap;
290         ParameterMenuMap _parameter_menu_map;
291
292         void post_construct ();
293
294         GainMeterBase gm;
295
296         static Glib::RefPtr<Gdk::Pixbuf> slider;
297
298         XMLNode* underlay_xml_node;
299         bool set_underlay_state();
300
301         typedef std::list<StreamView*> UnderlayList;
302         UnderlayList _underlay_streams;
303         typedef std::list<RouteTimeAxisView*> UnderlayMirrorList;
304         UnderlayMirrorList _underlay_mirrors;
305
306         bool _ignore_track_mode_change; ///< true to ignore track mode change signals
307 };
308
309 #endif /* __ardour_route_time_axis_h__ */
310