aboutsummaryrefslogtreecommitdiff
path: root/include/cru/ui/render/TextRenderObject.h
diff options
context:
space:
mode:
authorYuqian Yang <crupest@crupest.life>2025-11-21 21:43:42 +0800
committerYuqian Yang <crupest@crupest.life>2025-11-21 22:13:54 +0800
commitfd61739197ec009d47da87a7cc66970a55f12db4 (patch)
treebb2bc007aaf9b47fecb090df96c23b5ee6a898e3 /include/cru/ui/render/TextRenderObject.h
parent3b875091c445b7465b9bd044914318989a94d2ad (diff)
downloadcru-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/TextRenderObject.h')
-rw-r--r--include/cru/ui/render/TextRenderObject.h30
1 files changed, 11 insertions, 19 deletions
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: