diff options
author | crupest <crupest@outlook.com> | 2020-03-18 22:37:41 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-03-18 22:37:41 +0800 |
commit | 477155d6fccc8eafadb6d7f4c468c9141d7d4e92 (patch) | |
tree | 0fe935c8f699a1c42c8750a39b6ca70d31f941a0 /include/cru/ui/render | |
parent | 068714c0f2fe7ab003462e5483f9944b0bf2f8e0 (diff) | |
download | cru-477155d6fccc8eafadb6d7f4c468c9141d7d4e92.tar.gz cru-477155d6fccc8eafadb6d7f4c468c9141d7d4e92.tar.bz2 cru-477155d6fccc8eafadb6d7f4c468c9141d7d4e92.zip |
...
Diffstat (limited to 'include/cru/ui/render')
-rw-r--r-- | include/cru/ui/render/base.hpp | 12 | ||||
-rw-r--r-- | include/cru/ui/render/border_render_object.hpp | 34 | ||||
-rw-r--r-- | include/cru/ui/render/canvas_render_object.hpp | 19 | ||||
-rw-r--r-- | include/cru/ui/render/flex_layout_render_object.hpp | 37 | ||||
-rw-r--r-- | include/cru/ui/render/layout_render_object.hpp | 1 | ||||
-rw-r--r-- | include/cru/ui/render/layout_utility.hpp | 2 | ||||
-rw-r--r-- | include/cru/ui/render/render_object.hpp | 10 | ||||
-rw-r--r-- | include/cru/ui/render/stack_layout_render_object.hpp | 5 | ||||
-rw-r--r-- | include/cru/ui/render/text_render_object.hpp | 1 | ||||
-rw-r--r-- | include/cru/ui/render/window_render_object.hpp | 6 |
10 files changed, 14 insertions, 113 deletions
diff --git a/include/cru/ui/render/base.hpp b/include/cru/ui/render/base.hpp new file mode 100644 index 00000000..f9d936e0 --- /dev/null +++ b/include/cru/ui/render/base.hpp @@ -0,0 +1,12 @@ +#pragma once +#include "../base.hpp" + +namespace cru::ui::render { +class RenderObject; +class BorderRenderObject; +class CanvasRenderObject; +class FlexLayoutRenderObject; +class StackLayoutRenderObject; +class TextRenderObject; +class WindowRenderObject; +} // namespace cru::ui::render diff --git a/include/cru/ui/render/border_render_object.hpp b/include/cru/ui/render/border_render_object.hpp index b9af71c0..259c1530 100644 --- a/include/cru/ui/render/border_render_object.hpp +++ b/include/cru/ui/render/border_render_object.hpp @@ -1,41 +1,7 @@ #pragma once #include "render_object.hpp" -#include <memory> - namespace cru::ui::render { -struct CornerRadius { - constexpr CornerRadius() - : left_top(), right_top(), left_bottom(), right_bottom() {} - constexpr CornerRadius(const Point& value) - : left_top(value), - right_top(value), - left_bottom(value), - right_bottom(value) {} - constexpr CornerRadius(Point left_top, Point right_top, Point left_bottom, - Point right_bottom) - : left_top(left_top), - right_top(right_top), - left_bottom(left_bottom), - right_bottom(right_bottom) {} - - Point left_top; - Point right_top; - Point left_bottom; - Point right_bottom; -}; - -inline bool operator==(const CornerRadius& left, const CornerRadius& right) { - return left.left_top == right.left_top && - left.left_bottom == right.left_bottom && - left.right_top == right.right_top && - left.right_bottom == right.right_bottom; -} - -inline bool operator!=(const CornerRadius& left, const CornerRadius& right) { - return !(left == right); -} - class BorderRenderObject : public RenderObject { public: BorderRenderObject(); diff --git a/include/cru/ui/render/canvas_render_object.hpp b/include/cru/ui/render/canvas_render_object.hpp index e3388014..cb3828b6 100644 --- a/include/cru/ui/render/canvas_render_object.hpp +++ b/include/cru/ui/render/canvas_render_object.hpp @@ -1,26 +1,7 @@ #pragma once #include "render_object.hpp" -#include "cru/common/event.hpp" - namespace cru::ui::render { -class CanvasPaintEventArgs { - public: - CanvasPaintEventArgs(platform::graph::IPainter* painter, - const Rect& paint_rect) - : painter_(painter), paint_rect_(paint_rect) {} - CRU_DEFAULT_COPY(CanvasPaintEventArgs) - CRU_DEFAULT_MOVE(CanvasPaintEventArgs) - ~CanvasPaintEventArgs() = default; - - platform::graph::IPainter* GetPainter() const { return painter_; } - Rect GetPaintRect() const { return paint_rect_; } - - private: - platform::graph::IPainter* painter_; - Rect paint_rect_; -}; - // The measure logic for `CanvasRenderObject` is that you set a desired size by // `SetDesiredSize` (not `SetPreferredSize`) and it will compare desired size // and available size and use the smaller one (by `Min`). diff --git a/include/cru/ui/render/flex_layout_render_object.hpp b/include/cru/ui/render/flex_layout_render_object.hpp index c2bc5fd1..849c1a0d 100644 --- a/include/cru/ui/render/flex_layout_render_object.hpp +++ b/include/cru/ui/render/flex_layout_render_object.hpp @@ -1,44 +1,7 @@ #pragma once #include "layout_render_object.hpp" -#include <optional> - namespace cru::ui::render { -enum class FlexDirection { - Horizontal, - HorizontalReverse, - Vertical, - VertivalReverse -}; - -namespace internal { -constexpr int align_start = 0; -constexpr int align_end = align_start + 1; -constexpr int align_center = align_end + 1; -// constexpr int align_stretch = align_center + 1; -} // namespace internal - -enum class FlexMainAlignment { - Start = internal::align_start, - End = internal::align_end, - Center = internal::align_center -}; -enum class FlexCrossAlignment { - Start = internal::align_start, - End = internal::align_end, - Center = internal::align_center, - // Stretch = internal::align_stretch -}; - -struct FlexChildLayoutData { - // nullopt stands for looking at my content - std::optional<float> flex_basis = std::nullopt; - float flex_grow = 0; - float flex_shrink = 0; - // nullopt stands for looking at parent's setting - std::optional<FlexCrossAlignment> cross_alignment = std::nullopt; -}; - class FlexLayoutRenderObject : public LayoutRenderObject<FlexChildLayoutData> { public: FlexLayoutRenderObject() = default; diff --git a/include/cru/ui/render/layout_render_object.hpp b/include/cru/ui/render/layout_render_object.hpp index db6daba9..0b60a647 100644 --- a/include/cru/ui/render/layout_render_object.hpp +++ b/include/cru/ui/render/layout_render_object.hpp @@ -4,7 +4,6 @@ #include "cru/platform/graph/util/painter.hpp" #include <cassert> -#include <functional> namespace cru::ui::render { template <typename TChildLayoutData> diff --git a/include/cru/ui/render/layout_utility.hpp b/include/cru/ui/render/layout_utility.hpp index 5cf74e71..16a15d87 100644 --- a/include/cru/ui/render/layout_utility.hpp +++ b/include/cru/ui/render/layout_utility.hpp @@ -1,5 +1,5 @@ #pragma once -#include "../base.hpp" +#include "base.hpp" namespace cru::ui::render { Size Min(const Size& left, const Size& right); diff --git a/include/cru/ui/render/render_object.hpp b/include/cru/ui/render/render_object.hpp index 8db1a20f..ca31386a 100644 --- a/include/cru/ui/render/render_object.hpp +++ b/include/cru/ui/render/render_object.hpp @@ -1,15 +1,7 @@ #pragma once -#include "../base.hpp" +#include "base.hpp" #include "cru/common/event.hpp" -#include "cru/platform/graph/base.hpp" - -#include <vector> - -// forward declarations -namespace cru::ui { -class Control; -} namespace cru::ui::render { diff --git a/include/cru/ui/render/stack_layout_render_object.hpp b/include/cru/ui/render/stack_layout_render_object.hpp index 0d33e7e3..c259b98d 100644 --- a/include/cru/ui/render/stack_layout_render_object.hpp +++ b/include/cru/ui/render/stack_layout_render_object.hpp @@ -2,11 +2,6 @@ #include "layout_render_object.hpp" namespace cru::ui::render { -struct StackChildLayoutData { - Alignment horizontal = Alignment::Start; - Alignment vertical = Alignment::Start; -}; - class StackLayoutRenderObject : public LayoutRenderObject<StackChildLayoutData> { public: diff --git a/include/cru/ui/render/text_render_object.hpp b/include/cru/ui/render/text_render_object.hpp index 62313cd3..1c472753 100644 --- a/include/cru/ui/render/text_render_object.hpp +++ b/include/cru/ui/render/text_render_object.hpp @@ -1,7 +1,6 @@ #pragma once #include "render_object.hpp" -#include <memory> #include <string> namespace cru::ui::render { diff --git a/include/cru/ui/render/window_render_object.hpp b/include/cru/ui/render/window_render_object.hpp index ae95b8ee..2f7f1e84 100644 --- a/include/cru/ui/render/window_render_object.hpp +++ b/include/cru/ui/render/window_render_object.hpp @@ -1,12 +1,6 @@ #pragma once #include "render_object.hpp" -#include <memory> - -namespace cru::ui { -class Window; -} - namespace cru::ui::render { class WindowRenderObject : public RenderObject { public: |