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.

ScrollWidget.hpp 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. ~ScrollWidget();
  19. void scrollTo(math::Rect r);
  20. /** Returns the bound of allowed `offset` values in pixels. */
  21. math::Rect getContainerOffsetBound();
  22. /** Returns the handle position relative to the scrollbar. [0, 1]. */
  23. math::Vec getHandleOffset();
  24. /** Returns the handle size relative to the scrollbar. [0, 1]. */
  25. math::Vec getHandleSize();
  26. /** The user is considered scrolling with the wheel until the mouse is moved. */
  27. bool isScrolling();
  28. void draw(const DrawArgs& args) override;
  29. void step() override;
  30. void onHover(const HoverEvent& e) override;
  31. void onButton(const ButtonEvent& e) override;
  32. void onDragStart(const DragStartEvent& e) override;
  33. void onDragMove(const DragMoveEvent& e) override;
  34. void onHoverScroll(const HoverScrollEvent& e) override;
  35. void onHoverKey(const HoverKeyEvent& e) override;
  36. };
  37. } // namespace ui
  38. } // namespace rack