diff options
Diffstat (limited to 'src/ui/widget')
| -rw-r--r-- | src/ui/widget/scalar-unit.cpp | 22 | ||||
| -rw-r--r-- | src/ui/widget/scalar-unit.h | 3 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/ui/widget/scalar-unit.cpp b/src/ui/widget/scalar-unit.cpp index e00e82198..533f0a200 100644 --- a/src/ui/widget/scalar-unit.cpp +++ b/src/ui/widget/scalar-unit.cpp @@ -118,6 +118,19 @@ ScalarUnit::setValue(double number, Glib::ustring const &units) { Scalar::setValue(number); } +/** Convert and sets the number only and keeps the current unit. */ +void +ScalarUnit::setValueKeepUnit(double number, Glib::ustring const &units) { + g_assert(_unit_menu != NULL); + if (units == "") { + // set the value in the default units + Scalar::setValue(number); + } else { + double conversion = _unit_menu->getConversion(units); + Scalar::setValue(number / conversion); + } +} + /** Sets the number only */ void ScalarUnit::setValue(double number) { @@ -137,6 +150,15 @@ ScalarUnit::getValue(Glib::ustring const &unit_name) const { } } +/** Grab focus, and select the text that is in the entry field. + */ +void +ScalarUnit::grabFocusAndSelectEntry() { + _widget->grab_focus(); + static_cast<SpinButton*>(_widget)->select_region(0, 20); +} + + void ScalarUnit::setHundredPercent(double number) { diff --git a/src/ui/widget/scalar-unit.h b/src/ui/widget/scalar-unit.h index d8b2edbd5..8f6c8e210 100644 --- a/src/ui/widget/scalar-unit.h +++ b/src/ui/widget/scalar-unit.h @@ -41,8 +41,11 @@ public: bool setUnit(Glib::ustring const &units); void setValue(double number, Glib::ustring const &units); + void setValueKeepUnit(double number, Glib::ustring const &units); void setValue(double number); + void grabFocusAndSelectEntry(); + void setHundredPercent(double number); void setAbsoluteIsIncrement(bool value); void setPercentageIsIncrement(bool value); |
