diff options
| author | Yuqian Yang <crupest@crupest.life> | 2025-11-21 21:43:42 +0800 |
|---|---|---|
| committer | Yuqian Yang <crupest@crupest.life> | 2025-11-21 22:13:54 +0800 |
| commit | fd61739197ec009d47da87a7cc66970a55f12db4 (patch) | |
| tree | bb2bc007aaf9b47fecb090df96c23b5ee6a898e3 /include/cru/ui/render/RenderObject.h | |
| parent | 3b875091c445b7465b9bd044914318989a94d2ad (diff) | |
| download | cru-fd61739197ec009d47da87a7cc66970a55f12db4.tar.gz cru-fd61739197ec009d47da87a7cc66970a55f12db4.tar.bz2 cru-fd61739197ec009d47da87a7cc66970a55f12db4.zip | |
Clean codes. Remove member function const in RenderObject.
Diffstat (limited to 'include/cru/ui/render/RenderObject.h')
| -rw-r--r-- | include/cru/ui/render/RenderObject.h | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/include/cru/ui/render/RenderObject.h b/include/cru/ui/render/RenderObject.h index c7e534a8..5569c788 100644 --- a/include/cru/ui/render/RenderObject.h +++ b/include/cru/ui/render/RenderObject.h @@ -5,6 +5,7 @@ #include <cru/base/Event.h> #include <cru/platform/graphics/Painter.h> +#include <string> namespace cru::ui::render { struct BoxConstraint { @@ -61,52 +62,52 @@ struct BoxConstraint { * content_rect) override; */ class CRU_UI_API RenderObject : public Object { - CRU_DEFINE_CLASS_LOG_TAG("RenderObject") + CRU_DEFINE_CLASS_LOG_TAG("cru::ui::render::RenderObject") public: + RenderObject(std::string name); ~RenderObject() override; - controls::Control* GetAttachedControl() const { return control_; } + controls::Control* GetAttachedControl() { return control_; } void SetAttachedControl(controls::Control* new_control); - RenderObject* GetParent() const { return parent_; } + RenderObject* GetParent() { return parent_; } void SetParent(RenderObject* new_parent); // Offset from parent's lefttop to lefttop of this render object. Margin is // accounted for. - Point GetOffset() const { return offset_; } - Size GetSize() const { return size_; } + Point GetOffset() { return offset_; } + Size GetSize() { return size_; } - Point GetTotalOffset() const; - Point FromRootToContent(const Point& point) const; + Point GetTotalOffset(); + Point FromRootToContent(const Point& point); - Size GetDesiredSize() const { return desired_size_; } + Size GetDesiredSize() { return desired_size_; } - Thickness GetMargin() const { return margin_; } + Thickness GetMargin() { return margin_; } void SetMargin(const Thickness& margin); - Thickness GetPadding() const { return padding_; } + Thickness GetPadding() { return padding_; } void SetPadding(const Thickness& padding); - MeasureSize GetPreferredSize() const { return preferred_size_; } + MeasureSize GetPreferredSize() { return preferred_size_; } void SetPreferredSize(const MeasureSize& preferred_size); - MeasureSize GetMinSize() const { return custom_measure_requirement_.min; } + MeasureSize GetMinSize() { return custom_measure_requirement_.min; } void SetMinSize(const MeasureSize& min_size); - MeasureSize GetMaxSize() const { return custom_measure_requirement_.max; } + MeasureSize GetMaxSize() { return custom_measure_requirement_.max; } void SetMaxSize(const MeasureSize& max_size); - MeasureRequirement GetCustomMeasureRequirement() const { + MeasureRequirement GetCustomMeasureRequirement() { return custom_measure_requirement_; } - Size GetMinSize1() const { return min_size_; } + Size GetMinSize1() { return min_size_; } void SetMinSize1(const Size& min_size); - Size GetMaxSize1() const { return max_size_; } + Size GetMaxSize1() { return max_size_; } void SetMaxSize1(const Size& max_size); - BoxConstraint CalculateMergedConstraint( - const BoxConstraint& constraint) const; + BoxConstraint CalculateMergedConstraint(const BoxConstraint& constraint); // This method will merge requirement passed by argument and requirement of // the render object using MeasureRequirement::Merge and then call @@ -122,11 +123,11 @@ class CRU_UI_API RenderObject : public Object { Size Measure1(const BoxConstraint& constraint); - virtual Thickness GetTotalSpaceThickness() const; - virtual Thickness GetInnerSpaceThickness() const; + virtual Thickness GetTotalSpaceThickness(); + virtual Thickness GetInnerSpaceThickness(); - virtual Rect GetPaddingRect() const; - virtual Rect GetContentRect() const; + virtual Rect GetPaddingRect(); + virtual Rect GetContentRect(); virtual void Draw(platform::graphics::IPainter* painter) = 0; @@ -140,8 +141,8 @@ class CRU_UI_API RenderObject : public Object { void InvalidatePaint(); public: - virtual std::string GetName() const; - std::string GetDebugPathInTree() const; + std::string GetName(); + std::string GetDebugPathInTree(); CRU_DEFINE_EVENT(Destroy, RenderObject*) @@ -180,6 +181,7 @@ class CRU_UI_API RenderObject : public Object { virtual void OnResize(const Size& new_size) {} private: + std::string name_; controls::Control* control_ = nullptr; RenderObject* parent_ = nullptr; |
