diff options
| author | crupest <crupest@outlook.com> | 2021-03-24 19:14:19 +0800 | 
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2021-03-24 19:14:19 +0800 | 
| commit | 7f15a1ff9a2007e119798053083a0a87d042990a (patch) | |
| tree | cb35c01a7eaee867376d959b96c9bbd15df939e5 /src/ui/controls/TextBlock.cpp | |
| parent | 74956951ee663012df0c3fe4ebe29799cb2f7732 (diff) | |
| parent | 7703063a5816b089483e78ccd74bb9902ccfbea8 (diff) | |
| download | cru-7f15a1ff9a2007e119798053083a0a87d042990a.tar.gz cru-7f15a1ff9a2007e119798053083a0a87d042990a.tar.bz2 cru-7f15a1ff9a2007e119798053083a0a87d042990a.zip | |
Merge branch 'master' of https://github.com/crupest/CruUI
Diffstat (limited to 'src/ui/controls/TextBlock.cpp')
| -rw-r--r-- | src/ui/controls/TextBlock.cpp | 22 | 
1 files changed, 17 insertions, 5 deletions
| diff --git a/src/ui/controls/TextBlock.cpp b/src/ui/controls/TextBlock.cpp index 9ce99ab6..0724edcf 100644 --- a/src/ui/controls/TextBlock.cpp +++ b/src/ui/controls/TextBlock.cpp @@ -1,16 +1,22 @@  #include "cru/ui/controls/TextBlock.hpp" -#include "TextControlService.hpp"  #include "cru/ui/UiManager.hpp"  #include "cru/ui/render/CanvasRenderObject.hpp"  #include "cru/ui/render/StackLayoutRenderObject.hpp"  #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(); @@ -20,8 +26,10 @@ TextBlock::TextBlock() {    text_render_object_->SetAttachedControl(this); -  service_ = std::make_unique<TextControlService<TextBlock>>(this); -  service_->SetEnabled(true); +  service_ = std::make_unique<TextHostControlService>(this); + +  service_->SetEnabled(false); +  service_->SetEditable(false);  }  TextBlock::~TextBlock() = default; @@ -36,6 +44,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();  } | 
