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.
This commit is contained in:
Julien "_FrnchFrgg_" RIVAUD 2016-08-20 18:12:49 +02:00
parent aed07c4998
commit fcadcac7e7
2 changed files with 14 additions and 3 deletions

View File

@ -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)
{

View File

@ -292,6 +292,8 @@ class GenericPluginUI : public PlugUIBase, public Gtk::VBox
void set_automation_state (ARDOUR::AutoState state, ControlUI* cui);
void set_all_automation (ARDOUR::AutoState state);
void knob_size_request(Gtk::Requisition* req, ControlUI* cui);
/* XXX: remove */
void print_parameter (char *buf, uint32_t len, uint32_t param);
bool integer_printer (char* buf, Gtk::Adjustment &, ControlUI *);