summaryrefslogtreecommitdiff
path: root/gtk2_ardour/generic_pluginui.cc
diff options
context:
space:
mode:
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>2016-08-20 18:12:49 +0200
committerJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>2016-08-20 18:12:49 +0200
commitfcadcac7e7c6959c0306bfadaf21ded20a2ea5ea (patch)
tree637b8672e0037aebd8b82a04f7331cc19d0deec4 /gtk2_ardour/generic_pluginui.cc
parentaed07c49987b497c225944059f4da72ab64a4cff (diff)
Make knobs size requests dynamic
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.
Diffstat (limited to 'gtk2_ardour/generic_pluginui.cc')
-rw-r--r--gtk2_ardour/generic_pluginui.cc15
1 files changed, 12 insertions, 3 deletions
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)
{