aboutsummaryrefslogtreecommitdiff
path: root/src/ui/controls/text_box.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-05-24 01:40:02 +0800
committercrupest <crupest@outlook.com>2020-05-24 01:40:02 +0800
commitd86a71f79afe0e4dac768f61d6bff690567aca5b (patch)
tree4957e9a64c77680deb07201fbd879bf036616dae /src/ui/controls/text_box.cpp
parentf3a8fd608a9776ef0a5f547da918a32cf6074060 (diff)
downloadcru-d86a71f79afe0e4dac768f61d6bff690567aca5b.tar.gz
cru-d86a71f79afe0e4dac768f61d6bff690567aca5b.tar.bz2
cru-d86a71f79afe0e4dac768f61d6bff690567aca5b.zip
...
Diffstat (limited to 'src/ui/controls/text_box.cpp')
-rw-r--r--src/ui/controls/text_box.cpp70
1 files changed, 0 insertions, 70 deletions
diff --git a/src/ui/controls/text_box.cpp b/src/ui/controls/text_box.cpp
deleted file mode 100644
index 8b7dc692..00000000
--- a/src/ui/controls/text_box.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-#include "cru/ui/controls/text_box.hpp"
-
-#include "cru/ui/render/border_render_object.hpp"
-#include "cru/ui/render/canvas_render_object.hpp"
-#include "cru/ui/render/stack_layout_render_object.hpp"
-#include "cru/ui/render/text_render_object.hpp"
-#include "cru/ui/ui_manager.hpp"
-#include "text_control_service.hpp"
-
-namespace cru::ui::controls {
-using render::BorderRenderObject;
-using render::CanvasRenderObject;
-using render::StackLayoutRenderObject;
-using render::TextRenderObject;
-
-TextBox::TextBox() : border_render_object_(new BorderRenderObject()) {
- const auto theme_resources = UiManager::GetInstance()->GetThemeResources();
-
- border_style_ = theme_resources->text_box_border_style;
-
- text_render_object_ = std::make_unique<TextRenderObject>(
- theme_resources->text_brush, theme_resources->default_font,
- theme_resources->text_selection_brush, theme_resources->caret_brush);
-
- border_render_object_->AddChild(text_render_object_.get(), 0);
-
- border_render_object_->SetAttachedControl(this);
- text_render_object_->SetAttachedControl(this);
-
- service_ = std::make_unique<TextControlService<TextBox>>(this);
- service_->SetEnabled(true);
- service_->SetCaretVisible(true);
-
- GainFocusEvent()->Direct()->AddHandler([this](event::FocusChangeEventArgs&) {
- this->service_->SetEnabled(true);
- this->UpdateBorderStyle();
- });
-
- LoseFocusEvent()->Direct()->AddHandler([this](event::FocusChangeEventArgs&) {
- this->service_->SetEnabled(false);
- this->UpdateBorderStyle();
- });
-}
-
-TextBox::~TextBox() {}
-
-render::RenderObject* TextBox::GetRenderObject() const {
- return border_render_object_.get();
-}
-
-render::TextRenderObject* TextBox::GetTextRenderObject() {
- return text_render_object_.get();
-}
-
-const TextBoxBorderStyle& TextBox::GetBorderStyle() { return border_style_; }
-
-void TextBox::SetBorderStyle(TextBoxBorderStyle border_style) {
- border_style_ = std::move(border_style);
-}
-
-void TextBox::OnMouseHoverChange(bool) { UpdateBorderStyle(); }
-
-void TextBox::UpdateBorderStyle() {
- const auto focus = HasFocus();
- const auto hover = IsMouseOver();
- border_render_object_->SetBorderStyle(
- focus ? (hover ? border_style_.focus_hover : border_style_.focus)
- : (hover ? border_style_.hover : border_style_.normal));
-}
-} // namespace cru::ui::controls