remove color.h
[ardour.git] / gtk2_ardour / route_time_axis.h
1 /*
2     Copyright (C) 2006 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 */
19
20 #ifndef __ardour_route_time_axis_h__
21 #define __ardour_route_time_axis_h__
22
23 #include <gtkmm/table.h>
24 #include <gtkmm/button.h>
25 #include <gtkmm/box.h>
26 #include <gtkmm/menu.h>
27 #include <gtkmm/menuitem.h>
28 #include <gtkmm/radiomenuitem.h>
29 #include <gtkmm/checkmenuitem.h>
30
31 #include <gtkmm2ext/selector.h>
32 #include <list>
33
34 #include <ardour/types.h>
35
36 #include "ardour_dialog.h"
37 #include "route_ui.h"
38 #include "enums.h"
39 #include "time_axis_view.h"
40 #include "canvas.h"
41
42 namespace ARDOUR {
43         class Session;
44         class Region;
45         class Diskstream;
46         class RouteGroup;
47         class IOProcessor;
48         class Processor;
49         class Location;
50         class Playlist;
51 }
52
53 class PublicEditor;
54 class RegionView;
55 class StreamView;
56 class Selection;
57 class RegionSelection;
58 class Selectable;
59 class AutomationTimeAxisView;
60 class AutomationLine;
61 class ProcessorAutomationLine;
62 class TimeSelection;
63
64 class RouteTimeAxisView : public RouteUI, public TimeAxisView
65 {
66 public:
67         RouteTimeAxisView (PublicEditor&, ARDOUR::Session&, boost::shared_ptr<ARDOUR::Route>, ArdourCanvas::Canvas& canvas);
68         virtual ~RouteTimeAxisView ();
69
70         void show_selection (TimeSelection&);
71
72         void set_samples_per_unit (double);
73         void set_height (TimeAxisView::TrackHeight);
74         void show_timestretch (nframes_t start, nframes_t end);
75         void hide_timestretch ();
76         void selection_click (GdkEventButton*);
77         void set_selected_points (PointSelection&);
78         void set_selected_regionviews (RegionSelection&);
79         void get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable *>&);
80         void get_inverted_selectables (Selection&, list<Selectable*>&);
81         bool show_automation(ARDOUR::ParamID param);
82                 
83         boost::shared_ptr<ARDOUR::Region> find_next_region (nframes_t pos, ARDOUR::RegionPoint, int32_t dir);
84
85         /* Editing operations */
86         bool cut_copy_clear (Selection&, Editing::CutCopyOp);
87         bool paste (nframes_t, float times, Selection&, size_t nth);
88
89         list<TimeAxisView*> get_child_list();
90
91         /* The editor calls these when mapping an operation across multiple tracks */
92         void use_new_playlist (bool prompt);
93         void use_copy_playlist (bool prompt);
94         void clear_playlist ();
95         
96         void build_playlist_menu (Gtk::Menu *);
97
98         virtual void create_automation_child (ARDOUR::ParamID param) = 0;
99         
100         string              name() const;
101         StreamView*         view() const { return _view; }
102         ARDOUR::RouteGroup* edit_group() const;
103         boost::shared_ptr<ARDOUR::Playlist> playlist() const;
104
105 protected:
106         friend class StreamView;
107         
108         struct RouteAutomationNode {
109                 ARDOUR::ParamID         param;
110             Gtk::CheckMenuItem*     menu_item;
111             AutomationTimeAxisView* track;
112             
113                 RouteAutomationNode (ARDOUR::ParamID par, Gtk::CheckMenuItem* mi, AutomationTimeAxisView* tr)
114                     : param (par), menu_item (mi), track (tr) {}
115         };
116
117         struct InsertAutomationNode {
118                 ARDOUR::ParamID         what;
119             Gtk::CheckMenuItem*     menu_item;
120             AutomationTimeAxisView* view;
121             RouteTimeAxisView&      parent;
122
123             InsertAutomationNode (ARDOUR::ParamID w, Gtk::CheckMenuItem* mitem, RouteTimeAxisView& p)
124                     : what (w), menu_item (mitem), view (0), parent (p) {}
125
126             ~InsertAutomationNode ();
127         };
128
129         struct InsertAutomationInfo {
130             boost::shared_ptr<ARDOUR::Processor> processor;
131             bool                                 valid;
132             Gtk::Menu*                           menu;
133             vector<InsertAutomationNode*>        lines;
134
135             InsertAutomationInfo (boost::shared_ptr<ARDOUR::Processor> i) 
136                     : processor (i), valid (true), menu (0) {}
137
138             ~InsertAutomationInfo ();
139         };
140         
141
142         void diskstream_changed ();
143         void update_diskstream_display ();
144         
145         gint edit_click  (GdkEventButton *);
146
147         void processors_changed ();
148         
149         void add_processor_to_subplugin_menu (boost::shared_ptr<ARDOUR::Processor>);
150         void remove_ran (InsertAutomationNode* ran);
151
152         void processor_menu_item_toggled (RouteTimeAxisView::InsertAutomationInfo*,
153                                          RouteTimeAxisView::InsertAutomationNode*);
154         
155         void processor_automation_track_hidden (InsertAutomationNode*,
156                                                boost::shared_ptr<ARDOUR::Processor>);
157         
158         void automation_track_hidden (ARDOUR::ParamID param);
159
160         RouteAutomationNode* automation_track(ARDOUR::ParamID param);
161         RouteAutomationNode* automation_track(ARDOUR::AutomationType type);
162
163         InsertAutomationNode*
164         find_processor_automation_node (boost::shared_ptr<ARDOUR::Processor> i, ARDOUR::ParamID);
165         
166         ProcessorAutomationLine*
167         find_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> i, ARDOUR::ParamID);
168
169         void add_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> r, ARDOUR::ParamID);
170         void add_existing_processor_automation_curves (boost::shared_ptr<ARDOUR::Processor>);
171
172         void add_automation_child(ARDOUR::ParamID param, AutomationTimeAxisView* track);
173         
174         void reset_processor_automation_curves ();
175
176         void take_name_changed (void *src);
177         void route_name_changed ();
178         void name_entry_changed ();
179
180         void update_rec_display ();
181
182         virtual void label_view ();
183         
184         void add_edit_group_menu_item (ARDOUR::RouteGroup *, Gtk::RadioMenuItem::Group*);
185         void set_edit_group_from_menu (ARDOUR::RouteGroup *);
186
187         void reset_samples_per_unit ();
188
189         void select_track_color();
190         
191         virtual void build_automation_action_menu ();
192         virtual void append_extra_display_menu_items () {}
193         void         build_display_menu ();
194         
195         void align_style_changed ();
196         void set_align_style (ARDOUR::AlignStyle);
197         
198         virtual void set_playlist (boost::shared_ptr<ARDOUR::Playlist>);
199         void         playlist_click ();
200         void         show_playlist_selector ();
201         void         playlist_changed ();
202         void         playlist_modified ();
203
204         void rename_current_playlist ();
205         
206         void         automation_click ();
207         void         toggle_automation_track (ARDOUR::ParamID param);
208         virtual void show_all_automation ();
209         virtual void show_existing_automation ();
210         virtual void hide_all_automation ();
211
212         void timestretch (nframes_t start, nframes_t end);
213
214         void visual_click ();
215         void hide_click ();
216
217         void speed_changed ();
218         
219         void map_frozen ();
220
221         void color_handler ();
222
223         void region_view_added (RegionView*);
224         void add_ghost_to_processor (RegionView*, AutomationTimeAxisView*);
225         
226         StreamView*           _view;
227         ArdourCanvas::Canvas& parent_canvas;
228         bool                  no_redraw;
229   
230         Gtk::HBox   other_button_hbox;
231         Gtk::Table  button_table;
232         Gtk::Button processor_button;
233         Gtk::Button edit_group_button;
234         Gtk::Button playlist_button;
235         Gtk::Button size_button;
236         Gtk::Button automation_button;
237         Gtk::Button hide_button;
238         Gtk::Button visual_button;
239         
240         Gtk::Menu           subplugin_menu;
241         Gtk::Menu*          automation_action_menu;
242         Gtk::Menu           edit_group_menu;
243         Gtk::RadioMenuItem* align_existing_item;
244         Gtk::RadioMenuItem* align_capture_item;
245         Gtk::RadioMenuItem* normal_track_mode_item;
246         Gtk::RadioMenuItem* destructive_track_mode_item;
247         Gtk::Menu*          playlist_menu;
248         Gtk::Menu*          playlist_action_menu;
249         Gtk::MenuItem*      playlist_item;
250
251         void use_playlist (boost::weak_ptr<ARDOUR::Playlist>);
252
253         ArdourCanvas::SimpleRect* timestretch_rect;
254
255         void set_track_mode (ARDOUR::TrackMode);
256         void _set_track_mode (ARDOUR::Track* track, ARDOUR::TrackMode mode, Gtk::RadioMenuItem* reset_item);
257         void track_mode_changed ();
258
259         list<InsertAutomationInfo*>   processor_automation;
260         vector<ProcessorAutomationLine*> processor_automation_curves;
261         
262         // Set from XML so context menu automation buttons can be correctly initialized
263         set<ARDOUR::ParamID> _show_automation;
264
265         map<ARDOUR::ParamID, RouteAutomationNode*> _automation_tracks;
266
267         sigc::connection modified_connection;
268
269         void post_construct ();
270         
271         void set_state (const XMLNode&);
272         
273         XMLNode* get_child_xml_node (const string & childname);
274 };
275
276 #endif /* __ardour_route_time_axis_h__ */
277