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 <gtkmm/menu.h>
22 #include "pbd/string_convert.h"
24 #include "ardour/mute_control.h"
25 #include "ardour/profile.h"
26 #include "ardour/session.h"
27 #include "ardour/solo_control.h"
28 #include "ardour/vca.h"
30 #include "gtkmm2ext/doi.h"
31 #include "gtkmm2ext/utils.h"
32 #include "widgets/tooltips.h"
34 #include "gui_thread.h"
35 #include "public_editor.h"
37 #include "ui_config.h"
38 #include "vca_time_axis.h"
42 using namespace ARDOUR;
43 using namespace ArdourWidgets;
45 using namespace Gtkmm2ext;
48 VCATimeAxisView::VCATimeAxisView (PublicEditor& ed, Session* s, ArdourCanvas::Canvas& canvas)
49 : SessionHandlePtr (s)
50 , StripableTimeAxisView (ed, s, canvas)
51 , gain_meter (s, true, 75, 14) // XXX stupid magic numbers, match sizes in RouteTimeAxisView
52 , automation_action_menu (0)
55 controls_base_selected_name = X_("ControlMasterBaseSelected");
56 controls_base_unselected_name = X_("ControlMasterBaseUnselected");
58 solo_button.set_name ("solo button");
59 set_tooltip (solo_button, _("Solo slaves"));
60 solo_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCATimeAxisView::solo_release), false);
61 solo_button.unset_flags (Gtk::CAN_FOCUS);
63 mute_button.set_name ("mute button");
64 mute_button.set_text (S_("Mute|M"));
65 set_tooltip (mute_button, _("Mute slaves"));
66 mute_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCATimeAxisView::mute_release), false);
67 mute_button.unset_flags (Gtk::CAN_FOCUS);
69 drop_button.set_name ("mute button");
70 drop_button.set_text (S_("VCA|D"));
71 set_tooltip (drop_button, _("Unassign all slaves"));
72 drop_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCATimeAxisView::drop_release), false);
73 drop_button.unset_flags (Gtk::CAN_FOCUS);
75 automation_button.set_name ("route button");
76 automation_button.set_text (S_("RTAV|A"));
77 set_tooltip (automation_button, _("Automation"));
78 automation_button.signal_button_press_event().connect (sigc::mem_fun (*this, &VCATimeAxisView::automation_click), false);
79 automation_button.unset_flags (Gtk::CAN_FOCUS);
81 mute_button.set_tweaks(ArdourButton::TrackHeader);
82 solo_button.set_tweaks(ArdourButton::TrackHeader);
83 drop_button.set_tweaks(ArdourButton::TrackHeader);
84 automation_button.set_tweaks(ArdourButton::TrackHeader);
86 if (ARDOUR::Profile->get_mixbus()) {
87 controls_button_size_group->add_widget(mute_button);
89 Gtk::Fixed *blank = manage(new Gtk::Fixed());
90 controls_button_size_group->add_widget(*blank);
91 controls_table.attach (*blank, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
94 controls_table.attach (mute_button, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
95 controls_table.attach (solo_button, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
96 controls_table.attach (automation_button, 1, 2, 2, 3, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
97 controls_table.attach (drop_button, 2, 3, 2, 3, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
98 controls_table.attach (gain_meter.get_gain_slider(), 3, 5, 2, 3, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 1, 0);
100 controls_table.attach (mute_button, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
101 controls_table.attach (solo_button, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
102 controls_table.attach (automation_button, 2, 3, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
103 controls_table.attach (drop_button, 3, 4, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 0, 0);
104 controls_table.attach (gain_meter.get_gain_slider(), 0, 2, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 1, 0);
110 automation_button.show ();
111 gain_meter.get_gain_slider().show ();
113 controls_ebox.set_name (controls_base_unselected_name);
114 time_axis_frame.set_name (controls_base_unselected_name);
116 s->config.ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCATimeAxisView::parameter_changed, this, _1), gui_context());
117 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCATimeAxisView::parameter_changed, this, _1), gui_context());
118 UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &VCATimeAxisView::parameter_changed));
121 VCATimeAxisView::~VCATimeAxisView ()
126 VCATimeAxisView::self_delete ()
128 /* reset reference immediately rather than deferring to idle */
130 delete_when_idle (this);
134 VCATimeAxisView::parameter_changed (std::string const & p)
136 if (p == "track-name-number") {
137 update_track_number_visibility();
138 } else if (p == "use-monitor-bus" || p == "solo-control-is-listen-control" || p == "listen-position") {
144 VCATimeAxisView::solo_release (GdkEventButton*)
146 /* We use NoGroup because VCA controls are never part of a group. This
147 is redundant, but clear.
149 _vca->solo_control()->set_value (_vca->solo_control()->self_soloed() ? 0.0 : 1.0, Controllable::NoGroup);
154 VCATimeAxisView::mute_release (GdkEventButton*)
156 /* We use NoGroup because VCA controls are never part of a group. This
157 is redundant, but clear.
159 _vca->mute_control()->set_value (_vca->mute_control()->muted_by_self() ? 0.0 : 1.0, Controllable::NoGroup);
164 VCATimeAxisView::set_vca (boost::shared_ptr<VCA> v)
166 StripableTimeAxisView::set_stripable (v);
169 gain_meter.set_controls (boost::shared_ptr<Route>(),
170 boost::shared_ptr<PeakMeter>(),
171 boost::shared_ptr<Amp>(),
172 _vca->gain_control());
174 // Mixer_UI::instance()->show_vca_change.connect (sigc::mem_fun (*this, &VCAMasterStrip::spill_change));
176 _vca->PropertyChanged.connect (vca_connections, invalidator (*this), boost::bind (&VCATimeAxisView::vca_property_changed, this, _1), gui_context());
178 _vca->solo_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCATimeAxisView::update_solo_display, this), gui_context());
179 _vca->mute_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCATimeAxisView::update_mute_display, this), gui_context());
180 _vca->DropReferences.connect (vca_connections, invalidator (*this), boost::bind (&VCATimeAxisView::self_delete, this), gui_context());
182 solo_button.set_controllable (_vca->solo_control());
183 mute_button.set_controllable (_vca->mute_control());
185 /* VCA number never changes */
186 number_label.set_text (PBD::to_string (_vca->number()));
188 set_height (preset_height (HeightNormal));
190 if (automation_child (GainAutomation) == 0) {
191 create_automation_child (GainAutomation, false);
193 if (automation_child (MuteAutomation) == 0) {
194 create_automation_child (MuteAutomation, false);
199 update_solo_display ();
200 update_mute_display ();
201 update_track_number_visibility ();
205 VCATimeAxisView::vca_property_changed (PropertyChange const & what_changed)
207 if (what_changed.contains (ARDOUR::Properties::name)) {
213 VCATimeAxisView::update_vca_name ()
215 name_label.set_text (_vca->full_name());
219 VCATimeAxisView::name_entry_changed (std::string const& str)
221 _vca->set_name (str);
226 VCATimeAxisView::update_mute_display ()
228 if (_vca->mute_control()->muted_by_self()) {
229 mute_button.set_active_state (ExplicitActive);
230 } else if (_vca->mute_control()->muted_by_masters ()) {
231 mute_button.set_active_state (ImplicitActive);
233 mute_button.set_active_state (Gtkmm2ext::Off);
238 VCATimeAxisView::update_solo_display ()
240 if (_vca->solo_control()->self_soloed()) {
241 solo_button.set_active_state (ExplicitActive);
242 } else if (_vca->solo_control()->soloed_by_masters ()) {
243 solo_button.set_active_state (ImplicitActive);
245 solo_button.set_active_state (Gtkmm2ext::Off);
248 update_mute_display ();
252 VCATimeAxisView::name() const
258 VCATimeAxisView::state_id() const
260 return string_compose ("vtv %1", _vca->id().to_s());
264 VCATimeAxisView::set_button_names ()
266 if (Config->get_solo_control_is_listen_control()) {
267 switch (Config->get_listen_position()) {
268 case AfterFaderListen:
269 solo_button.set_text (S_("AfterFader|A"));
270 set_tooltip (solo_button, _("After-fade listen (AFL)"));
273 solo_button.set_text (S_("PreFader|P"));
274 set_tooltip (solo_button, _("Pre-fade listen (PFL)"));
278 solo_button.set_text (S_("Solo|S"));
279 set_tooltip (solo_button, _("Solo"));
284 VCATimeAxisView::update_track_number_visibility ()
287 bool show_label = _session->config.get_track_name_number();
289 if (number_label.get_parent()) {
290 controls_table.remove (number_label);
294 if (ARDOUR::Profile->get_mixbus()) {
295 controls_table.attach (number_label, 3, 4, 0, 1, Gtk::SHRINK, Gtk::EXPAND|Gtk::FILL, 1, 0);
297 controls_table.attach (number_label, 0, 1, 0, 1, Gtk::SHRINK, Gtk::EXPAND|Gtk::FILL, 1, 0);
300 // see ArdourButton::on_size_request(), we should probably use a global size-group here instead.
301 // except the width of the number label is subtracted from the name-hbox, so we
302 // need to explictly calculate it anyway until the name-label & entry become ArdourWidgets.
304 int tnw = (2 + std::max(2u, _session->track_number_decimals())) * number_label.char_pixel_width();
306 number_label.set_size_request(tnw, -1);
307 number_label.show ();
309 number_label.hide ();
314 VCATimeAxisView::automation_click (GdkEventButton* ev)
316 if (ev->button != 1) {
320 conditionally_add_to_selection ();
321 build_automation_action_menu (false);
322 Gtkmm2ext::anchored_menu_popup (automation_action_menu, &automation_button, "", 1, ev->time);
327 VCATimeAxisView::drop_release (GdkEventButton*)
329 _vca->Drop (); /* EMIT SIGNAL */
334 PresentationInfo const &
335 VCATimeAxisView::presentation_info () const
337 return _vca->presentation_info();
340 boost::shared_ptr<Stripable>
341 VCATimeAxisView::stripable () const
347 VCATimeAxisView::color () const
349 return ARDOUR_UI_UTILS::gdk_color_from_rgb (_vca->presentation_info().color ());
353 VCATimeAxisView::set_height (uint32_t h, TrackHeightMode m)
355 TimeAxisView::set_height (h, m);
356 if (height >= preset_height (HeightNormal)) {
358 automation_button.show ();
359 gain_meter.get_gain_slider().show ();
362 automation_button.hide ();
363 gain_meter.get_gain_slider().hide ();
366 set_gui_property ("height", h);
367 _vca->gui_changed ("track_height", (void*) 0); /* EMIT SIGNAL */
371 VCATimeAxisView::marked_for_display () const
373 return _vca && !_vca->presentation_info().hidden();
377 VCATimeAxisView::set_marked_for_display (bool yn)
379 if (_vca && (yn == _vca->presentation_info().hidden())) {
380 _vca->presentation_info().set_hidden (!yn);
381 return true; // things changed
387 VCATimeAxisView::create_gain_automation_child (const Evoral::Parameter& param, bool show)
389 boost::shared_ptr<AutomationControl> c = _vca->gain_control();
391 error << "VCA has no gain automation, unable to add automation track view." << endmsg;
395 gain_track.reset (new AutomationTimeAxisView (_session,
396 _vca, boost::shared_ptr<Automatable> (), c, param,
401 /*_route->amp()->describe_parameter(param)*/"Fader"));
403 add_automation_child (Evoral::Parameter(GainAutomation), gain_track, show);
407 VCATimeAxisView::create_mute_automation_child (const Evoral::Parameter& param, bool show)
409 boost::shared_ptr<AutomationControl> c = _vca->mute_control();
411 error << "VCA has no mute automation, unable to add automation track view." << endmsg;
415 mute_track.reset (new AutomationTimeAxisView (_session,
416 _vca, boost::shared_ptr<Automatable> (), c, param,
421 /*_route->describe_parameter(param)*/ "Mute"));
423 add_automation_child (Evoral::Parameter(MuteAutomation), mute_track, show);
427 VCATimeAxisView::create_automation_child (const Evoral::Parameter& param, bool show)
429 switch (param.type()) {
431 create_gain_automation_child (param, show);
434 create_mute_automation_child (param, show);
442 VCATimeAxisView::build_display_menu ()
444 using namespace Menu_Helpers;
446 TimeAxisView::build_display_menu ();
448 MenuList& items = display_menu->items();
449 items.push_back (MenuElem (_("Color..."), sigc::mem_fun (*this, &VCATimeAxisView::choose_color)));
451 detach_menu (*_size_menu);
454 items.push_back (MenuElem (_("Height"), *_size_menu));
455 items.push_back (SeparatorElem());
457 build_automation_action_menu (true);
458 items.push_back (MenuElem (_("Automation"), *automation_action_menu));
460 items.push_back (SeparatorElem());
461 items.push_back (MenuElem (_("Drop All Slaves"), sigc::mem_fun (*this, &VCATimeAxisView::drop_all_slaves)));
462 items.push_back (SeparatorElem());
463 items.push_back (MenuElem (_("Remove"), sigc::mem_fun(_editor, &PublicEditor::remove_tracks)));
468 VCATimeAxisView::build_automation_action_menu (bool for_selection)
470 using namespace Menu_Helpers;
471 _main_automation_menu_map.clear ();
472 delete automation_action_menu;
473 automation_action_menu = new Menu;
475 MenuList& items = automation_action_menu->items();
477 automation_action_menu->set_name ("ArdourContextMenu");
479 items.push_back (MenuElem (_("Show All Automation"),
480 sigc::bind (sigc::mem_fun (*this, &VCATimeAxisView::show_all_automation), for_selection)));
482 items.push_back (MenuElem (_("Show Existing Automation"),
483 sigc::bind (sigc::mem_fun (*this, &VCATimeAxisView::show_existing_automation), for_selection)));
485 items.push_back (MenuElem (_("Hide All Automation"),
486 sigc::bind (sigc::mem_fun (*this, &VCATimeAxisView::hide_all_automation), for_selection)));
489 items.push_back (CheckMenuElem (_("Fader"), sigc::mem_fun (*this, &VCATimeAxisView::update_gain_track_visibility)));
490 gain_automation_item = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
491 gain_automation_item->set_active (string_to<bool>(gain_track->gui_property ("visible")));
493 _main_automation_menu_map[Evoral::Parameter(GainAutomation)] = gain_automation_item;
497 items.push_back (CheckMenuElem (_("Trim"), sigc::mem_fun (*this, &VCATimeAxisView::update_trim_track_visibility)));
498 trim_automation_item = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
499 trim_automation_item->set_active (string_to<bool>(trim_track->gui_property ("visible")));
501 _main_automation_menu_map[Evoral::Parameter(TrimAutomation)] = trim_automation_item;
505 items.push_back (CheckMenuElem (_("Mute"), sigc::mem_fun (*this, &VCATimeAxisView::update_mute_track_visibility)));
506 mute_automation_item = dynamic_cast<Gtk::CheckMenuItem*> (&items.back ());
507 mute_automation_item->set_active (string_to<bool>(mute_track->gui_property ("visible")));
509 _main_automation_menu_map[Evoral::Parameter(MuteAutomation)] = mute_automation_item;
514 VCATimeAxisView::show_all_automation (bool apply_to_selection)
516 assert (!apply_to_selection); // VCAs can't yet be selected
519 StripableTimeAxisView::show_all_automation ();
526 VCATimeAxisView::show_existing_automation (bool apply_to_selection)
528 assert (!apply_to_selection); // VCAs can't yet be selected
531 StripableTimeAxisView::show_existing_automation ();
538 VCATimeAxisView::hide_all_automation (bool apply_to_selection)
540 assert (!apply_to_selection); // VCAs can't yet be selected
543 StripableTimeAxisView::hide_all_automation ();
550 VCATimeAxisView::drop_all_slaves ()
552 _vca->Drop (); /* EMIT SIGNAL */
554 if (Mixer_UI::instance()->showing_spill_for (_vca)) {
555 Mixer_UI::instance()->show_spill (boost::shared_ptr<Stripable>());
560 VCATimeAxisView::choose_color () {
561 _color_picker.popup (_vca);