aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/cru/ui/UiManager.hpp2
-rw-r--r--include/cru/ui/controls/TextHostControlService.hpp8
-rw-r--r--include/cru/ui/render/TextRenderObject.hpp8
-rw-r--r--src/ui/ThemeManager.cpp7
-rw-r--r--src/ui/UiManager.cpp4
-rw-r--r--src/ui/controls/TextHostControlService.cpp7
-rw-r--r--src/ui/render/FlexLayoutRenderObject.cpp3
-rw-r--r--src/ui/render/RenderObject.cpp6
-rw-r--r--src/ui/render/ScrollBar.cpp2
-rw-r--r--src/ui/render/TextRenderObject.cpp10
-rw-r--r--test/platform/MatrixTest.cpp2
11 files changed, 23 insertions, 36 deletions
diff --git a/include/cru/ui/UiManager.hpp b/include/cru/ui/UiManager.hpp
index 10b12e87..6b1083b2 100644
--- a/include/cru/ui/UiManager.hpp
+++ b/include/cru/ui/UiManager.hpp
@@ -13,7 +13,7 @@
namespace cru::ui {
struct ThemeResources {
- std::u16string default_font_family;
+ String default_font_family;
std::shared_ptr<platform::graphics::IFont> default_font;
std::shared_ptr<platform::graphics::IBrush> text_brush;
std::shared_ptr<platform::graphics::IBrush> text_selection_brush;
diff --git a/include/cru/ui/controls/TextHostControlService.hpp b/include/cru/ui/controls/TextHostControlService.hpp
index f39d9456..84c226ca 100644
--- a/include/cru/ui/controls/TextHostControlService.hpp
+++ b/include/cru/ui/controls/TextHostControlService.hpp
@@ -7,7 +7,6 @@
#include "cru/ui/controls/Control.hpp"
#include "cru/ui/helper/ShortcutHub.hpp"
-
#include <functional>
#include <string>
@@ -43,9 +42,8 @@ class TextHostControlService : public Object {
bool IsEditable() { return this->editable_; }
void SetEditable(bool editable);
- std::u16string GetText() { return this->text_; }
- std::u16string_view GetTextView() { return this->text_; }
- void SetText(std::u16string text, bool stop_composition = false);
+ String GetText() { return this->text_; }
+ void SetText(String text, bool stop_composition = false);
void InsertText(gsl::index position, std::u16string_view text,
bool stop_composition = false);
@@ -121,7 +119,7 @@ class TextHostControlService : public Object {
EventRevokerListGuard event_guard_;
EventRevokerListGuard input_method_context_event_guard_;
- std::u16string text_;
+ String text_;
TextRange selection_;
bool enable_ = false;
diff --git a/include/cru/ui/render/TextRenderObject.hpp b/include/cru/ui/render/TextRenderObject.hpp
index cf585d6f..ef39b7a6 100644
--- a/include/cru/ui/render/TextRenderObject.hpp
+++ b/include/cru/ui/render/TextRenderObject.hpp
@@ -34,13 +34,9 @@ class TextRenderObject : public RenderObject {
TextRenderObject& operator=(TextRenderObject&& other) = delete;
~TextRenderObject() override;
- std::u16string GetText() const;
- std::u16string_view GetTextView() const;
- void SetText(std::u16string new_text);
+ String GetText() const;
+ void SetText(String new_text);
- std::shared_ptr<platform::graphics::IBrush> GetBrush() const {
- return brush_;
- }
void SetBrush(std::shared_ptr<platform::graphics::IBrush> new_brush);
std::shared_ptr<platform::graphics::IFont> GetFont() const;
diff --git a/src/ui/ThemeManager.cpp b/src/ui/ThemeManager.cpp
index be986bb5..4a0e08a5 100644
--- a/src/ui/ThemeManager.cpp
+++ b/src/ui/ThemeManager.cpp
@@ -16,7 +16,7 @@ ThemeManager::ThemeManager() { Init(); }
void ThemeManager::Init() {
theme_tree_.put("scrollbar.collapse-thumb.color",
- colors::gray.WithAlpha(128).ToUtf8String());
+ colors::gray.WithAlpha(128).ToString().ToUtf8());
theme_tree_.put("scrollbar.arrow.normal.color", "#505050");
theme_tree_.put("scrollbar.arrow.hover.color", "#505050");
theme_tree_.put("scrollbar.arrow.press.color", "#ffffff");
@@ -43,11 +43,12 @@ ThemeManager::GetBrush(std::u16string key) {
return cached_brush_iter->second;
}
- auto color_string = ToUtf16(theme_tree_.get<std::string>(ToUtf8(key)));
+ auto color_string =
+ String::FromUtf8(theme_tree_.get<std::string>(ToUtf8(key)));
auto color = Color::Parse(color_string);
if (!color) throw BadThemeResourceException("Value is not a valid color.");
std::shared_ptr<platform::graphics::IBrush> brush =
- GetUiApplication()->GetGraphFactory()->CreateSolidColorBrush(*color);
+ GetUiApplication()->GetGraphicsFactory()->CreateSolidColorBrush(*color);
brushes_[k] = brush;
return brush;
}
diff --git a/src/ui/UiManager.cpp b/src/ui/UiManager.cpp
index 85ca552c..ed40e70f 100644
--- a/src/ui/UiManager.cpp
+++ b/src/ui/UiManager.cpp
@@ -20,8 +20,8 @@ using namespace cru::ui::style;
using namespace cru::ui::helper;
namespace {
-std::unique_ptr<ISolidColorBrush> CreateSolidColorBrush(IGraphicsFactory* factory,
- const Color& color) {
+std::unique_ptr<ISolidColorBrush> CreateSolidColorBrush(
+ IGraphicsFactory* factory, const Color& color) {
auto brush = factory->CreateSolidColorBrush();
brush->SetColor(color);
return brush;
diff --git a/src/ui/controls/TextHostControlService.cpp b/src/ui/controls/TextHostControlService.cpp
index 07b4f1e8..2f096126 100644
--- a/src/ui/controls/TextHostControlService.cpp
+++ b/src/ui/controls/TextHostControlService.cpp
@@ -59,8 +59,7 @@ void TextHostControlService::SetEditable(bool editable) {
if (!editable) CancelComposition();
}
-void TextHostControlService::SetText(std::u16string text,
- bool stop_composition) {
+void TextHostControlService::SetText(String text, bool stop_composition) {
this->text_ = std::move(text);
CoerceSelection();
if (stop_composition) {
@@ -259,7 +258,7 @@ void TextHostControlService::SyncTextRenderObject() {
if (composition_info) {
const auto caret_position = GetCaretPosition();
auto text = this->text_;
- text.insert(caret_position, composition_info->text);
+ text.insert(text.cbegin() + caret_position, composition_info->text);
text_render_object->SetText(text);
text_render_object->SetCaretPosition(caret_position +
composition_info->selection.GetEnd());
@@ -284,7 +283,7 @@ void TextHostControlService::UpdateInputMethodPosition() {
if constexpr (debug_flags::text_service) {
log::TagDebug(log_tag,
u"Calculate input method candidate window position: {}.",
- right_bottom.ToDebugString());
+ right_bottom);
}
input_method_context->SetCandidateWindowPosition(right_bottom);
diff --git a/src/ui/render/FlexLayoutRenderObject.cpp b/src/ui/render/FlexLayoutRenderObject.cpp
index e4b3774f..6d1f9c26 100644
--- a/src/ui/render/FlexLayoutRenderObject.cpp
+++ b/src/ui/render/FlexLayoutRenderObject.cpp
@@ -91,8 +91,7 @@ template <typename direction_tag_t,
Size FlexLayoutMeasureContentImpl(
const MeasureRequirement& requirement, const MeasureSize& preferred_size,
const std::vector<RenderObject*>& children,
- const std::vector<FlexChildLayoutData>& layout_data,
- std::u16string_view log_tag) {
+ const std::vector<FlexChildLayoutData>& layout_data, StringView log_tag) {
Expects(children.size() == layout_data.size());
direction_tag_t direction_tag;
diff --git a/src/ui/render/RenderObject.cpp b/src/ui/render/RenderObject.cpp
index e49ed3c2..75bf1380 100644
--- a/src/ui/render/RenderObject.cpp
+++ b/src/ui/render/RenderObject.cpp
@@ -1,7 +1,7 @@
#include "cru/ui/render/RenderObject.hpp"
#include "cru/common/Logger.hpp"
-#include "cru/platform/GraphBase.hpp"
+#include "cru/platform/GraphicsBase.hpp"
#include "cru/platform/graphics/util/Painter.hpp"
#include "cru/ui/Base.hpp"
#include "cru/ui/DebugFlags.hpp"
@@ -102,7 +102,7 @@ void RenderObject::Measure(const MeasureRequirement& requirement,
if constexpr (cru::ui::debug_flags::layout) {
log::Debug(u"{} Measure ends :\nresult size: {}",
- this->GetDebugPathInTree(), size_.ToDebugString());
+ this->GetDebugPathInTree(), size_);
}
Ensures(size_.width >= 0);
@@ -112,7 +112,7 @@ void RenderObject::Measure(const MeasureRequirement& requirement,
void RenderObject::Layout(const Point& offset) {
if constexpr (cru::ui::debug_flags::layout) {
log::Debug(u"{} Layout :\noffset: {} size: {}", this->GetDebugPathInTree(),
- offset.ToDebugString(), GetSize().ToDebugString());
+ offset, GetSize());
}
offset_ = offset;
OnLayoutCore();
diff --git a/src/ui/render/ScrollBar.cpp b/src/ui/render/ScrollBar.cpp
index ec583b2a..1dfe67bf 100644
--- a/src/ui/render/ScrollBar.cpp
+++ b/src/ui/render/ScrollBar.cpp
@@ -2,7 +2,7 @@
#include "../Helper.hpp"
#include "cru/common/Base.hpp"
-#include "cru/platform/GraphBase.hpp"
+#include "cru/platform/GraphicsBase.hpp"
#include "cru/platform/graphics/Factory.hpp"
#include "cru/platform/graphics/Geometry.hpp"
#include "cru/platform/graphics/Painter.hpp"
diff --git a/src/ui/render/TextRenderObject.cpp b/src/ui/render/TextRenderObject.cpp
index a5dcf053..dc6b2d43 100644
--- a/src/ui/render/TextRenderObject.cpp
+++ b/src/ui/render/TextRenderObject.cpp
@@ -33,15 +33,9 @@ TextRenderObject::TextRenderObject(
TextRenderObject::~TextRenderObject() = default;
-std::u16string TextRenderObject::GetText() const {
- return text_layout_->GetText();
-}
-
-std::u16string_view TextRenderObject::GetTextView() const {
- return text_layout_->GetTextView();
-}
+String TextRenderObject::GetText() const { return text_layout_->GetText(); }
-void TextRenderObject::SetText(std::u16string new_text) {
+void TextRenderObject::SetText(String new_text) {
text_layout_->SetText(std::move(new_text));
InvalidateLayout();
}
diff --git a/test/platform/MatrixTest.cpp b/test/platform/MatrixTest.cpp
index 3b8aab27..3364600e 100644
--- a/test/platform/MatrixTest.cpp
+++ b/test/platform/MatrixTest.cpp
@@ -1,4 +1,4 @@
-#include "cru/platform/GraphBase.hpp"
+#include "cru/platform/GraphicsBase.hpp"
#include "cru/platform/Matrix.hpp"
#include <gtest/gtest.h>