2 Copyright (C) 2016 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 #include "pbd/convert.h"
22 #include "ardour/mute_control.h"
23 #include "ardour/profile.h"
24 #include "ardour/session.h"
25 #include "ardour/solo_control.h"
26 #include "ardour/vca.h"
28 #include "gtkmm2ext/doi.h"
30 #include "gui_thread.h"
31 #include "public_editor.h"
33 #include "ui_config.h"
34 #include "vca_time_axis.h"
38 using namespace ARDOUR;
39 using namespace ARDOUR_UI_UTILS;
40 using namespace Gtkmm2ext;
43 VCATimeAxisView::VCATimeAxisView (PublicEditor& ed, Session* s, ArdourCanvas::Canvas& canvas)
44 : SessionHandlePtr (s)
45 , TimeAxisView (s, ed, (TimeAxisView*) 0, canvas)
46 , gain_meter (s, true, 75, 14) // XXX stupid magic numbers, match sizes in RouteTimeAxisView
48 solo_button.set_name ("solo button");
49 set_tooltip (solo_button, _("Solo slaves"));
50 solo_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCATimeAxisView::solo_release), false);
51 mute_button.unset_flags (Gtk::CAN_FOCUS);
53 mute_button.set_name ("mute button");
54 mute_button.set_text (_("M"));
55 set_tooltip (mute_button, _("Mute slaves"));
56 mute_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCATimeAxisView::mute_release), false);
57 solo_button.unset_flags (Gtk::CAN_FOCUS);
59 drop_button.set_name ("mute button");
60 drop_button.set_text (_("D"));
61 set_tooltip (drop_button, _("Unassign all slaves"));
62 drop_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCATimeAxisView::drop_release), false);
64 spill_button.set_name ("mute button");
65 spill_button.set_text (_("V"));
66 set_tooltip (spill_button, _("Show only slaves"));
67 spill_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCATimeAxisView::spill_release), false);
69 mute_button.set_tweaks(ArdourButton::TrackHeader);
70 solo_button.set_tweaks(ArdourButton::TrackHeader);
71 drop_button.set_tweaks(ArdourButton::TrackHeader);
72 spill_button.set_tweaks(ArdourButton::TrackHeader);
74 controls_table.attach (mute_button, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
75 controls_table.attach (solo_button, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
76 controls_table.attach (drop_button, 2, 3, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
77 controls_table.attach (spill_button, 3, 4, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
78 controls_table.attach (gain_meter.get_gain_slider(), 0, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 1, 0);
84 gain_meter.get_gain_slider().show ();
86 controls_ebox.set_name ("ControlMasterBaseUnselected");
87 time_axis_frame.set_name ("ControlMasterBaseUnselected");
89 s->config.ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCATimeAxisView::parameter_changed, this, _1), gui_context());
90 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCATimeAxisView::parameter_changed, this, _1), gui_context());
91 UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &VCATimeAxisView::parameter_changed));
94 VCATimeAxisView::~VCATimeAxisView ()
99 VCATimeAxisView::self_delete ()
101 /* reset reference immediately rather than deferring to idle */
103 delete_when_idle (this);
107 VCATimeAxisView::parameter_changed (std::string const & p)
109 if (p == "track-name-number") {
110 update_track_number_visibility();
111 } else if (p == "use-monitor-bus" || p == "solo-control-is-listen-control" || p == "listen-position") {
117 VCATimeAxisView::solo_release (GdkEventButton*)
119 /* We use NoGroup because VCA controls are never part of a group. This
120 is redundant, but clear.
122 _vca->solo_control()->set_value (_vca->solo_control()->self_soloed() ? 0.0 : 1.0, Controllable::NoGroup);
127 VCATimeAxisView::mute_release (GdkEventButton*)
129 /* We use NoGroup because VCA controls are never part of a group. This
130 is redundant, but clear.
132 _vca->mute_control()->set_value (_vca->mute_control()->muted_by_self() ? 0.0 : 1.0, Controllable::NoGroup);
137 VCATimeAxisView::set_vca (boost::shared_ptr<VCA> v)
141 gain_meter.set_controls (boost::shared_ptr<Route>(),
142 boost::shared_ptr<PeakMeter>(),
143 boost::shared_ptr<Amp>(),
144 _vca->gain_control());
146 // Mixer_UI::instance()->show_vca_change.connect (sigc::mem_fun (*this, &VCAMasterStrip::spill_change));
148 _vca->PropertyChanged.connect (vca_connections, invalidator (*this), boost::bind (&VCATimeAxisView::vca_property_changed, this, _1), gui_context());
150 _vca->solo_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCATimeAxisView::update_solo_display, this), gui_context());
151 _vca->mute_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCATimeAxisView::update_mute_display, this), gui_context());
152 _vca->DropReferences.connect (vca_connections, invalidator (*this), boost::bind (&VCATimeAxisView::self_delete, this), gui_context());
154 solo_button.set_controllable (_vca->solo_control());
155 mute_button.set_controllable (_vca->mute_control());
157 /* VCA number never changes */
158 number_label.set_text (to_string (_vca->number(), std::dec));
160 set_height (preset_height (HeightNormal));
164 update_solo_display ();
165 update_mute_display ();
166 update_track_number_visibility ();
170 VCATimeAxisView::vca_property_changed (PropertyChange const & what_changed)
172 if (what_changed.contains (ARDOUR::Properties::name)) {
178 VCATimeAxisView::update_vca_name ()
180 name_label.set_text (_vca->name());
184 VCATimeAxisView::update_mute_display ()
186 if (_vca->mute_control()->muted_by_self()) {
187 mute_button.set_active_state (ExplicitActive);
188 } else if (_vca->mute_control()->muted_by_masters ()) {
189 mute_button.set_active_state (ImplicitActive);
191 mute_button.set_active_state (Gtkmm2ext::Off);
196 VCATimeAxisView::update_solo_display ()
198 if (_vca->solo_control()->self_soloed()) {
199 solo_button.set_active_state (ExplicitActive);
200 } else if (_vca->solo_control()->soloed_by_masters ()) {
201 solo_button.set_active_state (ImplicitActive);
203 solo_button.set_active_state (Gtkmm2ext::Off);
206 update_mute_display ();
210 VCATimeAxisView::name() const
216 VCATimeAxisView::state_id() const
218 return string_compose ("vtv %1", _vca->id().to_s());
222 VCATimeAxisView::set_button_names ()
224 if (Config->get_solo_control_is_listen_control()) {
225 switch (Config->get_listen_position()) {
226 case AfterFaderListen:
227 solo_button.set_text (S_("AfterFader|A"));
228 set_tooltip (solo_button, _("After-fade listen (AFL)"));
231 solo_button.set_text (S_("PreFader|P"));
232 set_tooltip (solo_button, _("Pre-fade listen (PFL)"));
236 solo_button.set_text (S_("Solo|S"));
237 set_tooltip (solo_button, _("Solo"));
242 VCATimeAxisView::update_track_number_visibility ()
245 bool show_label = _session->config.get_track_name_number();
247 if (number_label.get_parent()) {
248 controls_table.remove (number_label);
252 if (ARDOUR::Profile->get_mixbus()) {
253 controls_table.attach (number_label, 3, 4, 0, 1, Gtk::SHRINK, Gtk::EXPAND|Gtk::FILL, 1, 0);
255 controls_table.attach (number_label, 0, 1, 0, 1, Gtk::SHRINK, Gtk::EXPAND|Gtk::FILL, 1, 0);
258 // see ArdourButton::on_size_request(), we should probably use a global size-group here instead.
259 // except the width of the number label is subtracted from the name-hbox, so we
260 // need to explictly calculate it anyway until the name-label & entry become ArdourWidgets.
262 int tnw = (2 + std::max(2u, _session->track_number_decimals())) * number_label.char_pixel_width();
264 number_label.set_size_request(tnw, -1);
265 number_label.show ();
267 number_label.hide ();
272 VCATimeAxisView::spill_release (GdkEventButton*)
278 VCATimeAxisView::drop_release (GdkEventButton*)
280 _vca->Drop (); /* EMIT SIGNAL */
285 PresentationInfo const &
286 VCATimeAxisView::presentation_info () const
288 return _vca->presentation_info();
291 boost::shared_ptr<Stripable>
292 VCATimeAxisView::stripable () const
298 VCATimeAxisView::color () const
300 return gdk_color_from_rgb (_vca->presentation_info().color ());
304 VCATimeAxisView::set_height (uint32_t h, TrackHeightMode m)
306 TimeAxisView::set_height (h, m);
307 set_gui_property ("height", h);
308 _vca->gui_changed ("track_height", (void*) 0); /* EMIT SIGNAL */
312 VCATimeAxisView::marked_for_display () const
314 return _vca && !_vca->presentation_info().hidden();
318 VCATimeAxisView::set_marked_for_display (bool yn)
320 if (_vca && (yn == _vca->presentation_info().hidden())) {
321 _vca->presentation_info().set_hidden (!yn);
322 return true; // things changed