Merge edit and mix groups to just being route groups. Add properties to route groups...
[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
49 namespace ARDOUR {
50         class Session;
51         class Region;
52         class Diskstream;
53         class RouteGroup;
54         class IOProcessor;
55         class Processor;
56         class Location;
57         class Playlist;
58 }
59
60 class PublicEditor;
61 class RegionView;
62 class StreamView;
63 class Selection;
64 class RegionSelection;
65 class Selectable;
66 class AutomationTimeAxisView;
67 class AutomationLine;
68 class ProcessorAutomationLine;
69 class TimeSelection;
70
71 class RouteTimeAxisView : public RouteUI, public TimeAxisView
72 {
73 public:
74         RouteTimeAxisView (PublicEditor&, ARDOUR::Session&, boost::shared_ptr<ARDOUR::Route>, ArdourCanvas::Canvas& canvas);
75         virtual ~RouteTimeAxisView ();
76
77         void show_selection (TimeSelection&);
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         bool show_automation(Evoral::Parameter param);
89         void set_layer_display (LayerDisplay d);
90         LayerDisplay layer_display () const;
91                 
92         boost::shared_ptr<ARDOUR::Region> find_next_region (nframes_t pos, ARDOUR::RegionPoint, int32_t dir);
93         nframes64_t find_next_region_boundary (nframes64_t pos, int32_t dir);
94
95         /* Editing operations */
96         bool cut_copy_clear (Selection&, Editing::CutCopyOp);
97         bool paste (nframes_t, float times, Selection&, size_t nth);
98
99         TimeAxisView::Children get_child_list();
100
101         /* The editor calls these when mapping an operation across multiple tracks */
102         void use_new_playlist (bool prompt, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
103         void use_copy_playlist (bool prompt, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
104         void clear_playlist ();
105
106         /* group playlist name resolving */
107         std::string resolve_new_group_playlist_name(std::string &, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
108
109         
110         void build_playlist_menu (Gtk::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&);
117         
118         /* This is a bit nasty to expose :/ */
119         struct RouteAutomationNode {
120                 Evoral::Parameter                         param;
121                 Gtk::CheckMenuItem*                       menu_item;
122                 boost::shared_ptr<AutomationTimeAxisView> track;
123             
124                 RouteAutomationNode (Evoral::Parameter par, Gtk::CheckMenuItem* mi, boost::shared_ptr<AutomationTimeAxisView> tr)
125                     : param (par), menu_item (mi), track (tr) {}
126         };
127
128         virtual void create_automation_child (const Evoral::Parameter& param, bool show) = 0;
129         
130         /* make sure we get the right version of this */
131
132         XMLNode* get_automation_child_xml_node (Evoral::Parameter param) { return RouteUI::get_automation_child_xml_node (param); }
133         
134         typedef std::map<Evoral::Parameter, RouteAutomationNode*> AutomationTracks;
135         AutomationTracks automation_tracks() { return _automation_tracks; }
136
137         boost::shared_ptr<AutomationTimeAxisView> automation_child(Evoral::Parameter param);
138         
139         std::string         name() const;
140         StreamView*         view() const { return _view; }
141         ARDOUR::RouteGroup* route_group() const;
142         boost::shared_ptr<ARDOUR::Playlist> playlist() const;
143
144         void fast_update ();
145         void hide_meter ();
146         void show_meter ();
147         void reset_meter ();
148         void clear_meter ();
149         void io_changed (ARDOUR::IOChange, void *);
150         void meter_changed (void *);
151         void effective_gain_display () { gm.effective_gain_display(); }
152
153         static void setup_slider_pix ();
154
155 protected:
156         friend class StreamView;
157
158         struct ProcessorAutomationNode {
159                 Evoral::Parameter                         what;
160                 Gtk::CheckMenuItem*                       menu_item;
161                 boost::shared_ptr<AutomationTimeAxisView> view;
162                 RouteTimeAxisView&                        parent;
163
164             ProcessorAutomationNode (Evoral::Parameter w, Gtk::CheckMenuItem* mitem, RouteTimeAxisView& p)
165                     : what (w), menu_item (mitem), parent (p) {}
166
167             ~ProcessorAutomationNode ();
168         };
169
170         struct ProcessorAutomationInfo {
171             boost::shared_ptr<ARDOUR::Processor> processor;
172             bool                                 valid;
173             Gtk::Menu*                           menu;
174             std::vector<ProcessorAutomationNode*>     lines;
175
176             ProcessorAutomationInfo (boost::shared_ptr<ARDOUR::Processor> i) 
177                     : processor (i), valid (true), menu (0) {}
178
179             ~ProcessorAutomationInfo ();
180         };
181         
182
183         void diskstream_changed ();
184         void update_diskstream_display ();
185         
186         gint edit_click  (GdkEventButton *);
187
188         void processors_changed ();
189         
190         void add_processor_to_subplugin_menu (boost::weak_ptr<ARDOUR::Processor>);
191         void remove_processor_automation_node (ProcessorAutomationNode* pan);
192
193         void processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo*,
194                                          RouteTimeAxisView::ProcessorAutomationNode*);
195         
196         void processor_automation_track_hidden (ProcessorAutomationNode*,
197                                                boost::shared_ptr<ARDOUR::Processor>);
198         
199         void automation_track_hidden (Evoral::Parameter param);
200
201         RouteAutomationNode* automation_track(Evoral::Parameter param);
202         RouteAutomationNode* automation_track(ARDOUR::AutomationType type);
203
204         ProcessorAutomationNode*
205         find_processor_automation_node (boost::shared_ptr<ARDOUR::Processor> i, Evoral::Parameter);
206         
207         boost::shared_ptr<AutomationLine>
208         find_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> i, Evoral::Parameter);
209
210         void add_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> r, Evoral::Parameter);
211         void add_existing_processor_automation_curves (boost::weak_ptr<ARDOUR::Processor>);
212
213         void add_automation_child(Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show=true);
214         
215         void reset_processor_automation_curves ();
216
217         void take_name_changed (void *src);
218         void route_name_changed ();
219         void name_entry_changed ();
220
221         void update_rec_display ();
222
223         virtual void label_view ();
224         
225         void add_route_group_menu_item (ARDOUR::RouteGroup *, Gtk::RadioMenuItem::Group*);
226         void set_route_group_from_menu (ARDOUR::RouteGroup *);
227         void set_route_group_to_new ();
228
229         void reset_samples_per_unit ();
230
231         void select_track_color();
232         
233         virtual void build_automation_action_menu ();
234         virtual void append_extra_display_menu_items () {}
235         void         build_display_menu ();
236         
237         void align_style_changed ();
238         void set_align_style (ARDOUR::AlignStyle);
239         
240         virtual void set_playlist (boost::shared_ptr<ARDOUR::Playlist>);
241         void         playlist_click ();
242         void         show_playlist_selector ();
243         void         playlist_changed ();
244         void         playlist_modified ();
245
246         void rename_current_playlist ();
247         
248         void         automation_click ();
249         void         toggle_automation_track (Evoral::Parameter param);
250         virtual void show_all_automation ();
251         virtual void show_existing_automation ();
252         virtual void hide_all_automation ();
253
254         void timestretch (nframes_t start, nframes_t end);
255
256         void visual_click ();
257         void hide_click ();
258
259         void speed_changed ();
260         
261         void map_frozen ();
262
263         void color_handler ();
264
265         void region_view_added (RegionView*);
266
267         StreamView*           _view;
268         ArdourCanvas::Canvas& parent_canvas;
269         bool                  no_redraw;
270   
271         Gtk::HBox   other_button_hbox;
272         Gtk::Table  button_table;
273         Gtk::Button processor_button;
274         Gtk::Button route_group_button;
275         Gtk::Button playlist_button;
276         Gtk::Button size_button;
277         Gtk::Button automation_button;
278         Gtk::Button hide_button;
279         Gtk::Button visual_button;
280         
281         Gtk::Menu           subplugin_menu;
282         Gtk::Menu*          automation_action_menu;
283         Gtk::Menu           route_group_menu;
284         Gtk::RadioMenuItem* align_existing_item;
285         Gtk::RadioMenuItem* align_capture_item;
286         Gtk::RadioMenuItem* normal_track_mode_item;
287         Gtk::RadioMenuItem* non_layered_track_mode_item;
288         Gtk::RadioMenuItem* destructive_track_mode_item;
289         Gtk::Menu*          playlist_menu;
290         Gtk::Menu*          playlist_action_menu;
291         Gtk::MenuItem*      playlist_item;
292         Gtk::Menu*          mode_menu;
293         Gtk::Menu*          color_mode_menu;
294
295         virtual Gtk::Menu* build_mode_menu() { return 0; }
296         virtual Gtk::Menu* build_color_mode_menu() { return 0; }
297
298         void use_playlist (boost::weak_ptr<ARDOUR::Playlist>);
299
300         ArdourCanvas::SimpleRect* timestretch_rect;
301
302         void set_track_mode (ARDOUR::TrackMode);
303         void _set_track_mode (ARDOUR::Track* track, ARDOUR::TrackMode mode, Gtk::RadioMenuItem* reset_item, Gtk::RadioMenuItem* reset_item_2);
304         void track_mode_changed ();
305
306         std::list<ProcessorAutomationInfo*> processor_automation;
307
308         typedef std::vector<boost::shared_ptr<AutomationLine> > ProcessorAutomationCurves;
309         ProcessorAutomationCurves processor_automation_curves;
310         
311         // Set from XML so context menu automation buttons can be correctly initialized
312         std::set<Evoral::Parameter> _show_automation;
313
314         AutomationTracks _automation_tracks;
315
316         sigc::connection modified_connection;
317
318         void post_construct ();
319         
320         GainMeterBase gm;
321
322         static Glib::RefPtr<Gdk::Pixbuf> slider;
323
324         XMLNode* underlay_xml_node;
325         bool set_underlay_state();
326
327         typedef std::list<StreamView*> UnderlayList;
328         UnderlayList _underlay_streams;
329         typedef std::list<RouteTimeAxisView*> UnderlayMirrorList;
330         UnderlayMirrorList _underlay_mirrors;
331 };
332
333 #endif /* __ardour_route_time_axis_h__ */
334