diff --git a/src/app/RackScrollWidget.cpp b/src/app/RackScrollWidget.cpp index 9f3c2344..3ed4fdf5 100644 --- a/src/app/RackScrollWidget.cpp +++ b/src/app/RackScrollWidget.cpp @@ -71,26 +71,15 @@ void RackScrollWidget::step() { offset.y += speed; } + // Hide scrollbars if fullscreen + hideScrollbars = APP->window->isFullScreen(); + ScrollWidget::step(); oldOffset = offset; } void RackScrollWidget::draw(const DrawArgs& args) { - // Hide scrollbars if full screen - bool fullscreen = APP->window->isFullScreen(); - bool horizontalVisible; - bool verticalVisible; - if (fullscreen) { - horizontalVisible = horizontalScrollbar->visible; - verticalVisible = verticalScrollbar->visible; - horizontalScrollbar->visible = false; - verticalScrollbar->visible = false; - } ScrollWidget::draw(args); - if (fullscreen) { - horizontalScrollbar->visible = horizontalVisible; - verticalScrollbar->visible = verticalVisible; - } } void RackScrollWidget::onHoverKey(const event::HoverKey& e) { diff --git a/src/ui/ScrollWidget.cpp b/src/ui/ScrollWidget.cpp index e0eac6b6..f3f7a908 100644 --- a/src/ui/ScrollWidget.cpp +++ b/src/ui/ScrollWidget.cpp @@ -70,8 +70,14 @@ void ScrollWidget::step() { container->box.pos = offset.neg().round(); // 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 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()) return; - // Consume right button only if the scrollbars are visible - if (!(horizontalScrollbar->isVisible() || verticalScrollbar->isVisible())) - return; - if (e.button == GLFW_MOUSE_BUTTON_MIDDLE) { e.consume(this); } @@ -105,12 +107,10 @@ void ScrollWidget::onDragStart(const event::DragStart& 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()) return; - // Scroll only if the scrollbars are visible - if (!(horizontalScrollbar->isVisible() || verticalScrollbar->isVisible())) - return; - math::Vec scrollDelta = e.scrollDelta; // Flip coordinates if shift is held // Mac (or GLFW?) already does this for us.