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