Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/scrollbar.cc')
-rw-r--r--src/ui/scrollbar.cc19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/ui/scrollbar.cc b/src/ui/scrollbar.cc
index 9be1432..a8826a5 100644
--- a/src/ui/scrollbar.cc
+++ b/src/ui/scrollbar.cc
@@ -160,17 +160,16 @@ void ScrollBar::on_mousemove(const math::Vector2f &cursor)
}
if (scrollbar_dragging && (scrollbar_maximum > scrollbar_minimum)) {
- // total width of dragable area
- if ((cursor.y() >= 2.0f * width()) && (cursor.y() <= height() - 2.0f * width())) {
+ float y = cursor.y();
+ math::clamp(y, 2.0f * width() , height() - 2.0f * width());
- const float h = (height() - 4.0f * width());
- const float s = h / (scrollbar_maximum - scrollbar_minimum);
- const float p = cursor.y() - 2.0f * width();
- const float newvalue = scrollbar_minimum + round(p / s);
- if (scrollbar_value != newvalue) {
- scrollbar_value = newvalue;
- emit(EventScrollBarChanged, this);
- }
+ const float h = (height() - 4.0f * width());
+ const float s = h / (scrollbar_maximum - scrollbar_minimum);
+ const float p = y - 2.0f * width();
+ const float newvalue = scrollbar_minimum + round(p / s);
+ if (scrollbar_value != newvalue) {
+ scrollbar_value = newvalue;
+ emit(EventScrollBarChanged, this);
}
}