diff options
author | crupest <crupest@outlook.com> | 2022-02-21 18:44:40 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-02-21 18:44:40 +0800 |
commit | ced1a63686e6c64cb574d74a34d1bbd07d0a668e (patch) | |
tree | 4082e4689e5e7cede8d59a0538d0f1ae37064acb /src/ui/host | |
parent | 6b00fca7c662301bf657a99cb1e89f21541a46bc (diff) | |
download | cru-ced1a63686e6c64cb574d74a34d1bbd07d0a668e.tar.gz cru-ced1a63686e6c64cb574d74a34d1bbd07d0a668e.tar.bz2 cru-ced1a63686e6c64cb574d74a34d1bbd07d0a668e.zip |
...
Diffstat (limited to 'src/ui/host')
-rw-r--r-- | src/ui/host/RoutedEventDispatch.h | 21 | ||||
-rw-r--r-- | src/ui/host/WindowHost.cpp | 4 |
2 files changed, 13 insertions, 12 deletions
diff --git a/src/ui/host/RoutedEventDispatch.h b/src/ui/host/RoutedEventDispatch.h index 2ab51645..3c2a98d8 100644 --- a/src/ui/host/RoutedEventDispatch.h +++ b/src/ui/host/RoutedEventDispatch.h @@ -1,5 +1,5 @@ #pragma once -#include "cru/common/Logger.h" +#include "cru/common/log/Logger.h" #include "cru/ui/DebugFlags.h" #include "cru/ui/controls/Control.h" @@ -21,18 +21,19 @@ namespace cru::ui { // as the rest arguments. template <typename EventArgs, typename... Args> void DispatchEvent( - const std::u16string_view& event_name, - controls::Control* const original_sender, + 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"; + if (original_sender == nullptr) return; CRU_UNUSED(event_name) if (original_sender == last_receiver) { if constexpr (debug_flags::routed_event) - log::Debug( - "Routed event {} no need to dispatch (original_sender == " + CRU_LOG_DEBUG( + u"Routed event {} no need to dispatch (original_sender == " "last_receiver). Original sender is {}.", event_name, original_sender->GetControlType()); return; @@ -49,7 +50,7 @@ void DispatchEvent( } if constexpr (debug_flags::routed_event) { - std::u16string log = u"Dispatch routed event "; + String log = u"Dispatch routed event "; log += event_name; log += u". Path (parent first): "; auto i = receive_list.crbegin(); @@ -59,7 +60,7 @@ void DispatchEvent( log += u" -> "; } log += (*i)->GetControlType(); - log::Debug(log); + CRU_LOG_DEBUG(log); } auto handled = false; @@ -75,7 +76,7 @@ void DispatchEvent( if (event_args.IsHandled()) { handled = true; if constexpr (debug_flags::routed_event) - log::Debug( + CRU_LOG_DEBUG( u"Routed event is short-circuit in TUNNEL at {}-st control (count " u"from parent).", count); @@ -92,7 +93,7 @@ void DispatchEvent( ->Raise(event_args); if (event_args.IsHandled()) { if constexpr (debug_flags::routed_event) - log::Debug( + CRU_LOG_DEBUG( u"Routed event is short-circuit in BUBBLE at {}-st control " u"(count from parent).", count); @@ -109,6 +110,6 @@ void DispatchEvent( } if constexpr (debug_flags::routed_event) - log::Debug(u"Routed event dispatch finished."); + CRU_LOG_DEBUG(u"Routed event dispatch finished."); } } // namespace cru::ui diff --git a/src/ui/host/WindowHost.cpp b/src/ui/host/WindowHost.cpp index 91b5f438..42d0945f 100644 --- a/src/ui/host/WindowHost.cpp +++ b/src/ui/host/WindowHost.cpp @@ -2,7 +2,7 @@ #include "RoutedEventDispatch.h" #include "cru/common/Base.h" -#include "cru/common/Logger.h" +#include "cru/common/log/Logger.h" #include "cru/platform/graphics/Painter.h" #include "cru/platform/gui/InputMethod.h" #include "cru/platform/gui/UiApplication.h" @@ -191,7 +191,7 @@ void WindowHost::RelayoutWithSize(const Size& available_size, after_layout_event_.Raise(AfterLayoutEventArgs{}); after_layout_stable_action_.clear(); if constexpr (debug_flags::layout) - log::TagDebug(log_tag, u"A relayout is finished."); + CRU_LOG_DEBUG(u"A relayout is finished."); } void WindowHost::Repaint() { |