From b53527fbe50a953ad0e3225cc812eb76b8a1f82d Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 27 Jun 2019 17:02:58 +0800 Subject: ... --- include/cru/ui/render/border_render_object.hpp | 22 +++++++------- .../cru/ui/render/flex_layout_render_object.hpp | 2 +- include/cru/ui/render/render_object.hpp | 6 ++-- include/cru/ui/render/text_render_object.hpp | 34 +++++++++++----------- include/cru/ui/render/window_render_object.hpp | 2 +- 5 files changed, 34 insertions(+), 32 deletions(-) (limited to 'include/cru/ui/render') diff --git a/include/cru/ui/render/border_render_object.hpp b/include/cru/ui/render/border_render_object.hpp index 407edbb3..ab424e60 100644 --- a/include/cru/ui/render/border_render_object.hpp +++ b/include/cru/ui/render/border_render_object.hpp @@ -4,9 +4,9 @@ #include namespace cru::platform::graph { -struct IBrush; -struct IGeometry; -} // namespace cru::platform +class Brush; +class Geometry; +} // namespace cru::platform::graph namespace cru::ui::render { struct CornerRadius { @@ -32,7 +32,7 @@ struct CornerRadius { class BorderRenderObject : public RenderObject { public: - explicit BorderRenderObject(std::shared_ptr brush); + explicit BorderRenderObject(std::shared_ptr brush); BorderRenderObject(const BorderRenderObject& other) = delete; BorderRenderObject(BorderRenderObject&& other) = delete; BorderRenderObject& operator=(const BorderRenderObject& other) = delete; @@ -42,8 +42,10 @@ class BorderRenderObject : public RenderObject { bool IsEnabled() const { return is_enabled_; } void SetEnabled(bool enabled) { is_enabled_ = enabled; } - std::shared_ptr GetBrush() const { return border_brush_; } - void SetBrush(std::shared_ptr new_brush) { + std::shared_ptr GetBrush() const { + return border_brush_; + } + void SetBrush(std::shared_ptr new_brush) { border_brush_ = std::move(new_brush); } @@ -59,7 +61,7 @@ class BorderRenderObject : public RenderObject { void Refresh() { RecreateGeometry(); } - void Draw(platform::graph::IPainter* painter) override; + void Draw(platform::graph::Painter* painter) override; RenderObject* HitTest(const Point& point) override; @@ -83,11 +85,11 @@ class BorderRenderObject : public RenderObject { private: bool is_enabled_ = false; - std::shared_ptr border_brush_ = nullptr; + std::shared_ptr border_brush_ = nullptr; Thickness border_thickness_{}; CornerRadius corner_radius_{}; - std::shared_ptr geometry_ = nullptr; - std::shared_ptr border_outer_geometry_ = nullptr; + std::shared_ptr geometry_ = nullptr; + std::shared_ptr border_outer_geometry_ = nullptr; }; } // namespace cru::ui::render diff --git a/include/cru/ui/render/flex_layout_render_object.hpp b/include/cru/ui/render/flex_layout_render_object.hpp index 8d881239..1234b920 100644 --- a/include/cru/ui/render/flex_layout_render_object.hpp +++ b/include/cru/ui/render/flex_layout_render_object.hpp @@ -64,7 +64,7 @@ class FlexLayoutRenderObject : public RenderObject { FlexChildLayoutData* GetChildLayoutData(int position); - void Draw(platform::graph::IPainter* painter) override; + void Draw(platform::graph::Painter* painter) override; RenderObject* HitTest(const Point& point) override; diff --git a/include/cru/ui/render/render_object.hpp b/include/cru/ui/render/render_object.hpp index b6614317..dca254cc 100644 --- a/include/cru/ui/render/render_object.hpp +++ b/include/cru/ui/render/render_object.hpp @@ -1,7 +1,7 @@ #pragma once #include "cru/common/base.hpp" -#include "cru/common/ui_base.hpp" +#include "../base.hpp" #include @@ -11,7 +11,7 @@ class Control; } namespace cru::platform::graph { -struct IPainter; +class Painter; } namespace cru::ui::render { @@ -58,7 +58,7 @@ class RenderObject : public Object { void Measure(const Size& available_size); void Layout(const Rect& rect); - virtual void Draw(platform::graph::IPainter* painter) = 0; + virtual void Draw(platform::graph::Painter* painter) = 0; virtual RenderObject* HitTest(const Point& point) = 0; diff --git a/include/cru/ui/render/text_render_object.hpp b/include/cru/ui/render/text_render_object.hpp index ecad6bb8..054d9b47 100644 --- a/include/cru/ui/render/text_render_object.hpp +++ b/include/cru/ui/render/text_render_object.hpp @@ -6,17 +6,17 @@ // forward declarations namespace cru::platform::graph { -struct IBrush; -struct IFontDescriptor; -struct ITextLayout; +class Brush; +class Font; +class TextLayout; } // namespace cru::platform::graph namespace cru::ui::render { class TextRenderObject : public RenderObject { public: - TextRenderObject(std::shared_ptr brush, - std::shared_ptr font, - std::shared_ptr selection_brush); + TextRenderObject(std::shared_ptr brush, + std::shared_ptr font, + std::shared_ptr selection_brush); TextRenderObject(const TextRenderObject& other) = delete; TextRenderObject(TextRenderObject&& other) = delete; TextRenderObject& operator=(const TextRenderObject& other) = delete; @@ -26,13 +26,13 @@ class TextRenderObject : public RenderObject { std::wstring GetText() const; void SetText(std::wstring new_text); - std::shared_ptr GetBrush() const { return brush_; } - void SetBrush(std::shared_ptr new_brush) { + std::shared_ptr GetBrush() const { return brush_; } + void SetBrush(std::shared_ptr new_brush) { new_brush.swap(brush_); } - std::shared_ptr GetFont() const; - void SetFont(std::shared_ptr font); + std::shared_ptr GetFont() const; + void SetFont(std::shared_ptr font); std::optional GetSelectionRange() const { return selection_range_; @@ -41,14 +41,14 @@ class TextRenderObject : public RenderObject { selection_range_ = std::move(new_range); } - std::shared_ptr GetSelectionBrush() const { + std::shared_ptr GetSelectionBrush() const { return selection_brush_; } - void SetSelectionBrush(std::shared_ptr new_brush) { + void SetSelectionBrush(std::shared_ptr new_brush) { new_brush.swap(selection_brush_); } - void Draw(platform::graph::IPainter* painter) override; + void Draw(platform::graph::Painter* painter) override; RenderObject* HitTest(const Point& point) override; @@ -59,11 +59,11 @@ class TextRenderObject : public RenderObject { void OnLayoutContent(const Rect& content_rect) override; private: - std::shared_ptr brush_; - std::shared_ptr font_; - std::shared_ptr text_layout_; + std::shared_ptr brush_; + std::shared_ptr font_; + std::shared_ptr text_layout_; std::optional selection_range_ = std::nullopt; - std::shared_ptr selection_brush_; + std::shared_ptr selection_brush_; }; } // 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 b95acbce..dfeae487 100644 --- a/include/cru/ui/render/window_render_object.hpp +++ b/include/cru/ui/render/window_render_object.hpp @@ -17,7 +17,7 @@ class WindowRenderObject : public RenderObject { void MeasureAndLayout(); - void Draw(platform::graph::IPainter* painter) override; + void Draw(platform::graph::Painter* painter) override; RenderObject* HitTest(const Point& point) override; -- cgit v1.2.3