X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fvca_master_strip.cc;h=087e5621975d54f4fc5a3d8602743e999cdb0083;hb=f513878c8a54bdbed0d2657ac904f51590d4556e;hp=6f43228424b360191393f3f4d932bb7e0e2df13b;hpb=6de4953be8dc5cd413b405d4801f086567923965;p=ardour.git diff --git a/gtk2_ardour/vca_master_strip.cc b/gtk2_ardour/vca_master_strip.cc index 6f43228424..087e562197 100644 --- a/gtk2_ardour/vca_master_strip.cc +++ b/gtk2_ardour/vca_master_strip.cc @@ -16,6 +16,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include + #include "pbd/convert.h" #include "ardour/rc_configuration.h" @@ -23,11 +25,15 @@ #include "ardour/vca.h" #include "ardour/vca_manager.h" +#include "gtkmm2ext/doi.h" #include "gtkmm2ext/keyboard.h" -#include "gui_thread.h" +#include "ardour_dialog.h" #include "floating_text_entry.h" +#include "gui_thread.h" +#include "mixer_ui.h" #include "tooltips.h" +#include "ui_config.h" #include "vca_master_strip.h" #include "i18n.h" @@ -39,11 +45,14 @@ using namespace Gtk; using namespace PBD; using std::string; +PBD::Signal1 VCAMasterStrip::CatchDeletion; + VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr v) : AxisView (s) , _vca (v) , gain_meter (s, 250) , context_menu (0) + , delete_dialog (0) { gain_meter.set_controls (boost::shared_ptr(), boost::shared_ptr(), @@ -82,21 +91,32 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr v) number_label.set_alignment (.5, .5); number_label.set_fallthrough_to_parent (true); - name_button.signal_button_press_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::name_button_press), false); - top_padding.set_size_request (-1, 16); /* must match height in GroupTabs::set_size_request() */ - bottom_padding.set_size_request (-1, 50); /* this one is a hack. there's no trivial way to compute it */ + bottom_padding.set_size_request (-1, 30); /* this one is a hack. there's no trivial way to compute it */ + + //Glib::RefPtr layout = vertical_button.get_layout (); + // layout->set_justify (JUSTIFY_CENTER); + /* horizontally centered, with a little space (5%) at the top */ + vertical_button.set_angle (90); + vertical_button.set_layout_font (UIConfiguration::instance().get_NormalBoldFont()); + vertical_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::vertical_button_press)); + vertical_button.set_fallthrough_to_parent (true); + set_tooltip (vertical_button, _("Click to show slaves only")); /* tooltip updated dynamically */ + + drop_button.set_text(_("drop")); + drop_button.signal_clicked.connect (sigc::mem_fun (*this, &VCAMasterStrip::drop_button_press)); + set_tooltip (drop_button, _("Unassign all slaves from this control master")); global_vpacker.set_border_width (1); global_vpacker.set_spacing (0); global_vpacker.pack_start (top_padding, false, false); global_vpacker.pack_start (width_hide_box, false, false); - global_vpacker.pack_start (name_button, false, false); - global_vpacker.pack_start (vertical_padding, true, true); + global_vpacker.pack_start (vertical_button, true, true); global_vpacker.pack_start (solo_mute_box, false, false); - global_vpacker.pack_start (gain_meter, false, false); + global_vpacker.pack_start (gain_meter, false, false, 2); global_vpacker.pack_start (assign_button, false, false); + global_vpacker.pack_start (drop_button, false, false); global_vpacker.pack_start (bottom_padding, false, false); global_frame.add (global_vpacker); @@ -109,14 +129,14 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr v) global_frame.show (); top_padding.show (); bottom_padding.show (); - vertical_padding.show (); + vertical_button.show (); hide_button.show (); number_label.show (); width_hide_box.show (); - name_button.show (); gain_meter.show (); solo_mute_box.show_all (); assign_button.show (); + drop_button.show (); /* force setting of visible selected status */ @@ -125,6 +145,11 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr v) set_solo_text (); update_vca_display (); update_vca_name (); + solo_changed (); + mute_changed (); + spill_change (boost::shared_ptr()); + + Mixer_UI::instance()->show_vca_change.connect (sigc::mem_fun (*this, &VCAMasterStrip::spill_change)); _vca->PropertyChanged.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::vca_property_changed, this, _1), gui_context()); @@ -137,6 +162,60 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr v) invalidator (*this), boost::bind (&VCAMasterStrip::update_vca_display, this), gui_context()); + + + _vca->DropReferences.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::self_delete, this), gui_context()); + + s->config.ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCAMasterStrip::parameter_changed, this, _1), gui_context()); + Config->ParameterChanged.connect (*this, invalidator (*this), boost::bind (&VCAMasterStrip::parameter_changed, this, _1), gui_context()); + UIConfiguration::instance().ParameterChanged.connect (sigc::mem_fun (*this, &VCAMasterStrip::parameter_changed)); +} + +VCAMasterStrip::~VCAMasterStrip () +{ + if ((_session && !_session->deletion_in_progress()) && Mixer_UI::instance()->showing_vca_slaves_for (_vca)) { + /* cancel spill for this VCA */ + Mixer_UI::instance()->show_vca_slaves (boost::shared_ptr()); + } + + delete delete_dialog; + delete context_menu; + + CatchDeletion (this); /* EMIT SIGNAL */ +} + +void +VCAMasterStrip::self_delete () +{ + delete_when_idle (this); +} + +void +VCAMasterStrip::parameter_changed (std::string const & p) +{ + if (p == "use-monitor-bus" || p == "solo-control-is-listen-control" || p == "listen-position") { + set_button_names (); + } +} + +void +VCAMasterStrip::set_button_names () +{ + if (Config->get_solo_control_is_listen_control()) { + switch (Config->get_listen_position()) { + case AfterFaderListen: + solo_button.set_text (S_("AfterFader|A")); + set_tooltip (solo_button, _("After-fade listen (AFL)")); + break; + case PreFaderListen: + solo_button.set_text (S_("PreFader|P")); + set_tooltip (solo_button, _("Pre-fade listen (PFL)")); + break; + } + } else { + solo_button.set_text (S_("Solo|S")); + set_tooltip (solo_button, _("Solo")); + } } void @@ -146,7 +225,7 @@ VCAMasterStrip::update_vca_display () string label; for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) { - if (_vca->gain_control()->slaved_to ((*v)->gain_control())) { + if (_vca->slaved_to (*v)) { if (!label.empty()) { label += ' '; } @@ -173,6 +252,31 @@ VCAMasterStrip::name() const void VCAMasterStrip::hide_clicked () { + if (!delete_dialog) { + delete_dialog = new MessageDialog (_("Removing a Master will deassign all slaves. Remove it anyway?"), + true, MESSAGE_WARNING, BUTTONS_YES_NO, true); + delete_dialog->signal_response().connect (sigc::mem_fun (*this, &VCAMasterStrip::hide_confirmation)); + } + + delete_dialog->set_position (Gtk::WIN_POS_MOUSE); + delete_dialog->present (); +} + +void +VCAMasterStrip::hide_confirmation (int response) +{ + delete_dialog->hide (); + + switch (response) { + case RESPONSE_YES: + /* get everything to deassign. This will also delete ourselves (when + * idle) and that in turn will remove us from the Mixer GUI + */ + _session->vca_manager().remove_vca (_vca); + break; + default: + break; + } } bool @@ -237,10 +341,9 @@ VCAMasterStrip::set_solo_text () void VCAMasterStrip::mute_changed () { - std::cerr << "Mute changed for " << _vca->number() << std::endl; if (_vca->mute_control()->muted_by_self()) { mute_button.set_active_state (ExplicitActive); - } else if (_vca->mute_control()->muted_by_others()) { + } else if (_vca->mute_control()->muted_by_masters ()) { mute_button.set_active_state (ImplicitActive); } else { mute_button.set_active_state (Gtkmm2ext::Off); @@ -250,42 +353,39 @@ VCAMasterStrip::mute_changed () void VCAMasterStrip::solo_changed () { - if (_vca->solo_control()->soloed() || _vca->solo_control()->get_masters_value()) { + if (_vca->solo_control()->self_soloed()) { solo_button.set_active_state (ExplicitActive); + } else if (_vca->solo_control()->soloed_by_masters ()) { + solo_button.set_active_state (ImplicitActive); } else { solo_button.set_active_state (Gtkmm2ext::Off); } } void -VCAMasterStrip::vca_menu_toggle (CheckMenuItem* menuitem, uint32_t n) +VCAMasterStrip::vca_menu_toggle (Gtk::CheckMenuItem* menuitem, uint32_t n) { boost::shared_ptr vca = _session->vca_manager().vca_by_number (n); if (!menuitem->get_active()) { if (!vca) { /* null VCA means drop all VCA assignments */ - vca_unassign (); + _vca->unassign (boost::shared_ptr()); + } else { - _vca->gain_control()->remove_master (vca->gain_control()); - _vca->solo_control()->remove_master (vca->solo_control()); - _vca->mute_control()->remove_master (vca->mute_control()); + _vca->unassign (vca); } } else { if (vca) { - _vca->gain_control()->add_master (vca->gain_control()); - _vca->mute_control()->add_master (vca->mute_control()); - _vca->solo_control()->add_master (vca->solo_control()); + _vca->assign (vca); } } } void -VCAMasterStrip::vca_unassign () +VCAMasterStrip::unassign () { - _vca->gain_control()->clear_masters (); - _vca->solo_control()->clear_masters (); - _vca->mute_control()->clear_masters (); + _vca->unassign (boost::shared_ptr()); } bool @@ -313,7 +413,7 @@ VCAMasterStrip::vca_button_release (GdkEventButton* ev) Menu* menu = new Menu; MenuList& items = menu->items(); - items.push_back (MenuElem (_("Unassign"), sigc::mem_fun (*this, &VCAMasterStrip::vca_unassign))); + items.push_back (MenuElem (_("Unassign"), sigc::mem_fun (*this, &VCAMasterStrip::unassign))); for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) { @@ -323,7 +423,7 @@ VCAMasterStrip::vca_button_release (GdkEventButton* ev) } items.push_back (CheckMenuElem ((*v)->name())); - CheckMenuItem* item = dynamic_cast (&items.back()); + Gtk::CheckMenuItem* item = dynamic_cast (&items.back()); if (_vca->gain_control()->slaved_to ((*v)->gain_control())) { item->set_active (true); } @@ -336,13 +436,10 @@ VCAMasterStrip::vca_button_release (GdkEventButton* ev) } bool -VCAMasterStrip::name_button_press (GdkEventButton* ev) +VCAMasterStrip::vertical_button_press (GdkEventButton* ev) { if (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) { - Gtk::Window* win = dynamic_cast(get_toplevel()); - FloatingTextEntry* fte = new FloatingTextEntry (win, _vca->name()); - fte->use_text.connect (sigc::mem_fun (*this, &VCAMasterStrip::finish_name_edit)); - fte->present (); + start_name_edit (); return true; } @@ -354,11 +451,24 @@ VCAMasterStrip::name_button_press (GdkEventButton* ev) return true; } - return false; + if (ev->button == 1) { + spill (); + } + + return true; } void -VCAMasterStrip::finish_name_edit (std::string str) +VCAMasterStrip::start_name_edit () +{ + Gtk::Window* win = dynamic_cast(get_toplevel()); + FloatingTextEntry* fte = new FloatingTextEntry (win, _vca->name()); + fte->use_text.connect (sigc::mem_fun (*this, &VCAMasterStrip::finish_name_edit)); + fte->present (); +} + +void +VCAMasterStrip::finish_name_edit (std::string str, int) { _vca->set_name (str); } @@ -374,7 +484,8 @@ VCAMasterStrip::vca_property_changed (PropertyChange const & what_changed) void VCAMasterStrip::update_vca_name () { - name_button.set_text (short_version (_vca->name(), 8)); + /* 20 is a rough guess at the number of letters we can fit. */ + vertical_button.set_text (short_version (_vca->name(), 20)); } void @@ -383,5 +494,57 @@ VCAMasterStrip::build_context_menu () using namespace Gtk::Menu_Helpers; context_menu = new Menu; MenuList& items = context_menu->items(); - items.push_back (MenuElem (_("Remove"))); + items.push_back (MenuElem (_("Rename"), sigc::mem_fun (*this, &VCAMasterStrip::start_name_edit))); + items.push_back (SeparatorElem()); + items.push_back (MenuElem (_("Drop All Slaves"), sigc::mem_fun (*this, &VCAMasterStrip::drop_all_slaves))); + items.push_back (SeparatorElem()); + items.push_back (MenuElem (_("Remove"), sigc::mem_fun (*this, &VCAMasterStrip::remove))); +} + +void +VCAMasterStrip::spill () +{ + if (Mixer_UI::instance()->showing_vca_slaves_for (_vca)) { + Mixer_UI::instance()->show_vca_slaves (boost::shared_ptr()); + } else { + Mixer_UI::instance()->show_vca_slaves (_vca); + } +} + +void +VCAMasterStrip::spill_change (boost::shared_ptr vca) +{ + if (vca != _vca) { + vertical_button.set_active_state (Gtkmm2ext::Off); + set_tooltip (vertical_button, _("Click to show slaves only")); + } else { + vertical_button.set_active_state (Gtkmm2ext::ExplicitActive); + set_tooltip (vertical_button, _("Click to show normal mixer")); + } +} + +void +VCAMasterStrip::remove () +{ + if (!_session) { + return; + } + + _session->vca_manager().remove_vca (_vca); +} + +void +VCAMasterStrip::drop_all_slaves () +{ + _vca->Drop (); /* EMIT SIGNAL */ + + if (Mixer_UI::instance()->showing_vca_slaves_for (_vca)) { + Mixer_UI::instance()->show_vca_slaves (boost::shared_ptr()); + } +} + +void +VCAMasterStrip::drop_button_press () +{ + drop_all_slaves (); }