moved 2.1-staging to trunk @ rev 1765
[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 "color.h"
42
43 namespace ARDOUR {
44         class Session;
45         class Region;
46         class Diskstream;
47         class RouteGroup;
48         class Redirect;
49         class Insert;
50         class Location;
51         class Playlist;
52 }
53
54 class PublicEditor;
55 class RegionView;
56 class StreamView;
57 class Selection;
58 class RegionSelection;
59 class Selectable;
60 class AutomationTimeAxisView;
61 class AutomationLine;
62 class RedirectAutomationLine;
63 class TimeSelection;
64
65 class RouteTimeAxisView : public RouteUI, public TimeAxisView
66 {
67 public:
68         RouteTimeAxisView (PublicEditor&, ARDOUR::Session&, boost::shared_ptr<ARDOUR::Route>, ArdourCanvas::Canvas& canvas);
69         virtual ~RouteTimeAxisView ();
70
71         void show_selection (TimeSelection&);
72
73         void set_samples_per_unit (double);
74         void set_height (TimeAxisView::TrackHeight);
75         void show_timestretch (nframes_t start, nframes_t end);
76         void hide_timestretch ();
77         void selection_click (GdkEventButton*);
78         void set_selected_points (PointSelection&);
79         void set_selected_regionviews (RegionSelection&);
80         void get_selectables (nframes_t start, nframes_t end, double top, double bot, list<Selectable *>&);
81         void get_inverted_selectables (Selection&, list<Selectable*>&);
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         string              name() const;
99         StreamView*         view() const { return _view; }
100         ARDOUR::RouteGroup* edit_group() const;
101         boost::shared_ptr<ARDOUR::Playlist> playlist() const;
102
103 protected:
104         friend class StreamView;
105         
106         struct RedirectAutomationNode {
107             uint32_t                what;
108             Gtk::CheckMenuItem*     menu_item;
109             AutomationTimeAxisView* view;
110             RouteTimeAxisView&      parent;
111
112             RedirectAutomationNode (uint32_t w, Gtk::CheckMenuItem* mitem, RouteTimeAxisView& p)
113                     : what (w), menu_item (mitem), view (0), parent (p) {}
114
115             ~RedirectAutomationNode ();
116         };
117
118         struct RedirectAutomationInfo {
119             boost::shared_ptr<ARDOUR::Redirect> redirect;
120             bool                                valid;
121             Gtk::Menu*                          menu;
122             vector<RedirectAutomationNode*>     lines;
123
124             RedirectAutomationInfo (boost::shared_ptr<ARDOUR::Redirect> r) 
125                     : redirect (r), valid (true), menu (0) {}
126
127             ~RedirectAutomationInfo ();
128         };
129         
130
131         void diskstream_changed ();
132         void update_diskstream_display ();
133         
134         gint edit_click  (GdkEventButton *);
135
136         void redirects_changed (void *);
137         
138         void add_redirect_to_subplugin_menu (boost::shared_ptr<ARDOUR::Redirect>);
139         void remove_ran (RedirectAutomationNode* ran);
140
141         void redirect_menu_item_toggled (RouteTimeAxisView::RedirectAutomationInfo*,
142                                          RouteTimeAxisView::RedirectAutomationNode*);
143         
144         void redirect_automation_track_hidden (RedirectAutomationNode*,
145                                                boost::shared_ptr<ARDOUR::Redirect>);
146
147         RedirectAutomationNode*
148         find_redirect_automation_node (boost::shared_ptr<ARDOUR::Redirect> r, uint32_t);
149         
150         RedirectAutomationLine*
151         find_redirect_automation_curve (boost::shared_ptr<ARDOUR::Redirect> r, uint32_t);
152
153         void add_redirect_automation_curve (boost::shared_ptr<ARDOUR::Redirect> r, uint32_t);
154         void add_existing_redirect_automation_curves (boost::shared_ptr<ARDOUR::Redirect>);
155         
156         void reset_redirect_automation_curves ();
157
158         void take_name_changed (void *);
159         void route_name_changed (void *);
160         void name_entry_changed ();
161
162         void update_rec_display ();
163
164         virtual void label_view ();
165         
166         void add_edit_group_menu_item (ARDOUR::RouteGroup *, Gtk::RadioMenuItem::Group*);
167         void set_edit_group_from_menu (ARDOUR::RouteGroup *);
168
169         void reset_samples_per_unit ();
170
171         void select_track_color();
172         
173         virtual void build_automation_action_menu ();
174         virtual void append_extra_display_menu_items () {}
175         void         build_display_menu ();
176         
177         void align_style_changed ();
178         void set_align_style (ARDOUR::AlignStyle);
179         
180         virtual void set_playlist (boost::shared_ptr<ARDOUR::Playlist>);
181         void         playlist_click ();
182         void         show_playlist_selector ();
183         void         playlist_changed ();
184         void         playlist_modified ();
185
186         void rename_current_playlist ();
187         
188         void         automation_click ();
189         virtual void show_all_automation ();
190         virtual void show_existing_automation ();
191         virtual void hide_all_automation ();
192
193         void timestretch (nframes_t start, nframes_t end);
194
195         void visual_click ();
196         void hide_click ();
197
198         void speed_changed ();
199         
200         void map_frozen ();
201
202         void color_handler (ColorID, uint32_t);
203
204         void region_view_added (RegionView*);
205         void add_ghost_to_redirect (RegionView*, AutomationTimeAxisView*);
206         
207         
208         StreamView*           _view;
209         ArdourCanvas::Canvas& parent_canvas;
210         bool                  no_redraw;
211   
212         Gtk::HBox   other_button_hbox;
213         Gtk::Table  button_table;
214         Gtk::Button redirect_button;
215         Gtk::Button edit_group_button;
216         Gtk::Button playlist_button;
217         Gtk::Button size_button;
218         Gtk::Button automation_button;
219         Gtk::Button hide_button;
220         Gtk::Button visual_button;
221         
222         Gtk::Menu           subplugin_menu;
223         Gtk::Menu*          automation_action_menu;
224         Gtk::Menu           edit_group_menu;
225         Gtk::RadioMenuItem* align_existing_item;
226         Gtk::RadioMenuItem* align_capture_item;
227         Gtk::RadioMenuItem* normal_track_mode_item;
228         Gtk::RadioMenuItem* destructive_track_mode_item;
229         Gtk::Menu*          playlist_menu;
230         Gtk::Menu*          playlist_action_menu;
231         Gtk::MenuItem*      playlist_item;
232
233         void use_playlist (boost::weak_ptr<ARDOUR::Playlist>);
234
235         ArdourCanvas::SimpleRect* timestretch_rect;
236
237         void set_track_mode (ARDOUR::TrackMode);
238         void _set_track_mode (ARDOUR::Track* track, ARDOUR::TrackMode mode, Gtk::RadioMenuItem* reset_item);
239         void track_mode_changed ();
240
241         list<RedirectAutomationInfo*>   redirect_automation;
242         vector<RedirectAutomationLine*> redirect_automation_curves;
243
244         sigc::connection modified_connection;
245
246         void post_construct ();
247 };
248
249 #endif /* __ardour_route_time_axis_h__ */
250