aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/cru/ui/render/BorderRenderObject.h21
-rw-r--r--include/cru/ui/render/CanvasRenderObject.h9
-rw-r--r--include/cru/ui/render/FlexLayoutRenderObject.h18
-rw-r--r--include/cru/ui/render/GeometryRenderObject.h24
-rw-r--r--include/cru/ui/render/LayoutRenderObject.h11
-rw-r--r--include/cru/ui/render/RenderObject.h50
-rw-r--r--include/cru/ui/render/ScrollBar.h27
-rw-r--r--include/cru/ui/render/ScrollRenderObject.h18
-rw-r--r--include/cru/ui/render/SingleChildRenderObject.h7
-rw-r--r--include/cru/ui/render/StackLayoutRenderObject.h13
-rw-r--r--include/cru/ui/render/TextRenderObject.h30
-rw-r--r--include/cru/ui/render/TreeRenderObject.h21
12 files changed, 103 insertions, 146 deletions
diff --git a/include/cru/ui/render/BorderRenderObject.h b/include/cru/ui/render/BorderRenderObject.h
index 001494a6..16f04962 100644
--- a/include/cru/ui/render/BorderRenderObject.h
+++ b/include/cru/ui/render/BorderRenderObject.h
@@ -6,15 +6,14 @@
namespace cru::ui::render {
class CRU_UI_API BorderRenderObject : public SingleChildRenderObject {
- CRU_DEFINE_CLASS_LOG_TAG("BorderRenderObject")
+ CRU_DEFINE_CLASS_LOG_TAG("cru::ui::render::BorderRenderObject")
public:
+ static constexpr auto kRenderObjectName = "BorderRenderObject";
+
BorderRenderObject();
- CRU_DELETE_COPY(BorderRenderObject)
- CRU_DELETE_MOVE(BorderRenderObject)
- ~BorderRenderObject() override;
- bool IsBorderEnabled() const { return is_border_enabled_; }
+ bool IsBorderEnabled() { return is_border_enabled_; }
void SetBorderEnabled(bool enabled);
std::shared_ptr<platform::graphics::IBrush> GetBorderBrush() {
@@ -22,7 +21,7 @@ class CRU_UI_API BorderRenderObject : public SingleChildRenderObject {
}
void SetBorderBrush(std::shared_ptr<platform::graphics::IBrush> brush);
- Thickness GetBorderThickness() const { return border_thickness_; }
+ Thickness GetBorderThickness() { return border_thickness_; }
void SetBorderThickness(const Thickness thickness);
CornerRadius GetBorderRadius() { return border_radius_; }
@@ -45,12 +44,10 @@ class CRU_UI_API BorderRenderObject : public SingleChildRenderObject {
RenderObject* HitTest(const Point& point) override;
void Draw(platform::graphics::IPainter* painter) override;
- Thickness GetTotalSpaceThickness() const override;
- Thickness GetInnerSpaceThickness() const override;
- Rect GetPaddingRect() const override;
- Rect GetContentRect() const override;
-
- std::string GetName() const override;
+ Thickness GetTotalSpaceThickness() override;
+ Thickness GetInnerSpaceThickness() override;
+ Rect GetPaddingRect() override;
+ Rect GetContentRect() override;
protected:
Size OnMeasureContent(const MeasureRequirement& requirement,
diff --git a/include/cru/ui/render/CanvasRenderObject.h b/include/cru/ui/render/CanvasRenderObject.h
index dfe8f090..3471d75f 100644
--- a/include/cru/ui/render/CanvasRenderObject.h
+++ b/include/cru/ui/render/CanvasRenderObject.h
@@ -26,17 +26,14 @@ class CanvasPaintEventArgs {
// required range.
class CRU_UI_API CanvasRenderObject : public RenderObject {
public:
- CanvasRenderObject();
-
- CRU_DELETE_COPY(CanvasRenderObject)
- CRU_DELETE_MOVE(CanvasRenderObject)
+ static constexpr auto kRenderObjectName = "CanvasRenderObject";
- ~CanvasRenderObject();
+ CanvasRenderObject();
public:
RenderObject* HitTest(const Point& point) override;
- Size GetDesiredSize() const { return desired_size_; }
+ Size GetDesiredSize() { return desired_size_; }
IEvent<CanvasPaintEventArgs>* PaintEvent() { return &paint_event_; }
diff --git a/include/cru/ui/render/FlexLayoutRenderObject.h b/include/cru/ui/render/FlexLayoutRenderObject.h
index bf68720a..82ac6639 100644
--- a/include/cru/ui/render/FlexLayoutRenderObject.h
+++ b/include/cru/ui/render/FlexLayoutRenderObject.h
@@ -93,32 +93,26 @@ struct FlexChildLayoutData {
//
class CRU_UI_API FlexLayoutRenderObject
: public LayoutRenderObject<FlexChildLayoutData> {
- CRU_DEFINE_CLASS_LOG_TAG("FlexLayoutRenderObject")
+ CRU_DEFINE_CLASS_LOG_TAG("cru::ui::render::FlexLayoutRenderObject")
public:
- FlexLayoutRenderObject() = default;
- FlexLayoutRenderObject(const FlexLayoutRenderObject& other) = delete;
- FlexLayoutRenderObject& operator=(const FlexLayoutRenderObject& other) =
- delete;
- FlexLayoutRenderObject(FlexLayoutRenderObject&& other) = delete;
- FlexLayoutRenderObject& operator=(FlexLayoutRenderObject&& other) = delete;
- ~FlexLayoutRenderObject() override = default;
+ static constexpr auto kRenderObjectName = "FlexLayoutRenderObject";
- std::string GetName() const override;
+ FlexLayoutRenderObject();
- FlexDirection GetFlexDirection() const { return direction_; }
+ FlexDirection GetFlexDirection() { return direction_; }
void SetFlexDirection(FlexDirection direction) {
direction_ = direction;
InvalidateLayout();
}
- FlexMainAlignment GetContentMainAlign() const { return content_main_align_; }
+ FlexMainAlignment GetContentMainAlign() { return content_main_align_; }
void SetContentMainAlign(FlexMainAlignment align) {
content_main_align_ = align;
InvalidateLayout();
}
- FlexCrossAlignment GetItemCrossAlign() const { return item_cross_align_; }
+ FlexCrossAlignment GetItemCrossAlign() { return item_cross_align_; }
void SetItemCrossAlign(FlexCrossAlignment align) {
item_cross_align_ = align;
InvalidateLayout();
diff --git a/include/cru/ui/render/GeometryRenderObject.h b/include/cru/ui/render/GeometryRenderObject.h
index 5d2ba1e0..1c998ef0 100644
--- a/include/cru/ui/render/GeometryRenderObject.h
+++ b/include/cru/ui/render/GeometryRenderObject.h
@@ -1,39 +1,37 @@
#pragma once
+#include "MeasureRequirement.h"
#include "RenderObject.h"
-#include "cru/platform/graphics/Brush.h"
-#include "cru/platform/graphics/Geometry.h"
-#include "cru/ui/render/MeasureRequirement.h"
+
+#include <cru/platform/graphics/Brush.h>
+#include <cru/platform/graphics/Geometry.h>
#include <optional>
namespace cru::ui::render {
class GeometryRenderObject : public RenderObject {
public:
- GeometryRenderObject();
+ static constexpr auto kRenderObjectName = "GeometryRenderObject";
- CRU_DELETE_COPY(GeometryRenderObject)
- CRU_DELETE_MOVE(GeometryRenderObject)
-
- ~GeometryRenderObject() override;
+ GeometryRenderObject();
public:
void Draw(platform::graphics::IPainter* painter) override;
RenderObject* HitTest(const Point& point) override;
- std::shared_ptr<platform::graphics::IGeometry> GetGeometry() const;
+ std::shared_ptr<platform::graphics::IGeometry> GetGeometry();
void SetGeometry(std::shared_ptr<platform::graphics::IGeometry> geometry,
std::optional<Rect> view_port = std::nullopt);
- Rect GetViewPort() const;
+ Rect GetViewPort();
void SetViewPort(const Rect& view_port);
- std::shared_ptr<platform::graphics::IBrush> GetFillBrush() const;
+ std::shared_ptr<platform::graphics::IBrush> GetFillBrush();
void SetFillBrush(std::shared_ptr<platform::graphics::IBrush> brush);
- std::shared_ptr<platform::graphics::IBrush> GetStrokeBrush() const;
+ std::shared_ptr<platform::graphics::IBrush> GetStrokeBrush();
void SetStrokeBrush(std::shared_ptr<platform::graphics::IBrush> brush);
- float GetStrokeWidth() const;
+ float GetStrokeWidth();
void SetStrokeWidth(float width);
protected:
diff --git a/include/cru/ui/render/LayoutRenderObject.h b/include/cru/ui/render/LayoutRenderObject.h
index 9970c16c..4010ae7c 100644
--- a/include/cru/ui/render/LayoutRenderObject.h
+++ b/include/cru/ui/render/LayoutRenderObject.h
@@ -20,15 +20,10 @@ class LayoutRenderObject : public RenderObject {
};
protected:
- LayoutRenderObject() = default;
+ LayoutRenderObject(std::string name) : RenderObject(std::move(name)) {}
public:
- CRU_DELETE_COPY(LayoutRenderObject)
- CRU_DELETE_MOVE(LayoutRenderObject)
-
- ~LayoutRenderObject() override = default;
-
- Index GetChildCount() const { return static_cast<Index>(children_.size()); }
+ Index GetChildCount() { return static_cast<Index>(children_.size()); }
RenderObject* GetChildAt(Index position) {
Expects(position >= 0 && position < GetChildCount());
@@ -75,7 +70,7 @@ class LayoutRenderObject : public RenderObject {
InvalidateLayout();
}
- const ChildLayoutData& GetChildLayoutDataAt(Index position) const {
+ const ChildLayoutData& GetChildLayoutDataAt(Index position) {
Expects(position >= 0 && position < GetChildCount());
return children_[position].layout_data;
}
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;
diff --git a/include/cru/ui/render/ScrollBar.h b/include/cru/ui/render/ScrollBar.h
index 2325acd1..f3a42b66 100644
--- a/include/cru/ui/render/ScrollBar.h
+++ b/include/cru/ui/render/ScrollBar.h
@@ -1,13 +1,12 @@
#pragma once
-#include "cru/base/Base.h"
-#include "cru/base/Event.h"
-#include "cru/platform/graphics/Base.h"
-#include "cru/platform/graphics/Brush.h"
-#include "cru/platform/graphics/Geometry.h"
-#include "cru/platform/graphics/Painter.h"
-#include "cru/platform/gui/UiApplication.h"
-#include "cru/ui/Base.h"
-#include "cru/ui/controls/Control.h"
+#include "../Base.h"
+#include "../controls/Control.h"
+
+#include <cru/platform/graphics/Base.h>
+#include <cru/platform/graphics/Brush.h>
+#include <cru/platform/graphics/Geometry.h>
+#include <cru/platform/graphics/Painter.h>
+#include <cru/platform/gui/UiApplication.h>
#include <memory>
#include <optional>
@@ -45,12 +44,12 @@ class CRU_UI_API ScrollBar : public Object {
~ScrollBar() override;
public:
- Direction GetDirection() const { return direction_; }
+ Direction GetDirection() { return direction_; }
- bool IsEnabled() const { return is_enabled_; }
+ bool IsEnabled() { return is_enabled_; }
void SetEnabled(bool value);
- bool IsExpanded() const { return is_expanded_; }
+ bool IsExpanded() { return is_expanded_; }
void SetExpanded(bool value);
void Draw(platform::graphics::IPainter* painter);
@@ -209,12 +208,12 @@ class CRU_UI_API ScrollBarDelegate : public Object {
~ScrollBarDelegate() override = default;
public:
- bool IsHorizontalBarEnabled() const { return horizontal_bar_.IsEnabled(); }
+ bool IsHorizontalBarEnabled() { return horizontal_bar_.IsEnabled(); }
void SetHorizontalBarEnabled(bool value) {
horizontal_bar_.SetEnabled(value);
}
- bool IsVerticalBarEnabled() const { return horizontal_bar_.IsEnabled(); }
+ bool IsVerticalBarEnabled() { return horizontal_bar_.IsEnabled(); }
void SetVerticalBarEnabled(bool value) { horizontal_bar_.SetEnabled(value); }
IEvent<Scroll>* ScrollAttemptEvent() { return &scroll_attempt_event_; }
diff --git a/include/cru/ui/render/ScrollRenderObject.h b/include/cru/ui/render/ScrollRenderObject.h
index 348d7af1..b3d1a09f 100644
--- a/include/cru/ui/render/ScrollRenderObject.h
+++ b/include/cru/ui/render/ScrollRenderObject.h
@@ -1,9 +1,6 @@
#pragma once
-#include "SingleChildRenderObject.h"
-
#include "ScrollBar.h"
-#include "cru/base/Event.h"
-#include "cru/ui/render/RenderObject.h"
+#include "SingleChildRenderObject.h"
#include <memory>
#include <optional>
@@ -19,12 +16,9 @@ namespace cru::ui::render {
// Or layout by scroll state.
class CRU_UI_API ScrollRenderObject : public SingleChildRenderObject {
public:
- ScrollRenderObject();
+ static constexpr auto kRenderObjectName = "ScrollRenderObject";
- CRU_DELETE_COPY(ScrollRenderObject)
- CRU_DELETE_MOVE(ScrollRenderObject)
-
- ~ScrollRenderObject() override = default;
+ ScrollRenderObject();
RenderObject* HitTest(const Point& point) override;
@@ -46,7 +40,7 @@ class CRU_UI_API ScrollRenderObject : public SingleChildRenderObject {
void ApplyScroll(const Scroll& scroll);
- Point GetRawScrollOffset() const { return scroll_offset_; }
+ Point GetRawScrollOffset() { return scroll_offset_; }
// Return the viewable area rect.
// Lefttop is scroll offset. Size is content size.
@@ -60,9 +54,7 @@ class CRU_UI_API ScrollRenderObject : public SingleChildRenderObject {
// Param margin is just for convenience and it will just add to the rect.
void ScrollToContain(const Rect& rect, const Thickness& margin = Thickness{});
- std::string GetName() const override { return "ScrollRenderObject"; }
-
- bool IsMouseWheelScrollEnabled() const { return is_mouse_wheel_enabled_; }
+ bool IsMouseWheelScrollEnabled() { return is_mouse_wheel_enabled_; }
void SetMouseWheelScrollEnabled(bool enable);
bool HorizontalCanScrollUp();
diff --git a/include/cru/ui/render/SingleChildRenderObject.h b/include/cru/ui/render/SingleChildRenderObject.h
index 85442eda..4c1891c5 100644
--- a/include/cru/ui/render/SingleChildRenderObject.h
+++ b/include/cru/ui/render/SingleChildRenderObject.h
@@ -3,13 +3,10 @@
namespace cru::ui::render {
class CRU_UI_API SingleChildRenderObject : public RenderObject {
- CRU_DEFINE_CLASS_LOG_TAG("SingleChildRenderObject")
+ CRU_DEFINE_CLASS_LOG_TAG("cru::ui::render::SingleChildRenderObject")
public:
- SingleChildRenderObject() = default;
- CRU_DELETE_COPY(SingleChildRenderObject)
- CRU_DELETE_MOVE(SingleChildRenderObject)
- ~SingleChildRenderObject() override = default;
+ SingleChildRenderObject(std::string name);
RenderObject* GetChild() const { return child_; }
void SetChild(RenderObject* new_child);
diff --git a/include/cru/ui/render/StackLayoutRenderObject.h b/include/cru/ui/render/StackLayoutRenderObject.h
index 0d75d032..bd08fffc 100644
--- a/include/cru/ui/render/StackLayoutRenderObject.h
+++ b/include/cru/ui/render/StackLayoutRenderObject.h
@@ -28,24 +28,21 @@ struct StackChildLayoutData {
// to min size.
class CRU_UI_API StackLayoutRenderObject
: public LayoutRenderObject<StackChildLayoutData> {
- CRU_DEFINE_CLASS_LOG_TAG("StackLayoutRenderObject")
+ CRU_DEFINE_CLASS_LOG_TAG("cru::ui::render::StackLayoutRenderObject")
public:
- StackLayoutRenderObject() = default;
- CRU_DELETE_COPY(StackLayoutRenderObject)
- CRU_DELETE_MOVE(StackLayoutRenderObject)
- ~StackLayoutRenderObject() = default;
+ static constexpr auto kRenderObjectName = "StackLayoutRenderObject";
- std::string GetName() const override { return "StackLayoutRenderObject"; }
+ StackLayoutRenderObject();
- Alignment GetDefaultHorizontalAlignment() const {
+ Alignment GetDefaultHorizontalAlignment() {
return default_vertical_alignment_;
}
void SetDefaultHorizontalAlignment(Alignment alignment);
Alignment GetDefaultVerticalAlignment() {
return default_horizontal_alignment_;
}
- void SetDefaultVertialAlignment(Alignment alignment);
+ void SetDefaultVerticalAlignment(Alignment alignment);
protected:
Size OnMeasureContent(const MeasureRequirement& requirement,
diff --git a/include/cru/ui/render/TextRenderObject.h b/include/cru/ui/render/TextRenderObject.h
index 5b99ae98..19ff800a 100644
--- a/include/cru/ui/render/TextRenderObject.h
+++ b/include/cru/ui/render/TextRenderObject.h
@@ -19,9 +19,10 @@ namespace cru::ui::render {
// If the result layout box is bigger than actual text box, then text is center
// aligned.
class CRU_UI_API TextRenderObject : public RenderObject {
- CRU_DEFINE_CLASS_LOG_TAG("TextRenderObject")
+ CRU_DEFINE_CLASS_LOG_TAG("cru::ui::render::TextRenderObject")
public:
+ static constexpr auto kRenderObjectName = "TextRenderObject";
constexpr static float default_caret_width = 2;
public:
@@ -29,19 +30,14 @@ class CRU_UI_API TextRenderObject : public RenderObject {
std::shared_ptr<platform::graphics::IFont> font,
std::shared_ptr<platform::graphics::IBrush> selection_brush,
std::shared_ptr<platform::graphics::IBrush> caret_brush);
- TextRenderObject(const TextRenderObject& other) = delete;
- TextRenderObject(TextRenderObject&& other) = delete;
- TextRenderObject& operator=(const TextRenderObject& other) = delete;
- TextRenderObject& operator=(TextRenderObject&& other) = delete;
- ~TextRenderObject() override;
- std::string GetText() const;
+ std::string GetText();
void SetText(std::string new_text);
std::shared_ptr<platform::graphics::IBrush> GetBrush() { return brush_; }
void SetBrush(std::shared_ptr<platform::graphics::IBrush> new_brush);
- std::shared_ptr<platform::graphics::IFont> GetFont() const;
+ std::shared_ptr<platform::graphics::IFont> GetFont();
void SetFont(std::shared_ptr<platform::graphics::IFont> font);
bool IsEditMode();
@@ -54,23 +50,21 @@ class CRU_UI_API TextRenderObject : public RenderObject {
Rect TextSinglePoint(Index position, bool trailing);
platform::graphics::TextHitTestResult TextHitTest(const Point& point);
- std::optional<TextRange> GetSelectionRange() const {
- return selection_range_;
- }
+ std::optional<TextRange> GetSelectionRange() { return selection_range_; }
void SetSelectionRange(std::optional<TextRange> new_range);
- std::shared_ptr<platform::graphics::IBrush> GetSelectionBrush() const {
+ std::shared_ptr<platform::graphics::IBrush> GetSelectionBrush() {
return selection_brush_;
}
void SetSelectionBrush(std::shared_ptr<platform::graphics::IBrush> new_brush);
- bool IsDrawCaret() const { return draw_caret_; }
+ bool IsDrawCaret() { return draw_caret_; }
void SetDrawCaret(bool draw_caret);
void ToggleDrawCaret() { SetDrawCaret(!IsDrawCaret()); }
// Caret position can be any value. When it is negative, 0 is used. When it
// exceeds the size of the string, the size of the string is used.
- Index GetCaretPosition() const { return caret_position_; }
+ Index GetCaretPosition() { return caret_position_; }
void SetCaretPosition(Index position);
// Lefttop relative to content lefttop.
@@ -78,23 +72,21 @@ class CRU_UI_API TextRenderObject : public RenderObject {
// Lefttop relative to render object lefttop.
Rect GetCaretRect();
- std::shared_ptr<platform::graphics::IBrush> GetCaretBrush() const {
+ std::shared_ptr<platform::graphics::IBrush> GetCaretBrush() {
return caret_brush_;
}
void GetCaretBrush(std::shared_ptr<platform::graphics::IBrush> brush);
- float GetCaretWidth() const { return caret_width_; }
+ float GetCaretWidth() { return caret_width_; }
void SetCaretWidth(float width);
- bool IsMeasureIncludingTrailingSpace() const {
+ bool IsMeasureIncludingTrailingSpace() {
return is_measure_including_trailing_space_;
}
void SetMeasureIncludingTrailingSpace(bool including);
RenderObject* HitTest(const Point& point) override;
- std::string GetName() const override { return "TextRenderObject"; }
-
void Draw(platform::graphics::IPainter* painter) override;
protected:
diff --git a/include/cru/ui/render/TreeRenderObject.h b/include/cru/ui/render/TreeRenderObject.h
index de6e6f9b..90c35747 100644
--- a/include/cru/ui/render/TreeRenderObject.h
+++ b/include/cru/ui/render/TreeRenderObject.h
@@ -1,6 +1,7 @@
#pragma once
#include "RenderObject.h"
-#include "cru/platform/graphics/Painter.h"
+
+#include <cru/platform/graphics/Painter.h>
namespace cru::ui::render {
class TreeRenderObject;
@@ -18,11 +19,9 @@ class CRU_UI_API TreeRenderObjectItem : public Object {
RenderObject* GetRenderObject() { return render_object_; }
void SetRenderObject(RenderObject* render_object);
- const std::vector<TreeRenderObjectItem*>& GetChildren() const {
- return children_;
- }
+ const std::vector<TreeRenderObjectItem*>& GetChildren() { return children_; }
- Index GetChildCount() const { return children_.size(); }
+ Index GetChildCount() { return children_.size(); }
TreeRenderObjectItem* GetChildAt(Index index) {
Expects(index >= 0 && index < children_.size());
@@ -32,7 +31,7 @@ class CRU_UI_API TreeRenderObjectItem : public Object {
TreeRenderObjectItem* AddItem(Index position);
void RemoveItem(Index position);
- void* GetUserData() const { return user_data_; }
+ void* GetUserData() { return user_data_; }
void SetUserData(void* user_data) { user_data_ = user_data; }
private:
@@ -47,19 +46,17 @@ class CRU_UI_API TreeRenderObjectItem : public Object {
};
class CRU_UI_API TreeRenderObject : public RenderObject {
- CRU_DEFINE_CLASS_LOG_TAG("TreeRenderObject")
+ CRU_DEFINE_CLASS_LOG_TAG("cru::ui::render::TreeRenderObject")
public:
+ static constexpr auto kRenderObjectName = "TreeRenderObject";
+
TreeRenderObject();
- CRU_DELETE_COPY(TreeRenderObject)
- CRU_DELETE_MOVE(TreeRenderObject)
~TreeRenderObject() override;
- std::string GetName() const override { return "TreeRenderObject"; }
-
TreeRenderObjectItem* GetRootItem() { return root_item_; }
- float GetTabWidth() const { return tab_width_; }
+ float GetTabWidth() { return tab_width_; }
void SetTabWidth(float tab_width);
RenderObject* HitTest(const Point& point) override;