export range markers patch (revisited), change selection model, copy-drag tempo+meter...
[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 DiskStream;
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&, 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   private:
130         friend class StreamView;
131         friend class AudioRegionView;
132
133         ArdourCanvas::Canvas& parent_canvas;
134
135         bool         no_redraw;
136   
137         AutomationTimeAxisView *gain_track;
138         AutomationTimeAxisView *pan_track;
139
140         void update_automation_view (ARDOUR::AutomationType);
141         void reset_redirect_automation_curves ();
142
143         Gtk::HBox  other_button_hbox;
144
145         Gtk::Table button_table;
146
147         Gtk::Button       redirect_button;
148         Gtk::Button       edit_group_button;
149         Gtk::Button       playlist_button;
150         Gtk::Button       size_button;
151         Gtk::Button       automation_button;
152         Gtk::Button       hide_button;
153         Gtk::Button       visual_button;
154
155         void route_active_changed ();
156
157         void diskstream_changed (void *src);
158         void update_diskstream_display ();
159         
160         gint edit_click  (GdkEventButton *);
161
162         // variables to get the context menu
163         // automation buttons correctly initialized
164         bool show_gain_automation;
165         bool show_pan_automation;
166
167         void build_redirect_window ();
168         void redirect_click ();
169         void redirect_add ();
170         void redirect_remove ();
171         void redirect_edit ();
172         void redirect_relist ();
173         void redirect_row_selected (gint row, gint col, GdkEvent *ev);
174         void add_to_redirect_display (ARDOUR::Redirect *);
175         void redirects_changed (void *);
176
177         sigc::connection modified_connection;
178         sigc::connection state_changed_connection;
179
180         void take_name_changed (void *);
181         void route_name_changed (void *);
182         void name_entry_changed ();
183
184         void on_area_realize ();
185
186         virtual void label_view ();
187
188         Gtk::Menu edit_group_menu;
189         Gtk::RadioMenuItem::Group edit_group_menu_radio_group;
190
191         void add_edit_group_menu_item (ARDOUR::RouteGroup *);
192         void set_edit_group_from_menu (ARDOUR::RouteGroup *);
193
194         void reset_samples_per_unit ();
195
196         void select_track_color();
197         
198         virtual void build_display_menu ();
199
200         Gtk::CheckMenuItem* waveform_item;
201         Gtk::RadioMenuItem* traditional_item;
202         Gtk::RadioMenuItem* rectified_item;
203         
204         Gtk::RadioMenuItem* align_existing_item;
205         Gtk::RadioMenuItem* align_capture_item;
206         
207         void align_style_changed ();
208         void set_align_style (ARDOUR::AlignStyle);
209
210         void toggle_show_waveforms ();
211
212         void set_waveform_shape (WaveformShape);
213         void toggle_waveforms ();
214
215         Gtk::Menu *playlist_menu;
216         Gtk::Menu *playlist_action_menu;
217         Gtk::MenuItem *playlist_item;
218         
219         /* playlist */
220
221         void set_playlist (ARDOUR::AudioPlaylist *);
222         void playlist_click ();
223         void show_playlist_selector ();
224
225         void playlist_changed ();
226         void playlist_state_changed (ARDOUR::Change);
227         void playlist_modified ();
228
229         void add_playlist_to_playlist_menu (ARDOUR::Playlist*);
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         void color_handler (ColorID, uint32_t);
316 };
317
318 #endif /* __ardour_trackview_h__ */
319