aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/controls/TextBlock.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/ui/controls/TextBlock.cpp b/src/ui/controls/TextBlock.cpp
index 9ce99ab6..1a432582 100644
--- a/src/ui/controls/TextBlock.cpp
+++ b/src/ui/controls/TextBlock.cpp
@@ -7,10 +7,17 @@
#include "cru/ui/render/TextRenderObject.hpp"
namespace cru::ui::controls {
-using render::CanvasRenderObject;
-using render::StackLayoutRenderObject;
using render::TextRenderObject;
+TextBlock* TextBlock::Create() { return new TextBlock(); }
+
+TextBlock* TextBlock::Create(std::u16string text, bool selectable) {
+ auto c = new TextBlock();
+ c->SetText(text);
+ c->SetSelectable(selectable);
+ return c;
+}
+
TextBlock::TextBlock() {
const auto theme_resources = UiManager::GetInstance()->GetThemeResources();
@@ -21,7 +28,9 @@ TextBlock::TextBlock() {
text_render_object_->SetAttachedControl(this);
service_ = std::make_unique<TextControlService<TextBlock>>(this);
- service_->SetEnabled(true);
+
+ service_->SetEnabled(false);
+ service_->SetEditable(false);
}
TextBlock::~TextBlock() = default;
@@ -36,6 +45,10 @@ void TextBlock::SetText(std::u16string text) {
service_->SetText(std::move(text));
}
+bool TextBlock::IsSelectable() const { return service_->IsEnabled(); }
+
+void TextBlock::SetSelectable(bool value) { service_->SetEnabled(value); }
+
gsl::not_null<render::TextRenderObject*> TextBlock::GetTextRenderObject() {
return text_render_object_.get();
}