|
@@ -70,8 +70,14 @@ void ScrollWidget::step() { |
|
|
container->box.pos = offset.neg().round(); |
|
|
container->box.pos = offset.neg().round(); |
|
|
|
|
|
|
|
|
// Make scrollbars visible only if there is a positive range to scroll. |
|
|
// Make scrollbars visible only if there is a positive range to scroll. |
|
|
horizontalScrollbar->setVisible(offsetBounds.size.x > 0.f); |
|
|
|
|
|
verticalScrollbar->setVisible(offsetBounds.size.y > 0.f); |
|
|
|
|
|
|
|
|
if (hideScrollbars) { |
|
|
|
|
|
horizontalScrollbar->setVisible(false); |
|
|
|
|
|
verticalScrollbar->setVisible(false); |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
horizontalScrollbar->setVisible(offsetBounds.size.x > 0.f); |
|
|
|
|
|
verticalScrollbar->setVisible(offsetBounds.size.y > 0.f); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// Reposition and resize scroll bars |
|
|
// Reposition and resize scroll bars |
|
|
math::Vec inner = box.size.minus(math::Vec(verticalScrollbar->box.size.x, horizontalScrollbar->box.size.y)); |
|
|
math::Vec inner = box.size.minus(math::Vec(verticalScrollbar->box.size.x, horizontalScrollbar->box.size.y)); |
|
@@ -87,10 +93,6 @@ void ScrollWidget::onButton(const event::Button& e) { |
|
|
if (e.isConsumed()) |
|
|
if (e.isConsumed()) |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
// Consume right button only if the scrollbars are visible |
|
|
|
|
|
if (!(horizontalScrollbar->isVisible() || verticalScrollbar->isVisible())) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if (e.button == GLFW_MOUSE_BUTTON_MIDDLE) { |
|
|
if (e.button == GLFW_MOUSE_BUTTON_MIDDLE) { |
|
|
e.consume(this); |
|
|
e.consume(this); |
|
|
} |
|
|
} |
|
@@ -105,12 +107,10 @@ void ScrollWidget::onDragStart(const event::DragStart& e) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ScrollWidget::onDragMove(const event::DragMove& e) { |
|
|
void ScrollWidget::onDragMove(const event::DragMove& e) { |
|
|
// Scroll only if the scrollbars are visible |
|
|
|
|
|
if (!(horizontalScrollbar->isVisible() || verticalScrollbar->isVisible())) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
math::Vec offsetDelta = e.mouseDelta.div(getAbsoluteZoom()); |
|
|
|
|
|
offset = offset.minus(offsetDelta); |
|
|
|
|
|
|
|
|
if (e.button == GLFW_MOUSE_BUTTON_LEFT || e.button == GLFW_MOUSE_BUTTON_MIDDLE) { |
|
|
|
|
|
math::Vec offsetDelta = e.mouseDelta.div(getAbsoluteZoom()); |
|
|
|
|
|
offset = offset.minus(offsetDelta); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -119,10 +119,6 @@ void ScrollWidget::onHoverScroll(const event::HoverScroll& e) { |
|
|
if (e.isConsumed()) |
|
|
if (e.isConsumed()) |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
|
// Scroll only if the scrollbars are visible |
|
|
|
|
|
if (!(horizontalScrollbar->isVisible() || verticalScrollbar->isVisible())) |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
math::Vec scrollDelta = e.scrollDelta; |
|
|
math::Vec scrollDelta = e.scrollDelta; |
|
|
// Flip coordinates if shift is held |
|
|
// Flip coordinates if shift is held |
|
|
// Mac (or GLFW?) already does this for us. |
|
|
// Mac (or GLFW?) already does this for us. |
|
|