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/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"
31 #include "ardour_dialog.h"
32 #include "floating_text_entry.h"
33 #include "gui_thread.h"
36 #include "ui_config.h"
37 #include "vca_master_strip.h"
41 using namespace ARDOUR;
42 using namespace ARDOUR_UI_UTILS;
43 using namespace Gtkmm2ext;
48 PBD::Signal1<void,VCAMasterStrip*> VCAMasterStrip::CatchDeletion;
50 VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr<VCA> v)
57 gain_meter.set_controls (boost::shared_ptr<Route>(),
58 boost::shared_ptr<PeakMeter>(),
59 boost::shared_ptr<Amp>(),
60 _vca->gain_control());
62 solo_button.set_name ("solo button");
63 set_tooltip (solo_button, _("Solo slaves"));
64 solo_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::solo_release), false);
66 mute_button.set_name ("mute button");
67 mute_button.set_text (_("M"));
68 set_tooltip (mute_button, _("Mute slaves"));
69 mute_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::mute_release), false);
71 hide_button.set_icon (ArdourIcon::CloseCross);
72 set_tooltip (&hide_button, _("Hide this VCA strip"));
74 assign_button.set_name (X_("vca assign"));
75 set_tooltip (assign_button, _("Click to assign a VCA Master to this VCA"));
76 assign_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::vca_button_release), false);
78 hide_button.signal_clicked.connect (sigc::mem_fun(*this, &VCAMasterStrip::hide_clicked));
80 width_hide_box.pack_start (number_label, true, true);
81 width_hide_box.pack_end (hide_button, false, true);
83 solo_mute_box.set_spacing (2);
84 solo_mute_box.pack_start (mute_button, true, true);
85 solo_mute_box.pack_start (solo_button, true, true);
87 number_label.set_text (to_string (v->number(), std::dec));
88 number_label.set_elements((ArdourButton::Element)(ArdourButton::Edge|ArdourButton::Body|ArdourButton::Text|ArdourButton::Inactive));
89 number_label.set_no_show_all ();
90 number_label.set_name ("generic button");
91 number_label.set_alignment (.5, .5);
92 number_label.set_fallthrough_to_parent (true);
94 top_padding.set_size_request (-1, 16); /* must match height in GroupTabs::set_size_request() */
95 bottom_padding.set_size_request (-1, 30); /* this one is a hack. there's no trivial way to compute it */
97 //Glib::RefPtr<Pango::Layout> layout = vertical_button.get_layout ();
98 // layout->set_justify (JUSTIFY_CENTER);
99 /* horizontally centered, with a little space (5%) at the top */
100 vertical_button.set_angle (90);
101 vertical_button.set_layout_font (UIConfiguration::instance().get_NormalBoldFont());
102 vertical_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::vertical_button_press));
103 vertical_button.set_fallthrough_to_parent (true);
104 set_tooltip (vertical_button, _("Click to show slaves only")); /* tooltip updated dynamically */
106 drop_button.set_text(_("drop"));
107 drop_button.signal_clicked.connect (sigc::mem_fun (*this, &VCAMasterStrip::drop_button_press));
108 set_tooltip (drop_button, _("Unassign all slaves from this control master"));
110 global_vpacker.set_border_width (1);
111 global_vpacker.set_spacing (0);
113 global_vpacker.pack_start (top_padding, false, false);
114 global_vpacker.pack_start (width_hide_box, false, false);
115 global_vpacker.pack_start (vertical_button, true, true);
116 global_vpacker.pack_start (solo_mute_box, false, false);
117 global_vpacker.pack_start (gain_meter, false, false, 2);
118 global_vpacker.pack_start (assign_button, false, false);
119 global_vpacker.pack_start (drop_button, false, false);
120 global_vpacker.pack_start (bottom_padding, false, false);
122 global_frame.add (global_vpacker);
123 global_frame.set_shadow_type (Gtk::SHADOW_IN);
124 global_frame.set_name ("BaseFrame");
128 global_vpacker.show ();
129 global_frame.show ();
131 bottom_padding.show ();
132 vertical_button.show ();
134 number_label.show ();
135 width_hide_box.show ();
137 solo_mute_box.show_all ();
138 assign_button.show ();
141 /* force setting of visible selected status */
144 set_selected (false);
146 update_vca_display ();
150 spill_change (boost::shared_ptr<VCA>());
152 Mixer_UI::instance()->show_vca_change.connect (sigc::mem_fun (*this, &VCAMasterStrip::spill_change));
154 _vca->PropertyChanged.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::vca_property_changed, this, _1), gui_context());
156 _vca->solo_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::solo_changed, this), gui_context());
157 _vca->mute_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::mute_changed, this), gui_context());
159 /* only need to connect to one of these to update VCA status */
161 _vca->gain_control()->MasterStatusChange.connect (vca_connections,
163 boost::bind (&VCAMasterStrip::update_vca_display, this),
167 _vca->DropReferences.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::self_delete, this), gui_context());
171 VCAMasterStrip::~VCAMasterStrip ()
173 if ((_session && !_session->deletion_in_progress()) && Mixer_UI::instance()->showing_vca_slaves_for (_vca)) {
174 /* cancel spill for this VCA */
175 Mixer_UI::instance()->show_vca_slaves (boost::shared_ptr<VCA>());
178 delete delete_dialog;
181 CatchDeletion (this); /* EMIT SIGNAL */
185 VCAMasterStrip::self_delete ()
187 delete_when_idle (this);
191 VCAMasterStrip::update_vca_display ()
193 VCAList vcas (_session->vca_manager().vcas());
196 for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) {
197 if (_vca->slaved_to (*v)) {
198 if (!label.empty()) {
201 label += to_string ((*v)->number(), std::dec);
207 assign_button.set_active_state (Gtkmm2ext::Off);
209 assign_button.set_active_state (Gtkmm2ext::ExplicitActive);
212 assign_button.set_text (label);
216 VCAMasterStrip::name() const
222 VCAMasterStrip::hide_clicked ()
224 if (!delete_dialog) {
225 delete_dialog = new MessageDialog (_("Removing a Master will deassign all slaves. Remove it anyway?"),
226 true, MESSAGE_WARNING, BUTTONS_YES_NO, true);
227 delete_dialog->signal_response().connect (sigc::mem_fun (*this, &VCAMasterStrip::hide_confirmation));
230 delete_dialog->set_position (Gtk::WIN_POS_MOUSE);
231 delete_dialog->present ();
235 VCAMasterStrip::hide_confirmation (int response)
237 delete_dialog->hide ();
241 /* get everything to deassign. This will also delete ourselves (when
242 * idle) and that in turn will remove us from the Mixer GUI
244 _session->vca_manager().remove_vca (_vca);
252 VCAMasterStrip::width_button_pressed (GdkEventButton* ev)
258 VCAMasterStrip::set_selected (bool yn)
260 AxisView::set_selected (yn);
263 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
264 global_frame.set_name ("MixerStripSelectedFrame");
266 global_frame.set_shadow_type (Gtk::SHADOW_IN);
267 global_frame.set_name ("MixerStripFrame");
270 global_frame.queue_draw ();
274 VCAMasterStrip::solo_release (GdkEventButton*)
276 /* We use NoGroup because VCA controls are never part of a group. This
277 is redundant, but clear.
279 _vca->solo_control()->set_value (_vca->solo_control()->self_soloed() ? 0.0 : 1.0, Controllable::NoGroup);
284 VCAMasterStrip::mute_release (GdkEventButton*)
286 /* We use NoGroup because VCA controls are never part of a group. This
287 is redundant, but clear.
289 _vca->mute_control()->set_value (_vca->mute_control()->muted_by_self() ? 0.0 : 1.0, Controllable::NoGroup);
294 VCAMasterStrip::set_solo_text ()
296 if (Config->get_solo_control_is_listen_control ()) {
297 switch (Config->get_listen_position()) {
298 case AfterFaderListen:
299 solo_button.set_text (_("A"));
302 solo_button.set_text (_("P"));
306 solo_button.set_text (_("S"));
311 VCAMasterStrip::mute_changed ()
313 if (_vca->mute_control()->muted_by_self()) {
314 mute_button.set_active_state (ExplicitActive);
315 } else if (_vca->mute_control()->muted_by_masters ()) {
316 mute_button.set_active_state (ImplicitActive);
318 mute_button.set_active_state (Gtkmm2ext::Off);
323 VCAMasterStrip::solo_changed ()
325 if (_vca->solo_control()->self_soloed()) {
326 solo_button.set_active_state (ExplicitActive);
327 } else if (_vca->solo_control()->soloed_by_masters ()) {
328 solo_button.set_active_state (ImplicitActive);
330 solo_button.set_active_state (Gtkmm2ext::Off);
335 VCAMasterStrip::vca_menu_toggle (CheckMenuItem* menuitem, uint32_t n)
337 boost::shared_ptr<VCA> vca = _session->vca_manager().vca_by_number (n);
339 if (!menuitem->get_active()) {
341 /* null VCA means drop all VCA assignments */
342 _vca->unassign (boost::shared_ptr<VCA>());
345 _vca->unassign (vca);
355 VCAMasterStrip::unassign ()
357 _vca->unassign (boost::shared_ptr<VCA>());
361 VCAMasterStrip::vca_button_release (GdkEventButton* ev)
363 using namespace Gtk::Menu_Helpers;
369 /* primary click only */
371 if (ev->button != 1) {
375 VCAList vcas (_session->vca_manager().vcas());
378 /* XXX should probably show a message saying "No VCA masters" */
382 Menu* menu = new Menu;
383 MenuList& items = menu->items();
385 items.push_back (MenuElem (_("Unassign"), sigc::mem_fun (*this, &VCAMasterStrip::unassign)));
387 for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) {
390 /* no self-mastering */
394 items.push_back (CheckMenuElem ((*v)->name()));
395 CheckMenuItem* item = dynamic_cast<CheckMenuItem*> (&items.back());
396 if (_vca->gain_control()->slaved_to ((*v)->gain_control())) {
397 item->set_active (true);
399 item->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &VCAMasterStrip::vca_menu_toggle), item, (*v)->number()));
402 menu->popup (1, ev->time);
408 VCAMasterStrip::vertical_button_press (GdkEventButton* ev)
410 if (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
415 if (Keyboard::is_context_menu_event (ev)) {
417 build_context_menu ();
419 context_menu->popup (1, ev->time);
423 if (ev->button == 1) {
431 VCAMasterStrip::start_name_edit ()
433 Gtk::Window* win = dynamic_cast<Gtk::Window*>(get_toplevel());
434 FloatingTextEntry* fte = new FloatingTextEntry (win, _vca->name());
435 fte->use_text.connect (sigc::mem_fun (*this, &VCAMasterStrip::finish_name_edit));
440 VCAMasterStrip::finish_name_edit (std::string str)
442 _vca->set_name (str);
446 VCAMasterStrip::vca_property_changed (PropertyChange const & what_changed)
448 if (what_changed.contains (ARDOUR::Properties::name)) {
454 VCAMasterStrip::update_vca_name ()
456 /* 20 is a rough guess at the number of letters we can fit. */
457 vertical_button.set_text (short_version (_vca->name(), 20));
461 VCAMasterStrip::build_context_menu ()
463 using namespace Gtk::Menu_Helpers;
464 context_menu = new Menu;
465 MenuList& items = context_menu->items();
466 items.push_back (MenuElem (_("Rename"), sigc::mem_fun (*this, &VCAMasterStrip::start_name_edit)));
467 items.push_back (SeparatorElem());
468 items.push_back (MenuElem (_("Drop All Slaves"), sigc::mem_fun (*this, &VCAMasterStrip::drop_all_slaves)));
469 items.push_back (SeparatorElem());
470 items.push_back (MenuElem (_("Remove"), sigc::mem_fun (*this, &VCAMasterStrip::remove)));
474 VCAMasterStrip::spill ()
476 if (Mixer_UI::instance()->showing_vca_slaves_for (_vca)) {
477 Mixer_UI::instance()->show_vca_slaves (boost::shared_ptr<VCA>());
479 Mixer_UI::instance()->show_vca_slaves (_vca);
484 VCAMasterStrip::spill_change (boost::shared_ptr<VCA> vca)
487 vertical_button.set_active_state (Gtkmm2ext::Off);
488 set_tooltip (vertical_button, _("Click to show slaves only"));
490 vertical_button.set_active_state (Gtkmm2ext::ExplicitActive);
491 set_tooltip (vertical_button, _("Click to show normal mixer"));
496 VCAMasterStrip::remove ()
502 _session->vca_manager().remove_vca (_vca);
506 VCAMasterStrip::drop_all_slaves ()
508 _vca->Drop (); /* EMIT SIGNAL */
510 if (Mixer_UI::instance()->showing_vca_slaves_for (_vca)) {
511 Mixer_UI::instance()->show_vca_slaves (boost::shared_ptr<VCA>());
516 VCAMasterStrip::drop_button_press ()