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