2 * Copyright (C) 2005-2006 Nick Mainsbridge <mainsbridge@gmail.com>
3 * Copyright (C) 2005-2006 Sampo Savolainen <v2@iki.fi>
4 * Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
5 * Copyright (C) 2005-2007 Doug McLain <doug@nostar.net>
6 * Copyright (C) 2005-2017 Paul Davis <paul@linuxaudiosystems.com>
7 * Copyright (C) 2005 Karsten Wiese <fzuuzf@googlemail.com>
8 * Copyright (C) 2006-2015 David Robillard <d@drobilla.net>
9 * Copyright (C) 2007-2012 Carl Hetherington <carl@carlh.net>
10 * Copyright (C) 2013-2014 John Emmas <john@creativepost.co.uk>
11 * Copyright (C) 2014-2019 Robin Gareus <robin@gareus.org>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
36 #include <sigc++/bind.h>
38 #include "pbd/error.h"
39 #include "pbd/stl_delete.h"
40 #include "pbd/memento_command.h"
42 #include "gtkmm2ext/gtk_ui.h"
43 #include "gtkmm2ext/utils.h"
45 #include "widgets/ardour_button.h"
47 #include "ardour/event_type_map.h"
48 #include "ardour/pannable.h"
49 #include "ardour/panner.h"
50 #include "ardour/panner_shell.h"
52 #include "audio_time_axis.h"
53 #include "automation_line.h"
55 #include "gui_thread.h"
56 #include "automation_time_axis.h"
58 #include "playlist_selector.h"
59 #include "public_editor.h"
60 #include "audio_region_view.h"
61 #include "audio_streamview.h"
62 #include "ui_config.h"
68 using namespace ARDOUR;
69 using namespace ArdourWidgets;
70 using namespace ARDOUR_UI_UTILS;
73 using namespace Editing;
75 AudioTimeAxisView::AudioTimeAxisView (PublicEditor& ed, Session* sess, ArdourCanvas::Canvas& canvas)
76 : SessionHandlePtr (sess)
77 , RouteTimeAxisView(ed, sess, canvas)
79 UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &AudioTimeAxisView::parameter_changed));
83 AudioTimeAxisView::set_route (boost::shared_ptr<Route> rt)
87 /* RouteTimeAxisView::set_route() sets up some things in the View,
88 so it must be created before RouteTimeAxis::set_route() is
91 _view = new AudioStreamView (*this);
93 RouteTimeAxisView::set_route (rt);
95 _view->apply_color (gdk_color_to_rgba (color()), StreamView::RegionColor);
97 // Make sure things are sane...
98 assert(!is_track() || is_audio_track());
100 subplugin_menu.set_name ("ArdourContextMenu");
102 ignore_toggle = false;
104 if (is_audio_track()) {
105 controls_ebox.set_name ("AudioTrackControlsBaseUnselected");
106 time_axis_frame.set_name ("AudioTrackControlsBaseUnselected");
108 controls_ebox.set_name ("AudioBusControlsBaseUnselected");
109 time_axis_frame.set_name ("AudioBusControlsBaseUnselected");
112 /* if set_state above didn't create a gain automation child, we need to make one */
113 if (automation_child (GainAutomation) == 0) {
114 create_automation_child (GainAutomation, false);
117 if (automation_child (TrimAutomation) == 0) {
118 create_automation_child (TrimAutomation, false);
121 /* if set_state above didn't create a mute automation child, we need to make one */
122 if (automation_child (MuteAutomation) == 0) {
123 create_automation_child (MuteAutomation, false);
126 if (_route->panner_shell()) {
127 _route->panner_shell()->Changed.connect (*this, invalidator (*this),
128 boost::bind (&AudioTimeAxisView::ensure_pan_views, this, false), gui_context());
131 /* map current state of the route */
133 processors_changed (RouteProcessorChange ());
134 reset_processor_automation_curves ();
135 ensure_pan_views (false);
136 update_control_names ();
138 if (is_audio_track()) {
140 /* ask for notifications of any new RegionViews */
141 _view->RegionViewAdded.connect (sigc::mem_fun(*this, &AudioTimeAxisView::region_view_added));
143 if (!_editor.have_idled()) {
144 /* first idle will do what we need */
154 AudioTimeAxisView::~AudioTimeAxisView ()
159 AudioTimeAxisView::first_idle ()
166 AudioTimeAxisView::audio_view()
168 return dynamic_cast<AudioStreamView*>(_view);
172 AudioTimeAxisView::show_at (double y, int& nth, Gtk::VBox *parent)
174 set_gui_property ("visible", true);
175 return TimeAxisView::show_at (y, nth, parent);
179 AudioTimeAxisView::hide ()
181 set_gui_property ("visible", false);
182 TimeAxisView::hide ();
186 AudioTimeAxisView::create_automation_child (const Evoral::Parameter& param, bool show)
188 if (param.type() == NullAutomation) {
192 AutomationTracks::iterator existing = _automation_tracks.find (param);
194 if (existing != _automation_tracks.end()) {
196 /* automation track created because we had existing data for
197 * the processor, but visibility may need to be controlled
198 * since it will have been set visible by default.
201 existing->second->set_marked_for_display (show);
210 if (param.type() == GainAutomation) {
212 create_gain_automation_child (param, show);
214 } else if (param.type() == TrimAutomation) {
216 create_trim_automation_child (param, show);
218 } else if (param.type() == PanWidthAutomation ||
219 param.type() == PanElevationAutomation ||
220 param.type() == PanAzimuthAutomation) {
222 ensure_pan_views (show);
224 } else if (param.type() == PluginAutomation) {
226 /* handled elsewhere */
228 } else if (param.type() == MuteAutomation) {
230 create_mute_automation_child (param, show);
234 error << "AudioTimeAxisView: unknown automation child " << EventTypeMap::instance().to_symbol(param) << endmsg;
239 AudioTimeAxisView::show_all_automation (bool apply_to_selection)
241 if (apply_to_selection) {
242 _editor.get_selection().tracks.foreach_audio_time_axis (boost::bind (&AudioTimeAxisView::show_all_automation, _1, false));
247 RouteTimeAxisView::show_all_automation ();
255 AudioTimeAxisView::show_existing_automation (bool apply_to_selection)
257 if (apply_to_selection) {
258 _editor.get_selection().tracks.foreach_audio_time_axis (boost::bind (&AudioTimeAxisView::show_existing_automation, _1, false));
262 RouteTimeAxisView::show_existing_automation ();
271 AudioTimeAxisView::hide_all_automation (bool apply_to_selection)
273 if (apply_to_selection) {
274 _editor.get_selection().tracks.foreach_audio_time_axis (boost::bind (&AudioTimeAxisView::hide_all_automation, _1, false));
278 RouteTimeAxisView::hide_all_automation();
286 AudioTimeAxisView::route_active_changed ()
288 update_control_names ();
292 AudioTimeAxisView::parameter_changed (string const & p)
294 if (p == "vertical-region-gap") {
295 _view->update_contents_height ();
301 * Set up the names of the controls so that they are coloured
302 * correctly depending on whether this route is inactive or
307 AudioTimeAxisView::update_control_names ()
309 if (is_audio_track()) {
310 if (_route->active()) {
311 controls_base_selected_name = "AudioTrackControlsBaseSelected";
312 controls_base_unselected_name = "AudioTrackControlsBaseUnselected";
314 controls_base_selected_name = "AudioTrackControlsBaseInactiveSelected";
315 controls_base_unselected_name = "AudioTrackControlsBaseInactiveUnselected";
318 if (_route->active()) {
319 controls_base_selected_name = "BusControlsBaseSelected";
320 controls_base_unselected_name = "BusControlsBaseUnselected";
322 controls_base_selected_name = "BusControlsBaseInactiveSelected";
323 controls_base_unselected_name = "BusControlsBaseInactiveUnselected";
328 controls_ebox.set_name (controls_base_selected_name);
329 time_axis_frame.set_name (controls_base_selected_name);
331 controls_ebox.set_name (controls_base_unselected_name);
332 time_axis_frame.set_name (controls_base_unselected_name);
337 AudioTimeAxisView::build_automation_action_menu (bool for_selection)
339 RouteTimeAxisView::build_automation_action_menu (for_selection);