2 Copyright (C) 2006 Paul Davis
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.
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.
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.
20 #ifndef __ardour_route_time_axis_h__
21 #define __ardour_route_time_axis_h__
26 #include <gtkmm/table.h>
27 #include <gtkmm/button.h>
28 #include <gtkmm/box.h>
29 #include <gtkmm/menu.h>
30 #include <gtkmm/menuitem.h>
31 #include <gtkmm/radiomenuitem.h>
32 #include <gtkmm/checkmenuitem.h>
33 #include <gtkmm/adjustment.h>
35 #include <gtkmm2ext/selector.h>
36 #include <gtkmm2ext/slider_controller.h>
38 #include "ardour/playlist.h"
39 #include "ardour/types.h"
41 #include "ardour_button.h"
42 #include "ardour_dialog.h"
45 #include "time_axis_view.h"
46 #include "gain_meter.h"
58 namespace ArdourCanvas {
66 class RegionSelection;
68 class AutomationTimeAxisView;
70 class ProcessorAutomationLine;
75 class RouteTimeAxisView : public RouteUI, public TimeAxisView
78 RouteTimeAxisView (PublicEditor&, ARDOUR::Session*, ArdourCanvas::Canvas& canvas);
79 virtual ~RouteTimeAxisView ();
81 void set_route (boost::shared_ptr<ARDOUR::Route>);
83 ARDOUR::PresentationInfo const & presentation_info () const;
85 void show_selection (TimeSelection&);
86 void set_button_names ();
88 void set_samples_per_pixel (double);
89 void set_height (uint32_t h, TrackHeightMode m = OnlySelf);
90 void show_timestretch (framepos_t start, framepos_t end, int layers, int layer);
91 void hide_timestretch ();
92 void selection_click (GdkEventButton*);
93 void set_selected_points (PointSelection&);
94 void set_selected_regionviews (RegionSelection&);
95 void get_selectables (ARDOUR::framepos_t start, ARDOUR::framepos_t end, double top, double bot, std::list<Selectable *>&, bool within = false);
96 void get_inverted_selectables (Selection&, std::list<Selectable*>&);
97 void set_layer_display (LayerDisplay d, bool apply_to_selection = false);
98 LayerDisplay layer_display () const;
100 boost::shared_ptr<ARDOUR::Region> find_next_region (framepos_t pos, ARDOUR::RegionPoint, int32_t dir);
101 framepos_t find_next_region_boundary (framepos_t pos, int32_t dir);
103 /* Editing operations */
104 void cut_copy_clear (Selection&, Editing::CutCopyOp);
105 bool paste (ARDOUR::framepos_t, const Selection&, PasteContext& ctx);
106 RegionView* combine_regions ();
107 void uncombine_regions ();
108 void uncombine_region (RegionView*);
109 void toggle_automation_track (const Evoral::Parameter& param);
110 void fade_range (TimeSelection&);
112 /* The editor calls these when mapping an operation across multiple tracks */
113 void use_new_playlist (bool prompt, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
114 void use_copy_playlist (bool prompt, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
115 void clear_playlist ();
117 /* group playlist name resolving */
118 std::string resolve_new_group_playlist_name(std::string &, std::vector<boost::shared_ptr<ARDOUR::Playlist> > const &);
120 void build_playlist_menu ();
122 void add_underlay (StreamView*, bool update_xml = true);
123 void remove_underlay (StreamView*);
124 void build_underlay_menu(Gtk::Menu*);
126 int set_state (const XMLNode&, int version);
128 virtual void create_automation_child (const Evoral::Parameter& param, bool show) = 0;
130 typedef std::map<Evoral::Parameter, boost::shared_ptr<AutomationTimeAxisView> > AutomationTracks;
131 const AutomationTracks& automation_tracks() const { return _automation_tracks; }
133 boost::shared_ptr<AutomationTimeAxisView> automation_child(Evoral::Parameter param);
134 virtual Gtk::CheckMenuItem* automation_child_menu_item (Evoral::Parameter);
136 std::string name() const;
137 StreamView* view() const { return _view; }
138 ARDOUR::RouteGroup* route_group() const;
139 boost::shared_ptr<ARDOUR::Playlist> playlist() const;
146 void io_changed (ARDOUR::IOChange, void *);
147 void meter_changed ();
148 void effective_gain_display () { gm.effective_gain_display(); }
150 std::string state_id() const;
153 friend class StreamView;
155 struct ProcessorAutomationNode {
156 Evoral::Parameter what;
157 Gtk::CheckMenuItem* menu_item;
158 boost::shared_ptr<AutomationTimeAxisView> view;
159 RouteTimeAxisView& parent;
161 ProcessorAutomationNode (Evoral::Parameter w, Gtk::CheckMenuItem* mitem, RouteTimeAxisView& p)
162 : what (w), menu_item (mitem), parent (p) {}
164 ~ProcessorAutomationNode ();
167 struct ProcessorAutomationInfo {
168 boost::shared_ptr<ARDOUR::Processor> processor;
171 std::vector<ProcessorAutomationNode*> lines;
173 ProcessorAutomationInfo (boost::shared_ptr<ARDOUR::Processor> i)
174 : processor (i), valid (true), menu (0) {}
176 ~ProcessorAutomationInfo ();
180 void update_diskstream_display ();
182 gint route_group_click (GdkEventButton *);
184 void processors_changed (ARDOUR::RouteProcessorChange);
186 virtual void add_processor_to_subplugin_menu (boost::weak_ptr<ARDOUR::Processor>);
187 void remove_processor_automation_node (ProcessorAutomationNode* pan);
189 void processor_menu_item_toggled (RouteTimeAxisView::ProcessorAutomationInfo*,
190 RouteTimeAxisView::ProcessorAutomationNode*);
192 void processor_automation_track_hidden (ProcessorAutomationNode*,
193 boost::shared_ptr<ARDOUR::Processor>);
195 void automation_track_hidden (Evoral::Parameter param);
197 ProcessorAutomationNode*
198 find_processor_automation_node (boost::shared_ptr<ARDOUR::Processor> i, Evoral::Parameter);
200 boost::shared_ptr<AutomationLine>
201 find_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> i, Evoral::Parameter);
203 void add_processor_automation_curve (boost::shared_ptr<ARDOUR::Processor> r, Evoral::Parameter);
204 void add_existing_processor_automation_curves (boost::weak_ptr<ARDOUR::Processor>);
206 void add_automation_child(Evoral::Parameter param, boost::shared_ptr<AutomationTimeAxisView> track, bool show=true);
208 void reset_processor_automation_curves ();
210 void take_name_changed (void *src);
211 void route_property_changed (const PBD::PropertyChange&);
212 bool name_entry_changed (std::string const&);
214 void blink_rec_display (bool onoff);
216 virtual void label_view ();
218 void reset_samples_per_pixel ();
220 virtual void build_automation_action_menu (bool);
221 virtual void append_extra_display_menu_items () {}
222 void build_display_menu ();
224 void set_align_choice (Gtk::RadioMenuItem*, ARDOUR::AlignChoice, bool apply_to_selection = false);
226 void playlist_click ();
227 void show_playlist_selector ();
228 void playlist_changed ();
230 void rename_current_playlist ();
232 void automation_click ();
234 virtual void show_all_automation (bool apply_to_selection = false);
235 virtual void show_existing_automation (bool apply_to_selection = false);
236 virtual void hide_all_automation (bool apply_to_selection = false);
238 void timestretch (framepos_t start, framepos_t end);
239 void speed_changed ();
241 void color_handler ();
242 void region_view_added (RegionView*);
243 void create_gain_automation_child (const Evoral::Parameter &, bool);
244 void create_trim_automation_child (const Evoral::Parameter &, bool);
245 void create_mute_automation_child (const Evoral::Parameter &, bool);
246 void setup_processor_menu_and_curves ();
247 void route_color_changed ();
248 bool can_edit_name() const;
250 boost::shared_ptr<AutomationTimeAxisView> gain_track;
251 boost::shared_ptr<AutomationTimeAxisView> trim_track;
252 boost::shared_ptr<AutomationTimeAxisView> mute_track;
255 ArdourCanvas::Canvas& parent_canvas;
258 Gtk::HBox other_button_hbox;
259 Gtk::Table button_table;
260 ArdourButton route_group_button;
261 ArdourButton playlist_button;
262 ArdourButton automation_button;
263 ArdourButton number_label;
265 Gtk::Menu subplugin_menu;
266 Gtk::Menu* automation_action_menu;
267 Gtk::MenuItem* plugins_submenu_item;
268 RouteGroupMenu* route_group_menu;
269 Gtk::Menu* playlist_action_menu;
270 Gtk::MenuItem* playlist_item;
271 Gtk::Menu* mode_menu;
272 Gtk::Menu* color_mode_menu;
274 virtual Gtk::Menu* build_color_mode_menu() { return 0; }
276 void use_playlist (Gtk::RadioMenuItem *item, boost::weak_ptr<ARDOUR::Playlist> wpl);
278 ArdourCanvas::Rectangle* timestretch_rect;
280 void set_track_mode (ARDOUR::TrackMode, bool apply_to_selection = false);
282 /** Information about all automatable processor parameters that apply to
283 * this route. The Amp processor is not included in this list.
285 std::list<ProcessorAutomationInfo*> processor_automation;
287 typedef std::vector<boost::shared_ptr<AutomationLine> > ProcessorAutomationCurves;
288 ProcessorAutomationCurves processor_automation_curves;
290 AutomationTracks _automation_tracks;
291 typedef std::map<Evoral::Parameter, Gtk::CheckMenuItem*> ParameterMenuMap;
292 /** parameter -> menu item map for the main automation menu */
293 ParameterMenuMap _main_automation_menu_map;
294 /** parameter -> menu item map for the plugin automation menu */
295 ParameterMenuMap _subplugin_menu_map;
297 void post_construct ();
301 XMLNode* underlay_xml_node;
302 bool set_underlay_state();
304 typedef std::list<StreamView*> UnderlayList;
305 UnderlayList _underlay_streams;
306 typedef std::list<RouteTimeAxisView*> UnderlayMirrorList;
307 UnderlayMirrorList _underlay_mirrors;
309 bool _ignore_set_layer_display;
312 void update_gain_track_visibility ();
313 void update_trim_track_visibility ();
314 void update_mute_track_visibility ();
315 void update_pan_track_visibility ();
317 /** Ensure that we have the appropriate automation lanes for panners.
319 * @param show true to show any new views that we create, otherwise false.
321 void ensure_pan_views (bool show = true);
323 Gtk::CheckMenuItem* gain_automation_item;
324 Gtk::CheckMenuItem* trim_automation_item;
325 Gtk::CheckMenuItem* mute_automation_item;
326 std::list<boost::shared_ptr<AutomationTimeAxisView> > pan_tracks;
327 Gtk::CheckMenuItem* pan_automation_item;
331 void remove_child (boost::shared_ptr<TimeAxisView>);
332 void update_playlist_tip ();
333 void parameter_changed (std::string const & p);
334 void update_track_number_visibility();
337 #endif /* __ardour_route_time_axis_h__ */