aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/text_block.cpp
blob: 9d01dee99abcb6e466c7db94ddb8cede1043c5c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "cru/ui/controls/text_block.hpp"

#include "cru/ui/render/text_render_object.hpp"
#include "cru/ui/ui_manager.hpp"

namespace cru::ui::controls {
using render::TextRenderObject;

TextBlock::TextBlock() {
  const auto theme_resources = UiManager::GetInstance()->GetThemeResources();
  render_object_ = std::make_unique<TextRenderObject>(
      theme_resources->text_brush, theme_resources->default_font,
      theme_resources->text_selection_brush);
  render_object_->SetAttachedControl(this);
}

TextBlock::~TextBlock() = default;

render::RenderObject* TextBlock::GetRenderObject() const {
  return render_object_.get();
}

std::string TextBlock::GetText() const { return render_object_->GetText(); }

void TextBlock::SetText(std::string text) {
  render_object_->SetText(std::move(text));
}
}  // namespace cru::ui::controls