convert property_foo().set_value(bar) to property_foo() = bar
[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::Canvas& 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_key_release_handler (GdkEventKey*);
177         gint name_entry_button_release_handler (GdkEventButton*);
178         gint name_entry_button_press_handler (GdkEventButton*);
179         void on_area_realize ();
180
181         virtual void label_view ();
182
183         Gtk::Menu edit_group_menu;
184         Gtk::RadioMenuItem::Group edit_group_menu_radio_group;
185
186         void add_edit_group_menu_item (ARDOUR::RouteGroup *);
187         void set_edit_group_from_menu (ARDOUR::RouteGroup *);
188
189         void reset_samples_per_unit ();
190
191         void select_track_color();
192         
193         virtual void build_display_menu ();
194
195         Gtk::CheckMenuItem* waveform_item;
196         Gtk::RadioMenuItem* traditional_item;
197         Gtk::RadioMenuItem* rectified_item;
198         
199         Gtk::RadioMenuItem* align_existing_item;
200         Gtk::RadioMenuItem* align_capture_item;
201         
202         void align_style_changed ();
203         void set_align_style (ARDOUR::AlignStyle);
204
205         void toggle_show_waveforms ();
206
207         void set_waveform_shape (WaveformShape);
208         void toggle_waveforms ();
209
210         Gtk::Menu *playlist_menu;
211         Gtk::Menu *playlist_action_menu;
212         Gtk::MenuItem *playlist_item;
213         
214         /* playlist */
215
216         void set_playlist (ARDOUR::AudioPlaylist *);
217         void playlist_click ();
218         void show_playlist_selector ();
219
220         void playlist_changed ();
221         void playlist_state_changed (ARDOUR::Change);
222         void playlist_modified ();
223
224         void add_playlist_to_playlist_menu (ARDOUR::Playlist*);
225         void playlist_selected (ARDOUR::AudioPlaylist*);
226         void use_new_playlist ();
227         void use_copy_playlist ();
228         void clear_playlist ();
229         void rename_current_playlist ();
230
231         /* automation stuff */
232         
233         Gtk::Menu* automation_action_menu;
234         Gtk::CheckMenuItem* gain_automation_item;
235         Gtk::CheckMenuItem* pan_automation_item;
236
237         void automation_click ();
238         void clear_automation ();
239         void hide_all_automation ();
240         void show_all_automation ();
241         void show_existing_automation ();
242
243         struct RedirectAutomationNode {
244             uint32_t     what;
245             Gtk::CheckMenuItem* menu_item;
246             AutomationTimeAxisView* view;
247             AudioTimeAxisView& parent;
248
249             RedirectAutomationNode (uint32_t w, Gtk::CheckMenuItem* mitem, AudioTimeAxisView& p)
250                     : what (w), menu_item (mitem), view (0), parent (p) {}
251
252             ~RedirectAutomationNode ();
253         };
254
255         struct RedirectAutomationInfo {
256             ARDOUR::Redirect* redirect;
257             bool valid;
258             Gtk::Menu* menu;
259             vector<RedirectAutomationNode*> lines;
260
261             RedirectAutomationInfo (ARDOUR::Redirect* r) 
262                     : redirect (r), valid (true) {}
263
264             ~RedirectAutomationInfo ();
265         };
266
267         list<RedirectAutomationInfo*> redirect_automation;
268         RedirectAutomationNode* find_redirect_automation_node (ARDOUR::Redirect *redirect, uint32_t what);
269         
270         Gtk::Menu subplugin_menu;
271         void add_redirect_to_subplugin_menu (ARDOUR::Redirect *);
272
273         void remove_ran (RedirectAutomationNode* ran);
274
275         void redirect_menu_item_toggled (AudioTimeAxisView::RedirectAutomationInfo*,
276                                          AudioTimeAxisView::RedirectAutomationNode*);
277         void redirect_automation_track_hidden (RedirectAutomationNode*, ARDOUR::Redirect*);
278         
279         vector<RedirectAutomationLine*> redirect_automation_curves;
280         RedirectAutomationLine *find_redirect_automation_curve (ARDOUR::Redirect*,uint32_t);
281         void add_redirect_automation_curve (ARDOUR::Redirect*, uint32_t);
282         void add_existing_redirect_automation_curves (ARDOUR::Redirect*);
283
284         ArdourCanvas::SimpleRect *timestretch_rect;
285
286         void timestretch (jack_nframes_t start, jack_nframes_t end);
287
288         void visual_click ();
289         void hide_click ();
290         gint when_displayed (GdkEventAny*);
291
292         void speed_changed ();
293         
294         void add_gain_automation_child ();
295         void add_pan_automation_child ();
296         void add_parameter_automation_child ();
297
298         void toggle_gain_track ();
299         void toggle_pan_track ();
300
301         void gain_hidden ();
302         void pan_hidden ();
303
304         void update_pans ();
305
306         void region_view_added (AudioRegionView*);
307         void add_ghost_to_redirect (AudioRegionView*, AutomationTimeAxisView*);
308
309         void map_frozen ();
310 };
311
312 #endif /* __ardour_trackview_h__ */
313