From 18f8283e343b5b702b4e51c56c45559be490519a Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Fri, 2 Oct 2020 14:03:13 -0400 Subject: [PATCH] Rename ui::ScrollBar to Scrollbar. (Wikipedia says "scrollbar" rather than "scroll bar".) --- include/ui/ScrollWidget.hpp | 9 ++--- include/ui/{ScrollBar.hpp => Scrollbar.hpp} | 9 +++-- src/app/RackScrollWidget.cpp | 12 +++---- src/ui/ScrollWidget.cpp | 38 ++++++++++----------- src/ui/{ScrollBar.cpp => Scrollbar.cpp} | 16 ++++----- 5 files changed, 44 insertions(+), 40 deletions(-) rename include/ui/{ScrollBar.hpp => Scrollbar.hpp} (81%) rename src/ui/{ScrollBar.cpp => Scrollbar.cpp} (85%) diff --git a/include/ui/ScrollWidget.hpp b/include/ui/ScrollWidget.hpp index 12965b61..8095f0a4 100644 --- a/include/ui/ScrollWidget.hpp +++ b/include/ui/ScrollWidget.hpp @@ -1,24 +1,25 @@ #pragma once #include #include -#include +#include namespace rack { namespace ui { -/** Handles a container with ScrollBar */ +/** Handles a container with Scrollbar */ struct ScrollWidget : widget::OpaqueWidget { struct Internal; Internal* internal; widget::Widget* container; - ScrollBar* horizontalScrollBar; - ScrollBar* verticalScrollBar; + Scrollbar* horizontalScrollbar; + Scrollbar* verticalScrollbar; math::Vec offset; math::Rect containerBox; + bool hideScrollbars = false; ScrollWidget(); void scrollTo(math::Rect r); diff --git a/include/ui/ScrollBar.hpp b/include/ui/Scrollbar.hpp similarity index 81% rename from include/ui/ScrollBar.hpp rename to include/ui/Scrollbar.hpp index 0ce57659..1a0669c6 100644 --- a/include/ui/ScrollBar.hpp +++ b/include/ui/Scrollbar.hpp @@ -8,14 +8,14 @@ namespace ui { /** Parent must be a ScrollWidget */ -struct ScrollBar : widget::OpaqueWidget { +struct Scrollbar : widget::OpaqueWidget { struct Internal; Internal* internal; bool vertical = false; - ScrollBar(); - ~ScrollBar(); + Scrollbar(); + ~Scrollbar(); void draw(const DrawArgs& args) override; void onButton(const event::Button& e) override; void onDragStart(const event::DragStart& e) override; @@ -24,5 +24,8 @@ struct ScrollBar : widget::OpaqueWidget { }; +DEPRECATED typedef Scrollbar ScrollBar; + + } // namespace ui } // namespace rack diff --git a/src/app/RackScrollWidget.cpp b/src/app/RackScrollWidget.cpp index 73b74766..9f3c2344 100644 --- a/src/app/RackScrollWidget.cpp +++ b/src/app/RackScrollWidget.cpp @@ -81,15 +81,15 @@ void RackScrollWidget::draw(const DrawArgs& args) { bool horizontalVisible; bool verticalVisible; if (fullscreen) { - horizontalVisible = horizontalScrollBar->visible; - verticalVisible = verticalScrollBar->visible; - horizontalScrollBar->visible = false; - verticalScrollBar->visible = false; + horizontalVisible = horizontalScrollbar->visible; + verticalVisible = verticalScrollbar->visible; + horizontalScrollbar->visible = false; + verticalScrollbar->visible = false; } ScrollWidget::draw(args); if (fullscreen) { - horizontalScrollBar->visible = horizontalVisible; - verticalScrollBar->visible = verticalVisible; + horizontalScrollbar->visible = horizontalVisible; + verticalScrollbar->visible = verticalVisible; } } diff --git a/src/ui/ScrollWidget.cpp b/src/ui/ScrollWidget.cpp index f101083a..e0eac6b6 100644 --- a/src/ui/ScrollWidget.cpp +++ b/src/ui/ScrollWidget.cpp @@ -13,15 +13,15 @@ ScrollWidget::ScrollWidget() { container = new widget::Widget; addChild(container); - horizontalScrollBar = new ScrollBar; - horizontalScrollBar->vertical = false; - horizontalScrollBar->hide(); - addChild(horizontalScrollBar); - - verticalScrollBar = new ScrollBar; - verticalScrollBar->vertical = true; - verticalScrollBar->hide(); - addChild(verticalScrollBar); + horizontalScrollbar = new Scrollbar; + horizontalScrollbar->vertical = false; + horizontalScrollbar->hide(); + addChild(horizontalScrollbar); + + verticalScrollbar = new Scrollbar; + verticalScrollbar->vertical = true; + verticalScrollbar->hide(); + addChild(verticalScrollbar); } @@ -70,15 +70,15 @@ 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); + 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)); - horizontalScrollBar->box.pos.y = inner.y; - verticalScrollBar->box.pos.x = inner.x; - horizontalScrollBar->box.size.x = verticalScrollBar->isVisible() ? inner.x : box.size.x; - verticalScrollBar->box.size.y = horizontalScrollBar->isVisible() ? inner.y : box.size.y; + math::Vec inner = box.size.minus(math::Vec(verticalScrollbar->box.size.x, horizontalScrollbar->box.size.y)); + horizontalScrollbar->box.pos.y = inner.y; + verticalScrollbar->box.pos.x = inner.x; + horizontalScrollbar->box.size.x = verticalScrollbar->isVisible() ? inner.x : box.size.x; + verticalScrollbar->box.size.y = horizontalScrollbar->isVisible() ? inner.y : box.size.y; } @@ -88,7 +88,7 @@ void ScrollWidget::onButton(const event::Button& e) { return; // Consume right button only if the scrollbars are visible - if (!(horizontalScrollBar->isVisible() || verticalScrollBar->isVisible())) + if (!(horizontalScrollbar->isVisible() || verticalScrollbar->isVisible())) return; if (e.button == GLFW_MOUSE_BUTTON_MIDDLE) { @@ -106,7 +106,7 @@ 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())) + if (!(horizontalScrollbar->isVisible() || verticalScrollbar->isVisible())) return; math::Vec offsetDelta = e.mouseDelta.div(getAbsoluteZoom()); @@ -120,7 +120,7 @@ void ScrollWidget::onHoverScroll(const event::HoverScroll& e) { return; // Scroll only if the scrollbars are visible - if (!(horizontalScrollBar->isVisible() || verticalScrollBar->isVisible())) + if (!(horizontalScrollbar->isVisible() || verticalScrollbar->isVisible())) return; math::Vec scrollDelta = e.scrollDelta; diff --git a/src/ui/ScrollBar.cpp b/src/ui/Scrollbar.cpp similarity index 85% rename from src/ui/ScrollBar.cpp rename to src/ui/Scrollbar.cpp index d3f02d34..39e51d3c 100644 --- a/src/ui/ScrollBar.cpp +++ b/src/ui/Scrollbar.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -11,16 +11,16 @@ namespace ui { // Internal not currently used -ScrollBar::ScrollBar() { +Scrollbar::Scrollbar() { box.size = math::Vec(BND_SCROLLBAR_WIDTH, BND_SCROLLBAR_HEIGHT); } -ScrollBar::~ScrollBar() { +Scrollbar::~Scrollbar() { } -void ScrollBar::draw(const DrawArgs& args) { +void Scrollbar::draw(const DrawArgs& args) { ScrollWidget* sw = dynamic_cast(parent); assert(sw); @@ -36,7 +36,7 @@ void ScrollBar::draw(const DrawArgs& args) { } -void ScrollBar::onButton(const event::Button& e) { +void Scrollbar::onButton(const event::Button& e) { if (e.button == GLFW_MOUSE_BUTTON_LEFT && e.action == GLFW_PRESS) { ScrollWidget* sw = dynamic_cast(parent); assert(sw); @@ -58,15 +58,15 @@ void ScrollBar::onButton(const event::Button& e) { } -void ScrollBar::onDragStart(const event::DragStart& e) { +void Scrollbar::onDragStart(const event::DragStart& e) { } -void ScrollBar::onDragEnd(const event::DragEnd& e) { +void Scrollbar::onDragEnd(const event::DragEnd& e) { } -void ScrollBar::onDragMove(const event::DragMove& e) { +void Scrollbar::onDragMove(const event::DragMove& e) { ScrollWidget* sw = dynamic_cast(parent); assert(sw);