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"
35 #include "ui_config.h"
36 #include "vca_master_strip.h"
40 using namespace ARDOUR;
41 using namespace ARDOUR_UI_UTILS;
42 using namespace Gtkmm2ext;
47 PBD::Signal1<void,VCAMasterStrip*> VCAMasterStrip::CatchDeletion;
50 verticalize (string const & str)
55 string::const_iterator s = str.begin();
60 while (s != str.end()) {
66 /* remove terminal newline */
68 ret.erase (ret.length() - 1, string::npos);
73 VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr<VCA> v)
80 gain_meter.set_controls (boost::shared_ptr<Route>(),
81 boost::shared_ptr<PeakMeter>(),
82 boost::shared_ptr<Amp>(),
83 _vca->gain_control());
85 solo_button.set_name ("solo button");
86 set_tooltip (solo_button, _("Solo slaves"));
87 solo_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::solo_release), false);
89 mute_button.set_name ("mute button");
90 mute_button.set_text (_("M"));
91 set_tooltip (mute_button, _("Mute slaves"));
92 mute_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::mute_release), false);
94 hide_button.set_icon (ArdourIcon::CloseCross);
95 set_tooltip (&hide_button, _("Hide this VCA strip"));
97 assign_button.set_name (X_("vca assign"));
98 set_tooltip (assign_button, _("Click to assign a VCA Master to this VCA"));
99 assign_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::vca_button_release), false);
101 hide_button.signal_clicked.connect (sigc::mem_fun(*this, &VCAMasterStrip::hide_clicked));
103 width_hide_box.pack_start (number_label, true, true);
104 width_hide_box.pack_end (hide_button, false, true);
106 solo_mute_box.set_spacing (2);
107 solo_mute_box.pack_start (mute_button, true, true);
108 solo_mute_box.pack_start (solo_button, true, true);
110 number_label.set_text (to_string (v->number(), std::dec));
111 number_label.set_elements((ArdourButton::Element)(ArdourButton::Edge|ArdourButton::Body|ArdourButton::Text|ArdourButton::Inactive));
112 number_label.set_no_show_all ();
113 number_label.set_name ("generic button");
114 number_label.set_alignment (.5, .5);
115 number_label.set_fallthrough_to_parent (true);
117 name_button.signal_button_press_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::name_button_press), false);
119 top_padding.set_size_request (-1, 16); /* must match height in GroupTabs::set_size_request() */
120 bottom_padding.set_size_request (-1, 50); /* this one is a hack. there's no trivial way to compute it */
122 //Glib::RefPtr<Pango::Layout> layout = vertical_button.get_layout ();
123 // layout->set_justify (JUSTIFY_CENTER);
124 /* horizontally centered, with a little space (5%) at the top */
125 vertical_button.set_angle (90);
126 vertical_button.set_layout_font (UIConfiguration::instance().get_NormalBoldFont());
128 global_vpacker.set_border_width (1);
129 global_vpacker.set_spacing (0);
131 global_vpacker.pack_start (top_padding, false, false);
132 global_vpacker.pack_start (width_hide_box, false, false);
133 global_vpacker.pack_start (name_button, false, false);
134 global_vpacker.pack_start (vertical_button, true, true);
135 global_vpacker.pack_start (solo_mute_box, false, false);
136 global_vpacker.pack_start (gain_meter, false, false);
137 global_vpacker.pack_start (assign_button, false, false);
138 global_vpacker.pack_start (bottom_padding, false, false);
140 global_frame.add (global_vpacker);
141 global_frame.set_shadow_type (Gtk::SHADOW_IN);
142 global_frame.set_name ("BaseFrame");
146 global_vpacker.show ();
147 global_frame.show ();
149 bottom_padding.show ();
150 vertical_button.show ();
152 number_label.show ();
153 width_hide_box.show ();
156 solo_mute_box.show_all ();
157 assign_button.show ();
159 /* force setting of visible selected status */
162 set_selected (false);
164 update_vca_display ();
169 /* this remains unchanged as the name changes */
170 name_button.set_text (string_compose (X_("VCA %1"), _vca->number()));
172 _vca->PropertyChanged.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::vca_property_changed, this, _1), gui_context());
174 _vca->solo_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::solo_changed, this), gui_context());
175 _vca->mute_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::mute_changed, this), gui_context());
177 /* only need to connect to one of these to update VCA status */
179 _vca->gain_control()->MasterStatusChange.connect (vca_connections,
181 boost::bind (&VCAMasterStrip::update_vca_display, this),
185 _vca->DropReferences.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::self_delete, this), gui_context());
189 VCAMasterStrip::~VCAMasterStrip ()
191 delete delete_dialog;
194 CatchDeletion (this); /* EMIT SIGNAL */
198 VCAMasterStrip::self_delete ()
200 delete_when_idle (this);
204 VCAMasterStrip::update_vca_display ()
206 VCAList vcas (_session->vca_manager().vcas());
209 for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) {
210 if (_vca->gain_control()->slaved_to ((*v)->gain_control())) {
211 if (!label.empty()) {
214 label += to_string ((*v)->number(), std::dec);
220 assign_button.set_active_state (Gtkmm2ext::Off);
222 assign_button.set_active_state (Gtkmm2ext::ExplicitActive);
225 assign_button.set_text (label);
229 VCAMasterStrip::name() const
235 VCAMasterStrip::hide_clicked ()
237 if (!delete_dialog) {
238 delete_dialog = new MessageDialog (_("Removing a Master will deassign all slaves. Remove it anyway?"),
239 true, MESSAGE_WARNING, BUTTONS_YES_NO, true);
240 delete_dialog->signal_response().connect (sigc::mem_fun (*this, &VCAMasterStrip::hide_confirmation));
243 delete_dialog->set_position (Gtk::WIN_POS_MOUSE);
244 delete_dialog->present ();
248 VCAMasterStrip::hide_confirmation (int response)
250 delete_dialog->hide ();
254 /* get everything to deassign. This will also delete ourselves (when
255 * idle) and that in turn will remove us from the Mixer GUI
257 _session->vca_manager().remove_vca (_vca);
265 VCAMasterStrip::width_button_pressed (GdkEventButton* ev)
271 VCAMasterStrip::set_selected (bool yn)
273 AxisView::set_selected (yn);
276 global_frame.set_shadow_type (Gtk::SHADOW_ETCHED_OUT);
277 global_frame.set_name ("MixerStripSelectedFrame");
279 global_frame.set_shadow_type (Gtk::SHADOW_IN);
280 global_frame.set_name ("MixerStripFrame");
283 global_frame.queue_draw ();
287 VCAMasterStrip::solo_release (GdkEventButton*)
289 /* We use NoGroup because VCA controls are never part of a group. This
290 is redundant, but clear.
292 _vca->solo_control()->set_value (_vca->solo_control()->self_soloed() ? 0.0 : 1.0, Controllable::NoGroup);
297 VCAMasterStrip::mute_release (GdkEventButton*)
299 /* We use NoGroup because VCA controls are never part of a group. This
300 is redundant, but clear.
302 _vca->mute_control()->set_value (_vca->mute_control()->muted_by_self() ? 0.0 : 1.0, Controllable::NoGroup);
307 VCAMasterStrip::set_solo_text ()
309 if (Config->get_solo_control_is_listen_control ()) {
310 switch (Config->get_listen_position()) {
311 case AfterFaderListen:
312 solo_button.set_text (_("A"));
315 solo_button.set_text (_("P"));
319 solo_button.set_text (_("S"));
324 VCAMasterStrip::mute_changed ()
326 if (_vca->mute_control()->muted_by_self()) {
327 mute_button.set_active_state (ExplicitActive);
328 } else if (_vca->mute_control()->muted_by_masters ()) {
329 mute_button.set_active_state (ImplicitActive);
331 mute_button.set_active_state (Gtkmm2ext::Off);
336 VCAMasterStrip::solo_changed ()
338 if (_vca->solo_control()->self_soloed()) {
339 solo_button.set_active_state (ExplicitActive);
340 } else if (_vca->solo_control()->soloed_by_masters ()) {
341 solo_button.set_active_state (ImplicitActive);
343 solo_button.set_active_state (Gtkmm2ext::Off);
348 VCAMasterStrip::vca_menu_toggle (CheckMenuItem* menuitem, uint32_t n)
350 boost::shared_ptr<VCA> vca = _session->vca_manager().vca_by_number (n);
352 if (!menuitem->get_active()) {
354 /* null VCA means drop all VCA assignments */
355 _vca->unassign (boost::shared_ptr<VCA>());
358 _vca->unassign (vca);
368 VCAMasterStrip::unassign ()
370 _vca->unassign (boost::shared_ptr<VCA>());
374 VCAMasterStrip::vca_button_release (GdkEventButton* ev)
376 using namespace Gtk::Menu_Helpers;
382 /* primary click only */
384 if (ev->button != 1) {
388 VCAList vcas (_session->vca_manager().vcas());
391 /* XXX should probably show a message saying "No VCA masters" */
395 Menu* menu = new Menu;
396 MenuList& items = menu->items();
398 items.push_back (MenuElem (_("Unassign"), sigc::mem_fun (*this, &VCAMasterStrip::unassign)));
400 for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) {
403 /* no self-mastering */
407 items.push_back (CheckMenuElem ((*v)->name()));
408 CheckMenuItem* item = dynamic_cast<CheckMenuItem*> (&items.back());
409 if (_vca->gain_control()->slaved_to ((*v)->gain_control())) {
410 item->set_active (true);
412 item->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &VCAMasterStrip::vca_menu_toggle), item, (*v)->number()));
415 menu->popup (1, ev->time);
421 VCAMasterStrip::vertical_box_press (GdkEventButton* ev)
423 if (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
428 if (Keyboard::is_context_menu_event (ev)) {
430 build_context_menu ();
432 context_menu->popup (1, ev->time);
436 if (ev->button == 1) {
444 VCAMasterStrip::name_button_press (GdkEventButton* ev)
446 if (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) {
451 if (Keyboard::is_context_menu_event (ev)) {
453 build_context_menu ();
455 context_menu->popup (1, ev->time);
463 VCAMasterStrip::start_name_edit ()
465 Gtk::Window* win = dynamic_cast<Gtk::Window*>(get_toplevel());
466 FloatingTextEntry* fte = new FloatingTextEntry (win, _vca->name());
467 fte->use_text.connect (sigc::mem_fun (*this, &VCAMasterStrip::finish_name_edit));
472 VCAMasterStrip::finish_name_edit (std::string str)
474 _vca->set_name (str);
478 VCAMasterStrip::vca_property_changed (PropertyChange const & what_changed)
480 if (what_changed.contains (ARDOUR::Properties::name)) {
486 VCAMasterStrip::update_vca_name ()
488 vertical_button.set_text (verticalize (short_version (_vca->name(), 15)));
492 VCAMasterStrip::build_context_menu ()
494 using namespace Gtk::Menu_Helpers;
495 context_menu = new Menu;
496 MenuList& items = context_menu->items();
497 items.push_back (MenuElem (_("Rename"), sigc::mem_fun (*this, &VCAMasterStrip::start_name_edit)));
498 items.push_back (MenuElem (_("Remove")));