diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/ThemeManager.cpp | 4 | ||||
-rw-r--r-- | src/ui/ThemeResourceDictionary.cpp | 4 | ||||
-rw-r--r-- | src/ui/document/DocumentElementType.cpp | 8 | ||||
-rw-r--r-- | src/ui/document/TextDocumentElement.cpp | 5 | ||||
-rw-r--r-- | src/ui/host/RoutedEventDispatch.h | 10 | ||||
-rw-r--r-- | src/ui/host/WindowHost.cpp | 3 | ||||
-rw-r--r-- | src/ui/mapper/FontMapper.cpp | 1 | ||||
-rw-r--r-- | src/ui/mapper/StringMapper.cpp | 9 | ||||
-rw-r--r-- | src/ui/render/BorderRenderObject.cpp | 2 | ||||
-rw-r--r-- | src/ui/render/FlexLayoutRenderObject.cpp | 5 | ||||
-rw-r--r-- | src/ui/render/RenderObject.cpp | 27 | ||||
-rw-r--r-- | src/ui/style/StyleRule.cpp | 2 |
12 files changed, 38 insertions, 42 deletions
diff --git a/src/ui/ThemeManager.cpp b/src/ui/ThemeManager.cpp index 0f4daeb7..14da3ef8 100644 --- a/src/ui/ThemeManager.cpp +++ b/src/ui/ThemeManager.cpp @@ -20,7 +20,7 @@ ThemeManager::ThemeManager() { } PrependThemeResourceDictionary( - ThemeResourceDictionary::FromFile(String::FromStdPath(resourses_file))); + ThemeResourceDictionary::FromFile(resourses_file)); } ThemeManager::~ThemeManager() {} @@ -44,7 +44,7 @@ void ThemeManager::PrependThemeResourceDictionary( } std::string ThemeManager::GetResourceString(std::string_view key) { - return GetResource<String>(key).ToUtf8(); + return GetResource<std::string>(key); } std::shared_ptr<platform::graphics::IBrush> ThemeManager::GetResourceBrush( diff --git a/src/ui/ThemeResourceDictionary.cpp b/src/ui/ThemeResourceDictionary.cpp index f76bdde8..587a14c5 100644 --- a/src/ui/ThemeResourceDictionary.cpp +++ b/src/ui/ThemeResourceDictionary.cpp @@ -8,8 +8,8 @@ namespace cru::ui { std::unique_ptr<ThemeResourceDictionary> ThemeResourceDictionary::FromFile( - const String& file_path) { - io::CFileStream stream(file_path.ToUtf8().c_str(), "r"); + std::filesystem::path file_path) { + io::CFileStream stream(file_path.c_str(), "r"); auto xml_string = stream.ReadToEndAsUtf8String(); auto parser = xml::XmlParser(xml_string); return std::make_unique<ThemeResourceDictionary>(parser.Parse(), false); diff --git a/src/ui/document/DocumentElementType.cpp b/src/ui/document/DocumentElementType.cpp index d548b494..ed076169 100644 --- a/src/ui/document/DocumentElementType.cpp +++ b/src/ui/document/DocumentElementType.cpp @@ -5,17 +5,17 @@ namespace cru::ui::document { DocumentElementType::DocumentElementType( - String name, std::vector<DocumentElementType*> parents) + std::string name, std::vector<DocumentElementType*> parents) : name_(std::move(name)), parents_(std::move(parents)) {} DocumentElementType::~DocumentElementType() {} DocumentElementType* const DocumentElementTypes::kBaseElementType = - new DocumentElementType(u"Base", {}); + new DocumentElementType("Base", {}); DocumentElementType* const DocumentElementTypes::kRootElementType = - new DocumentElementType(u"Root", {kBaseElementType}); + new DocumentElementType("Root", {kBaseElementType}); DocumentElementType* const DocumentElementTypes::kTextElementType = - new DocumentElementType(u"Text", {kBaseElementType}); + new DocumentElementType("Text", {kBaseElementType}); } // namespace cru::ui::document diff --git a/src/ui/document/TextDocumentElement.cpp b/src/ui/document/TextDocumentElement.cpp index 1ba39849..52cfac5a 100644 --- a/src/ui/document/TextDocumentElement.cpp +++ b/src/ui/document/TextDocumentElement.cpp @@ -1,10 +1,9 @@ #include "cru/ui/document/TextDocumentElement.h" -#include "cru/base/String.h" #include "cru/ui/document/DocumentElement.h" #include "cru/ui/document/DocumentElementType.h" namespace cru::ui::document { -TextDocumentElement::TextDocumentElement(String text, TextStyle style, +TextDocumentElement::TextDocumentElement(std::string text, TextStyle style, IDocumentLink* link) : DocumentElement(DocumentElementTypes::kTextElementType), text_(std::move(text)), @@ -13,5 +12,5 @@ TextDocumentElement::TextDocumentElement(String text, TextStyle style, TextDocumentElement::~TextDocumentElement() {} -void TextDocumentElement::SetText(String text) { text_ = std::move(text); } +void TextDocumentElement::SetText(std::string text) { text_ = std::move(text); } } // namespace cru::ui::document diff --git a/src/ui/host/RoutedEventDispatch.h b/src/ui/host/RoutedEventDispatch.h index 98042841..0729d176 100644 --- a/src/ui/host/RoutedEventDispatch.h +++ b/src/ui/host/RoutedEventDispatch.h @@ -23,7 +23,7 @@ namespace cru::ui::host { // as the rest arguments. template <typename EventArgs, typename... Args> void DispatchEvent( - const String& event_name, controls::Control* const original_sender, + const std::string& event_name, controls::Control* const original_sender, events::RoutedEvent<EventArgs>* (controls::Control::*event_ptr)(), controls::Control* const last_receiver, Args&&... args) { constexpr auto kLogTag = "DispatchEvent"; @@ -37,7 +37,7 @@ void DispatchEvent( CRU_LOG_TAG_DEBUG( "Routed event {} no need to dispatch (original_sender == " "last_receiver). Original sender is {}.", - event_name.ToUtf8(), original_sender->GetControlType().ToUtf8()); + event_name, original_sender->GetControlType()); return; } @@ -55,15 +55,15 @@ void DispatchEvent( if constexpr (debug_flags::routed_event) { std::string log = "Dispatch routed event "; - log += event_name.ToUtf8(); + log += event_name; log += ". Path (parent first): "; auto i = receive_list.crbegin(); const auto end = --receive_list.crend(); for (; i != end; ++i) { - log += i->Resolve()->GetControlType().ToUtf8(); + log += i->Resolve()->GetControlType(); log += " -> "; } - log += i->Resolve()->GetControlType().ToUtf8(); + log += i->Resolve()->GetControlType(); CRU_LOG_TAG_DEBUG("{}", log); } diff --git a/src/ui/host/WindowHost.cpp b/src/ui/host/WindowHost.cpp index 88e8cc87..4c707772 100644 --- a/src/ui/host/WindowHost.cpp +++ b/src/ui/host/WindowHost.cpp @@ -21,8 +21,7 @@ using platform::gui::INativeWindow; using platform::gui::IUiApplication; namespace event_names { -#define CRU_DEFINE_EVENT_NAME(name) \ - constexpr const char16_t* name = CRU_MAKE_UNICODE_LITERAL(name); +#define CRU_DEFINE_EVENT_NAME(name) constexpr const char* name = #name; CRU_DEFINE_EVENT_NAME(LoseFocus) CRU_DEFINE_EVENT_NAME(GainFocus) diff --git a/src/ui/mapper/FontMapper.cpp b/src/ui/mapper/FontMapper.cpp index a0dcdd9f..ebf7c27c 100644 --- a/src/ui/mapper/FontMapper.cpp +++ b/src/ui/mapper/FontMapper.cpp @@ -1,6 +1,5 @@ #include "cru/ui/mapper/FontMapper.h" #include "../Helper.h" -#include "cru/base/String.h" #include "cru/base/StringUtil.h" #include "cru/platform/graphics/Factory.h" diff --git a/src/ui/mapper/StringMapper.cpp b/src/ui/mapper/StringMapper.cpp index 5914da17..6f6b4546 100644 --- a/src/ui/mapper/StringMapper.cpp +++ b/src/ui/mapper/StringMapper.cpp @@ -1,19 +1,18 @@ #include "cru/ui/mapper/StringMapper.h" #include "cru/xml/XmlNode.h" -#include "cru/base/String.h" namespace cru::ui::mapper { StringMapper::StringMapper() { SetAllowedTags({"String"}); } StringMapper::~StringMapper() {} -String StringMapper::DoMapFromString(std::string str) { - return String::FromUtf8(str); +std::string StringMapper::DoMapFromString(std::string str) { + return std::move(str); } -String StringMapper::DoMapFromXml(xml::XmlElementNode* node) { +std::string StringMapper::DoMapFromXml(xml::XmlElementNode* node) { auto value_attr = node->GetOptionalAttributeValueCaseInsensitive("value"); - if (value_attr) return String::FromUtf8(*value_attr); + if (value_attr) return *value_attr; return {}; } } // namespace cru::ui::mapper diff --git a/src/ui/render/BorderRenderObject.cpp b/src/ui/render/BorderRenderObject.cpp index 957cf9bb..5c4bc22c 100644 --- a/src/ui/render/BorderRenderObject.cpp +++ b/src/ui/render/BorderRenderObject.cpp @@ -244,5 +244,5 @@ void BorderRenderObject::RecreateGeometry() { builder.reset(); } -String BorderRenderObject::GetName() const { return u"BorderRenderObject"; } +std::string BorderRenderObject::GetName() const { return "BorderRenderObject"; } } // namespace cru::ui::render diff --git a/src/ui/render/FlexLayoutRenderObject.cpp b/src/ui/render/FlexLayoutRenderObject.cpp index efc98602..53193867 100644 --- a/src/ui/render/FlexLayoutRenderObject.cpp +++ b/src/ui/render/FlexLayoutRenderObject.cpp @@ -4,12 +4,11 @@ #include "cru/ui/render/LayoutHelper.h" #include <algorithm> -#include <functional> #include <type_traits> namespace cru::ui::render { -String FlexLayoutRenderObject::GetName() const { - return u"FlexLayoutRenderObject"; +std::string FlexLayoutRenderObject::GetName() const { + return "FlexLayoutRenderObject"; } struct tag_horizontal_t {}; diff --git a/src/ui/render/RenderObject.cpp b/src/ui/render/RenderObject.cpp index 521e88c2..d10fd897 100644 --- a/src/ui/render/RenderObject.cpp +++ b/src/ui/render/RenderObject.cpp @@ -119,16 +119,17 @@ void RenderObject::Measure(const MeasureRequirement& requirement, preferred_size.OverrideBy(preferred_size_); if constexpr (cru::ui::debug_flags::layout) { - CRU_LOG_TAG_DEBUG("{} Measure begins :\nrequirement: {}\npreferred size: {}", - this->GetDebugPathInTree().ToUtf8(), requirement.ToDebugString().ToUtf8(), - preferred_size.ToDebugString().ToUtf8()); + CRU_LOG_TAG_DEBUG( + "{} Measure begins :\nrequirement: {}\npreferred size: {}", + this->GetDebugPathInTree(), requirement.ToDebugString(), + preferred_size.ToDebugString()); } desired_size_ = OnMeasureCore(merged_requirement, merged_preferred_size); if constexpr (cru::ui::debug_flags::layout) { CRU_LOG_TAG_DEBUG("{} Measure ends :\nresult size: {}", - this->GetDebugPathInTree().ToUtf8(), desired_size_); + this->GetDebugPathInTree(), desired_size_); } Ensures(desired_size_.width >= 0); @@ -145,7 +146,7 @@ Size RenderObject::Measure1(const BoxConstraint& constraint) { void RenderObject::Layout(const Point& offset) { if constexpr (cru::ui::debug_flags::layout) { CRU_LOG_TAG_DEBUG("{} Layout :\noffset: {} size: {}", - this->GetDebugPathInTree().ToUtf8(), offset, desired_size_); + this->GetDebugPathInTree(), offset, desired_size_); } offset_ = offset; size_ = desired_size_; @@ -193,13 +194,13 @@ Size RenderObject::OnMeasureCore1(const BoxConstraint& constraint) { if (space_size.width > merged_constraint.max.width) { space_size.width = merged_constraint.max.width; CRU_LOG_TAG_WARN("{} space width is over constraint.max.width", - this->GetDebugPathInTree().ToUtf8()); + this->GetDebugPathInTree()); } if (space_size.height > merged_constraint.max.height) { space_size.height = merged_constraint.max.height; CRU_LOG_TAG_WARN("{} space height is over constraint.max.height", - this->GetDebugPathInTree().ToUtf8()); + this->GetDebugPathInTree()); } BoxConstraint content_constraint{merged_constraint.max - space_size, @@ -284,20 +285,20 @@ void RenderObject::InvalidatePaint() { } } -String kUnamedName(u"UNNAMED"); -String RenderObject::GetName() const { return kUnamedName; } +std::string kUnamedName("UNNAMED"); +std::string RenderObject::GetName() const { return kUnamedName; } -String RenderObject::GetDebugPathInTree() const { - std::vector<String> chain; +std::string RenderObject::GetDebugPathInTree() const { + std::vector<std::string> chain; const RenderObject* parent = this; while (parent != nullptr) { chain.push_back(parent->GetName()); parent = parent->GetParent(); } - String result(chain.back()); + std::string result(chain.back()); for (auto iter = chain.crbegin() + 1; iter != chain.crend(); ++iter) { - result += u" -> "; + result += " -> "; result += *iter; } diff --git a/src/ui/style/StyleRule.cpp b/src/ui/style/StyleRule.cpp index ce823537..8b9b0a56 100644 --- a/src/ui/style/StyleRule.cpp +++ b/src/ui/style/StyleRule.cpp @@ -2,7 +2,7 @@ namespace cru::ui::style { StyleRule::StyleRule(ClonablePtr<Condition> condition, - ClonablePtr<Styler> styler, String name) + ClonablePtr<Styler> styler, std::string name) : condition_(std::move(condition)), styler_(std::move(styler)), name_(std::move(name)) {} |