From fcadcac7e7c6959c0306bfadaf21ded20a2ea5ea Mon Sep 17 00:00:00 2001 From: "Julien \"_FrnchFrgg_\" RIVAUD" Date: Sat, 20 Aug 2016 18:12:49 +0200 Subject: Make knobs size requests dynamic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At the point of creation, the automate_button size request is wrong since it has not the correct style yet. Instead of trying ugly hacks to fix that, connect to the knob's size_request signal and get the button's requisition only when needed. If the system font changes to one that has different extents (even if the point size is the same), the UI will thus correctly update. --- gtk2_ardour/generic_pluginui.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'gtk2_ardour/generic_pluginui.cc') diff --git a/gtk2_ardour/generic_pluginui.cc b/gtk2_ardour/generic_pluginui.cc index f7b30e2d18..14d05df344 100644 --- a/gtk2_ardour/generic_pluginui.cc +++ b/gtk2_ardour/generic_pluginui.cc @@ -664,8 +664,6 @@ GenericPluginUI::build_control_ui (const Evoral::Parameter& param, control_ui->label.set_name ("PluginParameterLabel"); control_ui->set_spacing (5); - Gtk::Requisition req (control_ui->automate_button.size_request()); - if (is_input) { if (desc.datatype == Variant::PATH) { @@ -764,7 +762,9 @@ GenericPluginUI::build_control_ui (const Evoral::Parameter& param, 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); + /* Delay size request so that styles are gotten right */ + control_ui->controller->widget()->signal_size_request().connect( + sigc::bind (sigc::mem_fun (*this, &GenericPluginUI::knob_size_request), control_ui)); } else { control_ui->controller->set_size_request (200, -1); control_ui->controller->set_name (X_("ProcessorControlSlider")); @@ -937,6 +937,15 @@ GenericPluginUI::build_control_ui (const Evoral::Parameter& param, return control_ui; } +void +GenericPluginUI::knob_size_request(Gtk::Requisition* req, ControlUI* cui) { + Gtk::Requisition astate_req (cui->automate_button.size_request()); + const int size = (int) (astate_req.height * 1.5); + req->width = max(req->width, size); + req->height = max(req->height, size); +} + + bool GenericPluginUI::astate_button_event (GdkEventButton* ev, ControlUI* cui) { -- cgit v1.2.3