diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/ThemeResourceDictionary.cpp | 5 | ||||
-rw-r--r-- | src/ui/controls/Control.cpp | 2 | ||||
-rw-r--r-- | src/ui/controls/TextHostControlService.cpp | 12 | ||||
-rw-r--r-- | src/ui/helper/ClickDetector.cpp | 4 | ||||
-rw-r--r-- | src/ui/helper/ShortcutHub.cpp | 24 | ||||
-rw-r--r-- | src/ui/host/RoutedEventDispatch.h | 28 | ||||
-rw-r--r-- | src/ui/host/WindowHost.cpp | 2 | ||||
-rw-r--r-- | src/ui/render/BorderRenderObject.cpp | 14 | ||||
-rw-r--r-- | src/ui/render/FlexLayoutRenderObject.cpp | 4 | ||||
-rw-r--r-- | src/ui/render/RenderObject.cpp | 22 | ||||
-rw-r--r-- | src/ui/render/TextRenderObject.cpp | 7 |
11 files changed, 65 insertions, 59 deletions
diff --git a/src/ui/ThemeResourceDictionary.cpp b/src/ui/ThemeResourceDictionary.cpp index fff25e09..421723f5 100644 --- a/src/ui/ThemeResourceDictionary.cpp +++ b/src/ui/ThemeResourceDictionary.cpp @@ -47,10 +47,11 @@ void ThemeResourceDictionary::UpdateResourceMap(xml::XmlElementNode* xml_root) { resource_map_[entry.name] = std::move(entry); } else { - CRU_LOG_TAG_DEBUG(u"Ignore unknown element {} of theme.", c->GetTag()); + CRU_LOG_TAG_DEBUG("Ignore unknown element {} of theme.", + c->GetTag().ToUtf8()); } } else { - CRU_LOG_TAG_DEBUG(u"Ignore text or comment node of theme."); + CRU_LOG_TAG_DEBUG("Ignore text or comment node of theme."); } } } diff --git a/src/ui/controls/Control.cpp b/src/ui/controls/Control.cpp index d6770684..3218f185 100644 --- a/src/ui/controls/Control.cpp +++ b/src/ui/controls/Control.cpp @@ -31,7 +31,7 @@ Control::Control() { Control::~Control() { if (host::WindowHost::IsInEventHandling()) { CRU_LOG_TAG_ERROR( - u"Control destroyed during event handling. Please use DeleteLater."); + "Control destroyed during event handling. Please use DeleteLater."); } in_destruction_ = true; diff --git a/src/ui/controls/TextHostControlService.cpp b/src/ui/controls/TextHostControlService.cpp index bc562e88..ace02a46 100644 --- a/src/ui/controls/TextHostControlService.cpp +++ b/src/ui/controls/TextHostControlService.cpp @@ -227,7 +227,7 @@ void TextHostControlService::SetText(String text, bool stop_composition) { void TextHostControlService::InsertText(Index position, StringView text, bool stop_composition) { if (!Utf16IsValidInsertPosition(this->text_, position)) { - CRU_LOG_TAG_ERROR(u"Invalid text insert position."); + CRU_LOG_TAG_ERROR("Invalid text insert position."); return; } this->text_.insert(this->text_.cbegin() + position, text); @@ -240,7 +240,7 @@ void TextHostControlService::InsertText(Index position, StringView text, void TextHostControlService::DeleteChar(Index position, bool stop_composition) { if (!Utf16IsValidInsertPosition(this->text_, position)) { - CRU_LOG_TAG_ERROR(u"Invalid text delete position."); + CRU_LOG_TAG_ERROR("Invalid text delete position."); return; } if (position == static_cast<Index>(this->text_.size())) return; @@ -253,7 +253,7 @@ void TextHostControlService::DeleteChar(Index position, bool stop_composition) { Index TextHostControlService::DeleteCharPrevious(Index position, bool stop_composition) { if (!Utf16IsValidInsertPosition(this->text_, position)) { - CRU_LOG_TAG_ERROR(u"Invalid text delete position."); + CRU_LOG_TAG_ERROR("Invalid text delete position."); return 0; } if (position == 0) return 0; @@ -269,11 +269,11 @@ void TextHostControlService::DeleteText(TextRange range, if (range.count == 0) return; range = range.Normalize(); if (!Utf16IsValidInsertPosition(this->text_, range.GetStart())) { - CRU_LOG_TAG_ERROR(u"Invalid text delete start position."); + CRU_LOG_TAG_ERROR("Invalid text delete start position."); return; } if (!Utf16IsValidInsertPosition(this->text_, range.GetStart())) { - CRU_LOG_TAG_ERROR(u"Invalid text delete end position."); + CRU_LOG_TAG_ERROR("Invalid text delete end position."); return; } this->text_.erase(this->text_.cbegin() + range.GetStart(), @@ -465,7 +465,7 @@ void TextHostControlService::UpdateInputMethodPosition() { right_bottom.y += 5; if constexpr (debug_flags::text_service) { - CRU_LOG_TAG_DEBUG(u"Calculate input method candidate window position: {}.", + CRU_LOG_TAG_DEBUG("Calculate input method candidate window position: {}.", right_bottom); } diff --git a/src/ui/helper/ClickDetector.cpp b/src/ui/helper/ClickDetector.cpp index b7e800a8..2e3dc1a0 100644 --- a/src/ui/helper/ClickDetector.cpp +++ b/src/ui/helper/ClickDetector.cpp @@ -58,7 +58,7 @@ ClickDetector::ClickDetector(controls::Control* control) { this->state_ == ClickState::Hover) { if (!this->control_->CaptureMouse()) { if constexpr (debug_flags::click_detector) { - CRU_LOG_TAG_DEBUG(u"Failed to capture mouse when begin click."); + CRU_LOG_TAG_DEBUG("Failed to capture mouse when begin click."); } return; } @@ -137,7 +137,7 @@ void ClickDetector::SetState(ClickState state) { UnreachableCode(); } }; - CRU_LOG_TAG_DEBUG(u"Click state changed, new state: {}.", to_string(state)); + CRU_LOG_TAG_DEBUG("Click state changed, new state: {}.", to_string(state)); } state_ = state; diff --git a/src/ui/helper/ShortcutHub.cpp b/src/ui/helper/ShortcutHub.cpp index c413ab2a..e3a06e8c 100644 --- a/src/ui/helper/ShortcutHub.cpp +++ b/src/ui/helper/ShortcutHub.cpp @@ -64,7 +64,7 @@ const std::vector<ShortcutInfo>& ShortcutHub::GetShortcutByKeyBind( void ShortcutHub::Install(controls::Control* control) { if (!event_guard_.IsEmpty()) { - CRU_LOG_TAG_ERROR(u"Shortcut hub is already installed. Failed to install."); + CRU_LOG_TAG_ERROR("Shortcut hub is already installed. Failed to install."); return; } @@ -74,7 +74,7 @@ void ShortcutHub::Install(controls::Control* control) { void ShortcutHub::Uninstall() { if (event_guard_.IsEmpty()) { - CRU_LOG_TAG_WARN(u"Shortcut hub is not installed. Failed to uninstall."); + CRU_LOG_TAG_WARN("Shortcut hub is not installed. Failed to uninstall."); return; } @@ -89,17 +89,18 @@ void ShortcutHub::OnKeyDown(events::KeyEventArgs& event) { if constexpr (debug_flags::shortcut) { if (shortcut_list.empty()) { - CRU_LOG_TAG_DEBUG(u"No shortcut for key bind {}.", key_bind.ToString()); + CRU_LOG_TAG_DEBUG("No shortcut for key bind {}.", + key_bind.ToString().ToUtf8()); } - CRU_LOG_TAG_DEBUG(u"Begin to handle shortcut for key bind {}.", - key_bind.ToString()); + CRU_LOG_TAG_DEBUG("Begin to handle shortcut for key bind {}.", + key_bind.ToString()); } for (const auto& shortcut : shortcut_list) { auto is_handled = shortcut.handler(); if (is_handled) { if constexpr (debug_flags::shortcut) { - CRU_LOG_TAG_DEBUG(u"Handle {} handled it.", shortcut.name); + CRU_LOG_TAG_DEBUG("Handle {} handled it.", shortcut.name.ToUtf8()); } handled = true; @@ -108,23 +109,24 @@ void ShortcutHub::OnKeyDown(events::KeyEventArgs& event) { break; } else { if constexpr (debug_flags::shortcut) { - CRU_LOG_TAG_DEBUG(u"Handle {} didn't handle it.", shortcut.name); + CRU_LOG_TAG_DEBUG("Handle {} didn't handle it.", + shortcut.name.ToUtf8()); } } } if constexpr (debug_flags::shortcut) { if (!shortcut_list.empty()) { - CRU_LOG_TAG_DEBUG(u"End handling shortcut for key bind {}.", - key_bind.ToString()); + CRU_LOG_TAG_DEBUG("End handling shortcut for key bind {}.", + key_bind.ToString().ToUtf8()); } } if (!handled) { if constexpr (debug_flags::shortcut) { CRU_LOG_TAG_DEBUG( - u"Raise fallback event for unhandled shortcut of key bind {}.", - key_bind.ToString()); + "Raise fallback event for unhandled shortcut of key bind {}.", + key_bind.ToString().ToUtf8()); } fallback_event_.Raise(event); } diff --git a/src/ui/host/RoutedEventDispatch.h b/src/ui/host/RoutedEventDispatch.h index 6677deea..4efc9208 100644 --- a/src/ui/host/RoutedEventDispatch.h +++ b/src/ui/host/RoutedEventDispatch.h @@ -26,7 +26,7 @@ void DispatchEvent( const 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 = u"DispatchEvent"; + constexpr auto kLogTag = "DispatchEvent"; if (original_sender == nullptr) return; @@ -35,9 +35,9 @@ void DispatchEvent( if (original_sender == last_receiver) { if constexpr (debug_flags::routed_event) CRU_LOG_TAG_DEBUG( - u"Routed event {} no need to dispatch (original_sender == " + "Routed event {} no need to dispatch (original_sender == " "last_receiver). Original sender is {}.", - event_name, original_sender->GetControlType()); + event_name.ToUtf8(), original_sender->GetControlType().ToUtf8()); return; } @@ -54,16 +54,16 @@ void DispatchEvent( } if constexpr (debug_flags::routed_event) { - String log = u"Dispatch routed event "; - log += event_name; - log += u". Path (parent first): "; + std::string log = "Dispatch routed event "; + log += event_name.ToUtf8(); + log += ". Path (parent first): "; auto i = receive_list.crbegin(); const auto end = --receive_list.crend(); for (; i != end; ++i) { - log += i->Resolve()->GetControlType(); - log += u" -> "; + log += i->Resolve()->GetControlType().ToUtf8(); + log += " -> "; } - log += i->Resolve()->GetControlType(); + log += i->Resolve()->GetControlType().ToUtf8(); CRU_LOG_TAG_DEBUG(log); } @@ -83,8 +83,8 @@ void DispatchEvent( handled = true; if constexpr (debug_flags::routed_event) CRU_LOG_TAG_DEBUG( - u"Routed event is short-circuit in TUNNEL at {}-st control (count " - u"from parent).", + "Routed event is short-circuit in TUNNEL at {}-st control (count " + "from parent).", count); break; } @@ -103,8 +103,8 @@ void DispatchEvent( if (event_args.IsHandled()) { if constexpr (debug_flags::routed_event) CRU_LOG_TAG_DEBUG( - u"Routed event is short-circuit in BUBBLE at {}-st control " - u"(count from parent).", + "Routed event is short-circuit in BUBBLE at {}-st control " + "(count from parent).", count); break; } @@ -121,7 +121,7 @@ void DispatchEvent( } if constexpr (debug_flags::routed_event) - CRU_LOG_TAG_DEBUG(u"Routed event dispatch finished."); + CRU_LOG_TAG_DEBUG("Routed event dispatch finished."); WindowHost::LeaveEventHandling(); } diff --git a/src/ui/host/WindowHost.cpp b/src/ui/host/WindowHost.cpp index 9d0e2006..59e383c5 100644 --- a/src/ui/host/WindowHost.cpp +++ b/src/ui/host/WindowHost.cpp @@ -202,7 +202,7 @@ void WindowHost::RelayoutWithSize(const Size& available_size, for (auto& action : after_layout_stable_action_) action(); after_layout_event_.Raise(AfterLayoutEventArgs{}); after_layout_stable_action_.clear(); - if constexpr (debug_flags::layout) CRU_LOG_TAG_DEBUG(u"A relayout is finished."); + if constexpr (debug_flags::layout) CRU_LOG_TAG_DEBUG("A relayout is finished."); } void WindowHost::Repaint() { diff --git a/src/ui/render/BorderRenderObject.cpp b/src/ui/render/BorderRenderObject.cpp index 0e97c5e8..03fdff24 100644 --- a/src/ui/render/BorderRenderObject.cpp +++ b/src/ui/render/BorderRenderObject.cpp @@ -82,11 +82,13 @@ RenderObject* BorderRenderObject::HitTest(const Point& point) { void BorderRenderObject::Draw(platform::graphics::IPainter* painter) { if constexpr (debug_flags::draw) { CRU_LOG_TAG_DEBUG( - u"BorderRenderObject draw, background: {}, foreground: {}.", - background_brush_ == nullptr ? u"NONE" - : background_brush_->GetDebugString(), - foreground_brush_ == nullptr ? u"NONE" - : foreground_brush_->GetDebugString()); + "BorderRenderObject draw, background: {}, foreground: {}.", + background_brush_ == nullptr + ? "NONE" + : background_brush_->GetDebugString().ToUtf8(), + foreground_brush_ == nullptr + ? "NONE" + : foreground_brush_->GetDebugString().ToUtf8()); } if (background_brush_ != nullptr) @@ -95,7 +97,7 @@ void BorderRenderObject::Draw(platform::graphics::IPainter* painter) { if (is_border_enabled_) { if (border_brush_ == nullptr) { - CRU_LOG_TAG_WARN(u"Border is enabled but border brush is null."); + CRU_LOG_TAG_WARN("Border is enabled but border brush is null."); } else { painter->FillGeometry(geometry_.get(), border_brush_.get()); } diff --git a/src/ui/render/FlexLayoutRenderObject.cpp b/src/ui/render/FlexLayoutRenderObject.cpp index 588c379b..efc98602 100644 --- a/src/ui/render/FlexLayoutRenderObject.cpp +++ b/src/ui/render/FlexLayoutRenderObject.cpp @@ -90,7 +90,7 @@ Size FlexLayoutMeasureContentImpl( const MeasureRequirement& requirement, const MeasureSize& preferred_size, const std::vector<RenderObject*>& children, const std::vector<FlexChildLayoutData>& layout_data, - Alignment item_cross_align, String kLogTag) { + Alignment item_cross_align, std::string kLogTag) { Expects(children.size() == layout_data.size()); direction_tag_t direction_tag; @@ -301,7 +301,7 @@ Size FlexLayoutMeasureContentImpl( if (max_main_length.IsSpecified() && total_length > max_main_length.GetLengthOrUndefined()) { CRU_LOG_TAG_WARN( - u"(Measure) Children's main axis length exceeds required max length."); + "(Measure) Children's main axis length exceeds required max length."); total_length = max_main_length.GetLengthOrUndefined(); } else if (min_main_length.IsSpecified() && total_length < min_main_length.GetLengthOrUndefined()) { diff --git a/src/ui/render/RenderObject.cpp b/src/ui/render/RenderObject.cpp index b3a28d6d..1803a131 100644 --- a/src/ui/render/RenderObject.cpp +++ b/src/ui/render/RenderObject.cpp @@ -119,16 +119,16 @@ void RenderObject::Measure(const MeasureRequirement& requirement, preferred_size.OverrideBy(preferred_size_); if constexpr (cru::ui::debug_flags::layout) { - CRU_LOG_TAG_DEBUG(u"{} Measure begins :\nrequirement: {}\npreferred size: {}", - this->GetDebugPathInTree(), requirement.ToDebugString(), - preferred_size.ToDebugString()); + CRU_LOG_TAG_DEBUG("{} Measure begins :\nrequirement: {}\npreferred size: {}", + this->GetDebugPathInTree().ToUtf8(), requirement.ToDebugString().ToUtf8(), + preferred_size.ToDebugString().ToUtf8()); } desired_size_ = OnMeasureCore(merged_requirement, merged_preferred_size); if constexpr (cru::ui::debug_flags::layout) { - CRU_LOG_TAG_DEBUG(u"{} Measure ends :\nresult size: {}", - this->GetDebugPathInTree(), desired_size_); + CRU_LOG_TAG_DEBUG("{} Measure ends :\nresult size: {}", + this->GetDebugPathInTree().ToUtf8(), desired_size_); } Ensures(desired_size_.width >= 0); @@ -144,8 +144,8 @@ Size RenderObject::Measure1(const BoxConstraint& constraint) { void RenderObject::Layout(const Point& offset) { if constexpr (cru::ui::debug_flags::layout) { - CRU_LOG_TAG_DEBUG(u"{} Layout :\noffset: {} size: {}", - this->GetDebugPathInTree(), offset, desired_size_); + CRU_LOG_TAG_DEBUG("{} Layout :\noffset: {} size: {}", + this->GetDebugPathInTree().ToUtf8(), offset, desired_size_); } offset_ = offset; size_ = desired_size_; @@ -192,14 +192,14 @@ 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(u"{} space width is over constraint.max.width", - this->GetDebugPathInTree()); + CRU_LOG_TAG_WARN("{} space width is over constraint.max.width", + this->GetDebugPathInTree().ToUtf8()); } if (space_size.height > merged_constraint.max.height) { space_size.height = merged_constraint.max.height; - CRU_LOG_TAG_WARN(u"{} space height is over constraint.max.height", - this->GetDebugPathInTree()); + CRU_LOG_TAG_WARN("{} space height is over constraint.max.height", + this->GetDebugPathInTree().ToUtf8()); } BoxConstraint content_constraint{merged_constraint.max - space_size, diff --git a/src/ui/render/TextRenderObject.cpp b/src/ui/render/TextRenderObject.cpp index 8a579041..346b4957 100644 --- a/src/ui/render/TextRenderObject.cpp +++ b/src/ui/render/TextRenderObject.cpp @@ -178,10 +178,11 @@ RenderObject* TextRenderObject::HitTest(const Point& point) { void TextRenderObject::Draw(platform::graphics::IPainter* painter) { if constexpr (debug_flags::draw) { CRU_LOG_TAG_DEBUG( - u"Begin to paint, total_offset: {}, size: {}, text_layout: " - u"{}, brush: {}.", + "Begin to paint, total_offset: {}, size: {}, text_layout: " + "{}, brush: {}.", this->GetTotalOffset(), this->GetDesiredSize(), - this->text_layout_->GetDebugString(), this->brush_->GetDebugString()); + this->text_layout_->GetDebugString().ToUtf8(), + this->brush_->GetDebugString().ToUtf8()); } if (this->selection_range_.has_value()) { |