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.
19 #include <gtkmm/stock.h>
21 #include "pbd/string_convert.h"
23 #include "ardour/rc_configuration.h"
24 #include "ardour/session.h"
25 #include "ardour/vca.h"
26 #include "ardour/vca_manager.h"
28 #include "gtkmm2ext/doi.h"
29 #include "gtkmm2ext/keyboard.h"
30 #include "widgets/tooltips.h"
32 #include "ardour_dialog.h"
33 #include "floating_text_entry.h"
34 #include "gui_thread.h"
36 #include "ui_config.h"
38 #include "vca_master_strip.h"
42 using namespace ARDOUR;
43 using namespace ArdourWidgets;
44 using namespace Gtkmm2ext;
49 PBD::Signal1<void,VCAMasterStrip*> VCAMasterStrip::CatchDeletion;
51 VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr<VCA> v)
52 : SessionHandlePtr (s)
54 , gain_meter (s, 254) /* magic number, don't adjust blindly */
57 , control_slave_ui (s)
59 /* set color for the VCA, if not already done. */
61 if (!_vca->presentation_info().color_set()) {
62 _vca->presentation_info().set_color (ARDOUR_UI_UTILS::gdk_color_to_rgba (unique_random_color()));
65 control_slave_ui.set_stripable (boost::dynamic_pointer_cast<Stripable> (v));
67 gain_meter.set_controls (boost::shared_ptr<Route>(),
68 boost::shared_ptr<PeakMeter>(),
69 boost::shared_ptr<Amp>(),
70 _vca->gain_control());
72 solo_button.set_name ("solo button");
73 set_tooltip (solo_button, _("Solo slaves"));
74 solo_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::solo_release), false);
76 mute_button.set_name ("mute button");
77 mute_button.set_text (_("M"));
78 set_tooltip (mute_button, _("Mute slaves"));
79 mute_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::mute_release), false);
81 hide_button.set_icon (ArdourIcon::CloseCross);
82 set_tooltip (&hide_button, _("Hide this VCA strip"));
84 hide_button.signal_clicked.connect (sigc::mem_fun(*this, &VCAMasterStrip::hide_clicked));
86 solo_mute_box.set_spacing (2);
87 solo_mute_box.pack_start (mute_button, true, true);
88 solo_mute_box.pack_start (solo_button, true, true);
90 mute_button.set_controllable (_vca->mute_control());
91 solo_button.set_controllable (_vca->solo_control());
93 number_label.set_text (PBD::to_string (v->number()));
94 number_label.set_elements((ArdourButton::Element)(ArdourButton::Edge|ArdourButton::Body|ArdourButton::Text|ArdourButton::Inactive));
95 number_label.set_no_show_all ();
96 number_label.set_name ("generic button");
97 number_label.set_alignment (.5, .5);
98 number_label.set_fallthrough_to_parent (true);
99 number_label.set_inactive_color (_vca->presentation_info().color ());
100 number_label.signal_button_release_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::number_button_press), false);
102 update_bottom_padding ();
104 //Glib::RefPtr<Pango::Layout> layout = vertical_button.get_layout ();
105 // layout->set_justify (JUSTIFY_CENTER);
106 /* horizontally centered, with a little space (5%) at the top */
107 vertical_button.set_angle (90);
108 vertical_button.set_layout_font (UIConfiguration::instance().get_NormalBoldFont());
109 vertical_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::vertical_button_press));
110 vertical_button.set_fallthrough_to_parent (true);
111 vertical_button.set_active_color (_vca->presentation_info().color ());
112 set_tooltip (vertical_button, _("Click to show slaves only")); /* tooltip updated dynamically */
114 global_vpacker.set_border_width (0);
115 global_vpacker.set_spacing (0);
116 gain_meter.set_spacing(4);
118 global_vpacker.pack_start (number_label, false, false, 1);
119 global_vpacker.pack_start (hide_button, false, false, 1);
120 global_vpacker.pack_start (vertical_button, true, true, 1);
121 global_vpacker.pack_start (solo_mute_box, false, false, 1);
122 global_vpacker.pack_start (gain_meter, false, false, 1);
123 global_vpacker.pack_start (control_slave_ui, false, false, 1);
124 global_vpacker.pack_start (gain_meter.gain_automation_state_button, false, false, 1);
125 global_vpacker.pack_start (bottom_padding, false, false, 0);
127 global_sample.add (global_vpacker);
128 global_sample.set_shadow_type (Gtk::SHADOW_IN);
129 global_sample.set_name ("BaseFrame");
133 global_vpacker.show ();
134 global_sample.show ();
136 vertical_button.show ();
138 number_label.show ();
140 solo_mute_box.show_all ();
141 control_slave_ui.show ();
142 gain_meter.gain_automation_state_button.show ();
144 /* force setting of visible selected status */
147 set_selected (false);
152 spill_change (boost::shared_ptr<VCA>());
154 Mixer_UI::instance()->show_spill_change.connect (sigc::mem_fun (*this, &VCAMasterStrip::spill_change));
156 _vca->PropertyChanged.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::vca_property_changed, this, _1), gui_context());
157 _vca->presentation_info().PropertyChanged.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::vca_property_changed, this, _1), gui_context());
158 _vca->DropReferences.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::self_delete, this), gui_context());
160 _vca->solo_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::solo_changed, this), gui_context());
161 _vca->mute_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::mute_changed, this), gui_context());
164 s->config.ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCAMasterStrip::parameter_changed, this, _1), gui_context());
165 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCAMasterStrip::parameter_changed, this, _1), gui_context());
166 UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &VCAMasterStrip::parameter_changed));
169 VCAMasterStrip::~VCAMasterStrip ()
171 if ((_session && !_session->deletion_in_progress()) && Mixer_UI::instance()->showing_spill_for (_vca)) {
172 /* cancel spill for this VCA */
173 Mixer_UI::instance()->show_spill (boost::shared_ptr<Stripable>());
176 delete delete_dialog;
179 CatchDeletion (this); /* EMIT SIGNAL */
183 VCAMasterStrip::self_delete ()
185 if ((_session && !_session->deletion_in_progress()) && Mixer_UI::instance()->showing_spill_for (_vca)) {
186 /* cancel spill for this VCA */
187 Mixer_UI::instance()->show_spill (boost::shared_ptr<Stripable>());
189 /* Drop reference immediately, delete self when idle */
191 gain_meter.set_controls (boost::shared_ptr<Route>(),
192 boost::shared_ptr<PeakMeter>(),
193 boost::shared_ptr<Amp>(),
194 boost::shared_ptr<GainControl>());
195 delete_when_idle (this);
199 VCAMasterStrip::parameter_changed (std::string const & p)
201 if (p == "use-monitor-bus" || p == "solo-control-is-listen-control" || p == "listen-position") {
203 } else if (p == "mixer-element-visibility") {
204 update_bottom_padding ();
209 VCAMasterStrip::set_button_names ()
211 if (Config->get_solo_control_is_listen_control()) {
212 switch (Config->get_listen_position()) {
213 case AfterFaderListen:
214 solo_button.set_text (S_("AfterFader|A"));
215 set_tooltip (solo_button, _("After-fade listen (AFL)"));
218 solo_button.set_text (S_("PreFader|P"));
219 set_tooltip (solo_button, _("Pre-fade listen (PFL)"));
223 solo_button.set_text (S_("Solo|S"));
224 set_tooltip (solo_button, _("Solo"));
229 VCAMasterStrip::update_bottom_padding ()
231 std::string viz = UIConfiguration::instance().get_mixer_strip_visibility ();
233 ArdourButton output_button (_("Output"));
234 ArdourButton comment_button (_("Comments"));
236 output_button.set_name ("mixer strip button");
237 comment_button.set_name ("generic button");
239 if (viz.find ("VCA") == std::string::npos) {
240 control_slave_ui.hide ();
242 control_slave_ui.show ();
246 if (viz.find ("Output") != std::string::npos) {
247 Gtk::Window window (WINDOW_TOPLEVEL);
248 window.add (output_button);
249 Gtk::Requisition requisition(output_button.size_request ());
250 h += requisition.height + 2;
252 if (viz.find ("Comments") != std::string::npos) {
253 Gtk::Window window (WINDOW_TOPLEVEL);
254 window.add (comment_button);
255 Gtk::Requisition requisition(comment_button.size_request ());
256 h += requisition.height + 2;
259 bottom_padding.set_size_request (-1, 1);
260 bottom_padding.hide ();
262 bottom_padding.set_size_request (-1, h);
263 bottom_padding.show ();
268 VCAMasterStrip::name() const
274 VCAMasterStrip::hide_clicked ()
276 _vca->presentation_info().set_hidden (true);
280 VCAMasterStrip::hide_confirmation (int response)
282 delete_dialog->hide ();
286 /* get everything to deassign. This will also delete ourselves (when
287 * idle) and that in turn will remove us from the Mixer GUI
289 _session->vca_manager().remove_vca (_vca);
297 VCAMasterStrip::width_button_pressed (GdkEventButton* ev)
303 VCAMasterStrip::set_selected (bool yn)
305 AxisView::set_selected (yn);
308 global_sample.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
309 global_sample.set_name ("MixerStripSelectedFrame");
311 global_sample.set_shadow_type (Gtk::SHADOW_IN);
312 global_sample.set_name ("MixerStripFrame");
315 global_sample.queue_draw ();
319 VCAMasterStrip::solo_release (GdkEventButton*)
321 /* We use NoGroup because VCA controls are never part of a group. This
322 is redundant, but clear.
324 _vca->solo_control()->set_value (_vca->solo_control()->self_soloed() ? 0.0 : 1.0, Controllable::NoGroup);
329 VCAMasterStrip::mute_release (GdkEventButton*)
331 /* We use NoGroup because VCA controls are never part of a group. This
332 is redundant, but clear.
334 _vca->mute_control()->set_value (_vca->mute_control()->muted_by_self() ? 0.0 : 1.0, Controllable::NoGroup);
339 VCAMasterStrip::set_solo_text ()
341 if (Config->get_solo_control_is_listen_control ()) {
342 switch (Config->get_listen_position()) {
343 case AfterFaderListen:
344 solo_button.set_text (_("A"));
347 solo_button.set_text (_("P"));
351 solo_button.set_text (_("S"));
356 VCAMasterStrip::mute_changed ()
358 if (_vca->mute_control()->muted_by_self()) {
359 mute_button.set_active_state (ExplicitActive);
360 } else if (_vca->mute_control()->muted_by_masters ()) {
361 mute_button.set_active_state (ImplicitActive);
363 mute_button.set_active_state (Gtkmm2ext::Off);
368 VCAMasterStrip::solo_changed ()
370 if (_vca->solo_control()->self_soloed()) {
371 solo_button.set_active_state (ExplicitActive);
372 } else if (_vca->solo_control()->soloed_by_masters ()) {
373 solo_button.set_active_state (ImplicitActive);
375 solo_button.set_active_state (Gtkmm2ext::Off);
380 VCAMasterStrip::vertical_button_press (GdkEventButton* ev)
382 if (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
387 if (Keyboard::is_context_menu_event (ev)) {
389 build_context_menu ();
391 context_menu->popup (1, ev->time);
395 if (ev->button == 1) {
403 VCAMasterStrip::number_button_press (GdkEventButton* ev)
405 if (Keyboard::is_context_menu_event (ev)) {
407 build_context_menu ();
409 context_menu->popup (1, ev->time);
416 VCAMasterStrip::start_name_edit ()
418 Gtk::Window* win = dynamic_cast<Gtk::Window*>(get_toplevel());
419 FloatingTextEntry* fte = new FloatingTextEntry (win, _vca->name());
420 fte->use_text.connect (sigc::mem_fun (*this, &VCAMasterStrip::finish_name_edit));
425 VCAMasterStrip::finish_name_edit (std::string str, int)
427 _vca->set_name (str);
431 VCAMasterStrip::vca_property_changed (PropertyChange const & what_changed)
433 if (what_changed.contains (ARDOUR::Properties::name)) {
437 if (what_changed.contains (ARDOUR::Properties::color)) {
438 vertical_button.set_active_color (_vca->presentation_info().color ());
439 number_label.set_inactive_color (_vca->presentation_info().color ());
442 if (what_changed.contains (ARDOUR::Properties::hidden)) {
448 VCAMasterStrip::update_vca_name ()
450 /* 20 is a rough guess at the number of letters we can fit. */
451 vertical_button.set_text (short_version (_vca->full_name(), 20));
455 VCAMasterStrip::build_context_menu ()
457 using namespace Gtk::Menu_Helpers;
458 context_menu = new Menu;
459 MenuList& items = context_menu->items();
460 items.push_back (MenuElem (_("Rename"), sigc::mem_fun (*this, &VCAMasterStrip::start_name_edit)));
461 items.push_back (MenuElem (_("Color..."), sigc::mem_fun (*this, &VCAMasterStrip::start_color_edit)));
462 items.push_back (SeparatorElem());
463 items.push_back (MenuElem (_("Assign Selected Channels"), sigc::mem_fun (*this, &VCAMasterStrip::assign_all_selected)));
464 items.push_back (MenuElem (_("Drop Selected Channels"), sigc::mem_fun (*this, &VCAMasterStrip::unassign_all_selected)));
465 items.push_back (SeparatorElem());
466 items.push_back (MenuElem (_("Drop All Slaves"), sigc::mem_fun (*this, &VCAMasterStrip::drop_all_slaves)));
467 items.push_back (SeparatorElem());
468 items.push_back (MenuElem (_("Remove"), sigc::mem_fun (*this, &VCAMasterStrip::remove)));
472 VCAMasterStrip::spill ()
474 if (Mixer_UI::instance()->showing_spill_for (_vca)) {
475 Mixer_UI::instance()->show_spill (boost::shared_ptr<Stripable>());
477 Mixer_UI::instance()->show_spill (_vca);
482 VCAMasterStrip::spill_change (boost::shared_ptr<Stripable> vca)
485 vertical_button.set_active_state (Gtkmm2ext::Off);
486 set_tooltip (vertical_button, _("Click to show slaves only"));
488 vertical_button.set_active_state (Gtkmm2ext::ExplicitActive);
489 set_tooltip (vertical_button, _("Click to show normal mixer"));
494 VCAMasterStrip::remove ()
500 _session->vca_manager().remove_vca (_vca);
504 VCAMasterStrip::assign_all_selected ()
506 Mixer_UI::instance()->do_vca_assign (_vca);
510 VCAMasterStrip::unassign_all_selected ()
512 Mixer_UI::instance()->do_vca_unassign (_vca);
516 VCAMasterStrip::drop_all_slaves ()
518 _vca->Drop (); /* EMIT SIGNAL */
520 if (Mixer_UI::instance()->showing_spill_for (_vca)) {
521 Mixer_UI::instance()->show_spill (boost::shared_ptr<Stripable>());
526 VCAMasterStrip::color () const
528 return ARDOUR_UI_UTILS::gdk_color_from_rgba (_vca->presentation_info().color ());
532 VCAMasterStrip::state_id () const
534 return string_compose (X_("vms-%1"), _vca->number());
538 VCAMasterStrip::start_color_edit ()
540 _color_picker.popup (_vca);
544 VCAMasterStrip::marked_for_display () const
546 return !_vca->presentation_info().hidden();
550 VCAMasterStrip::set_marked_for_display (bool yn)
552 if (yn == _vca->presentation_info().hidden()) {
553 _vca->presentation_info().set_hidden (!yn);
554 return true; // things changed
559 PresentationInfo const &
560 VCAMasterStrip::presentation_info () const
562 return _vca->presentation_info();
565 boost::shared_ptr<Stripable>
566 VCAMasterStrip::stripable () const