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