diff options
author | crupest <crupest@outlook.com> | 2021-02-28 00:22:34 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-02-28 00:22:34 +0800 |
commit | 4b78e0b74f70bca2e24dc89b4fdca4dc9222c8b9 (patch) | |
tree | 257971a08ccb6bba0fa30857e0fcbd07902a0c91 /include/cru/ui/render/ScrollRenderObject.hpp | |
parent | 4a0c86d94a06e72be0988062d49a19c05142434a (diff) | |
download | cru-4b78e0b74f70bca2e24dc89b4fdca4dc9222c8b9.tar.gz cru-4b78e0b74f70bca2e24dc89b4fdca4dc9222c8b9.tar.bz2 cru-4b78e0b74f70bca2e24dc89b4fdca4dc9222c8b9.zip |
...
Diffstat (limited to 'include/cru/ui/render/ScrollRenderObject.hpp')
-rw-r--r-- | include/cru/ui/render/ScrollRenderObject.hpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/cru/ui/render/ScrollRenderObject.hpp b/include/cru/ui/render/ScrollRenderObject.hpp index 6a6ef198..aed25f8e 100644 --- a/include/cru/ui/render/ScrollRenderObject.hpp +++ b/include/cru/ui/render/ScrollRenderObject.hpp @@ -2,6 +2,7 @@ #include "RenderObject.hpp" #include "cru/platform/graphics/util/Painter.hpp" +#include "cru/ui/Base.hpp" #include "cru/ui/render/ScrollBar.hpp" #include <memory> @@ -29,8 +30,22 @@ class ScrollRenderObject : public RenderObject { // Return the coerced scroll offset. Point GetScrollOffset(); + float GetScrollOffset(Direction direction) { + return direction == Direction::Horizontal ? GetScrollOffset().x + : GetScrollOffset().y; + } void SetScrollOffset(const Point& offset); void SetScrollOffset(std::optional<float> x, std::optional<float> y); + void SetScrollOffset(Direction direction, std::optional<float> value) { + if (direction == Direction::Horizontal) { + SetScrollOffset(value, std::nullopt); + } else { + SetScrollOffset(std::nullopt, value); + } + } + + void Scroll(const Scroll& scroll); + Point GetRawScrollOffset() const { return scroll_offset_; } // Return the viewable area rect. |