added RCU handling of Session route list, and major use of shared_ptr<T> everywhere...
[ardour.git] / gtk2_ardour / audio_time_axis.h
1 /*
2     Copyright (C) 2000 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     $Id$
19 */
20
21 #ifndef __ardour_trackview_h__
22 #define __ardour_trackview_h__
23
24 #include <gtkmm/table.h>
25 #include <gtkmm/button.h>
26 #include <gtkmm/box.h>
27 #include <gtkmm/menu.h>
28 #include <gtkmm/menuitem.h>
29 #include <gtkmm/radiomenuitem.h>
30 #include <gtkmm/checkmenuitem.h>
31
32 #include <gtkmm2ext/selector.h>
33 #include <list>
34
35 #include <ardour/types.h>
36 #include <ardour/region.h>
37
38 #include "ardour_dialog.h"
39 #include "route_ui.h"
40 #include "enums.h"
41 #include "time_axis_view.h"
42 #include "canvas.h"
43 #include "color.h"
44
45 namespace ALSA {
46         class MultiChannelDevice;
47 }
48
49 namespace ARDOUR {
50         class Session;
51         class AudioDiskstream;
52         class RouteGroup;
53         class Redirect;
54         class Insert;
55         class Location;
56         class AudioPlaylist;
57 }
58
59 namespace LADSPA {
60         class Manager;
61         class Plugin;
62 }
63
64 class PublicEditor;
65 class AudioThing;
66 class StreamView;
67 class Selection;
68 class Selectable;
69 class AudioRegionView;
70 class AutomationLine;
71 class AutomationGainLine;
72 class AutomationPanLine;
73 class RedirectAutomationLine;
74 class TimeSelection;
75 class AutomationTimeAxisView;
76
77 class AudioTimeAxisView : public RouteUI, public TimeAxisView
78 {
79   public:
80         AudioTimeAxisView (PublicEditor&, ARDOUR::Session&, boost::shared_ptr<ARDOUR::Route>, ArdourCanvas::Canvas& canvas);
81         virtual ~AudioTimeAxisView ();
82
83         void show_selection (TimeSelection&);
84         void automation_control_point_changed (ARDOUR::AutomationType);
85
86         void set_samples_per_unit (double);
87         void set_height (TimeAxisView::TrackHeight);
88         void set_show_waveforms (bool yn);
89         void set_show_waveforms_recording (bool yn);
90         void show_timestretch (jack_nframes_t start, jack_nframes_t end);
91         void hide_timestretch ();
92         void selection_click (GdkEventButton*);
93         void set_selected_regionviews (AudioRegionSelection&);
94         void set_selected_points (PointSelection&);
95         void get_selectables (jack_nframes_t start, jack_nframes_t end, double top, double bot, list<Selectable *>&);
96         void get_inverted_selectables (Selection&, list<Selectable*>&);
97         void show_all_xfades ();
98         void hide_all_xfades ();
99         void hide_dependent_views (TimeAxisViewItem&);
100         void reveal_dependent_views (TimeAxisViewItem&);
101                 
102         ARDOUR::Region* find_next_region (jack_nframes_t pos, ARDOUR::RegionPoint, int32_t dir);
103
104         string name() const;
105
106         ARDOUR::RouteGroup* edit_group() const;
107
108         void build_playlist_menu (Gtk::Menu *);
109         ARDOUR::Playlist* playlist() const;
110
111         /* overridden from parent to store display state */
112         guint32 show_at (double y, int& nth, Gtk::VBox *parent);
113         void hide ();
114         
115         /* need accessors/mutators */
116
117         StreamView      *view;
118
119         /* editing operations */
120         
121         bool cut_copy_clear (Selection&, Editing::CutCopyOp);
122         bool paste (jack_nframes_t, float times, Selection&, size_t nth);
123
124         list<TimeAxisView*>get_child_list();
125
126         void set_state (const XMLNode&);
127         XMLNode* get_child_xml_node (const string & childname);
128
129         /* the editor calls these when mapping an operation across multiple tracks */
130
131         void use_new_playlist (bool prompt);
132         void use_copy_playlist (bool prompt);
133         void clear_playlist ();
134
135   private:
136         friend class StreamView;
137         friend class AudioRegionView;
138
139         ArdourCanvas::Canvas& parent_canvas;
140
141         bool         no_redraw;
142   
143         AutomationTimeAxisView *gain_track;
144         AutomationTimeAxisView *pan_track;
145
146         void update_automation_view (ARDOUR::AutomationType);
147         void reset_redirect_automation_curves ();
148
149         Gtk::HBox  other_button_hbox;
150
151         Gtk::Table button_table;
152
153         Gtk::Button       redirect_button;
154         Gtk::Button       edit_group_button;
155         Gtk::Button       playlist_button;
156         Gtk::Button       size_button;
157         Gtk::Button       automation_button;
158         Gtk::Button       hide_button;
159         Gtk::Button       visual_button;
160
161         void route_active_changed ();
162
163         void diskstream_changed (void *src);
164         void update_diskstream_display ();
165         
166         gint edit_click  (GdkEventButton *);
167
168         // variables to get the context menu
169         // automation buttons correctly initialized
170         bool show_gain_automation;
171         bool show_pan_automation;
172
173         void build_redirect_window ();
174         void redirect_click ();
175         void redirect_add ();
176         void redirect_remove ();
177         void redirect_edit ();
178         void redirect_relist ();
179         void redirect_row_selected (gint row, gint col, GdkEvent *ev);
180         void add_to_redirect_display (boost::shared_ptr<ARDOUR::Redirect>);
181         void redirects_changed (void *);
182
183         sigc::connection modified_connection;
184         sigc::connection state_changed_connection;
185
186         void take_name_changed (void *);
187         void route_name_changed (void *);
188         void name_entry_changed ();
189
190         void on_area_realize ();
191
192         virtual void label_view ();
193
194         Gtk::Menu edit_group_menu;
195
196         void add_edit_group_menu_item (ARDOUR::RouteGroup *, Gtk::RadioMenuItem::Group*);
197         void set_edit_group_from_menu (ARDOUR::RouteGroup *);
198
199         void reset_samples_per_unit ();
200
201         void select_track_color();
202         
203         virtual void build_display_menu ();
204
205         Gtk::CheckMenuItem* waveform_item;
206         Gtk::RadioMenuItem* traditional_item;
207         Gtk::RadioMenuItem* rectified_item;
208         
209         Gtk::RadioMenuItem* align_existing_item;
210         Gtk::RadioMenuItem* align_capture_item;
211         
212         void align_style_changed ();
213         void set_align_style (ARDOUR::AlignStyle);
214
215         void toggle_show_waveforms ();
216
217         void set_waveform_shape (WaveformShape);
218         void toggle_waveforms ();
219
220         Gtk::Menu *playlist_menu;
221         Gtk::Menu *playlist_action_menu;
222         Gtk::MenuItem *playlist_item;
223         
224         /* playlist */
225
226         void set_playlist (ARDOUR::AudioPlaylist *);
227         void playlist_click ();
228         void show_playlist_selector ();
229
230         void playlist_changed ();
231         void playlist_state_changed (ARDOUR::Change);
232         void playlist_modified ();
233
234         void add_playlist_to_playlist_menu (ARDOUR::Playlist*);
235         void rename_current_playlist ();
236
237         /* automation stuff */
238         
239         Gtk::Menu* automation_action_menu;
240         Gtk::CheckMenuItem* gain_automation_item;
241         Gtk::CheckMenuItem* pan_automation_item;
242
243         void automation_click ();
244         void clear_automation ();
245         void hide_all_automation ();
246         void show_all_automation ();
247         void show_existing_automation ();
248
249         struct RedirectAutomationNode {
250             uint32_t     what;
251             Gtk::CheckMenuItem* menu_item;
252             AutomationTimeAxisView* view;
253             AudioTimeAxisView& parent;
254
255             RedirectAutomationNode (uint32_t w, Gtk::CheckMenuItem* mitem, AudioTimeAxisView& p)
256                     : what (w), menu_item (mitem), view (0), parent (p) {}
257
258             ~RedirectAutomationNode ();
259         };
260
261         struct RedirectAutomationInfo {
262             boost::shared_ptr<ARDOUR::Redirect> redirect;
263             bool valid;
264             Gtk::Menu* menu;
265             vector<RedirectAutomationNode*> lines;
266
267             RedirectAutomationInfo (boost::shared_ptr<ARDOUR::Redirect> r) 
268                     : redirect (r), valid (true) {}
269
270             ~RedirectAutomationInfo ();
271         };
272
273         list<RedirectAutomationInfo*> redirect_automation;
274         RedirectAutomationNode* find_redirect_automation_node (boost::shared_ptr<ARDOUR::Redirect> redirect, uint32_t what);
275         
276         Gtk::Menu subplugin_menu;
277         void add_redirect_to_subplugin_menu (boost::shared_ptr<ARDOUR::Redirect>);
278
279         void remove_ran (RedirectAutomationNode* ran);
280
281         void redirect_menu_item_toggled (AudioTimeAxisView::RedirectAutomationInfo*,
282                                          AudioTimeAxisView::RedirectAutomationNode*);
283         void redirect_automation_track_hidden (RedirectAutomationNode*, boost::shared_ptr<ARDOUR::Redirect>);
284         
285         vector<RedirectAutomationLine*> redirect_automation_curves;
286         RedirectAutomationLine *find_redirect_automation_curve (boost::shared_ptr<ARDOUR::Redirect>,uint32_t);
287         void add_redirect_automation_curve (boost::shared_ptr<ARDOUR::Redirect>, uint32_t);
288         void add_existing_redirect_automation_curves (boost::shared_ptr<ARDOUR::Redirect>);
289
290         ArdourCanvas::SimpleRect *timestretch_rect;
291
292         void timestretch (jack_nframes_t start, jack_nframes_t end);
293
294         void visual_click ();
295         void hide_click ();
296         gint when_displayed (GdkEventAny*);
297
298         void speed_changed ();
299         
300         void add_gain_automation_child ();
301         void add_pan_automation_child ();
302         void add_parameter_automation_child ();
303
304         void toggle_gain_track ();
305         void toggle_pan_track ();
306
307         void gain_hidden ();
308         void pan_hidden ();
309
310         void update_pans ();
311
312         void region_view_added (AudioRegionView*);
313         void add_ghost_to_redirect (AudioRegionView*, AutomationTimeAxisView*);
314
315         void map_frozen ();
316
317         void color_handler (ColorID, uint32_t);
318         bool select_me (GdkEventButton*);
319 };
320
321 #endif /* __ardour_trackview_h__ */
322