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