diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/cru/ui/Base.h | 42 | ||||
-rw-r--r-- | include/cru/ui/components/Component.h | 9 | ||||
-rw-r--r-- | include/cru/ui/controls/Control.h | 1 | ||||
-rw-r--r-- | include/cru/ui/controls/StackLayout.h | 2 | ||||
-rw-r--r-- | include/cru/ui/helper/ClickDetector.h | 4 | ||||
-rw-r--r-- | include/cru/ui/render/CanvasRenderObject.h | 17 | ||||
-rw-r--r-- | include/cru/ui/render/StackLayoutRenderObject.h | 5 | ||||
-rw-r--r-- | include/cru/ui/style/Styler.h | 2 |
8 files changed, 34 insertions, 48 deletions
diff --git a/include/cru/ui/Base.h b/include/cru/ui/Base.h index b16edbfc..4316fbbb 100644 --- a/include/cru/ui/Base.h +++ b/include/cru/ui/Base.h @@ -38,7 +38,6 @@ namespace colors = cru::platform::colors; //-------------------- region: forward declaration -------------------- namespace controls { -class Window; class Control; } // namespace controls @@ -46,27 +45,9 @@ namespace host { class WindowHost; } -namespace style { -class StyleRuleSet; -class StyleRuleSetBind; -} // namespace style - //-------------------- region: basic types -------------------- enum class Direction { Horizontal, Vertical }; - -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 Alignment { - Start = internal::align_start, - End = internal::align_end, - Center = internal::align_center, - Stretch = internal::align_stretch -}; +enum class Alignment { Start, End, Center, Stretch }; struct CornerRadius { constexpr CornerRadius() @@ -107,25 +88,4 @@ inline bool operator!=(const CornerRadius& left, const CornerRadius& right) { return !(left == right); } -class CanvasPaintEventArgs { - public: - CanvasPaintEventArgs(platform::graphics::IPainter* painter, - const Size& paint_size) - : painter_(painter), paint_size_(paint_size) {} - CRU_DEFAULT_COPY(CanvasPaintEventArgs) - CRU_DEFAULT_MOVE(CanvasPaintEventArgs) - ~CanvasPaintEventArgs() = default; - - platform::graphics::IPainter* GetPainter() const { return painter_; } - Size GetPaintSize() const { return paint_size_; } - - private: - platform::graphics::IPainter* painter_; - Size paint_size_; -}; - -struct StackChildLayoutData { - std::optional<Alignment> horizontal; - std::optional<Alignment> vertical; -}; } // namespace cru::ui diff --git a/include/cru/ui/components/Component.h b/include/cru/ui/components/Component.h index 8861f30b..795d0db0 100644 --- a/include/cru/ui/components/Component.h +++ b/include/cru/ui/components/Component.h @@ -3,9 +3,10 @@ namespace cru::ui::components { /** - * \remarks In destructor, component should first delete all child components - * and then remove root control from its parent (by calling - * Control::RemoveFromParent). Then delete all its root control. + * \brief A component is a composition of controls. + * \remarks In destructor, component should remove root control from its parent + * by calling Control::RemoveFromParent. It should respect children's + * Component::IsDeleteByParent value and decide whether to delete it. */ class CRU_UI_API Component : public Object { public: @@ -27,6 +28,6 @@ class CRU_UI_API Component : public Object { } private: - bool delete_by_parent_; + bool delete_by_parent_ = false; }; } // namespace cru::ui::components diff --git a/include/cru/ui/controls/Control.h b/include/cru/ui/controls/Control.h index 1d976970..97096e35 100644 --- a/include/cru/ui/controls/Control.h +++ b/include/cru/ui/controls/Control.h @@ -2,6 +2,7 @@ #include "../Base.h" #include "../events/UiEvents.h" #include "../render/RenderObject.h" +#include "../style/StyleRuleSet.h" namespace cru::ui::controls { diff --git a/include/cru/ui/controls/StackLayout.h b/include/cru/ui/controls/StackLayout.h index 82826171..cbf35cbe 100644 --- a/include/cru/ui/controls/StackLayout.h +++ b/include/cru/ui/controls/StackLayout.h @@ -4,6 +4,8 @@ #include "../render/StackLayoutRenderObject.h" namespace cru::ui::controls { +using render::StackChildLayoutData; + class CRU_UI_API StackLayout : public LayoutControl<render::StackLayoutRenderObject> { public: diff --git a/include/cru/ui/helper/ClickDetector.h b/include/cru/ui/helper/ClickDetector.h index 6e30aaf0..1cfb26bc 100644 --- a/include/cru/ui/helper/ClickDetector.h +++ b/include/cru/ui/helper/ClickDetector.h @@ -1,5 +1,7 @@ #pragma once -#include "../controls/Control.h" +#include "../Base.h" + +#include "cru/common/Event.h" namespace cru::ui::helper { class CRU_UI_API ClickEventArgs : Object { diff --git a/include/cru/ui/render/CanvasRenderObject.h b/include/cru/ui/render/CanvasRenderObject.h index 8343a5f5..2488dc91 100644 --- a/include/cru/ui/render/CanvasRenderObject.h +++ b/include/cru/ui/render/CanvasRenderObject.h @@ -4,6 +4,23 @@ #include "cru/common/Event.h" namespace cru::ui::render { +class CanvasPaintEventArgs { + public: + CanvasPaintEventArgs(platform::graphics::IPainter* painter, + const Size& paint_size) + : painter_(painter), paint_size_(paint_size) {} + CRU_DEFAULT_COPY(CanvasPaintEventArgs) + CRU_DEFAULT_MOVE(CanvasPaintEventArgs) + ~CanvasPaintEventArgs() = default; + + platform::graphics::IPainter* GetPainter() const { return painter_; } + Size GetPaintSize() const { return paint_size_; } + + private: + platform::graphics::IPainter* painter_; + Size paint_size_; +}; + // Layout logic: // If no preferred size is set. Then (100, 100) is used and then coerced to // required range. diff --git a/include/cru/ui/render/StackLayoutRenderObject.h b/include/cru/ui/render/StackLayoutRenderObject.h index 65b81b3d..b522ecbb 100644 --- a/include/cru/ui/render/StackLayoutRenderObject.h +++ b/include/cru/ui/render/StackLayoutRenderObject.h @@ -2,6 +2,11 @@ #include "LayoutRenderObject.h" namespace cru::ui::render { +struct StackChildLayoutData { + std::optional<Alignment> horizontal; + std::optional<Alignment> vertical; +}; + // Measure Logic: // Following rules are applied both horizontally and vertically. // diff --git a/include/cru/ui/style/Styler.h b/include/cru/ui/style/Styler.h index 9bdec294..6f84329f 100644 --- a/include/cru/ui/style/Styler.h +++ b/include/cru/ui/style/Styler.h @@ -1,10 +1,8 @@ #pragma once #include "../Base.h" #include "ApplyBorderStyleInfo.h" -#include "cru/common/Base.h" #include "cru/common/ClonablePtr.h" #include "cru/platform/gui/Cursor.h" -#include "cru/ui/controls/Control.h" #include <memory> #include <vector> |