diff options
author | Julien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr> | 2017-08-29 11:25:38 +0200 |
---|---|---|
committer | Julien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr> | 2017-08-29 12:06:33 +0200 |
commit | 1b561446b8c4c0f1b682ec04cb44c5f53672c5fc (patch) | |
tree | 5f31144d12faebf275468b4b43ce7d88b3ff2f83 | |
parent | d4c211ef6fd7ea823963f003ec18b22c4ea39582 (diff) |
GenericUI: rationalize Autostate button sizing
When there was a knobtable in the ControlUI, the behavior of the
automation state button changed by displaying one-char state as in track
headers. Factor out that logic to depend on a new boolean property of
the ControlUI, which should be set with set_short_autostate().
This regroups sizing logic in a single place and avoids future
discrepancies between the actual caption and the size allocated for it,
when several use-cases for smaller buttons are added.
-rw-r--r-- | gtk2_ardour/generic_pluginui.cc | 27 | ||||
-rw-r--r-- | gtk2_ardour/plugin_ui.h | 5 |
2 files changed, 23 insertions, 9 deletions
diff --git a/gtk2_ardour/generic_pluginui.cc b/gtk2_ardour/generic_pluginui.cc index 2578a39184..01984376b1 100644 --- a/gtk2_ardour/generic_pluginui.cc +++ b/gtk2_ardour/generic_pluginui.cc @@ -573,13 +573,6 @@ GenericPluginUI::ControlUI::ControlUI (const Evoral::Parameter& p) 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 - as the longest automation label (see ::automation_state_changed() - below). be sure to include a descender. - */ - - automate_button.set_sizing_text(_("Mgnual")); - ignore_change = false; update_pending = false; button = false; @@ -596,6 +589,21 @@ GenericPluginUI::ControlUI::~ControlUI() } void +GenericPluginUI::set_short_autostate (ControlUI* cui, bool value) +{ + cui->short_autostate = value; + if (value) { + cui->automate_button.set_sizing_text("M"); + } else { + /* XXX translators: use a string here that will be at least as long + as the longest automation label (see ::automation_state_changed() + below). be sure to include a descender. */ + cui->automate_button.set_sizing_text(_("Mgnual")); + } + automation_state_changed(cui); +} + +void GenericPluginUI::automation_state_changed (ControlUI* cui) { /* update button label */ @@ -607,7 +615,7 @@ GenericPluginUI::automation_state_changed (ControlUI* cui) cui->automate_button.set_active((state != ARDOUR::Off)); - if (cui->knobtable) { + if (cui->short_autostate) { cui->automate_button.set_text ( GainMeterBase::astate_string (state)); return; @@ -678,6 +686,7 @@ GenericPluginUI::build_control_ui (const Evoral::Parameter& param, control_ui->label.set_alignment (0.0, 0.5); control_ui->label.set_name ("PluginParameterLabel"); control_ui->set_spacing (5); + set_short_autostate(control_ui, false); if (is_input) { @@ -797,7 +806,7 @@ GenericPluginUI::build_control_ui (const Evoral::Parameter& param, } if (use_knob) { - control_ui->automate_button.set_sizing_text("M"); + set_short_autostate(control_ui, true); control_ui->label.set_alignment (0.5, 0.5); control_ui->knobtable = manage (new Table()); diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h index 4075c94eb7..3b374298ac 100644 --- a/gtk2_ardour/plugin_ui.h +++ b/gtk2_ardour/plugin_ui.h @@ -237,6 +237,7 @@ private: bool update_pending; bool ignore_change; + /* output */ Gtk::EventBox* display; @@ -252,8 +253,12 @@ private: /* layout */ Gtk::Table* knobtable; int x0, x1, y0, y1; + + bool short_autostate; // modify with set_short_autostate below }; + void set_short_autostate(ControlUI* cui, bool value); + std::vector<ControlUI*> input_controls; // workaround for preset load std::vector<ControlUI*> input_controls_with_automation; std::vector<ControlUI*> output_controls; |