Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-01-29 15:16:17 +0000
committerStijn Buys <ingar@osirion.org>2012-01-29 15:16:17 +0000
commit52bd0792d15e9a814cd38cf77b26784003b8569f (patch)
treeaaf0429fe0d93f66b3ecad49fb313523b3b24134 /src/ui/scrollbar.cc
parent46b534fbc2b0468f112676ee3149a57088eff97b (diff)
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);
}
}