From 3b875091c445b7465b9bd044914318989a94d2ad Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Fri, 21 Nov 2025 21:43:42 +0800 Subject: Clean codes. Remove member function const. --- src/ui/controls/TextBlock.cpp | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'src/ui/controls/TextBlock.cpp') diff --git a/src/ui/controls/TextBlock.cpp b/src/ui/controls/TextBlock.cpp index 790c534b..a36c6b41 100644 --- a/src/ui/controls/TextBlock.cpp +++ b/src/ui/controls/TextBlock.cpp @@ -1,20 +1,15 @@ #include "cru/ui/controls/TextBlock.h" - -#include "../Helper.h" #include "cru/platform/graphics/Factory.h" #include "cru/platform/gui/UiApplication.h" #include "cru/ui/ThemeManager.h" -#include "cru/ui/render/CanvasRenderObject.h" -#include "cru/ui/render/StackLayoutRenderObject.h" #include "cru/ui/render/TextRenderObject.h" -namespace cru::ui::controls { -using render::TextRenderObject; - -TextBlock::TextBlock() { - const auto theme_manager = ThemeManager::GetInstance(); +#include - text_render_object_ = std::make_unique( +namespace cru::ui::controls { +TextBlock::TextBlock() : Control(kControlName) { + auto theme_manager = ThemeManager::GetInstance(); + text_render_object_ = std::make_unique( theme_manager->GetResourceBrush("text.brush"), theme_manager->GetResourceFont("text.font"), theme_manager->GetResourceBrush("text.selection.brush"), @@ -23,30 +18,28 @@ TextBlock::TextBlock() { text_render_object_->SetAttachedControl(this); service_ = std::make_unique(this); - service_->SetEnabled(false); service_->SetEditable(false); } -TextBlock::~TextBlock() = default; - -render::RenderObject* TextBlock::GetRenderObject() const { +render::RenderObject* TextBlock::GetRenderObject() { return text_render_object_.get(); } -std::string TextBlock::GetText() const { return service_->GetText(); } +std::string TextBlock::GetText() { return service_->GetText(); } void TextBlock::SetText(std::string text) { service_->SetText(std::move(text)); } -bool TextBlock::IsSelectable() const { return service_->IsEnabled(); } +bool TextBlock::IsSelectable() { return service_->IsEnabled(); } void TextBlock::SetSelectable(bool value) { service_->SetEnabled(value); } void TextBlock::SetTextColor(const Color& color) { - text_render_object_->SetBrush( - GetUiApplication()->GetGraphicsFactory()->CreateSolidColorBrush(color)); + text_render_object_->SetBrush(platform::gui::IUiApplication::GetInstance() + ->GetGraphicsFactory() + ->CreateSolidColorBrush(color)); } render::TextRenderObject* TextBlock::GetTextRenderObject() { -- cgit v1.2.3