Browse Source

Add `ScrollWidget::hideScrollbars`. Use it for RackScrollWidget when fullscreen.

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
01f3f32716
2 changed files with 15 additions and 30 deletions
  1. +3
    -14
      src/app/RackScrollWidget.cpp
  2. +12
    -16
      src/ui/ScrollWidget.cpp

+ 3
- 14
src/app/RackScrollWidget.cpp View File

@@ -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) {


+ 12
- 16
src/ui/ScrollWidget.cpp View File

@@ -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.


Loading…
Cancel
Save