aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui/render/flex_layout_render_object.hpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-03-01 22:08:15 +0800
committercrupest <crupest@outlook.com>2020-03-01 22:08:15 +0800
commit6e0e0e18cbeff6487160c84d71997575f6cccebd (patch)
tree9b4c552234dfc4f9b5129dd96b25dba3518e4581 /include/cru/ui/render/flex_layout_render_object.hpp
parent8fc4e33b97372d93b1bcc4b598e5c8e2f15652d8 (diff)
downloadcru-6e0e0e18cbeff6487160c84d71997575f6cccebd.tar.gz
cru-6e0e0e18cbeff6487160c84d71997575f6cccebd.tar.bz2
cru-6e0e0e18cbeff6487160c84d71997575f6cccebd.zip
Add stack layout.
Diffstat (limited to 'include/cru/ui/render/flex_layout_render_object.hpp')
-rw-r--r--include/cru/ui/render/flex_layout_render_object.hpp25
1 files changed, 3 insertions, 22 deletions
diff --git a/include/cru/ui/render/flex_layout_render_object.hpp b/include/cru/ui/render/flex_layout_render_object.hpp
index ab6265d6..c2bc5fd1 100644
--- a/include/cru/ui/render/flex_layout_render_object.hpp
+++ b/include/cru/ui/render/flex_layout_render_object.hpp
@@ -1,5 +1,5 @@
#pragma once
-#include "render_object.hpp"
+#include "layout_render_object.hpp"
#include <optional>
@@ -39,9 +39,9 @@ struct FlexChildLayoutData {
std::optional<FlexCrossAlignment> cross_alignment = std::nullopt;
};
-class FlexLayoutRenderObject : public RenderObject {
+class FlexLayoutRenderObject : public LayoutRenderObject<FlexChildLayoutData> {
public:
- FlexLayoutRenderObject();
+ FlexLayoutRenderObject() = default;
FlexLayoutRenderObject(const FlexLayoutRenderObject& other) = delete;
FlexLayoutRenderObject& operator=(const FlexLayoutRenderObject& other) =
delete;
@@ -67,25 +67,7 @@ class FlexLayoutRenderObject : public RenderObject {
InvalidateLayout();
}
- FlexChildLayoutData GetChildLayoutData(int position) {
- assert(position >= 0 && position < static_cast<int>(child_layout_data_.size()));
- return child_layout_data_[position];
- }
-
- void SetChildLayoutData(int position, const FlexChildLayoutData& data) {
- assert(position >= 0 && position < static_cast<int>(child_layout_data_.size()));
- child_layout_data_[position] = data;
- InvalidateLayout();
- }
-
- void Draw(platform::graph::IPainter* painter) override;
-
- RenderObject* HitTest(const Point& point) override;
-
protected:
- void OnAddChild(RenderObject* new_child, int position) override;
- void OnRemoveChild(RenderObject* removed_child, int position) override;
-
Size OnMeasureContent(const Size& available_size) override;
void OnLayoutContent(const Rect& content_rect) override;
@@ -93,6 +75,5 @@ class FlexLayoutRenderObject : public RenderObject {
FlexDirection direction_ = FlexDirection::Horizontal;
FlexMainAlignment content_main_align_ = FlexMainAlignment::Start;
FlexCrossAlignment item_cross_align_ = FlexCrossAlignment::Center;
- std::vector<FlexChildLayoutData> child_layout_data_{};
};
} // namespace cru::ui::render