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