From 5614df9770b985070122b3c08b45902317c9bd15 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 15 Sep 2013 19:07:21 -0400 Subject: Enable unit evaluation in toolbars. (bzr r12475.1.22) --- src/ui/widget/spinbutton.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/ui/widget/spinbutton.cpp') 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) ) { -- cgit v1.2.3 From f55a53ef2d861b634ad83622edc5e26430baeae0 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 15 Sep 2013 23:59:14 -0400 Subject: C++ify expression evaluator. (bzr r12475.1.23) --- src/ui/widget/spinbutton.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/ui/widget/spinbutton.cpp') diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index 2c95e8b5a..62c17f821 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -33,7 +33,7 @@ SpinButton::connect_signals() { int SpinButton::on_input(double* newvalue) { try { - Inkscape::Util::GimpEevlQuantity result; + Inkscape::Util::EvaluatorQuantity result; if (_unit_menu || _unit_tracker) { Unit unit; if (_unit_menu) { @@ -41,13 +41,15 @@ int SpinButton::on_input(double* newvalue) } else { unit = _unit_tracker->getActiveUnit(); } - result = Inkscape::Util::gimp_eevl_evaluate (get_text().c_str(), &unit); + Inkscape::Util::ExpressionEvaluator eval = Inkscape::Util::ExpressionEvaluator(get_text().c_str(), &unit); + result = eval.evaluate(); // check if output dimension corresponds to input unit if (result.dimension != (unit.isAbsolute() ? 1 : 0) ) { throw Inkscape::Util::EvaluatorException("Input dimensions do not match with parameter dimensions.",""); } } else { - result = Inkscape::Util::gimp_eevl_evaluate (get_text().c_str(), NULL); + Inkscape::Util::ExpressionEvaluator eval = Inkscape::Util::ExpressionEvaluator(get_text().c_str(), NULL); + result = eval.evaluate(); } *newvalue = result.value; -- cgit v1.2.3 From 62b2cd734e684a93d1b9215aa8044c620939170d Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 24 Sep 2013 00:11:51 +0200 Subject: fix crash on uninitialized unittracker for spinbuttons. fixes crash on changing major grid line number, possibly other random crashes Fixed bugs: - https://launchpad.net/bugs/1229183 (bzr r12581) --- src/ui/widget/spinbutton.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui/widget/spinbutton.cpp') diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index 62c17f821..1114ff32b 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -65,7 +65,7 @@ int SpinButton::on_input(double* newvalue) bool SpinButton::on_my_focus_in_event(GdkEventFocus* /*event*/) { - on_focus_in_value = get_value(); + _on_focus_in_value = get_value(); return false; // do not consume the event } @@ -92,7 +92,7 @@ bool SpinButton::on_my_key_press_event(GdkEventKey* event) void SpinButton::undo() { - set_value(on_focus_in_value); + set_value(_on_focus_in_value); } -- cgit v1.2.3 From a970dc423d59ea844bdb1af48d5d9419a5e2a287 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 13 Oct 2013 00:24:05 +0200 Subject: Units: stop newing Unit objects. pass around pointers to "undeletable" Unit objects in the UnitTable. I think we should move to using indexed units, and pass around the index of the unit in the unittable, or smth like that... ? (bzr r12679) --- src/ui/widget/spinbutton.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/ui/widget/spinbutton.cpp') diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index 1114ff32b..6cbc15c1b 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -35,16 +35,16 @@ int SpinButton::on_input(double* newvalue) try { Inkscape::Util::EvaluatorQuantity result; if (_unit_menu || _unit_tracker) { - Unit unit; + Unit const *unit = NULL; if (_unit_menu) { unit = _unit_menu->getUnit(); } else { unit = _unit_tracker->getActiveUnit(); } - Inkscape::Util::ExpressionEvaluator eval = Inkscape::Util::ExpressionEvaluator(get_text().c_str(), &unit); + Inkscape::Util::ExpressionEvaluator eval = Inkscape::Util::ExpressionEvaluator(get_text().c_str(), unit); result = eval.evaluate(); // check if output dimension corresponds to input unit - if (result.dimension != (unit.isAbsolute() ? 1 : 0) ) { + if (result.dimension != (unit->isAbsolute() ? 1 : 0) ) { throw Inkscape::Util::EvaluatorException("Input dimensions do not match with parameter dimensions.",""); } } else { -- cgit v1.2.3