2a6aa1c4d68f9edffe47e386c14bb607d6276d84
[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_audio_time_axis_h__
22 #define __ardour_audio_time_axis_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 "route_time_axis.h"
42 #include "canvas.h"
43 #include "color.h"
44
45 namespace ARDOUR {
46         class Session;
47         class AudioDiskstream;
48         class RouteGroup;
49         class Redirect;
50         class Insert;
51         class Location;
52         class AudioPlaylist;
53 }
54
55 class PublicEditor;
56 class AudioThing;
57 class AudioStreamView;
58 class Selection;
59 class Selectable;
60 class RegionView;
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 RouteTimeAxisView
70 {
71   public:
72         AudioTimeAxisView (PublicEditor&, ARDOUR::Session&, boost::shared_ptr<ARDOUR::Route>, ArdourCanvas::Canvas& canvas);
73         virtual ~AudioTimeAxisView ();
74         
75         AudioStreamView* audio_view();
76
77         void set_show_waveforms (bool yn);
78         void set_show_waveforms_recording (bool yn);
79         void show_all_xfades ();
80         void hide_all_xfades ();
81         void set_selected_regionviews (RegionSelection&);
82         void hide_dependent_views (TimeAxisViewItem&);
83         void reveal_dependent_views (TimeAxisViewItem&);
84                 
85         /* overridden from parent to store display state */
86         guint32 show_at (double y, int& nth, Gtk::VBox *parent);
87         void hide ();
88         
89         void set_state (const XMLNode&);
90         XMLNode* get_child_xml_node (const string & childname);
91
92   private:
93         friend class AudioStreamView;
94         friend class AudioRegionView;
95         
96         void route_active_changed ();
97
98         AutomationTimeAxisView *gain_track;
99         AutomationTimeAxisView *pan_track;
100
101         void update_automation_view (ARDOUR::AutomationType);
102         void reset_redirect_automation_curves ();
103
104         // variables to get the context menu
105         // automation buttons correctly initialized
106         bool show_gain_automation;
107         bool show_pan_automation;
108
109         // FIXME?
110         void redirects_changed (void *);
111
112         void build_display_menu ();
113
114         Gtk::CheckMenuItem* waveform_item;
115         Gtk::RadioMenuItem* traditional_item;
116         Gtk::RadioMenuItem* rectified_item;
117         
118         void toggle_show_waveforms ();
119
120         void set_waveform_shape (WaveformShape);
121         void toggle_waveforms ();
122
123         /* automation stuff */
124         
125         Gtk::Menu*          automation_action_menu;
126         Gtk::CheckMenuItem* gain_automation_item;
127         Gtk::CheckMenuItem* pan_automation_item;
128
129         void automation_click ();
130         void clear_automation ();
131         void hide_all_automation ();
132         void show_all_automation ();
133         void show_existing_automation ();
134
135         struct RedirectAutomationNode {
136             uint32_t what;
137             Gtk::CheckMenuItem* menu_item;
138             AutomationTimeAxisView* view;
139             AudioTimeAxisView& parent;
140
141             RedirectAutomationNode (uint32_t w, Gtk::CheckMenuItem* mitem, AudioTimeAxisView& p)
142                     : what (w), menu_item (mitem), view (0), parent (p) {}
143
144             ~RedirectAutomationNode ();
145         };
146
147         struct RedirectAutomationInfo {
148             boost::shared_ptr<ARDOUR::Redirect> redirect;
149             bool valid;
150             Gtk::Menu* menu;
151             vector<RedirectAutomationNode*> lines;
152
153             RedirectAutomationInfo (boost::shared_ptr<ARDOUR::Redirect> r) 
154                     : redirect (r), valid (true) {}
155
156             ~RedirectAutomationInfo ();
157         };
158
159         list<RedirectAutomationInfo*> redirect_automation;
160         RedirectAutomationNode* find_redirect_automation_node (boost::shared_ptr<ARDOUR::Redirect> redirect, uint32_t what);
161         
162         Gtk::Menu subplugin_menu;
163         void add_redirect_to_subplugin_menu (boost::shared_ptr<ARDOUR::Redirect>);
164
165         void remove_ran (RedirectAutomationNode* ran);
166
167         void redirect_menu_item_toggled (AudioTimeAxisView::RedirectAutomationInfo*,
168                                          AudioTimeAxisView::RedirectAutomationNode*);
169         void redirect_automation_track_hidden (RedirectAutomationNode*, boost::shared_ptr<ARDOUR::Redirect>);
170         
171         vector<RedirectAutomationLine*> redirect_automation_curves;
172         RedirectAutomationLine *find_redirect_automation_curve (boost::shared_ptr<ARDOUR::Redirect>,uint32_t);
173         void add_redirect_automation_curve (boost::shared_ptr<ARDOUR::Redirect>, uint32_t);
174         void add_existing_redirect_automation_curves (boost::shared_ptr<ARDOUR::Redirect>);
175
176         void add_gain_automation_child ();
177         void add_pan_automation_child ();
178         void add_parameter_automation_child ();
179
180         void toggle_gain_track ();
181         void toggle_pan_track ();
182
183         void gain_hidden ();
184         void pan_hidden ();
185
186         void update_pans ();
187
188         void region_view_added (RegionView*);
189         void add_ghost_to_redirect (RegionView*, AutomationTimeAxisView*);
190 };
191
192 #endif /* __ardour_audio_time_axis_h__ */
193