aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/TextBlock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/controls/TextBlock.cpp')
-rw-r--r--src/ui/controls/TextBlock.cpp29
1 files changed, 11 insertions, 18 deletions
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 <memory>
- text_render_object_ = std::make_unique<TextRenderObject>(
+namespace cru::ui::controls {
+TextBlock::TextBlock() : Control(kControlName) {
+ auto theme_manager = ThemeManager::GetInstance();
+ text_render_object_ = std::make_unique<render::TextRenderObject>(
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<TextHostControlService>(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() {