X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fvca_master_strip.cc;h=8363f6d67d27b12aba3c03fec01d69d165673fa9;hb=cf52d6e4b40111eb04b244ec054055a4ec15dbe0;hp=4c4d7398591fd022bdf7434bb847663d898a292c;hpb=56c831199ecb9a2ef3c37f5391a34bd98e93f533;p=ardour.git diff --git a/gtk2_ardour/vca_master_strip.cc b/gtk2_ardour/vca_master_strip.cc index 4c4d739859..8363f6d67d 100644 --- a/gtk2_ardour/vca_master_strip.cc +++ b/gtk2_ardour/vca_master_strip.cc @@ -17,6 +17,7 @@ */ #include +#include #include "pbd/convert.h" @@ -34,9 +35,10 @@ #include "mixer_ui.h" #include "tooltips.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; @@ -50,10 +52,19 @@ PBD::Signal1 VCAMasterStrip::CatchDeletion; VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr v) : 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 (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(), @@ -71,15 +82,8 @@ 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); @@ -91,8 +95,7 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr v) number_label.set_alignment (.5, .5); number_label.set_fallthrough_to_parent (true); - top_padding.set_size_request (-1, 16); /* must match height in GroupTabs::set_size_request() */ - bottom_padding.set_size_request (-1, 30); /* this one is a hack. there's no trivial way to compute it */ + bottom_padding.set_size_request (-1, 55); /* 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); @@ -101,22 +104,18 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr v) 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 */ - 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 (number_label, false, false); + global_vpacker.pack_start (hide_button, false, false); 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, 2); - global_vpacker.pack_start (assign_button, false, false); - global_vpacker.pack_start (drop_button, false, false); + global_vpacker.pack_start (control_slave_ui, false, false); global_vpacker.pack_start (bottom_padding, false, false); global_frame.add (global_vpacker); @@ -132,18 +131,15 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr v) vertical_button.show (); hide_button.show (); number_label.show (); - width_hide_box.show (); gain_meter.show (); solo_mute_box.show_all (); - assign_button.show (); - drop_button.show (); + control_slave_ui.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 (); @@ -152,19 +148,12 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr v) 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()); + _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()); @@ -224,31 +213,6 @@ VCAMasterStrip::set_button_names () } } -void -VCAMasterStrip::update_vca_display () -{ - VCAList vcas (_session->vca_manager().vcas()); - string label; - - for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) { - if (_vca->slaved_to (*v)) { - if (!label.empty()) { - label += ' '; - } - label += to_string ((*v)->number(), std::dec); - } - } - - if (label.empty()) { - label = _("-vca-"); - assign_button.set_active_state (Gtkmm2ext::Off); - } else { - assign_button.set_active_state (Gtkmm2ext::ExplicitActive); - } - - assign_button.set_text (label); -} - string VCAMasterStrip::name() const { @@ -258,14 +222,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 @@ -368,79 +325,6 @@ VCAMasterStrip::solo_changed () } } -void -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 (boost::shared_ptr()); - - } else { - _vca->unassign (vca); - } - } else { - if (vca) { - _vca->assign (vca); - } - } -} - -void -VCAMasterStrip::unassign () -{ - _vca->unassign (boost::shared_ptr()); -} - -bool -VCAMasterStrip::vca_button_release (GdkEventButton* ev) -{ - using namespace Gtk::Menu_Helpers; - - if (!_session) { - return false; - } - - /* primary click only */ - - if (ev->button != 1) { - return false; - } - - VCAList vcas (_session->vca_manager().vcas()); - - if (vcas.empty()) { - /* XXX should probably show a message saying "No VCA masters" */ - return true; - } - - Menu* menu = new Menu; - MenuList& items = menu->items(); - - items.push_back (MenuElem (_("Unassign"), sigc::mem_fun (*this, &VCAMasterStrip::unassign))); - - for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) { - - if (*v == _vca) { - /* no self-mastering */ - continue; - } - - items.push_back (CheckMenuElem ((*v)->name())); - Gtk::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())); - } - - menu->popup (1, ev->time); - - return true; -} - bool VCAMasterStrip::vertical_button_press (GdkEventButton* ev) { @@ -485,6 +369,14 @@ VCAMasterStrip::vca_property_changed (PropertyChange const & what_changed) if (what_changed.contains (ARDOUR::Properties::name)) { update_vca_name (); } + + if (what_changed.contains (ARDOUR::Properties::color)) { + vertical_button.set_active_color (_vca->presentation_info().color ()); + } + + if (what_changed.contains (ARDOUR::Properties::hidden)) { + + } } void @@ -501,6 +393,7 @@ VCAMasterStrip::build_context_menu () 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 (_("Drop All Slaves"), sigc::mem_fun (*this, &VCAMasterStrip::drop_all_slaves))); items.push_back (SeparatorElem()); @@ -549,14 +442,71 @@ VCAMasterStrip::drop_all_slaves () } } +Gdk::Color +VCAMasterStrip::color () const +{ + return gdk_color_from_rgba (_vca->presentation_info().color ()); +} + +string +VCAMasterStrip::state_id () const +{ + return string_compose (X_("vms-%1"), _vca->number()); +} + void -VCAMasterStrip::drop_button_press () +VCAMasterStrip::start_color_edit () { - drop_all_slaves (); + Gtk::ColorSelectionDialog* color_dialog = new Gtk::ColorSelectionDialog; + + color_dialog->get_colorsel()->set_has_opacity_control (false); + color_dialog->get_colorsel()->set_has_palette (true); + + Gdk::Color c = gdk_color_from_rgba (_vca->presentation_info().color ()); + + color_dialog->get_colorsel()->set_previous_color (c); + color_dialog->get_colorsel()->set_current_color (c); + + color_dialog->signal_response().connect (sigc::bind (sigc::mem_fun (*this, &VCAMasterStrip::finish_color_edit), color_dialog)); + color_dialog->present (); } -Gdk::Color -VCAMasterStrip::color () const +void +VCAMasterStrip::finish_color_edit (int response, Gtk::ColorSelectionDialog* dialog) +{ + switch (response) { + case RESPONSE_OK: + _vca->presentation_info().set_color (gdk_color_to_rgba (dialog->get_colorsel()->get_current_color())); + break; + } + + delete_when_idle (dialog); +} + +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; +} + +PresentationInfo const & +VCAMasterStrip::presentation_info () const +{ + return _vca->presentation_info(); +} + +boost::shared_ptr +VCAMasterStrip::stripable () const { - return gdk_color_from_rgb (_vca->presentation_info().color ()); + return _vca; }