diff options
author | crupest <crupest@outlook.com> | 2021-10-26 16:32:13 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-10-26 16:32:13 +0800 |
commit | 9dec93315173999c4fb9ab5a0e57909eb5e7fd8b (patch) | |
tree | 042fff007fc3d0959146f131f425b9626448718e /src/ui | |
parent | 397843cda9e4161d3e92d8797f8012f478ce64f0 (diff) | |
download | cru-9dec93315173999c4fb9ab5a0e57909eb5e7fd8b.tar.gz cru-9dec93315173999c4fb9ab5a0e57909eb5e7fd8b.tar.bz2 cru-9dec93315173999c4fb9ab5a0e57909eb5e7fd8b.zip |
...
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/Helper.cpp | 2 | ||||
-rw-r--r-- | src/ui/Helper.hpp | 6 | ||||
-rw-r--r-- | src/ui/UiManager.cpp | 2 | ||||
-rw-r--r-- | src/ui/components/Menu.cpp | 6 | ||||
-rw-r--r-- | src/ui/controls/TextBlock.cpp | 8 | ||||
-rw-r--r-- | src/ui/controls/TextHostControlService.cpp | 11 | ||||
-rw-r--r-- | src/ui/render/BorderRenderObject.cpp | 2 | ||||
-rw-r--r-- | src/ui/render/ScrollBar.cpp | 2 | ||||
-rw-r--r-- | src/ui/render/TextRenderObject.cpp | 2 |
9 files changed, 17 insertions, 24 deletions
diff --git a/src/ui/Helper.cpp b/src/ui/Helper.cpp index fd54c05b..a5ab3a72 100644 --- a/src/ui/Helper.cpp +++ b/src/ui/Helper.cpp @@ -7,7 +7,7 @@ namespace cru::ui { using cru::platform::graphics::IGraphicsFactory; using cru::platform::gui::IUiApplication; -IGraphicsFactory* GetGraphFactory() { +IGraphicsFactory* GetGraphicsFactory() { return IUiApplication::GetInstance()->GetGraphicsFactory(); } diff --git a/src/ui/Helper.hpp b/src/ui/Helper.hpp index cf1140dc..27f1d7e6 100644 --- a/src/ui/Helper.hpp +++ b/src/ui/Helper.hpp @@ -2,8 +2,8 @@ #include "cru/ui/Base.hpp" namespace cru::platform { -namespace graph { -struct IGraphFactory; +namespace graphics { +struct IGraphicsFactory; } namespace native { struct ICursor; @@ -12,6 +12,6 @@ struct IUiApplication; } // namespace cru::platform namespace cru::ui { -cru::platform::graphics::IGraphicsFactory* GetGraphFactory(); +cru::platform::graphics::IGraphicsFactory* GetGraphicsFactory(); cru::platform::gui::IUiApplication* GetUiApplication(); } // namespace cru::ui diff --git a/src/ui/UiManager.cpp b/src/ui/UiManager.cpp index ed40e70f..fde82eed 100644 --- a/src/ui/UiManager.cpp +++ b/src/ui/UiManager.cpp @@ -38,7 +38,7 @@ UiManager* UiManager::GetInstance() { } UiManager::UiManager() { - const auto factory = GetGraphFactory(); + const auto factory = GetGraphicsFactory(); theme_resource_.default_font_family = u"等线"; diff --git a/src/ui/components/Menu.cpp b/src/ui/components/Menu.cpp index d45bc44f..afd1ab71 100644 --- a/src/ui/components/Menu.cpp +++ b/src/ui/components/Menu.cpp @@ -16,9 +16,7 @@ MenuItem::MenuItem() { &UiManager::GetInstance()->GetThemeResources()->menu_item_style); } -MenuItem::MenuItem(std::u16string text) : MenuItem() { - SetText(std::move(text)); -} +MenuItem::MenuItem(String text) : MenuItem() { SetText(std::move(text)); } MenuItem::~MenuItem() { if (!container_->GetWindowHost()) { @@ -27,7 +25,7 @@ MenuItem::~MenuItem() { } } -void MenuItem::SetText(std::u16string text) { text_->SetText(std::move(text)); } +void MenuItem::SetText(String text) { text_->SetText(std::move(text)); } Menu::Menu() { container_ = controls::FlexLayout::Create(); } diff --git a/src/ui/controls/TextBlock.cpp b/src/ui/controls/TextBlock.cpp index 0724edcf..16fd5df6 100644 --- a/src/ui/controls/TextBlock.cpp +++ b/src/ui/controls/TextBlock.cpp @@ -10,7 +10,7 @@ using render::TextRenderObject; TextBlock* TextBlock::Create() { return new TextBlock(); } -TextBlock* TextBlock::Create(std::u16string text, bool selectable) { +TextBlock* TextBlock::Create(String text, bool selectable) { auto c = new TextBlock(); c->SetText(text); c->SetSelectable(selectable); @@ -38,11 +38,9 @@ render::RenderObject* TextBlock::GetRenderObject() const { return text_render_object_.get(); } -std::u16string TextBlock::GetText() const { return service_->GetText(); } +String TextBlock::GetText() const { return service_->GetText(); } -void TextBlock::SetText(std::u16string text) { - service_->SetText(std::move(text)); -} +void TextBlock::SetText(String text) { service_->SetText(std::move(text)); } bool TextBlock::IsSelectable() const { return service_->IsEnabled(); } diff --git a/src/ui/controls/TextHostControlService.cpp b/src/ui/controls/TextHostControlService.cpp index 2f096126..2233d1e6 100644 --- a/src/ui/controls/TextHostControlService.cpp +++ b/src/ui/controls/TextHostControlService.cpp @@ -68,14 +68,13 @@ void TextHostControlService::SetText(String text, bool stop_composition) { SyncTextRenderObject(); } -void TextHostControlService::InsertText(gsl::index position, - std::u16string_view text, +void TextHostControlService::InsertText(gsl::index position, StringView text, bool stop_composition) { if (!Utf16IsValidInsertPosition(this->text_, position)) { log::TagError(log_tag, u"Invalid text insert position."); return; } - this->text_.insert(this->text_.cbegin() + position, text.begin(), text.end()); + this->text_.insert(this->text_.cbegin() + position, text); if (stop_composition) { CancelComposition(); } @@ -224,7 +223,7 @@ void TextHostControlService::AbortSelection() { SetSelection(GetCaretPosition()); } -void TextHostControlService::ReplaceSelectedText(std::u16string_view text) { +void TextHostControlService::ReplaceSelectedText(StringView text) { DeleteSelectedText(); InsertText(GetSelection().GetStart(), text); SetSelection(GetSelection().GetStart() + text.size()); @@ -344,9 +343,7 @@ void TextHostControlService::GainFocusHandler( input_method_context->CompositionEndEvent()->AddHandler(sync); input_method_context_event_guard_ += input_method_context->TextEvent()->AddHandler( - [this](const std::u16string_view& text) { - this->ReplaceSelectedText(text); - }); + [this](StringView text) { this->ReplaceSelectedText(text); }); host::WindowHost* window_host = control_->GetWindowHost(); if (window_host) diff --git a/src/ui/render/BorderRenderObject.cpp b/src/ui/render/BorderRenderObject.cpp index 6b2404db..9e081828 100644 --- a/src/ui/render/BorderRenderObject.cpp +++ b/src/ui/render/BorderRenderObject.cpp @@ -175,7 +175,7 @@ void BorderRenderObject::RecreateGeometry() { const Rect outer_rect{margin.left, margin.top, size.width - margin.GetHorizontalTotal(), size.height - margin.GetVerticalTotal()}; - const auto graph_factory = GetGraphFactory(); + const auto graph_factory = GetGraphicsFactory(); std::unique_ptr<platform::graphics::IGeometryBuilder> builder{ graph_factory->CreateGeometryBuilder()}; f(builder.get(), outer_rect, outer_radius); diff --git a/src/ui/render/ScrollBar.cpp b/src/ui/render/ScrollBar.cpp index 1dfe67bf..0d644a1f 100644 --- a/src/ui/render/ScrollBar.cpp +++ b/src/ui/render/ScrollBar.cpp @@ -77,7 +77,7 @@ std::u16string GenerateScrollBarThemeColorKey(ScrollBarBrushUsageKind usage, namespace { std::unique_ptr<platform::graphics::IGeometry> CreateScrollBarArrowGeometry() { - auto geometry_builder = GetGraphFactory()->CreateGeometryBuilder(); + auto geometry_builder = GetGraphicsFactory()->CreateGeometryBuilder(); geometry_builder->BeginFigure({-kScrollBarArrowHeight / 2, 0}); geometry_builder->LineTo({kScrollBarArrowHeight / 2, kScrollBarArrowHeight}); geometry_builder->LineTo({kScrollBarArrowHeight / 2, -kScrollBarArrowHeight}); diff --git a/src/ui/render/TextRenderObject.cpp b/src/ui/render/TextRenderObject.cpp index dc6b2d43..ff9ebc58 100644 --- a/src/ui/render/TextRenderObject.cpp +++ b/src/ui/render/TextRenderObject.cpp @@ -27,7 +27,7 @@ TextRenderObject::TextRenderObject( selection_brush.swap(selection_brush_); caret_brush.swap(caret_brush_); - const auto graph_factory = GetGraphFactory(); + const auto graph_factory = GetGraphicsFactory(); text_layout_ = graph_factory->CreateTextLayout(font_, u""); } |