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 | |
parent | 068714c0f2fe7ab003462e5483f9944b0bf2f8e0 (diff) | |
download | cru-477155d6fccc8eafadb6d7f4c468c9141d7d4e92.tar.gz cru-477155d6fccc8eafadb6d7f4c468c9141d7d4e92.tar.bz2 cru-477155d6fccc8eafadb6d7f4c468c9141d7d4e92.zip |
...
34 files changed, 161 insertions, 263 deletions
diff --git a/include/cru/platform/native/basic_types.hpp b/include/cru/platform/native/base.hpp index 84cc61d1..d62dc56b 100644 --- a/include/cru/platform/native/basic_types.hpp +++ b/include/cru/platform/native/base.hpp @@ -1,8 +1,15 @@ #pragma once #include "cru/common/base.hpp" #include "cru/common/bitmask.hpp" +#include "cru/platform/graph/base.hpp" namespace cru::platform::native { +struct ICursor; +struct ICursorManager; +struct IUiApplication; +struct INativeWindow; +struct INativeWindowResolver; + struct Dpi { float x; float y; @@ -20,4 +27,17 @@ constexpr MouseButton middle{0b10}; constexpr MouseButton right{0b100}; } // namespace mouse_buttons +enum class SystemCursorType { + Arrow, + Hand, +}; + +struct NativeMouseButtonEventArgs { + MouseButton button; + Point point; +}; + +enum class FocusChangeType { Gain, Lost }; + +enum class MouseEnterLeaveType { Enter, Leave }; } // namespace cru::platform::native diff --git a/include/cru/platform/native/cursor.hpp b/include/cru/platform/native/cursor.hpp index cb8b7ed2..eae51ffe 100644 --- a/include/cru/platform/native/cursor.hpp +++ b/include/cru/platform/native/cursor.hpp @@ -1,17 +1,12 @@ #pragma once - #include "../resource.hpp" +#include "base.hpp" #include <memory> namespace cru::platform::native { struct ICursor : virtual INativeResource {}; -enum class SystemCursorType { - Arrow, - Hand, -}; - struct ICursorManager : virtual INativeResource { virtual std::shared_ptr<ICursor> GetSystemCursor(SystemCursorType type) = 0; diff --git a/include/cru/platform/native/event.hpp b/include/cru/platform/native/event.hpp deleted file mode 100644 index 48e9cfca..00000000 --- a/include/cru/platform/native/event.hpp +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "../graph_base.hpp" -#include "basic_types.hpp" - -namespace cru::platform::native { -struct NativeMouseButtonEventArgs { - MouseButton button; - Point point; -}; - -enum class FocusChangeType { Gain, Lost }; - -enum class MouseEnterLeaveType { Enter, Leave }; -} // namespace cru::platform::native diff --git a/include/cru/platform/native/ui_application.hpp b/include/cru/platform/native/ui_application.hpp index e02904bb..0825251e 100644 --- a/include/cru/platform/native/ui_application.hpp +++ b/include/cru/platform/native/ui_application.hpp @@ -1,20 +1,13 @@ #pragma once #include "../resource.hpp" +#include "base.hpp" #include <chrono> #include <functional> #include <memory> #include <vector> -namespace cru::platform::graph { -struct IGraphFactory; -} - namespace cru::platform::native { -struct INativeWindow; -struct INativeWindowResolver; -struct ICursorManager; - // The entry point of a ui application. struct IUiApplication : public virtual INativeResource { public: diff --git a/include/cru/platform/native/window.hpp b/include/cru/platform/native/window.hpp index 9f2e2e71..85f809e5 100644 --- a/include/cru/platform/native/window.hpp +++ b/include/cru/platform/native/window.hpp @@ -1,19 +1,9 @@ #pragma once #include "../resource.hpp" - -#include "../graph_base.hpp" -#include "basic_types.hpp" +#include "base.hpp" #include "cru/common/event.hpp" -#include "cursor.hpp" -#include "event.hpp" - -namespace cru::platform::graph { -struct IPainter; -} namespace cru::platform::native { -struct INativeWindowResolver; - // Represents a native window, which exposes some low-level events and // operations. // diff --git a/include/cru/ui/base.hpp b/include/cru/ui/base.hpp index 703d61fc..fe53edd4 100644 --- a/include/cru/ui/base.hpp +++ b/include/cru/ui/base.hpp @@ -1,10 +1,15 @@ #pragma once #include "cru/common/base.hpp" -#include "cru/platform/graph_base.hpp" -#include "cru/platform/matrix.hpp" -#include "cru/platform/native/basic_types.hpp" +#include "cru/platform/graph/base.hpp" +#include "cru/platform/native/base.hpp" + +#include <functional> +#include <memory> +#include <optional> +#include <vector> namespace cru::ui { +//-------------------- region: import -------------------- using cru::platform::Color; using cru::platform::Ellipse; using cru::platform::Matrix; @@ -28,6 +33,12 @@ using cru::platform::colors::skyblue; using cru::platform::colors::white; } // namespace colors +//-------------------- region: forward declaration -------------------- +class Window; +class Control; +class ClickDetector; + +//-------------------- region: basic types -------------------- namespace internal { constexpr int align_start = 0; constexpr int align_end = align_start + 1; @@ -41,4 +52,77 @@ enum class Alignment { Center = internal::align_center, Stretch = internal::align_stretch }; + +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 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_; +}; + +enum class FlexDirection { + Horizontal, + HorizontalReverse, + Vertical, + VertivalReverse +}; + +using FlexMainAlignment = Alignment; +using FlexCrossAlignment = Alignment; + +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; +}; + +struct StackChildLayoutData { + Alignment horizontal = Alignment::Start; + Alignment vertical = Alignment::Start; +}; } // namespace cru::ui diff --git a/include/cru/ui/click_detector.hpp b/include/cru/ui/click_detector.hpp index 9b59c717..6c4761e7 100644 --- a/include/cru/ui/click_detector.hpp +++ b/include/cru/ui/click_detector.hpp @@ -1,8 +1,6 @@ #pragma once #include "control.hpp" -#include <optional> -#include <vector> namespace cru::ui { class ClickEventArgs : Object { diff --git a/include/cru/ui/control.hpp b/include/cru/ui/control.hpp index 1fe49261..95e2cf52 100644 --- a/include/cru/ui/control.hpp +++ b/include/cru/ui/control.hpp @@ -2,23 +2,12 @@ #include "base.hpp" #include "cru/common/event.hpp" +#include "render/base.hpp" #include "ui_event.hpp" -#include <functional> -#include <memory> #include <string_view> -#include <vector> - -namespace cru::platform::native { -struct ICursor; -} namespace cru::ui { -class Window; -namespace render { -class RenderObject; -} // namespace render - class Control : public Object { friend class Window; diff --git a/include/cru/ui/controls/button.hpp b/include/cru/ui/controls/button.hpp index b24a9934..a95b75ce 100644 --- a/include/cru/ui/controls/button.hpp +++ b/include/cru/ui/controls/button.hpp @@ -2,14 +2,8 @@ #include "../content_control.hpp" #include "../click_detector.hpp" -#include "../render/border_render_object.hpp" -#include "cru/platform/native/basic_types.hpp" - -#include <memory> namespace cru::ui::controls { -using render::CornerRadius; - struct ButtonStateStyle { std::shared_ptr<platform::graph::IBrush> border_brush; Thickness border_thickness; @@ -43,7 +37,7 @@ class Button : public ContentControl { Button(Button&& other) = delete; Button& operator=(const Button& other) = delete; Button& operator=(Button&& other) = delete; - ~Button() override = default; + ~Button() override; std::string_view GetControlType() const final { return control_type; } diff --git a/include/cru/ui/controls/container.hpp b/include/cru/ui/controls/container.hpp index efc099f7..d6aa5635 100644 --- a/include/cru/ui/controls/container.hpp +++ b/include/cru/ui/controls/container.hpp @@ -1,10 +1,6 @@ #pragma once #include "../content_control.hpp" -namespace cru::ui::render { -class BorderRenderObject; -} - namespace cru::ui::controls { class Container : public ContentControl { static constexpr std::string_view control_type = "Container"; @@ -19,9 +15,7 @@ class Container : public ContentControl { ~Container() override; public: - std::string_view GetControlType() const final { - return control_type; - } + std::string_view GetControlType() const final { return control_type; } render::RenderObject* GetRenderObject() const override; diff --git a/include/cru/ui/controls/flex_layout.hpp b/include/cru/ui/controls/flex_layout.hpp index 7861534a..52eaec75 100644 --- a/include/cru/ui/controls/flex_layout.hpp +++ b/include/cru/ui/controls/flex_layout.hpp @@ -1,17 +1,7 @@ #pragma once #include "../layout_control.hpp" -#include "../render/flex_layout_render_object.hpp" - -#include <memory> - namespace cru::ui::controls { -// import these basic entities -using render::FlexChildLayoutData; -using render::FlexCrossAlignment; -using render::FlexDirection; -using render::FlexMainAlignment; - class FlexLayout : public LayoutControl { public: static constexpr std::string_view control_type = "FlexLayout"; @@ -26,29 +16,17 @@ class FlexLayout : public LayoutControl { FlexLayout(FlexLayout&& other) = delete; FlexLayout& operator=(const FlexLayout& other) = delete; FlexLayout& operator=(FlexLayout&& other) = delete; - ~FlexLayout() override = default; + ~FlexLayout() override; std::string_view GetControlType() const final { return control_type; } render::RenderObject* GetRenderObject() const override; - FlexMainAlignment GetContentMainAlign() const { - return render_object_->GetContentMainAlign(); - } - - void SetContentMainAlign(FlexMainAlignment value) { - if (value == GetContentMainAlign()) return; - render_object_->SetContentMainAlign(value); - } - - FlexDirection GetFlexDirection() const { - return render_object_->GetFlexDirection(); - } + FlexMainAlignment GetContentMainAlign() const; + void SetContentMainAlign(FlexMainAlignment value); - void SetFlexDirection(FlexDirection direction) { - if (direction == GetFlexDirection()) return; - render_object_->SetFlexDirection(direction); - } + FlexDirection GetFlexDirection() const; + void SetFlexDirection(FlexDirection direction); FlexChildLayoutData GetChildLayoutData(Control* control); void SetChildLayoutData(Control* control, const FlexChildLayoutData& data); diff --git a/include/cru/ui/controls/stack_layout.hpp b/include/cru/ui/controls/stack_layout.hpp index 298de089..93861c19 100644 --- a/include/cru/ui/controls/stack_layout.hpp +++ b/include/cru/ui/controls/stack_layout.hpp @@ -1,12 +1,6 @@ #pragma once #include "../layout_control.hpp" -#include <memory> - -namespace cru::ui::render { -class StackLayoutRenderObject; -} - namespace cru::ui::controls { class StackLayout : public LayoutControl { public: diff --git a/include/cru/ui/controls/text_block.hpp b/include/cru/ui/controls/text_block.hpp index 02e0eb2b..db0fb4e5 100644 --- a/include/cru/ui/controls/text_block.hpp +++ b/include/cru/ui/controls/text_block.hpp @@ -3,14 +3,6 @@ #include "text_common.hpp" -#include <memory> - -namespace cru::ui::render { -class StackLayoutRenderObject; -class TextRenderObject; -class CanvasRenderObject; -} // namespace cru::ui::render - namespace cru::ui::controls { class TextBlock : public NoChildControl, public virtual ITextControl { public: diff --git a/include/cru/ui/controls/text_box.hpp b/include/cru/ui/controls/text_box.hpp index 888a9527..a7e4dfa0 100644 --- a/include/cru/ui/controls/text_box.hpp +++ b/include/cru/ui/controls/text_box.hpp @@ -1,15 +1,6 @@ #pragma once #include "../no_child_control.hpp" -#include <memory> - -namespace cru::ui::render { -class BorderRenderObject; -class StackLayoutRenderObject; -class TextRenderObject; -class CanvasRenderObject; -} // namespace cru::ui::render - namespace cru::ui::controls { class TextBox : public NoChildControl { public: diff --git a/include/cru/ui/controls/text_common.hpp b/include/cru/ui/controls/text_common.hpp index fbef6b06..64a9666c 100644 --- a/include/cru/ui/controls/text_common.hpp +++ b/include/cru/ui/controls/text_common.hpp @@ -3,9 +3,6 @@ #include "cru/ui/ui_event.hpp" -#include <functional> -#include <optional> - namespace cru::platform::graph { struct IBrush; } 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: diff --git a/include/cru/ui/ui_manager.hpp b/include/cru/ui/ui_manager.hpp index 8e5c7075..b2137c67 100644 --- a/include/cru/ui/ui_manager.hpp +++ b/include/cru/ui/ui_manager.hpp @@ -3,13 +3,6 @@ #include "controls/button.hpp" -#include <memory> - -namespace cru::platform::graph { -struct IBrush; -struct IFont; -} // namespace cru::platform::graph - namespace cru::ui { struct ThemeResources { std::shared_ptr<platform::graph::IFont> default_font; @@ -31,7 +24,7 @@ class UiManager : public Object { UiManager(UiManager&& other) = delete; UiManager& operator=(const UiManager& other) = delete; UiManager& operator=(UiManager&& other) = delete; - ~UiManager() override = default; + ~UiManager() override; ThemeResources* GetThemeResources() { return &theme_resource_; } diff --git a/include/cru/ui/window.hpp b/include/cru/ui/window.hpp index 9f37c9d5..251712cf 100644 --- a/include/cru/ui/window.hpp +++ b/include/cru/ui/window.hpp @@ -2,21 +2,8 @@ #include "content_control.hpp" #include "cru/common/self_resolvable.hpp" -#include "cru/platform/native/event.hpp" - -#include <memory> -#include <vector> - -namespace cru::platform::native { -struct INativeWindow; -struct INativeWindowResolver; -} // namespace cru::platform::native namespace cru::ui { -namespace render { -class WindowRenderObject; -} - // TODO: Make Window able to be invalid and handle operations in invalidity // situation. class Window final : public ContentControl, public SelfResolvable<Window> { diff --git a/src/platform/native/CMakeLists.txt b/src/platform/native/CMakeLists.txt index c3ca3d7e..5caf84e4 100644 --- a/src/platform/native/CMakeLists.txt +++ b/src/platform/native/CMakeLists.txt @@ -3,9 +3,8 @@ add_library(cru_platform_native STATIC ui_application.cpp ) target_sources(cru_platform_native PUBLIC - ${CRU_PLATFORM_NATIVE_INCLUDE_DIR}/basic_types.hpp + ${CRU_PLATFORM_NATIVE_INCLUDE_DIR}/base.hpp ${CRU_PLATFORM_NATIVE_INCLUDE_DIR}/cursor.hpp - ${CRU_PLATFORM_NATIVE_INCLUDE_DIR}/event.hpp ${CRU_PLATFORM_NATIVE_INCLUDE_DIR}/window.hpp ${CRU_PLATFORM_NATIVE_INCLUDE_DIR}/ui_application.hpp ) diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index dbd42d38..14cbf2fb 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -45,6 +45,7 @@ target_sources(cru_ui PUBLIC ${CRU_UI_INCLUDE_DIR}/controls/text_box.hpp ${CRU_UI_INCLUDE_DIR}/controls/text_block.hpp ${CRU_UI_INCLUDE_DIR}/controls/text_common.hpp + ${CRU_UI_INCLUDE_DIR}/render/base.hpp ${CRU_UI_INCLUDE_DIR}/render/border_render_object.hpp ${CRU_UI_INCLUDE_DIR}/render/canvas_render_object.hpp ${CRU_UI_INCLUDE_DIR}/render/flex_layout_render_object.hpp diff --git a/src/ui/control.cpp b/src/ui/control.cpp index cde602b7..04d89b5f 100644 --- a/src/ui/control.cpp +++ b/src/ui/control.cpp @@ -1,6 +1,5 @@ #include "cru/ui/control.hpp" -#include "cru/platform/native/basic_types.hpp" #include "cru/platform/native/cursor.hpp" #include "cru/platform/native/ui_application.hpp" #include "cru/platform/native/window.hpp" diff --git a/src/ui/controls/button.cpp b/src/ui/controls/button.cpp index 7dc5a5d7..7dd087ba 100644 --- a/src/ui/controls/button.cpp +++ b/src/ui/controls/button.cpp @@ -58,6 +58,8 @@ Button::Button() : click_detector_(this) { }); } +Button::~Button() = default; + render::RenderObject* Button::GetRenderObject() const { return render_object_.get(); } diff --git a/src/ui/controls/flex_layout.cpp b/src/ui/controls/flex_layout.cpp index 6ea26d92..1c649e3b 100644 --- a/src/ui/controls/flex_layout.cpp +++ b/src/ui/controls/flex_layout.cpp @@ -10,6 +10,8 @@ FlexLayout::FlexLayout() { render_object_->SetAttachedControl(this); } +FlexLayout::~FlexLayout() = default; + render::RenderObject* FlexLayout::GetRenderObject() const { return render_object_.get(); } @@ -39,6 +41,24 @@ void FlexLayout::SetChildLayoutData(Control* control, FindPosition(render_object_.get(), control->GetRenderObject())) = data; } +FlexMainAlignment FlexLayout::GetContentMainAlign() const { + return render_object_->GetContentMainAlign(); +} + +void FlexLayout::SetContentMainAlign(FlexMainAlignment value) { + if (value == GetContentMainAlign()) return; + render_object_->SetContentMainAlign(value); +} + +FlexDirection FlexLayout::GetFlexDirection() const { + return render_object_->GetFlexDirection(); +} + +void FlexLayout::SetFlexDirection(FlexDirection direction) { + if (direction == GetFlexDirection()) return; + render_object_->SetFlexDirection(direction); +} + void FlexLayout::OnAddChild(Control* child, int position) { render_object_->AddChild(child->GetRenderObject(), position); } diff --git a/src/ui/ui_manager.cpp b/src/ui/ui_manager.cpp index 2a6d6e5b..5c7e4577 100644 --- a/src/ui/ui_manager.cpp +++ b/src/ui/ui_manager.cpp @@ -58,6 +58,8 @@ UiManager::UiManager() { theme_resource_.button_style.hover.border_radius = theme_resource_.button_style.press.border_radius = theme_resource_.button_style.press_cancel.border_radius = - controls::CornerRadius({5, 5}); + CornerRadius({5, 5}); } + +UiManager::~UiManager() = default; } // namespace cru::ui diff --git a/src/win/native/dpi_util.hpp b/src/win/native/dpi_util.hpp index 0ebcd7e2..d8c5610c 100644 --- a/src/win/native/dpi_util.hpp +++ b/src/win/native/dpi_util.hpp @@ -1,5 +1,5 @@ #pragma once -#include "cru/platform/native/basic_types.hpp" +#include "cru/platform/native/base.hpp" // The dpi awareness needs to be implemented in the future. Currently we use 96 // as default. |