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)
51 : SessionHandlePtr (s)
56 , control_slave_ui (s)
58 control_slave_ui.set_stripable (boost::dynamic_pointer_cast<Stripable> (v));
60 gain_meter.set_controls (boost::shared_ptr<Route>(),
61 boost::shared_ptr<PeakMeter>(),
62 boost::shared_ptr<Amp>(),
63 _vca->gain_control());
65 solo_button.set_name ("solo button");
66 set_tooltip (solo_button, _("Solo slaves"));
67 solo_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::solo_release), false);
69 mute_button.set_name ("mute button");
70 mute_button.set_text (_("M"));
71 set_tooltip (mute_button, _("Mute slaves"));
72 mute_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::mute_release), false);
74 hide_button.set_icon (ArdourIcon::CloseCross);
75 set_tooltip (&hide_button, _("Hide this VCA strip"));
77 hide_button.signal_clicked.connect (sigc::mem_fun(*this, &VCAMasterStrip::hide_clicked));
79 solo_mute_box.set_spacing (2);
80 solo_mute_box.pack_start (mute_button, true, true);
81 solo_mute_box.pack_start (solo_button, true, true);
83 number_label.set_text (to_string (v->number(), std::dec));
84 number_label.set_elements((ArdourButton::Element)(ArdourButton::Edge|ArdourButton::Body|ArdourButton::Text|ArdourButton::Inactive));
85 number_label.set_no_show_all ();
86 number_label.set_name ("generic button");
87 number_label.set_alignment (.5, .5);
88 number_label.set_fallthrough_to_parent (true);
90 bottom_padding.set_size_request (-1, 32); /* this one is a hack. there's no trivial way to compute it */
92 //Glib::RefPtr<Pango::Layout> layout = vertical_button.get_layout ();
93 // layout->set_justify (JUSTIFY_CENTER);
94 /* horizontally centered, with a little space (5%) at the top */
95 vertical_button.set_angle (90);
96 vertical_button.set_layout_font (UIConfiguration::instance().get_NormalBoldFont());
97 vertical_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::vertical_button_press));
98 vertical_button.set_fallthrough_to_parent (true);
99 set_tooltip (vertical_button, _("Click to show slaves only")); /* tooltip updated dynamically */
101 drop_button.set_text(_("drop"));
102 drop_button.signal_clicked.connect (sigc::mem_fun (*this, &VCAMasterStrip::drop_button_press));
103 set_tooltip (drop_button, _("Unassign all slaves from this control master"));
105 global_vpacker.set_border_width (1);
106 global_vpacker.set_spacing (0);
108 global_vpacker.pack_start (number_label, false, false);
109 global_vpacker.pack_start (hide_button, false, false);
110 global_vpacker.pack_start (vertical_button, true, true);
111 global_vpacker.pack_start (solo_mute_box, false, false);
112 global_vpacker.pack_start (gain_meter, false, false, 2);
113 global_vpacker.pack_start (control_slave_ui, false, false);
114 global_vpacker.pack_start (drop_button, false, false);
115 global_vpacker.pack_start (bottom_padding, false, false);
117 global_frame.add (global_vpacker);
118 global_frame.set_shadow_type (Gtk::SHADOW_IN);
119 global_frame.set_name ("BaseFrame");
123 global_vpacker.show ();
124 global_frame.show ();
126 bottom_padding.show ();
127 vertical_button.show ();
129 number_label.show ();
131 solo_mute_box.show_all ();
132 control_slave_ui.show ();
135 /* force setting of visible selected status */
138 set_selected (false);
143 spill_change (boost::shared_ptr<VCA>());
145 Mixer_UI::instance()->show_vca_change.connect (sigc::mem_fun (*this, &VCAMasterStrip::spill_change));
147 _vca->PropertyChanged.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::vca_property_changed, this, _1), gui_context());
148 _vca->DropReferences.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::self_delete, this), gui_context());
150 _vca->solo_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::solo_changed, this), gui_context());
151 _vca->mute_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::mute_changed, this), gui_context());
154 s->config.ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCAMasterStrip::parameter_changed, this, _1), gui_context());
155 Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCAMasterStrip::parameter_changed, this, _1), gui_context());
156 UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &VCAMasterStrip::parameter_changed));
159 VCAMasterStrip::~VCAMasterStrip ()
161 if ((_session && !_session->deletion_in_progress()) && Mixer_UI::instance()->showing_vca_slaves_for (_vca)) {
162 /* cancel spill for this VCA */
163 Mixer_UI::instance()->show_vca_slaves (boost::shared_ptr<VCA>());
166 delete delete_dialog;
169 CatchDeletion (this); /* EMIT SIGNAL */
173 VCAMasterStrip::self_delete ()
175 if ((_session && !_session->deletion_in_progress()) && Mixer_UI::instance()->showing_vca_slaves_for (_vca)) {
176 /* cancel spill for this VCA */
177 Mixer_UI::instance()->show_vca_slaves (boost::shared_ptr<VCA>());
179 /* Drop reference immediately, delete self when idle */
181 delete_when_idle (this);
185 VCAMasterStrip::parameter_changed (std::string const & p)
187 if (p == "use-monitor-bus" || p == "solo-control-is-listen-control" || p == "listen-position") {
193 VCAMasterStrip::set_button_names ()
195 if (Config->get_solo_control_is_listen_control()) {
196 switch (Config->get_listen_position()) {
197 case AfterFaderListen:
198 solo_button.set_text (S_("AfterFader|A"));
199 set_tooltip (solo_button, _("After-fade listen (AFL)"));
202 solo_button.set_text (S_("PreFader|P"));
203 set_tooltip (solo_button, _("Pre-fade listen (PFL)"));
207 solo_button.set_text (S_("Solo|S"));
208 set_tooltip (solo_button, _("Solo"));
213 VCAMasterStrip::name() const
219 VCAMasterStrip::hide_clicked ()
221 if (!delete_dialog) {
222 delete_dialog = new MessageDialog (_("Removing a Master will deassign all slaves. Remove it anyway?"),
223 true, MESSAGE_WARNING, BUTTONS_YES_NO, true);
224 delete_dialog->signal_response().connect (sigc::mem_fun (*this, &VCAMasterStrip::hide_confirmation));
227 delete_dialog->set_position (Gtk::WIN_POS_MOUSE);
228 delete_dialog->present ();
232 VCAMasterStrip::hide_confirmation (int response)
234 delete_dialog->hide ();
238 /* get everything to deassign. This will also delete ourselves (when
239 * idle) and that in turn will remove us from the Mixer GUI
241 _session->vca_manager().remove_vca (_vca);
249 VCAMasterStrip::width_button_pressed (GdkEventButton* ev)
255 VCAMasterStrip::set_selected (bool yn)
257 AxisView::set_selected (yn);
260 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
261 global_frame.set_name ("MixerStripSelectedFrame");
263 global_frame.set_shadow_type (Gtk::SHADOW_IN);
264 global_frame.set_name ("MixerStripFrame");
267 global_frame.queue_draw ();
271 VCAMasterStrip::solo_release (GdkEventButton*)
273 /* We use NoGroup because VCA controls are never part of a group. This
274 is redundant, but clear.
276 _vca->solo_control()->set_value (_vca->solo_control()->self_soloed() ? 0.0 : 1.0, Controllable::NoGroup);
281 VCAMasterStrip::mute_release (GdkEventButton*)
283 /* We use NoGroup because VCA controls are never part of a group. This
284 is redundant, but clear.
286 _vca->mute_control()->set_value (_vca->mute_control()->muted_by_self() ? 0.0 : 1.0, Controllable::NoGroup);
291 VCAMasterStrip::set_solo_text ()
293 if (Config->get_solo_control_is_listen_control ()) {
294 switch (Config->get_listen_position()) {
295 case AfterFaderListen:
296 solo_button.set_text (_("A"));
299 solo_button.set_text (_("P"));
303 solo_button.set_text (_("S"));
308 VCAMasterStrip::mute_changed ()
310 if (_vca->mute_control()->muted_by_self()) {
311 mute_button.set_active_state (ExplicitActive);
312 } else if (_vca->mute_control()->muted_by_masters ()) {
313 mute_button.set_active_state (ImplicitActive);
315 mute_button.set_active_state (Gtkmm2ext::Off);
320 VCAMasterStrip::solo_changed ()
322 if (_vca->solo_control()->self_soloed()) {
323 solo_button.set_active_state (ExplicitActive);
324 } else if (_vca->solo_control()->soloed_by_masters ()) {
325 solo_button.set_active_state (ImplicitActive);
327 solo_button.set_active_state (Gtkmm2ext::Off);
332 VCAMasterStrip::vertical_button_press (GdkEventButton* ev)
334 if (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
339 if (Keyboard::is_context_menu_event (ev)) {
341 build_context_menu ();
343 context_menu->popup (1, ev->time);
347 if (ev->button == 1) {
355 VCAMasterStrip::start_name_edit ()
357 Gtk::Window* win = dynamic_cast<Gtk::Window*>(get_toplevel());
358 FloatingTextEntry* fte = new FloatingTextEntry (win, _vca->name());
359 fte->use_text.connect (sigc::mem_fun (*this, &VCAMasterStrip::finish_name_edit));
364 VCAMasterStrip::finish_name_edit (std::string str, int)
366 _vca->set_name (str);
370 VCAMasterStrip::vca_property_changed (PropertyChange const & what_changed)
372 if (what_changed.contains (ARDOUR::Properties::name)) {
378 VCAMasterStrip::update_vca_name ()
380 /* 20 is a rough guess at the number of letters we can fit. */
381 vertical_button.set_text (short_version (_vca->name(), 20));
385 VCAMasterStrip::build_context_menu ()
387 using namespace Gtk::Menu_Helpers;
388 context_menu = new Menu;
389 MenuList& items = context_menu->items();
390 items.push_back (MenuElem (_("Rename"), sigc::mem_fun (*this, &VCAMasterStrip::start_name_edit)));
391 items.push_back (SeparatorElem());
392 items.push_back (MenuElem (_("Drop All Slaves"), sigc::mem_fun (*this, &VCAMasterStrip::drop_all_slaves)));
393 items.push_back (SeparatorElem());
394 items.push_back (MenuElem (_("Remove"), sigc::mem_fun (*this, &VCAMasterStrip::remove)));
398 VCAMasterStrip::spill ()
400 if (Mixer_UI::instance()->showing_vca_slaves_for (_vca)) {
401 Mixer_UI::instance()->show_vca_slaves (boost::shared_ptr<VCA>());
403 Mixer_UI::instance()->show_vca_slaves (_vca);
408 VCAMasterStrip::spill_change (boost::shared_ptr<VCA> vca)
411 vertical_button.set_active_state (Gtkmm2ext::Off);
412 set_tooltip (vertical_button, _("Click to show slaves only"));
414 vertical_button.set_active_state (Gtkmm2ext::ExplicitActive);
415 set_tooltip (vertical_button, _("Click to show normal mixer"));
420 VCAMasterStrip::remove ()
426 _session->vca_manager().remove_vca (_vca);
430 VCAMasterStrip::drop_all_slaves ()
432 _vca->Drop (); /* EMIT SIGNAL */
434 if (Mixer_UI::instance()->showing_vca_slaves_for (_vca)) {
435 Mixer_UI::instance()->show_vca_slaves (boost::shared_ptr<VCA>());
440 VCAMasterStrip::drop_button_press ()
446 VCAMasterStrip::color () const
448 return gdk_color_from_rgb (_vca->presentation_info().color ());
452 VCAMasterStrip::state_id () const
454 return string_compose (X_("vms-%1"), _vca->number());