Do not constrain vertical size without need
[ardour.git] / gtk2_ardour / generic_pluginui.cc
index d8ce68e4b4d85ac94496b91e4aa662ebdeb88eaf..f7b30e2d18a5b8877007f99c7424df243302c170 100644 (file)
@@ -87,6 +87,7 @@ GenericPluginUI::GenericPluginUI (boost::shared_ptr<PluginInsert> pi, bool scrol
        set_latency_label ();
 
        smaller_hbox->pack_start (latency_button, false, false, 4);
+       smaller_hbox->pack_start (pin_management_button, false, false, 4);
        smaller_hbox->pack_start (_preset_combo, false, false);
        smaller_hbox->pack_start (_preset_modified, false, false);
        smaller_hbox->pack_start (add_button, false, false);
@@ -315,6 +316,9 @@ GenericPluginUI::build ()
        automation_play_all_button.signal_clicked.connect(sigc::bind (sigc::mem_fun (*this, &GenericPluginUI::set_all_automation), ARDOUR::Play));
        automation_write_all_button.signal_clicked.connect(sigc::bind (sigc::mem_fun (*this, &GenericPluginUI::set_all_automation), ARDOUR::Write));
        automation_touch_all_button.signal_clicked.connect(sigc::bind (sigc::mem_fun (*this, &GenericPluginUI::set_all_automation), ARDOUR::Touch));
+
+       /* XXX This is a workaround for AutomationControl not knowing about preset loads */
+       plugin->PresetLoaded.connect (*this, invalidator (*this), boost::bind (&GenericPluginUI::update_input_displays, this), gui_context ());
 }
 
 
@@ -551,7 +555,7 @@ GenericPluginUI::ControlUI::ControlUI (const Evoral::Parameter& p)
        , meterinfo (0)
        , knobtable (0)
 {
-       automate_button.set_name ("PluginAutomateButton");
+       automate_button.set_name ("plugin automation state button");
        set_tooltip (automate_button, _("Automation control"));
 
        /* XXX translators: use a string here that will be at least as long
@@ -559,7 +563,7 @@ GenericPluginUI::ControlUI::ControlUI (const Evoral::Parameter& p)
           below). be sure to include a descender.
        */
 
-       set_size_request_to_display_given_text (automate_button, _("Mgnual"), 12, 6);
+       automate_button.set_sizing_text(_("Mgnual"));
 
        ignore_change = false;
        update_pending = false;
@@ -584,15 +588,17 @@ GenericPluginUI::automation_state_changed (ControlUI* cui)
        // don't lock to avoid deadlock because we're triggered by
        // AutomationControl::Changed() while the automation lock is taken
 
+       AutoState state = insert->get_parameter_automation_state (cui->parameter());
+
+       cui->automate_button.set_active((state != ARDOUR::Off));
+
        if (cui->knobtable) {
                cui->automate_button.set_text (
-                               GainMeterBase::astate_string (
-                                       insert->get_parameter_automation_state (cui->parameter()))
-                               );
+                               GainMeterBase::astate_string (state));
                return;
        }
 
-       switch (insert->get_parameter_automation_state (cui->parameter()) & (ARDOUR::Off|Play|Touch|Write)) {
+       switch (state & (ARDOUR::Off|Play|Touch|Write)) {
        case ARDOUR::Off:
                cui->automate_button.set_text (S_("Automation|Manual"));
                break;
@@ -754,11 +760,13 @@ GenericPluginUI::build_control_ui (const Evoral::Parameter&             param,
                                        control_ui->clickbox->set_printer (sigc::bind (sigc::mem_fun (*this, &GenericPluginUI::integer_printer), control_ui));
                                }
                        } else if (desc.toggled) {
-                               control_ui->controller->set_size_request (req.height, req.height);
+                               ArdourButton* but = dynamic_cast<ArdourButton*> (control_ui->controller->widget());
+                               assert(but);
+                               but->set_tweaks(ArdourButton::Square);
                        } else if (use_knob) {
                                control_ui->controller->set_size_request (req.height * 1.5, req.height * 1.5);
                        } else {
-                               control_ui->controller->set_size_request (200, req.height);
+                               control_ui->controller->set_size_request (200, -1);
                                control_ui->controller->set_name (X_("ProcessorControlSlider"));
                        }
 
@@ -771,7 +779,7 @@ GenericPluginUI::build_control_ui (const Evoral::Parameter&             param,
                }
 
                if (use_knob) {
-                       set_size_request_to_display_given_text (control_ui->automate_button, "M", 2, 2);
+                       control_ui->automate_button.set_sizing_text("M");
 
                        control_ui->label.set_alignment (0.5, 0.5);
                        control_ui->knobtable = manage (new Table());
@@ -826,9 +834,10 @@ GenericPluginUI::build_control_ui (const Evoral::Parameter&             param,
                        control_ui->automate_button.set_sensitive (false);
                        set_tooltip(control_ui->automate_button, _("This control cannot be automated"));
                } else {
-                       control_ui->automate_button.signal_clicked.connect (sigc::bind (
-                                               sigc::mem_fun(*this, &GenericPluginUI::astate_clicked),
-                                               control_ui));
+                       control_ui->automate_button.signal_button_press_event().connect (
+                                       sigc::bind (sigc::mem_fun(*this, &GenericPluginUI::astate_button_event),
+                                                   control_ui),
+                                       false);
                        mcontrol->alist()->automation_state_changed.connect (
                                        control_connections,
                                        invalidator (*this),
@@ -847,6 +856,8 @@ GenericPluginUI::build_control_ui (const Evoral::Parameter&             param,
 
                automation_state_changed (control_ui);
 
+               /* Add to the list of CUIs that need manual update to workaround
+                * AutomationControl not knowing about preset loads */
                input_controls.push_back (control_ui);
 
        } else {
@@ -926,14 +937,19 @@ GenericPluginUI::build_control_ui (const Evoral::Parameter&             param,
        return control_ui;
 }
 
-void
-GenericPluginUI::astate_clicked (ControlUI* cui)
+bool
+GenericPluginUI::astate_button_event (GdkEventButton* ev, ControlUI* cui)
 {
+       if (ev->button != 1) {
+               return true;
+       }
+
        using namespace Menu_Helpers;
 
        if (automation_menu == 0) {
                automation_menu = manage (new Menu);
                automation_menu->set_name ("ArdourContextMenu");
+               automation_menu->set_reserve_toggle_size(false);
        }
 
        MenuList& items (automation_menu->items());
@@ -948,7 +964,10 @@ GenericPluginUI::astate_clicked (ControlUI* cui)
        items.push_back (MenuElem (_("Touch"),
                                   sigc::bind (sigc::mem_fun(*this, &GenericPluginUI::set_automation_state), (AutoState) Touch, cui)));
 
-       automation_menu->popup (1, gtk_get_current_event_time());
+       anchored_menu_popup(automation_menu, &cui->automate_button, cui->automate_button.get_text(),
+                           1, ev->time);
+
+       return true;
 }
 
 void
@@ -1013,6 +1032,18 @@ GenericPluginUI::update_control_display (ControlUI* cui)
        }*/
 }
 
+void
+GenericPluginUI::update_input_displays ()
+{
+       /* XXX This is a workaround for AutomationControl not knowing about preset loads */
+       for (vector<ControlUI*>::iterator i = input_controls.begin();
+            i != input_controls.end();
+            ++i) {
+               update_control_display(*i);
+       }
+       return;
+}
+
 void
 GenericPluginUI::control_combo_changed (ControlUI* cui, float value)
 {