You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.1KB

  1. #pragma once
  2. #include <ui/common.hpp>
  3. #include <widget/OpaqueWidget.hpp>
  4. #include <ui/ScrollBar.hpp>
  5. namespace rack {
  6. namespace ui {
  7. /** Handles a container with ScrollBar */
  8. struct ScrollWidget : widget::OpaqueWidget {
  9. struct Internal;
  10. Internal* internal;
  11. widget::Widget* container;
  12. ScrollBar* horizontalScrollBar;
  13. ScrollBar* verticalScrollBar;
  14. math::Vec offset;
  15. math::Rect containerBox;
  16. ScrollWidget();
  17. void scrollTo(math::Rect r);
  18. /** Returns the bound of allowed `offset` values in pixels. */
  19. math::Rect getContainerOffsetBound();
  20. /** Returns the handle position relative to the scrollbar. [0, 1]. */
  21. math::Vec getHandleOffset();
  22. /** Returns the handle size relative to the scrollbar. [0, 1]. */
  23. math::Vec getHandleSize();
  24. void draw(const DrawArgs& args) override;
  25. void step() override;
  26. void onButton(const event::Button& e) override;
  27. void onDragStart(const event::DragStart& e) override;
  28. void onDragMove(const event::DragMove& e) override;
  29. void onHoverScroll(const event::HoverScroll& e) override;
  30. void onHoverKey(const event::HoverKey& e) override;
  31. };
  32. } // namespace ui
  33. } // namespace rack