summaryrefslogtreecommitdiffstats
path: root/src/ui/widget/spinbutton.cpp
diff options
context:
space:
mode:
authorJabiertxof <jabier.arraiza@marker.es>2019-06-12 11:23:59 +0000
committerJabiertxof <jabier.arraiza@marker.es>2019-06-13 00:24:32 +0000
commit11e928db007f9bfb0beddd01faaab8b9ee301b00 (patch)
tree85ba483fe2780859a3833b325ce26ece53e0e441 /src/ui/widget/spinbutton.cpp
parentBetter word last commit (diff)
downloadinkscape-11e928db007f9bfb0beddd01faaab8b9ee301b00.tar.gz
inkscape-11e928db007f9bfb0beddd01faaab8b9ee301b00.zip
Fixes hover scrool bug
Diffstat (limited to '')
-rw-r--r--src/ui/widget/spinbutton.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp
index b5769d8e2..130cd6c39 100644
--- a/src/ui/widget/spinbutton.cpp
+++ b/src/ui/widget/spinbutton.cpp
@@ -9,7 +9,6 @@
*/
#include "spinbutton.h"
-
#include "unit-menu.h"
#include "unit-tracker.h"
#include "util/expression-evaluator.h"
@@ -25,6 +24,8 @@ SpinButton::connect_signals() {
signal_input().connect(sigc::mem_fun(*this, &SpinButton::on_input));
signal_focus_in_event().connect(sigc::mem_fun(*this, &SpinButton::on_my_focus_in_event));
signal_key_press_event().connect(sigc::mem_fun(*this, &SpinButton::on_my_key_press_event));
+ gtk_widget_add_events(GTK_WIDGET(gobj()), GDK_SCROLL_MASK | GDK_SMOOTH_SCROLL_MASK);
+ signal_scroll_event().connect(sigc::mem_fun(*this, &SpinButton::on_my_scroll_event));
};
int SpinButton::on_input(double* newvalue)
@@ -48,7 +49,6 @@ int SpinButton::on_input(double* newvalue)
Inkscape::Util::ExpressionEvaluator eval = Inkscape::Util::ExpressionEvaluator(get_text().c_str(), nullptr);
result = eval.evaluate();
}
-
*newvalue = result.value;
}
catch(Inkscape::Util::EvaluatorException &e) {
@@ -66,6 +66,28 @@ bool SpinButton::on_my_focus_in_event(GdkEventFocus* /*event*/)
return false; // do not consume the event
}
+bool SpinButton::on_my_scroll_event(GdkEventScroll* event)
+{
+ if (!property_has_focus()) {
+ return true;
+ }
+ double step, page;
+ get_increments(step, page);
+ double change = 0.0;
+ if (event->direction == GDK_SCROLL_UP) {
+ change = step;
+ } else if (event->direction == GDK_SCROLL_DOWN) {
+ change = step * -1.0;
+ } else if (event->direction == GDK_SCROLL_SMOOTH) {
+ double delta_y_clamped = CLAMP(event->delta_y, step * -1.0, step); // values > 1 result in excessive changes
+ change = step * -delta_y_clamped;
+ } else {
+ return false;
+ }
+ set_value(get_value() + change);
+ return false;
+}
+
bool SpinButton::on_my_key_press_event(GdkEventKey* event)
{
switch (Inkscape::UI::Tools::get_latin_keyval (event)) {