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)
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 s->config.ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCATimeAxisView::parameter_changed, this, _1), gui_context());
87 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCATimeAxisView::parameter_changed, this, _1), gui_context());
88 UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &VCATimeAxisView::parameter_changed));
91 VCATimeAxisView::~VCATimeAxisView ()
96 VCATimeAxisView::self_delete ()
98 delete_when_idle (this);
102 VCATimeAxisView::parameter_changed (std::string const & p)
104 if (p == "track-name-number") {
105 update_track_number_visibility();
106 } else if (p == "use-monitor-bus" || p == "solo-control-is-listen-control" || p == "listen-position") {
112 VCATimeAxisView::solo_release (GdkEventButton*)
114 /* We use NoGroup because VCA controls are never part of a group. This
115 is redundant, but clear.
117 _vca->solo_control()->set_value (_vca->solo_control()->self_soloed() ? 0.0 : 1.0, Controllable::NoGroup);
122 VCATimeAxisView::mute_release (GdkEventButton*)
124 /* We use NoGroup because VCA controls are never part of a group. This
125 is redundant, but clear.
127 _vca->mute_control()->set_value (_vca->mute_control()->muted_by_self() ? 0.0 : 1.0, Controllable::NoGroup);
132 VCATimeAxisView::set_vca (boost::shared_ptr<VCA> v)
136 gain_meter.set_controls (boost::shared_ptr<Route>(),
137 boost::shared_ptr<PeakMeter>(),
138 boost::shared_ptr<Amp>(),
139 _vca->gain_control());
141 // Mixer_UI::instance()->show_vca_change.connect (sigc::mem_fun (*this, &VCAMasterStrip::spill_change));
143 _vca->PropertyChanged.connect (vca_connections, invalidator (*this), boost::bind (&VCATimeAxisView::vca_property_changed, this, _1), gui_context());
145 _vca->solo_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCATimeAxisView::update_solo_display, this), gui_context());
146 _vca->mute_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCATimeAxisView::update_mute_display, this), gui_context());
147 _vca->DropReferences.connect (vca_connections, invalidator (*this), boost::bind (&VCATimeAxisView::self_delete, this), gui_context());
149 solo_button.set_controllable (_vca->solo_control());
150 mute_button.set_controllable (_vca->mute_control());
152 /* VCA number never changes */
153 number_label.set_text (to_string (_vca->number(), std::dec));
155 set_height (preset_height (HeightNormal));
159 update_solo_display ();
160 update_mute_display ();
161 update_track_number_visibility ();
165 VCATimeAxisView::vca_property_changed (PropertyChange const & what_changed)
167 if (what_changed.contains (ARDOUR::Properties::name)) {
173 VCATimeAxisView::update_vca_name ()
175 name_label.set_text (_vca->name());
179 VCATimeAxisView::update_mute_display ()
181 if (_vca->mute_control()->muted_by_self()) {
182 mute_button.set_active_state (ExplicitActive);
183 } else if (_vca->mute_control()->muted_by_masters ()) {
184 mute_button.set_active_state (ImplicitActive);
186 mute_button.set_active_state (Gtkmm2ext::Off);
191 VCATimeAxisView::update_solo_display ()
193 if (_vca->solo_control()->self_soloed()) {
194 solo_button.set_active_state (ExplicitActive);
195 } else if (_vca->solo_control()->soloed_by_masters ()) {
196 solo_button.set_active_state (ImplicitActive);
198 solo_button.set_active_state (Gtkmm2ext::Off);
201 update_mute_display ();
205 VCATimeAxisView::name() const
211 VCATimeAxisView::state_id() const
213 return string_compose ("vtv %1", _vca->id().to_s());
217 VCATimeAxisView::set_button_names ()
219 if (Config->get_solo_control_is_listen_control()) {
220 switch (Config->get_listen_position()) {
221 case AfterFaderListen:
222 solo_button.set_text (S_("AfterFader|A"));
223 set_tooltip (solo_button, _("After-fade listen (AFL)"));
226 solo_button.set_text (S_("PreFader|P"));
227 set_tooltip (solo_button, _("Pre-fade listen (PFL)"));
231 solo_button.set_text (S_("Solo|S"));
232 set_tooltip (solo_button, _("Solo"));
237 VCATimeAxisView::update_track_number_visibility ()
240 bool show_label = _session->config.get_track_name_number();
242 if (number_label.get_parent()) {
243 controls_table.remove (number_label);
247 if (ARDOUR::Profile->get_mixbus()) {
248 controls_table.attach (number_label, 3, 4, 0, 1, Gtk::SHRINK, Gtk::EXPAND|Gtk::FILL, 1, 0);
250 controls_table.attach (number_label, 0, 1, 0, 1, Gtk::SHRINK, Gtk::EXPAND|Gtk::FILL, 1, 0);
253 // see ArdourButton::on_size_request(), we should probably use a global size-group here instead.
254 // except the width of the number label is subtracted from the name-hbox, so we
255 // need to explictly calculate it anyway until the name-label & entry become ArdourWidgets.
257 int tnw = (2 + std::max(2u, _session->track_number_decimals())) * number_label.char_pixel_width();
259 number_label.set_size_request(tnw, -1);
260 number_label.show ();
262 number_label.hide ();
267 VCATimeAxisView::spill_release (GdkEventButton*)
273 VCATimeAxisView::drop_release (GdkEventButton*)
275 _vca->Drop (); /* EMIT SIGNAL */
280 PresentationInfo const &
281 VCATimeAxisView::presentation_info () const
283 return _vca->presentation_info();
286 boost::shared_ptr<Stripable>
287 VCATimeAxisView::stripable () const
293 VCATimeAxisView::color () const
295 return gdk_color_from_rgb (_vca->presentation_info().color ());