manually fix up various cases where Gtk:Frame foo_frame had been changed to foo_sample
[ardour.git] / gtk2_ardour / vca_master_strip.cc
index aa8b93a3e9c1ec8661fef65aa817a7465884c50e..eacc1a0ecd3844c63f7497e9a1d698cfbe9bada6 100644 (file)
@@ -17,9 +17,8 @@
 */
 
 #include <gtkmm/stock.h>
-#include <gtkmm/colorselection.h>
 
-#include "pbd/convert.h"
+#include "pbd/string_convert.h"
 
 #include "ardour/rc_configuration.h"
 #include "ardour/session.h"
 
 #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 "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;
+using namespace ArdourWidgets;
 using namespace Gtkmm2ext;
 using namespace Gtk;
 using namespace PBD;
@@ -57,13 +56,10 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr<VCA> v)
        , delete_dialog (0)
        , control_slave_ui (s)
 {
-
-       PresentationInfo::color_t c = _vca->presentation_info().color ();
-
        /* 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()));
+               _vca->presentation_info().set_color (ARDOUR_UI_UTILS::gdk_color_to_rgba (unique_random_color()));
        }
 
        control_slave_ui.set_stripable (boost::dynamic_pointer_cast<Stripable> (v));
@@ -91,14 +87,19 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr<VCA> v)
        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);
 
-       bottom_padding.set_size_request (-1, 32); /* this one is a hack. there's no trivial way to compute it */
+       update_bottom_padding ();
 
        //Glib::RefPtr<Pango::Layout> layout = vertical_button.get_layout ();
        // layout->set_justify (JUSTIFY_CENTER);
@@ -110,21 +111,18 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr<VCA> v)
        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_border_width (0);
        global_vpacker.set_spacing (0);
+       gain_meter.set_spacing(4);
 
-       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 (control_slave_ui, false, false);
-       global_vpacker.pack_start (drop_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);
@@ -135,14 +133,13 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr<VCA> v)
        global_vpacker.show ();
        global_frame.show ();
        top_padding.show ();
-       bottom_padding.show ();
        vertical_button.show ();
        hide_button.show ();
        number_label.show ();
        gain_meter.show ();
        solo_mute_box.show_all ();
        control_slave_ui.show ();
-       drop_button.show ();
+       gain_meter.gain_automation_state_button.show ();
 
        /* force setting of visible selected status */
 
@@ -154,7 +151,7 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr<VCA> v)
        mute_changed ();
        spill_change (boost::shared_ptr<VCA>());
 
-       Mixer_UI::instance()->show_vca_change.connect (sigc::mem_fun (*this, &VCAMasterStrip::spill_change));
+       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());
@@ -171,9 +168,9 @@ VCAMasterStrip::VCAMasterStrip (Session* s, boost::shared_ptr<VCA> v)
 
 VCAMasterStrip::~VCAMasterStrip ()
 {
-       if ((_session && !_session->deletion_in_progress()) && Mixer_UI::instance()->showing_vca_slaves_for (_vca)) {
+       if ((_session && !_session->deletion_in_progress()) && Mixer_UI::instance()->showing_spill_for (_vca)) {
                /* cancel spill for this VCA */
-               Mixer_UI::instance()->show_vca_slaves (boost::shared_ptr<VCA>());
+               Mixer_UI::instance()->show_spill (boost::shared_ptr<Stripable>());
        }
 
        delete delete_dialog;
@@ -185,12 +182,16 @@ VCAMasterStrip::~VCAMasterStrip ()
 void
 VCAMasterStrip::self_delete ()
 {
-       if ((_session && !_session->deletion_in_progress()) && Mixer_UI::instance()->showing_vca_slaves_for (_vca)) {
+       if ((_session && !_session->deletion_in_progress()) && Mixer_UI::instance()->showing_spill_for (_vca)) {
                /* cancel spill for this VCA */
-               Mixer_UI::instance()->show_vca_slaves (boost::shared_ptr<VCA>());
+               Mixer_UI::instance()->show_spill (boost::shared_ptr<Stripable>());
        }
        /* Drop reference immediately, delete self when idle */
        _vca.reset ();
+       gain_meter.set_controls (boost::shared_ptr<Route>(),
+                                boost::shared_ptr<PeakMeter>(),
+                                boost::shared_ptr<Amp>(),
+                                boost::shared_ptr<GainControl>());
        delete_when_idle (this);
 }
 
@@ -199,6 +200,8 @@ VCAMasterStrip::parameter_changed (std::string const & p)
 {
        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 ();
        }
 }
 
@@ -222,6 +225,45 @@ VCAMasterStrip::set_button_names ()
        }
 }
 
+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 {
+               control_slave_ui.show ();
+       }
+
+       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
 VCAMasterStrip::name() const
 {
@@ -231,14 +273,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
@@ -364,6 +399,19 @@ VCAMasterStrip::vertical_button_press (GdkEventButton* ev)
        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::start_name_edit ()
 {
@@ -388,6 +436,11 @@ VCAMasterStrip::vca_property_changed (PropertyChange const & what_changed)
 
        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 ());
+       }
+
+       if (what_changed.contains (ARDOUR::Properties::hidden)) {
+
        }
 }
 
@@ -395,7 +448,7 @@ 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->name(), 20));
+       vertical_button.set_text (short_version (_vca->full_name(), 20));
 }
 
 void
@@ -407,6 +460,9 @@ VCAMasterStrip::build_context_menu ()
        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)));
@@ -415,15 +471,15 @@ VCAMasterStrip::build_context_menu ()
 void
 VCAMasterStrip::spill ()
 {
-       if (Mixer_UI::instance()->showing_vca_slaves_for (_vca)) {
-               Mixer_UI::instance()->show_vca_slaves (boost::shared_ptr<VCA>());
+       if (Mixer_UI::instance()->showing_spill_for (_vca)) {
+               Mixer_UI::instance()->show_spill (boost::shared_ptr<Stripable>());
        } else {
-               Mixer_UI::instance()->show_vca_slaves (_vca);
+               Mixer_UI::instance()->show_spill (_vca);
        }
 }
 
 void
-VCAMasterStrip::spill_change (boost::shared_ptr<VCA> vca)
+VCAMasterStrip::spill_change (boost::shared_ptr<Stripable> vca)
 {
        if (vca != _vca) {
                vertical_button.set_active_state (Gtkmm2ext::Off);
@@ -445,25 +501,31 @@ VCAMasterStrip::remove ()
 }
 
 void
-VCAMasterStrip::drop_all_slaves ()
+VCAMasterStrip::assign_all_selected ()
 {
-       _vca->Drop (); /* EMIT SIGNAL */
+       Mixer_UI::instance()->do_vca_assign (_vca);
+}
 
-       if (Mixer_UI::instance()->showing_vca_slaves_for (_vca)) {
-               Mixer_UI::instance()->show_vca_slaves (boost::shared_ptr<VCA>());
-       }
+void
+VCAMasterStrip::unassign_all_selected ()
+{
+       Mixer_UI::instance()->do_vca_unassign (_vca);
 }
 
 void
-VCAMasterStrip::drop_button_press ()
+VCAMasterStrip::drop_all_slaves ()
 {
-       drop_all_slaves ();
+       _vca->Drop (); /* EMIT SIGNAL */
+
+       if (Mixer_UI::instance()->showing_spill_for (_vca)) {
+               Mixer_UI::instance()->show_spill (boost::shared_ptr<Stripable>());
+       }
 }
 
 Gdk::Color
 VCAMasterStrip::color () const
 {
-       return gdk_color_from_rgba (_vca->presentation_info().color ());
+       return ARDOUR_UI_UTILS::gdk_color_from_rgba (_vca->presentation_info().color ());
 }
 
 string
@@ -475,30 +537,7 @@ VCAMasterStrip::state_id () const
 void
 VCAMasterStrip::start_color_edit ()
 {
-       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 ();
-}
-
-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);
+       _color_picker.popup (_vca);
 }
 
 bool
@@ -516,3 +555,15 @@ VCAMasterStrip::set_marked_for_display (bool yn)
        }
        return false;
 }
+
+PresentationInfo const &
+VCAMasterStrip::presentation_info () const
+{
+       return _vca->presentation_info();
+}
+
+boost::shared_ptr<Stripable>
+VCAMasterStrip::stripable () const
+{
+       return _vca;
+}