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.

44 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. bool hideScrollbars = false;
  17. ScrollWidget();
  18. void scrollTo(math::Rect r);
  19. /** Returns the bound of allowed `offset` values in pixels. */
  20. math::Rect getContainerOffsetBound();
  21. /** Returns the handle position relative to the scrollbar. [0, 1]. */
  22. math::Vec getHandleOffset();
  23. /** Returns the handle size relative to the scrollbar. [0, 1]. */
  24. math::Vec getHandleSize();
  25. void draw(const DrawArgs& args) override;
  26. void step() override;
  27. void onButton(const event::Button& e) override;
  28. void onDragStart(const event::DragStart& e) override;
  29. void onDragMove(const event::DragMove& e) override;
  30. void onHoverScroll(const event::HoverScroll& e) override;
  31. void onHoverKey(const event::HoverKey& e) override;
  32. };
  33. } // namespace ui
  34. } // namespace rack