41599690730432ffd13f96fd08444de9080c62f0
[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 #include "level_meter.h"
42
43
44 namespace ARDOUR {
45         class Session;
46         class Region;
47         class Diskstream;
48         class RouteGroup;
49         class Redirect;
50         class Insert;
51         class Location;
52         class Playlist;
53 }
54
55 class PublicEditor;
56 class RegionView;
57 class StreamView;
58 class Selection;
59 class RegionSelection;
60 class Selectable;
61 class AutomationTimeAxisView;
62 class AutomationLine;
63 class RedirectAutomationLine;
64 class TimeSelection;
65
66 class RouteTimeAxisView : public RouteUI, public TimeAxisView
67 {
68 public:
69         RouteTimeAxisView (PublicEditor&, ARDOUR::Session&, boost::shared_ptr<ARDOUR::Route>, ArdourCanvas::Canvas& canvas);
70         virtual ~RouteTimeAxisView ();
71
72         void show_selection (TimeSelection&);
73
74         void set_samples_per_unit (double);
75         void set_height (TimeAxisView::TrackHeight);
76         void show_timestretch (nframes_t start, nframes_t end);
77         void hide_timestretch ();
78         void selection_click (GdkEventButton*);
79         void set_selected_points (PointSelection&);
80         void set_selected_regionviews (RegionSelection&);
81         void get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable *>&);
82         void get_inverted_selectables (Selection&, list<Selectable*>&);
83                 
84         boost::shared_ptr<ARDOUR::Region> find_next_region (nframes_t pos, ARDOUR::RegionPoint, int32_t dir);
85         nframes64_t find_next_region_boundary (nframes64_t pos, int32_t dir);
86
87         /* Editing operations */
88         bool cut_copy_clear (Selection&, Editing::CutCopyOp);
89         bool paste (nframes_t, float times, Selection&, size_t nth);
90
91         list<TimeAxisView*> get_child_list();
92
93         /* The editor calls these when mapping an operation across multiple tracks */
94         void use_new_playlist (bool prompt);
95         void use_copy_playlist (bool prompt);
96         void clear_playlist ();
97         
98         void build_playlist_menu (Gtk::Menu *);
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         void fast_update ();
105         void hide_meter ();
106         void show_meter ();
107         void reset_meter ();
108         void clear_meter ();
109         void io_changed (ARDOUR::IOChange, void *);
110         void meter_changed (void *);
111
112 protected:
113         friend class StreamView;
114         
115         struct RedirectAutomationNode {
116             uint32_t                what;
117             Gtk::CheckMenuItem*     menu_item;
118             AutomationTimeAxisView* view;
119             RouteTimeAxisView&      parent;
120
121             RedirectAutomationNode (uint32_t w, Gtk::CheckMenuItem* mitem, RouteTimeAxisView& p)
122                     : what (w), menu_item (mitem), view (0), parent (p) {}
123
124             ~RedirectAutomationNode ();
125         };
126
127         struct RedirectAutomationInfo {
128             boost::shared_ptr<ARDOUR::Redirect> redirect;
129             bool                                valid;
130             Gtk::Menu*                          menu;
131             vector<RedirectAutomationNode*>     lines;
132
133             RedirectAutomationInfo (boost::shared_ptr<ARDOUR::Redirect> r) 
134                     : redirect (r), valid (true), menu (0) {}
135
136             ~RedirectAutomationInfo ();
137         };
138         
139
140         void diskstream_changed ();
141         void update_diskstream_display ();
142         
143         gint edit_click  (GdkEventButton *);
144
145         void redirects_changed (void *);
146         
147         void add_redirect_to_subplugin_menu (boost::shared_ptr<ARDOUR::Redirect>);
148         void remove_ran (RedirectAutomationNode* ran);
149
150         void redirect_menu_item_toggled (RouteTimeAxisView::RedirectAutomationInfo*,
151                                          RouteTimeAxisView::RedirectAutomationNode*);
152         
153         void redirect_automation_track_hidden (RedirectAutomationNode*,
154                                                boost::shared_ptr<ARDOUR::Redirect>);
155
156         RedirectAutomationNode*
157         find_redirect_automation_node (boost::shared_ptr<ARDOUR::Redirect> r, uint32_t);
158         
159         RedirectAutomationLine*
160         find_redirect_automation_curve (boost::shared_ptr<ARDOUR::Redirect> r, uint32_t);
161
162         void add_redirect_automation_curve (boost::shared_ptr<ARDOUR::Redirect> r, uint32_t);
163         void add_existing_redirect_automation_curves (boost::shared_ptr<ARDOUR::Redirect>);
164         
165         void reset_redirect_automation_curves ();
166
167         void take_name_changed (void *);
168         void route_name_changed (void *);
169         void name_entry_changed ();
170
171         void update_rec_display ();
172
173         virtual void label_view ();
174         
175         void add_edit_group_menu_item (ARDOUR::RouteGroup *, Gtk::RadioMenuItem::Group*);
176         void set_edit_group_from_menu (ARDOUR::RouteGroup *);
177
178         void reset_samples_per_unit ();
179
180         void select_track_color();
181         
182         virtual void build_automation_action_menu ();
183         virtual void append_extra_display_menu_items () {}
184         void         build_display_menu ();
185         
186         void align_style_changed ();
187         void set_align_style (ARDOUR::AlignStyle);
188         
189         virtual void set_playlist (boost::shared_ptr<ARDOUR::Playlist>);
190         void         playlist_click ();
191         void         show_playlist_selector ();
192         void         playlist_changed ();
193         void         playlist_modified ();
194
195         void rename_current_playlist ();
196         
197         void         automation_click ();
198         virtual void show_all_automation ();
199         virtual void show_existing_automation ();
200         virtual void hide_all_automation ();
201
202         void timestretch (nframes_t start, nframes_t end);
203
204         void visual_click ();
205         void hide_click ();
206
207         void speed_changed ();
208         
209         void map_frozen ();
210
211         void color_handler ();
212
213         void region_view_added (RegionView*);
214         void add_ghost_to_redirect (RegionView*, AutomationTimeAxisView*);
215         
216         
217         StreamView*           _view;
218         ArdourCanvas::Canvas& parent_canvas;
219         bool                  no_redraw;
220   
221         Gtk::HBox   other_button_hbox;
222         Gtk::Table  button_table;
223         Gtk::Button redirect_button;
224         Gtk::Button edit_group_button;
225         Gtk::Button playlist_button;
226         Gtk::Button size_button;
227         Gtk::Button automation_button;
228         Gtk::Button hide_button;
229         Gtk::Button visual_button;
230         
231         Gtk::Menu           subplugin_menu;
232         Gtk::Menu*          automation_action_menu;
233         Gtk::Menu           edit_group_menu;
234         Gtk::RadioMenuItem* align_existing_item;
235         Gtk::RadioMenuItem* align_capture_item;
236         Gtk::RadioMenuItem* normal_track_mode_item;
237         Gtk::RadioMenuItem* destructive_track_mode_item;
238         Gtk::Menu*          playlist_menu;
239         Gtk::Menu*          playlist_action_menu;
240         Gtk::MenuItem*      playlist_item;
241
242         void use_playlist (boost::weak_ptr<ARDOUR::Playlist>);
243
244         ArdourCanvas::SimpleRect* timestretch_rect;
245
246         void set_track_mode (ARDOUR::TrackMode);
247         void _set_track_mode (boost::shared_ptr<ARDOUR::Track> track, ARDOUR::TrackMode mode, Gtk::RadioMenuItem* reset_item);
248         void track_mode_changed ();
249
250         list<RedirectAutomationInfo*>   redirect_automation;
251         vector<RedirectAutomationLine*> redirect_automation_curves;
252
253         sigc::connection modified_connection;
254
255         void post_construct ();
256         
257         LevelMeter      lm;
258 };
259
260 #endif /* __ardour_route_time_axis_h__ */
261