diff options
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/ThemeResourceDictionary.cpp | 5 | ||||
| -rw-r--r-- | src/ui/controls/Control.cpp | 3 | ||||
| -rw-r--r-- | src/ui/controls/ControlHost.cpp | 2 | ||||
| -rw-r--r-- | src/ui/controls/TextHostControlService.cpp | 20 | ||||
| -rw-r--r-- | src/ui/helper/ClickDetector.cpp | 7 | ||||
| -rw-r--r-- | src/ui/helper/ShortcutHub.cpp | 25 | ||||
| -rw-r--r-- | src/ui/render/BorderRenderObject.cpp | 6 | ||||
| -rw-r--r-- | src/ui/render/FlexLayoutRenderObject.cpp | 3 | ||||
| -rw-r--r-- | src/ui/render/RenderObject.cpp | 14 | ||||
| -rw-r--r-- | src/ui/render/TextRenderObject.cpp | 11 |
10 files changed, 52 insertions, 44 deletions
diff --git a/src/ui/ThemeResourceDictionary.cpp b/src/ui/ThemeResourceDictionary.cpp index 9f734054..82cad6c0 100644 --- a/src/ui/ThemeResourceDictionary.cpp +++ b/src/ui/ThemeResourceDictionary.cpp @@ -48,10 +48,11 @@ void ThemeResourceDictionary::UpdateResourceMap(xml::XmlElementNode* xml_root) { resource_map_[entry.name] = std::move(entry); } else { - CRU_LOG_TAG_DEBUG("Ignore unknown element {} of theme.", c->GetTag()); + CruLogDebug(kLogTag, "Ignore unknown element {} of theme.", + c->GetTag()); } } else { - CRU_LOG_TAG_DEBUG("Ignore text or comment node of theme."); + CruLogDebug(kLogTag, "Ignore text or comment node of theme."); } } } diff --git a/src/ui/controls/Control.cpp b/src/ui/controls/Control.cpp index 2a94252f..548c9726 100644 --- a/src/ui/controls/Control.cpp +++ b/src/ui/controls/Control.cpp @@ -23,7 +23,8 @@ Control::Control(std::string name) Control::~Control() { if (host_ && host_->IsInEventHandling()) { - CRU_LOG_TAG_WARN( + CruLogWarn( + kLogTag, "Better use delete later to delete control during event handling."); } diff --git a/src/ui/controls/ControlHost.cpp b/src/ui/controls/ControlHost.cpp index 7c934b7b..1dabb26f 100644 --- a/src/ui/controls/ControlHost.cpp +++ b/src/ui/controls/ControlHost.cpp @@ -168,7 +168,7 @@ void ControlHost::RelayoutWithSize(const Size& available_size, } render_object->Layout(Point{}); - CRU_LOG_TAG_DEBUG("A relayout is finished."); + CruLogDebug(kLogTag, "A relayout is finished."); AfterLayoutEvent_.Raise(nullptr); diff --git a/src/ui/controls/TextHostControlService.cpp b/src/ui/controls/TextHostControlService.cpp index 39c28393..9c57140c 100644 --- a/src/ui/controls/TextHostControlService.cpp +++ b/src/ui/controls/TextHostControlService.cpp @@ -222,7 +222,7 @@ void TextHostControlService::SetText(std::string text, bool stop_composition) { void TextHostControlService::InsertText(Index position, std::string_view text, bool stop_composition) { if (!Utf8IsValidInsertPosition(this->text_, position)) { - CRU_LOG_TAG_ERROR("Invalid text insert position."); + CruLogError(kLogTag, "Invalid text insert position."); return; } this->text_.insert(this->text_.cbegin() + position, text.cbegin(), @@ -236,7 +236,7 @@ void TextHostControlService::InsertText(Index position, std::string_view text, void TextHostControlService::DeleteChar(Index position, bool stop_composition) { if (!Utf8IsValidInsertPosition(this->text_, position)) { - CRU_LOG_TAG_ERROR("Invalid text delete position {}.", position); + CruLogError(kLogTag, "Invalid text delete position {}.", position); return; } if (position == static_cast<Index>(this->text_.size())) return; @@ -249,7 +249,7 @@ void TextHostControlService::DeleteChar(Index position, bool stop_composition) { Index TextHostControlService::DeleteCharPrevious(Index position, bool stop_composition) { if (!Utf8IsValidInsertPosition(this->text_, position)) { - CRU_LOG_TAG_ERROR("Invalid text delete position {}.", position); + CruLogError(kLogTag, "Invalid text delete position {}.", position); return 0; } if (position == 0) return 0; @@ -265,12 +265,13 @@ void TextHostControlService::DeleteText(TextRange range, if (range.count == 0) return; range = range.Normalize(); if (!Utf8IsValidInsertPosition(this->text_, range.GetStart())) { - CRU_LOG_TAG_ERROR("Invalid text delete start position {}.", - range.GetStart()); + CruLogError(kLogTag, "Invalid text delete start position {}.", + range.GetStart()); return; } if (!Utf8IsValidInsertPosition(this->text_, range.GetEnd())) { - CRU_LOG_TAG_ERROR("Invalid text delete end position {}.", range.GetEnd()); + CruLogError(kLogTag, "Invalid text delete end position {}.", + range.GetEnd()); return; } this->text_.erase(this->text_.cbegin() + range.GetStart(), @@ -464,8 +465,9 @@ void TextHostControlService::UpdateInputMethodPosition() { right_bottom.y += 5; if constexpr (debug_flags::text_service) { - CRU_LOG_TAG_DEBUG("Calculate input method candidate window position: {}.", - right_bottom); + CruLogDebug(kLogTag, + "Calculate input method candidate window position: {}.", + right_bottom); } input_method_context->SetCandidateWindowPosition(right_bottom); @@ -691,7 +693,7 @@ void TextHostControlService::SetUpShortcuts() { void TextHostControlService::OpenContextMenu(const Point& position, ContextMenuItem items) { - CRU_LOG_TAG_DEBUG("Open context menu."); + CruLogDebug(kLogTag, "Open context menu."); if (!context_menu_) { context_menu_.reset(new components::PopupMenu()); } diff --git a/src/ui/helper/ClickDetector.cpp b/src/ui/helper/ClickDetector.cpp index 0ac0515f..caa7061f 100644 --- a/src/ui/helper/ClickDetector.cpp +++ b/src/ui/helper/ClickDetector.cpp @@ -55,8 +55,8 @@ ClickDetector::ClickDetector(controls::Control* control) { this->state_ == ClickState::Hover) { if (!this->control_->CaptureMouse()) { if constexpr (debug_flags::click_detector) { - CRU_LOG_TAG_DEBUG( - "Failed to capture mouse when begin click."); + CruLogDebug(kLogTag, + "Failed to capture mouse when begin click."); } return; } @@ -133,7 +133,8 @@ void ClickDetector::SetState(ClickState state) { UnreachableCode(); } }; - CRU_LOG_TAG_DEBUG("Click state changed, new state: {}.", to_string(state)); + CruLogDebug(kLogTag, "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 fd23802e..13cce216 100644 --- a/src/ui/helper/ShortcutHub.cpp +++ b/src/ui/helper/ShortcutHub.cpp @@ -64,7 +64,8 @@ const std::vector<ShortcutInfo>& ShortcutHub::GetShortcutByKeyBind( void ShortcutHub::Install(controls::Control* control) { if (!event_guard_.IsEmpty()) { - CRU_LOG_TAG_ERROR("Shortcut hub is already installed. Failed to install."); + CruLogError(kLogTag, + "Shortcut hub is already installed. Failed to install."); return; } @@ -74,7 +75,7 @@ void ShortcutHub::Install(controls::Control* control) { void ShortcutHub::Uninstall() { if (event_guard_.IsEmpty()) { - CRU_LOG_TAG_WARN("Shortcut hub is not installed. Failed to uninstall."); + CruLogWarn(kLogTag, "Shortcut hub is not installed. Failed to uninstall."); return; } @@ -89,17 +90,17 @@ void ShortcutHub::OnKeyDown(events::KeyEventArgs& event) { if constexpr (debug_flags::shortcut) { if (shortcut_list.empty()) { - CRU_LOG_TAG_DEBUG("No shortcut for key bind {}.", key_bind.ToString()); + CruLogDebug(kLogTag, "No shortcut for key bind {}.", key_bind.ToString()); } - CRU_LOG_TAG_DEBUG("Begin to handle shortcut for key bind {}.", - key_bind.ToString()); + CruLogDebug(kLogTag, "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("Handle {} handled it.", shortcut.name); + CruLogDebug(kLogTag, "Handle {} handled it.", shortcut.name); } handled = true; @@ -108,23 +109,23 @@ void ShortcutHub::OnKeyDown(events::KeyEventArgs& event) { break; } else { if constexpr (debug_flags::shortcut) { - CRU_LOG_TAG_DEBUG("Handle {} didn't handle it.", shortcut.name); + CruLogDebug(kLogTag, "Handle {} didn't handle it.", shortcut.name); } } } if constexpr (debug_flags::shortcut) { if (!shortcut_list.empty()) { - CRU_LOG_TAG_DEBUG("End handling shortcut for key bind {}.", - key_bind.ToString()); + CruLogDebug(kLogTag, "End handling shortcut for key bind {}.", + key_bind.ToString()); } } if (!handled) { if constexpr (debug_flags::shortcut) { - CRU_LOG_TAG_DEBUG( - "Raise fallback event for unhandled shortcut of key bind {}.", - key_bind.ToString()); + CruLogDebug(kLogTag, + "Raise fallback event for unhandled shortcut of key bind {}.", + key_bind.ToString()); } fallback_event_.Raise(event); } diff --git a/src/ui/render/BorderRenderObject.cpp b/src/ui/render/BorderRenderObject.cpp index 18fc6475..080bcc4f 100644 --- a/src/ui/render/BorderRenderObject.cpp +++ b/src/ui/render/BorderRenderObject.cpp @@ -82,8 +82,8 @@ RenderObject* BorderRenderObject::HitTest(const Point& point) { void BorderRenderObject::Draw(platform::graphics::IPainter* painter) { if constexpr (debug_flags::draw) { - CRU_LOG_TAG_DEBUG( - "BorderRenderObject draw, background: {}, foreground: {}.", + CruLogDebug( + kLogTag, "BorderRenderObject draw, background: {}, foreground: {}.", background_brush_ == nullptr ? "NONE" : background_brush_->GetDebugString(), foreground_brush_ == nullptr ? "NONE" @@ -96,7 +96,7 @@ void BorderRenderObject::Draw(platform::graphics::IPainter* painter) { if (is_border_enabled_) { if (border_brush_ == nullptr) { - CRU_LOG_TAG_WARN("Border is enabled but border brush is null."); + CruLogWarn(kLogTag, "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 124f7e70..4c7762e3 100644 --- a/src/ui/render/FlexLayoutRenderObject.cpp +++ b/src/ui/render/FlexLayoutRenderObject.cpp @@ -299,7 +299,8 @@ Size FlexLayoutMeasureContentImpl( if (max_main_length.IsSpecified() && total_length > max_main_length.GetLengthOrUndefined()) { - CRU_LOG_TAG_WARN( + CruLogWarn( + kLogTag, "(Measure) Children's main axis length exceeds required max length."); total_length = max_main_length.GetLengthOrUndefined(); } else if (min_main_length.IsSpecified() && diff --git a/src/ui/render/RenderObject.cpp b/src/ui/render/RenderObject.cpp index 424fd2ee..f6f081ec 100644 --- a/src/ui/render/RenderObject.cpp +++ b/src/ui/render/RenderObject.cpp @@ -82,8 +82,8 @@ void RenderObject::SetMaxSize(const MeasureSize& max_size) { } void RenderObject::Measure(const MeasureRequirement& requirement) { - CRU_LOG_TAG_DEBUG("{} Measure begins, requirement {}.", - this->GetDebugPathInTree(), requirement); + CruLogDebug(kLogTag, "{} Measure begins, requirement {}.", + this->GetDebugPathInTree(), requirement); if (layout_valid_ && requirement == last_measure_requirement_) { return; @@ -96,8 +96,8 @@ void RenderObject::Measure(const MeasureRequirement& requirement) { last_measure_requirement_ = requirement; - CRU_LOG_TAG_DEBUG("{} Measure ends, result size: {}.", - this->GetDebugPathInTree(), measure_result_size_); + CruLogDebug(kLogTag, "{} Measure ends, result size: {}.", + this->GetDebugPathInTree(), measure_result_size_); } void RenderObject::Layout(const Point& offset) { @@ -105,8 +105,8 @@ void RenderObject::Layout(const Point& offset) { } void RenderObject::Layout(const Rect& rect) { - CRU_LOG_TAG_DEBUG("{} Layout begins, rect: {}.", this->GetDebugPathInTree(), - rect); + CruLogDebug(kLogTag, "{} Layout begins, rect: {}.", + this->GetDebugPathInTree(), rect); offset_ = rect.GetLeftTop(); auto new_size = rect.GetSize(); @@ -118,7 +118,7 @@ void RenderObject::Layout(const Rect& rect) { OnLayoutCore(rect); layout_valid_ = true; - CRU_LOG_TAG_DEBUG("{} Layout ends.", this->GetDebugPathInTree()); + CruLogDebug(kLogTag, "{} Layout ends.", this->GetDebugPathInTree()); } Thickness RenderObject::GetTotalSpaceThickness() { return margin_ + padding_; } diff --git a/src/ui/render/TextRenderObject.cpp b/src/ui/render/TextRenderObject.cpp index 1fe8e652..12d77d0d 100644 --- a/src/ui/render/TextRenderObject.cpp +++ b/src/ui/render/TextRenderObject.cpp @@ -178,11 +178,12 @@ RenderObject* TextRenderObject::HitTest(const Point& point) { void TextRenderObject::Draw(platform::graphics::IPainter* painter) { if constexpr (debug_flags::draw) { - CRU_LOG_TAG_DEBUG( - "Begin to paint, total_offset: {}, size: {}, text_layout: " - "{}, brush: {}.", - this->GetTotalOffset(), this->GetMeasureResultSize(), - this->text_layout_->GetDebugString(), this->brush_->GetDebugString()); + CruLogDebug(kLogTag, + "Begin to paint, total_offset: {}, size: {}, text_layout: " + "{}, brush: {}.", + this->GetTotalOffset(), this->GetMeasureResultSize(), + this->text_layout_->GetDebugString(), + this->brush_->GetDebugString()); } if (this->selection_range_.has_value()) { |
