diff options
| author | Matthew Petroff <matthew@mpetroff.net> | 2013-09-15 23:07:21 +0000 |
|---|---|---|
| committer | Matthew Petroff <matthew@mpetroff.net> | 2013-09-15 23:07:21 +0000 |
| commit | 5614df9770b985070122b3c08b45902317c9bd15 (patch) | |
| tree | eca7301deb23560b176f293c0c831ee41180328f /src/ui | |
| parent | Improved code readability. (diff) | |
| download | inkscape-5614df9770b985070122b3c08b45902317c9bd15.tar.gz inkscape-5614df9770b985070122b3c08b45902317c9bd15.zip | |
Enable unit evaluation in toolbars.
(bzr r12475.1.22)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/widget/spinbutton.cpp | 10 | ||||
| -rw-r--r-- | src/ui/widget/spinbutton.h | 5 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index c107979a8..2c95e8b5a 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -14,6 +14,7 @@ #include "spinbutton.h" #include "unit-menu.h" +#include "unit-tracker.h" #include "util/expression-evaluator.h" #include "event-context.h" @@ -33,8 +34,13 @@ int SpinButton::on_input(double* newvalue) { try { Inkscape::Util::GimpEevlQuantity result; - if (_unit_menu) { - Unit unit = _unit_menu->getUnit(); + if (_unit_menu || _unit_tracker) { + Unit unit; + if (_unit_menu) { + unit = _unit_menu->getUnit(); + } else { + unit = _unit_tracker->getActiveUnit(); + } result = Inkscape::Util::gimp_eevl_evaluate (get_text().c_str(), &unit); // check if output dimension corresponds to input unit if (result.dimension != (unit.isAbsolute() ? 1 : 0) ) { diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h index fe5d699e7..c772fe2a2 100644 --- a/src/ui/widget/spinbutton.h +++ b/src/ui/widget/spinbutton.h @@ -25,6 +25,7 @@ namespace UI { namespace Widget { class UnitMenu; +class UnitTracker; /** * SpinButton widget, that allows entry of simple math expressions (also units, when linked with UnitMenu), @@ -50,14 +51,18 @@ public: _unit_menu(NULL) { connect_signals(); + _unit_tracker = NULL; }; virtual ~SpinButton() {}; void setUnitMenu(UnitMenu* unit_menu) { _unit_menu = unit_menu; }; + + void addUnitTracker(UnitTracker* ut) { _unit_tracker = ut; }; protected: UnitMenu *_unit_menu; /// Linked unit menu for unit conversion in entered expressions. + UnitTracker *_unit_tracker; // Linked unit tracker for unit conversion in entered expressions. void connect_signals(); |
