Browse Source

Fix relative scrolling when dragging the ScrollBar with the mouse.

pull/1475/head
Mark Sanders 5 years ago
parent
commit
cc373d2b30
1 changed files with 3 additions and 4 deletions
  1. +3
    -4
      src/ui/ScrollBar.cpp

+ 3
- 4
src/ui/ScrollBar.cpp View File

@@ -30,14 +30,13 @@ void ScrollBar::onDragStart(const event::DragStart &e) {
}

void ScrollBar::onDragMove(const event::DragMove &e) {
const float sensitivity = 1.f;

ScrollWidget *scrollWidget = dynamic_cast<ScrollWidget*>(parent);
assert(scrollWidget);
math::Rect containerBox = scrollWidget->container->getChildrenBoundingBox();
if (orientation == HORIZONTAL)
scrollWidget->offset.x += sensitivity * e.mouseDelta.x;
scrollWidget->offset.x += (containerBox.size.x / box.size.x) * e.mouseDelta.x;
else
scrollWidget->offset.y += sensitivity * e.mouseDelta.y;
scrollWidget->offset.y += (containerBox.size.y / box.size.y) * e.mouseDelta.y;
}

void ScrollBar::onDragEnd(const event::DragEnd &e) {


Loading…
Cancel
Save