X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fvca_master_strip.cc;h=297ee32fd4f540e410dae2eb201e5bca59a4c792;hb=154f9825ff72d691ba550de573948424b81a09a6;hp=7468b1b0d4ded99d9ea9ffdd318249d62e8e4619;hpb=2886b9659b21ffa95c96cad71390842a34804507;p=ardour.git diff --git a/gtk2_ardour/vca_master_strip.cc b/gtk2_ardour/vca_master_strip.cc index 7468b1b0d4..297ee32fd4 100644 --- a/gtk2_ardour/vca_master_strip.cc +++ b/gtk2_ardour/vca_master_strip.cc @@ -18,7 +18,7 @@ #include -#include "pbd/convert.h" +#include "pbd/string_convert.h" #include "ardour/rc_configuration.h" #include "ardour/session.h" @@ -27,17 +27,20 @@ #include "gtkmm2ext/doi.h" #include "gtkmm2ext/keyboard.h" +#include "widgets/tooltips.h" #include "ardour_dialog.h" #include "floating_text_entry.h" #include "gui_thread.h" -#include "tooltips.h" +#include "mixer_ui.h" +#include "ui_config.h" +#include "utils.h" #include "vca_master_strip.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace ARDOUR; -using namespace ARDOUR_UI_UTILS; +using namespace ArdourWidgets; using namespace Gtkmm2ext; using namespace Gtk; using namespace PBD; @@ -45,37 +48,22 @@ using std::string; PBD::Signal1 VCAMasterStrip::CatchDeletion; -static string -verticalize (string const & str) -{ - return str; -#if 0 - string ret; - string::const_iterator s = str.begin(); - ret = *s; - ret += '\n'; - ++s; - - while (s != str.end()) { - ret += *s; - ret += '\n'; - ++s; - } - - /* remove terminal newline */ - - ret.erase (ret.length() - 1, string::npos); - return ret; -#endif -} - VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr v) - : AxisView (s) + : SessionHandlePtr (s) , _vca (v) - , gain_meter (s, 250) + , gain_meter (s, 254) /* magic number, don't adjust blindly */ , context_menu (0) , delete_dialog (0) + , control_slave_ui (s) { + /* set color for the VCA, if not already done. */ + + if (!_vca->presentation_info().color_set()) { + _vca->presentation_info().set_color (ARDOUR_UI_UTILS::gdk_color_to_rgba (unique_random_color())); + } + + control_slave_ui.set_stripable (boost::dynamic_pointer_cast (v)); + gain_meter.set_controls (boost::shared_ptr(), boost::shared_ptr(), boost::shared_ptr(), @@ -93,53 +81,48 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr v) hide_button.set_icon (ArdourIcon::CloseCross); set_tooltip (&hide_button, _("Hide this VCA strip")); - assign_button.set_name (X_("vca assign")); - set_tooltip (assign_button, _("Click to assign a VCA Master to this VCA")); - assign_button.signal_button_release_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::vca_button_release), false); - hide_button.signal_clicked.connect (sigc::mem_fun(*this, &VCAMasterStrip::hide_clicked)); - width_hide_box.pack_start (number_label, true, true); - width_hide_box.pack_end (hide_button, false, true); - solo_mute_box.set_spacing (2); solo_mute_box.pack_start (mute_button, true, true); solo_mute_box.pack_start (solo_button, true, true); - number_label.set_text (to_string (v->number(), std::dec)); + mute_button.set_controllable (_vca->mute_control()); + solo_button.set_controllable (_vca->solo_control()); + + number_label.set_text (PBD::to_string (v->number())); number_label.set_elements((ArdourButton::Element)(ArdourButton::Edge|ArdourButton::Body|ArdourButton::Text|ArdourButton::Inactive)); number_label.set_no_show_all (); number_label.set_name ("generic button"); number_label.set_alignment (.5, .5); number_label.set_fallthrough_to_parent (true); + number_label.set_inactive_color (_vca->presentation_info().color ()); + number_label.signal_button_release_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::number_button_press), false); - 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 */ + update_bottom_padding (); - vertical_label.set_justify (JUSTIFY_CENTER); + //Glib::RefPtr layout = vertical_button.get_layout (); + // layout->set_justify (JUSTIFY_CENTER); /* horizontally centered, with a little space (5%) at the top */ - vertical_label.set_alignment (0.5, 0.05); - vertical_label.set_name (X_("vca_vertical_box")); - vertical_label.set_angle (270); /* top to bottom */ - - vertical_box.add (vertical_label); - vertical_box.set_name (X_("vca_vertical_box")); - vertical_box.set_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK); - vertical_box.signal_button_press_event().connect (sigc::mem_fun (*this, &VCAMasterStrip::vertical_box_press), false); - - global_vpacker.set_border_width (1); + 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); + vertical_button.set_active_color (_vca->presentation_info().color ()); + set_tooltip (vertical_button, _("Click to show slaves only")); /* tooltip updated dynamically */ + + global_vpacker.set_border_width (0); global_vpacker.set_spacing (0); + gain_meter.set_spacing(4); - 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_box, true, true); - global_vpacker.pack_start (solo_mute_box, false, false); - global_vpacker.pack_start (gain_meter, false, false); - global_vpacker.pack_start (assign_button, false, false); - global_vpacker.pack_start (bottom_padding, false, false); + global_vpacker.pack_start (number_label, false, false, 1); + global_vpacker.pack_start (hide_button, false, false, 1); + global_vpacker.pack_start (vertical_button, true, true, 1); + global_vpacker.pack_start (solo_mute_box, false, false, 1); + global_vpacker.pack_start (gain_meter, false, false, 1); + global_vpacker.pack_start (control_slave_ui, false, false, 1); + global_vpacker.pack_start (gain_meter.gain_automation_state_button, false, false, 1); + global_vpacker.pack_start (bottom_padding, false, false, 0); global_frame.add (global_vpacker); global_frame.set_shadow_type (Gtk::SHADOW_IN); @@ -149,50 +132,46 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr v) global_vpacker.show (); global_frame.show (); - top_padding.show (); - bottom_padding.show (); - vertical_label.show (); - vertical_box.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 (); + control_slave_ui.show (); + gain_meter.gain_automation_state_button.show (); /* force setting of visible selected status */ _selected = true; set_selected (false); set_solo_text (); - update_vca_display (); update_vca_name (); solo_changed (); mute_changed (); + spill_change (boost::shared_ptr()); - /* this remains unchanged as the name changes */ - name_button.set_text (string_compose (X_("VCA %1"), _vca->number())); + Mixer_UI::instance()->show_spill_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()); + _vca->presentation_info().PropertyChanged.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::vca_property_changed, this, _1), gui_context()); + _vca->DropReferences.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::self_delete, this), gui_context()); _vca->solo_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::solo_changed, this), gui_context()); _vca->mute_control()->Changed.connect (vca_connections, invalidator (*this), boost::bind (&VCAMasterStrip::mute_changed, this), gui_context()); - /* only need to connect to one of these to update VCA status */ - - _vca->gain_control()->MasterStatusChange.connect (vca_connections, - 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_spill_for (_vca)) { + /* cancel spill for this VCA */ + Mixer_UI::instance()->show_spill (boost::shared_ptr()); + } + delete delete_dialog; delete context_menu; @@ -202,32 +181,86 @@ VCAMasterStrip::~VCAMasterStrip () void VCAMasterStrip::self_delete () { + if ((_session && !_session->deletion_in_progress()) && Mixer_UI::instance()->showing_spill_for (_vca)) { + /* cancel spill for this VCA */ + Mixer_UI::instance()->show_spill (boost::shared_ptr()); + } + /* Drop reference immediately, delete self when idle */ + _vca.reset (); + gain_meter.set_controls (boost::shared_ptr(), + boost::shared_ptr(), + boost::shared_ptr(), + boost::shared_ptr()); delete_when_idle (this); } void -VCAMasterStrip::update_vca_display () +VCAMasterStrip::parameter_changed (std::string const & p) { - VCAList vcas (_session->vca_manager().vcas()); - string label; + if (p == "use-monitor-bus" || p == "solo-control-is-listen-control" || p == "listen-position") { + set_button_names (); + } else if (p == "mixer-element-visibility") { + update_bottom_padding (); + } +} - for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) { - if (_vca->gain_control()->slaved_to ((*v)->gain_control())) { - if (!label.empty()) { - label += ' '; - } - label += to_string ((*v)->number(), std::dec); +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")); } +} - if (label.empty()) { - label = _("-vca-"); - assign_button.set_active_state (Gtkmm2ext::Off); +void +VCAMasterStrip::update_bottom_padding () +{ + std::string viz = UIConfiguration::instance().get_mixer_strip_visibility (); + + ArdourButton output_button (_("Output")); + ArdourButton comment_button (_("Comments")); + + output_button.set_name ("mixer strip button"); + comment_button.set_name ("generic button"); + + if (viz.find ("VCA") == std::string::npos) { + control_slave_ui.hide (); } else { - assign_button.set_active_state (Gtkmm2ext::ExplicitActive); + control_slave_ui.show (); } - assign_button.set_text (label); + int h = 0; + if (viz.find ("Output") != std::string::npos) { + Gtk::Window window (WINDOW_TOPLEVEL); + window.add (output_button); + Gtk::Requisition requisition(output_button.size_request ()); + h += requisition.height + 2; + } + if (viz.find ("Comments") != std::string::npos) { + Gtk::Window window (WINDOW_TOPLEVEL); + window.add (comment_button); + Gtk::Requisition requisition(comment_button.size_request ()); + h += requisition.height + 2; + } + if (h <= 0) { + bottom_padding.set_size_request (-1, 1); + bottom_padding.hide (); + } else { + bottom_padding.set_size_request (-1, h); + bottom_padding.show (); + } } string @@ -239,14 +272,7 @@ 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 (); + _vca->presentation_info().set_hidden (true); } void @@ -255,7 +281,7 @@ VCAMasterStrip::hide_confirmation (int response) delete_dialog->hide (); switch (response) { - case RESPONSE_OK: + 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 */ @@ -349,132 +375,194 @@ VCAMasterStrip::solo_changed () } } -void -VCAMasterStrip::vca_menu_toggle (CheckMenuItem* menuitem, uint32_t n) +bool +VCAMasterStrip::vertical_button_press (GdkEventButton* ev) { - 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 (boost::shared_ptr()); + if (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS) { + start_name_edit (); + return true; + } - } else { - _vca->unassign (vca); + if (Keyboard::is_context_menu_event (ev)) { + if (!context_menu) { + build_context_menu (); } - } else { - if (vca) { - _vca->assign (vca); + context_menu->popup (1, ev->time); + return true; + } + + if (ev->button == 1) { + spill (); + } + + return true; +} + +bool +VCAMasterStrip::number_button_press (GdkEventButton* ev) +{ + if (Keyboard::is_context_menu_event (ev)) { + if (!context_menu) { + build_context_menu (); } + context_menu->popup (1, ev->time); + return true; } + return false; } void -VCAMasterStrip::unassign () +VCAMasterStrip::start_name_edit () { - _vca->unassign (boost::shared_ptr()); + 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 (); } -bool -VCAMasterStrip::vca_button_release (GdkEventButton* ev) +void +VCAMasterStrip::finish_name_edit (std::string str, int) { - using namespace Gtk::Menu_Helpers; + _vca->set_name (str); +} - if (!_session) { - return false; +void +VCAMasterStrip::vca_property_changed (PropertyChange const & what_changed) +{ + if (what_changed.contains (ARDOUR::Properties::name)) { + update_vca_name (); } - /* primary click only */ - - if (ev->button != 1) { - return false; + if (what_changed.contains (ARDOUR::Properties::color)) { + vertical_button.set_active_color (_vca->presentation_info().color ()); + number_label.set_inactive_color (_vca->presentation_info().color ()); } - VCAList vcas (_session->vca_manager().vcas()); + if (what_changed.contains (ARDOUR::Properties::hidden)) { - if (vcas.empty()) { - /* XXX should probably show a message saying "No VCA masters" */ - return true; } +} - Menu* menu = new Menu; - MenuList& items = menu->items(); +void +VCAMasterStrip::update_vca_name () +{ + /* 20 is a rough guess at the number of letters we can fit. */ + vertical_button.set_text (short_version (_vca->full_name(), 20)); +} - items.push_back (MenuElem (_("Unassign"), sigc::mem_fun (*this, &VCAMasterStrip::unassign))); +void +VCAMasterStrip::build_context_menu () +{ + using namespace Gtk::Menu_Helpers; + context_menu = new Menu; + MenuList& items = context_menu->items(); + items.push_back (MenuElem (_("Rename"), sigc::mem_fun (*this, &VCAMasterStrip::start_name_edit))); + items.push_back (MenuElem (_("Color..."), sigc::mem_fun (*this, &VCAMasterStrip::start_color_edit))); + items.push_back (SeparatorElem()); + items.push_back (MenuElem (_("Assign Selected Channels"), sigc::mem_fun (*this, &VCAMasterStrip::assign_all_selected))); + items.push_back (MenuElem (_("Drop Selected Channels"), sigc::mem_fun (*this, &VCAMasterStrip::unassign_all_selected))); + 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))); +} - for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) { +void +VCAMasterStrip::spill () +{ + if (Mixer_UI::instance()->showing_spill_for (_vca)) { + Mixer_UI::instance()->show_spill (boost::shared_ptr()); + } else { + Mixer_UI::instance()->show_spill (_vca); + } +} - if (*v == _vca) { - /* no self-mastering */ - continue; - } +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")); + } +} - items.push_back (CheckMenuElem ((*v)->name())); - CheckMenuItem* item = dynamic_cast (&items.back()); - if (_vca->gain_control()->slaved_to ((*v)->gain_control())) { - item->set_active (true); - } - item->signal_activate().connect (sigc::bind (sigc::mem_fun (*this, &VCAMasterStrip::vca_menu_toggle), item, (*v)->number())); +void +VCAMasterStrip::remove () +{ + if (!_session) { + return; } - menu->popup (1, ev->time); + _session->vca_manager().remove_vca (_vca); +} - return true; +void +VCAMasterStrip::assign_all_selected () +{ + Mixer_UI::instance()->do_vca_assign (_vca); } -bool -VCAMasterStrip::vertical_box_press (GdkEventButton* ev) +void +VCAMasterStrip::unassign_all_selected () { - return name_button_press (ev); + Mixer_UI::instance()->do_vca_unassign (_vca); } -bool -VCAMasterStrip::name_button_press (GdkEventButton* ev) +void +VCAMasterStrip::drop_all_slaves () { - 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 (); - return true; - } + _vca->Drop (); /* EMIT SIGNAL */ - if (Keyboard::is_context_menu_event (ev)) { - if (!context_menu) { - build_context_menu (); - } - context_menu->popup (1, ev->time); - return true; + if (Mixer_UI::instance()->showing_spill_for (_vca)) { + Mixer_UI::instance()->show_spill (boost::shared_ptr()); } +} - return false; +Gdk::Color +VCAMasterStrip::color () const +{ + return ARDOUR_UI_UTILS::gdk_color_from_rgba (_vca->presentation_info().color ()); } -void -VCAMasterStrip::finish_name_edit (std::string str) +string +VCAMasterStrip::state_id () const { - _vca->set_name (str); + return string_compose (X_("vms-%1"), _vca->number()); } void -VCAMasterStrip::vca_property_changed (PropertyChange const & what_changed) +VCAMasterStrip::start_color_edit () { - if (what_changed.contains (ARDOUR::Properties::name)) { - update_vca_name (); + _color_picker.popup (_vca); +} + +bool +VCAMasterStrip::marked_for_display () const +{ + return !_vca->presentation_info().hidden(); +} + +bool +VCAMasterStrip::set_marked_for_display (bool yn) +{ + if (yn == _vca->presentation_info().hidden()) { + _vca->presentation_info().set_hidden (!yn); + return true; // things changed } + return false; } -void -VCAMasterStrip::update_vca_name () +PresentationInfo const & +VCAMasterStrip::presentation_info () const { - vertical_label.set_text (verticalize (short_version (_vca->name(), 15))); + return _vca->presentation_info(); } -void -VCAMasterStrip::build_context_menu () +boost::shared_ptr +VCAMasterStrip::stripable () const { - using namespace Gtk::Menu_Helpers; - context_menu = new Menu; - MenuList& items = context_menu->items(); - items.push_back (MenuElem (_("Remove"))); + return _vca; }