aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/Logger.cpp20
-rw-r--r--src/ui/ClickDetector.cpp6
-rw-r--r--src/ui/UiHost.cpp5
-rw-r--r--src/ui/controls/TextControlService.hpp17
-rw-r--r--src/ui/render/BorderRenderObject.cpp20
-rw-r--r--src/ui/render/FlexLayoutRenderObject.cpp21
-rw-r--r--src/ui/render/LayoutHelper.cpp5
-rw-r--r--src/ui/render/RenderObject.cpp18
-rw-r--r--src/ui/render/StackLayoutRenderObject.cpp12
-rw-r--r--src/ui/render/TextRenderObject.cpp10
-rw-r--r--src/win/DebugLogger.hpp2
-rw-r--r--src/win/native/Cursor.cpp4
-rw-r--r--src/win/native/GodWindow.cpp6
-rw-r--r--src/win/native/InputMethod.cpp34
-rw-r--r--src/win/native/Window.cpp26
15 files changed, 108 insertions, 98 deletions
diff --git a/src/common/Logger.cpp b/src/common/Logger.cpp
index ed9f9e64..da55047a 100644
--- a/src/common/Logger.cpp
+++ b/src/common/Logger.cpp
@@ -42,12 +42,12 @@ std::string_view LogLevelToString(LogLevel level) {
case LogLevel::Error:
return "ERROR";
default:
- std::abort();
+ std::terminate();
}
}
} // namespace
-void Logger::Log(LogLevel level, const std::string_view &s) {
+void Logger::Log(LogLevel level, std::string_view s) {
#ifndef CRU_DEBUG
if (level == LogLevel::Debug) {
return;
@@ -62,4 +62,20 @@ void Logger::Log(LogLevel level, const std::string_view &s) {
LogLevelToString(level), s));
}
}
+
+void Logger::Log(LogLevel level, std::string_view tag, std::string_view s) {
+#ifndef CRU_DEBUG
+ if (level == LogLevel::Debug) {
+ return;
+ }
+#endif
+ for (const auto &source : sources_) {
+ auto now = std::time(nullptr);
+ std::array<char, 50> buffer;
+ std::strftime(buffer.data(), 50, "%c", std::localtime(&now));
+
+ source->Write(level, fmt::format("[{}] {} {}: {}\n", buffer.data(),
+ LogLevelToString(level), tag, s));
+ }
+}
} // namespace cru::log
diff --git a/src/ui/ClickDetector.cpp b/src/ui/ClickDetector.cpp
index e873efd4..93e6f303 100644
--- a/src/ui/ClickDetector.cpp
+++ b/src/ui/ClickDetector.cpp
@@ -44,7 +44,8 @@ ClickDetector::ClickDetector(Control* control) {
if (this->enable_ && (button & this->trigger_button_) &&
this->state_ == ClickState::Hover) {
if (!this->control_->CaptureMouse()) {
- log::Debug("Failed to capture mouse when begin click.");
+ log::TagDebug(log_tag,
+ "Failed to capture mouse when begin click.");
return;
}
this->down_point_ = args.GetPoint();
@@ -120,7 +121,8 @@ void ClickDetector::SetState(ClickState state) {
UnreachableCode();
}
};
- log::Debug("Click state changed, new state: {}.", to_string(state));
+ log::TagDebug(log_tag, "Click state changed, new state: {}.",
+ to_string(state));
#endif
state_ = state;
diff --git a/src/ui/UiHost.cpp b/src/ui/UiHost.cpp
index 9bde06ad..975d0ffe 100644
--- a/src/ui/UiHost.cpp
+++ b/src/ui/UiHost.cpp
@@ -146,14 +146,13 @@ void UiHost::InvalidatePaint() {
}
void UiHost::InvalidateLayout() {
+ log::TagDebug(log_tag, "A relayout is requested.");
if (!need_layout_) {
platform::native::IUiApplication::GetInstance()->InvokeLater(
[resolver = this->CreateResolver()] {
if (const auto host = resolver.Resolve()) {
host->Relayout();
host->need_layout_ = false;
- host->after_layout_event_.Raise(AfterLayoutEventArgs{});
- log::Debug("A relayout finished.");
host->InvalidatePaint();
}
});
@@ -171,6 +170,8 @@ void UiHost::Relayout() {
render::MeasureSize::NotSpecified()},
render::MeasureSize::NotSpecified());
root_render_object_->Layout(Point{});
+ after_layout_event_.Raise(AfterLayoutEventArgs{});
+ log::TagDebug(log_tag, "A relayout is finished.");
}
bool UiHost::RequestFocusFor(Control* control) {
diff --git a/src/ui/controls/TextControlService.hpp b/src/ui/controls/TextControlService.hpp
index ad0db343..c320b0c5 100644
--- a/src/ui/controls/TextControlService.hpp
+++ b/src/ui/controls/TextControlService.hpp
@@ -5,9 +5,9 @@
#include "cru/platform/graph/Painter.hpp"
#include "cru/platform/native/UiApplication.hpp"
#include "cru/ui/Control.hpp"
+#include "cru/ui/UiEvent.hpp"
#include "cru/ui/render/CanvasRenderObject.hpp"
#include "cru/ui/render/TextRenderObject.hpp"
-#include "cru/ui/UiEvent.hpp"
namespace cru::ui::controls {
constexpr int k_default_caret_blink_duration = 500;
@@ -18,6 +18,8 @@ constexpr int k_default_caret_blink_duration = 500;
// ```
template <typename TControl>
class TextControlService : public Object {
+ CRU_DEFINE_CLASS_LOG_TAG("cru::ui::controls::TextControlService")
+
public:
TextControlService(TControl* control);
@@ -175,10 +177,9 @@ void TextControlService<TControl>::MouseMoveHandler(
const auto result = text_render_object->TextHitTest(
text_render_object->FromRootToContent(args.GetPoint()));
const auto position = result.position + (result.trailing ? 1 : 0);
- log::Debug(
- "TextControlService: Text selection changed on mouse move, range: {}, "
- "{}.",
- position, this->select_start_position_);
+ log::TagDebug(log_tag,
+ "Text selection changed on mouse move, range: {}, {}.",
+ position, this->select_start_position_);
this->control_->GetTextRenderObject()->SetSelectionRange(
TextRange::FromTwoSides(
static_cast<unsigned>(position),
@@ -203,8 +204,8 @@ void TextControlService<TControl>::MouseDownHandler(
text_render_object->SetSelectionRange(std::nullopt);
text_render_object->SetCaretPosition(position);
this->select_start_position_ = position;
- log::Debug("TextControlService: Begin to select text, start position: {}.",
- position);
+ log::TagDebug(log_tag, "Begin to select text, start position: {}.",
+ position);
}
}
@@ -215,7 +216,7 @@ void TextControlService<TControl>::MouseUpHandler(
this->select_down_button_.value() == args.GetButton()) {
this->control_->ReleaseMouse();
this->select_down_button_ = std::nullopt;
- log::Debug("TextControlService: End selecting text.");
+ log::TagDebug(log_tag, "End selecting text.");
}
}
diff --git a/src/ui/render/BorderRenderObject.cpp b/src/ui/render/BorderRenderObject.cpp
index 6513c4c4..f2e3eb9b 100644
--- a/src/ui/render/BorderRenderObject.cpp
+++ b/src/ui/render/BorderRenderObject.cpp
@@ -57,7 +57,7 @@ void BorderRenderObject::OnDrawCore(platform::graph::IPainter* painter) {
background_brush_.get());
if (is_border_enabled_) {
if (border_brush_ == nullptr) {
- log::Warn("Border is enabled but brush is null");
+ log::TagWarn(log_tag, "Border is enabled but border brush is null.");
} else {
painter->FillGeometry(geometry_.get(), border_brush_.get());
}
@@ -93,9 +93,9 @@ Size BorderRenderObject::OnMeasureCore(const MeasureRequirement& requirement,
if (!requirement.max.width.IsNotSpecified()) {
const auto max_width = requirement.max.width.GetLengthOrMax();
if (coerced_space_size.width > max_width) {
- log::Warn(
- "BorderRenderObject: During measure, horizontal length of padding, "
- "border and margin is bigger than required max length.");
+ log::TagWarn(log_tag,
+ "(Measure) Horizontal length of padding, border and margin "
+ "is bigger than required max length.");
coerced_space_size.width = max_width;
}
content_requirement.max.width = max_width - coerced_space_size.width;
@@ -109,9 +109,9 @@ Size BorderRenderObject::OnMeasureCore(const MeasureRequirement& requirement,
if (!requirement.max.height.IsNotSpecified()) {
const auto max_height = requirement.max.height.GetLengthOrMax();
if (coerced_space_size.height > max_height) {
- log::Warn(
- "BorderRenderObject: During measure, vertical length of padding, "
- "border and margin is bigger than required max length.");
+ log::TagWarn(log_tag,
+ "(Measure) Vertical length of padding, border and margin is "
+ "bigger than required max length.");
coerced_space_size.height = max_height;
}
content_requirement.max.height = max_height - coerced_space_size.height;
@@ -149,15 +149,9 @@ void BorderRenderObject::OnLayoutCore() {
auto content_size = size - space_size;
if (content_size.width < 0) {
- log::Warn(
- "BorderRenderObject: During layout, horizontal length of padding, "
- "border and margin is bigger than available length.");
content_size.width = 0;
}
if (content_size.height < 0) {
- log::Warn(
- "BorderRenderObject: During layout, vertical length of padding, "
- "border and margin is bigger than available length.");
content_size.height = 0;
}
diff --git a/src/ui/render/FlexLayoutRenderObject.cpp b/src/ui/render/FlexLayoutRenderObject.cpp
index 9e5139ff..8e6b41fe 100644
--- a/src/ui/render/FlexLayoutRenderObject.cpp
+++ b/src/ui/render/FlexLayoutRenderObject.cpp
@@ -87,7 +87,8 @@ 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) {
+ const std::vector<FlexChildLayoutData>& layout_data,
+ std::string_view log_tag) {
Expects(children.size() == layout_data.size());
direction_tag_t direction_tag;
@@ -109,9 +110,9 @@ Size FlexLayoutMeasureContentImpl(
child_cross_measure_requirement.push_back(
StackLayoutCalculateChildMaxLength(
preferred_cross_length, max_cross_length,
- GetCross(child->GetMinSize(), direction_tag),
- "StackLayoutRenderObject: Child's min cross size is bigger than "
- "parent's max cross size."));
+ GetCross(child->GetMinSize(), direction_tag), log_tag,
+ "(Measure) Child's min cross size is bigger than parent's max "
+ "cross size."));
}
// step 1.
@@ -312,9 +313,9 @@ Size FlexLayoutMeasureContentImpl(
if (max_main_length.IsSpecified() &&
total_length > max_main_length.GetLengthOrUndefined()) {
- log::Warn(
- "FlexLayoutRenderObject: Children's main axis length exceeds required "
- "max length.");
+ log::TagWarn(
+ log_tag,
+ "(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()) {
@@ -336,10 +337,12 @@ Size FlexLayoutRenderObject::OnMeasureContent(
direction_ == FlexDirection::HorizontalReverse);
if (horizontal) {
return FlexLayoutMeasureContentImpl<tag_horizontal_t>(
- requirement, preferred_size, GetChildren(), GetChildLayoutDataList());
+ requirement, preferred_size, GetChildren(), GetChildLayoutDataList(),
+ log_tag);
} else {
return FlexLayoutMeasureContentImpl<tag_vertical_t>(
- requirement, preferred_size, GetChildren(), GetChildLayoutDataList());
+ requirement, preferred_size, GetChildren(), GetChildLayoutDataList(),
+ log_tag);
}
}
diff --git a/src/ui/render/LayoutHelper.cpp b/src/ui/render/LayoutHelper.cpp
index 31cf5c08..9f94b84d 100644
--- a/src/ui/render/LayoutHelper.cpp
+++ b/src/ui/render/LayoutHelper.cpp
@@ -19,9 +19,10 @@ float CalculateAnchorByAlignment(Alignment alignment, float start_point,
MeasureLength StackLayoutCalculateChildMaxLength(
MeasureLength parent_preferred_size, MeasureLength parent_max_size,
- MeasureLength child_min_size, std::string_view exceeds_message) {
+ MeasureLength child_min_size, std::string_view log_tag,
+ std::string_view exceeds_message) {
if (parent_max_size.GetLengthOrMax() < child_min_size.GetLengthOr0()) {
- log::Warn(exceeds_message);
+ log::TagWarn(log_tag, exceeds_message);
return parent_max_size;
}
diff --git a/src/ui/render/RenderObject.cpp b/src/ui/render/RenderObject.cpp
index d9977f2a..66b62e6e 100644
--- a/src/ui/render/RenderObject.cpp
+++ b/src/ui/render/RenderObject.cpp
@@ -151,9 +151,9 @@ Size RenderObject::OnMeasureCore(const MeasureRequirement& requirement,
if (!requirement.max.width.IsNotSpecified()) {
const auto max_width = requirement.max.width.GetLengthOrMax();
if (coerced_space_size.width > max_width) {
- log::Warn(
- "RenderObject: During measure, horizontal length of padding and "
- "margin is bigger than required max length.");
+ log::TagWarn(log_tag,
+ "(Measure) Horizontal length of padding and margin is "
+ "bigger than required max length.");
coerced_space_size.width = max_width;
}
content_requirement.max.width = max_width - coerced_space_size.width;
@@ -167,9 +167,9 @@ Size RenderObject::OnMeasureCore(const MeasureRequirement& requirement,
if (!requirement.max.height.IsNotSpecified()) {
const auto max_height = requirement.max.height.GetLengthOrMax();
if (coerced_space_size.height > max_height) {
- log::Warn(
- "RenderObject: During measure, vertical length of padding and "
- "margin is bigger than required max length.");
+ log::TagWarn(log_tag,
+ "(Measure) Vertical length of padding and margin is bigger "
+ "than required max length.");
coerced_space_size.height = max_height;
}
content_requirement.max.height = max_height - coerced_space_size.height;
@@ -198,15 +198,9 @@ void RenderObject::OnLayoutCore() {
auto content_size = total_size - space_size;
if (content_size.width < 0) {
- log::Warn(
- "RenderObject: During layout, horizontal length of padding and margin "
- "is bigger than available length.");
content_size.width = 0;
}
if (content_size.height < 0) {
- log::Warn(
- "RenderObject: During layout, vertical length of padding and margin "
- "is bigger than available length.");
content_size.height = 0;
}
diff --git a/src/ui/render/StackLayoutRenderObject.cpp b/src/ui/render/StackLayoutRenderObject.cpp
index a6ed7708..168ff379 100644
--- a/src/ui/render/StackLayoutRenderObject.cpp
+++ b/src/ui/render/StackLayoutRenderObject.cpp
@@ -14,14 +14,14 @@ Size StackLayoutRenderObject::OnMeasureContent(
MeasureRequirement{
MeasureSize{StackLayoutCalculateChildMaxLength(
preferred_size.width, requirement.max.width,
- child->GetMinSize().width,
- "StackLayoutRenderObject: Child's min width is "
- "bigger than parent's max width."),
+ child->GetMinSize().width, log_tag,
+ "(Measure) Child's min width is bigger than "
+ "parent's max width."),
StackLayoutCalculateChildMaxLength(
preferred_size.height, requirement.max.height,
- child->GetMinSize().height,
- "StackLayoutRenderObject: Child's min height is "
- "bigger than parent's max height.")},
+ child->GetMinSize().height, log_tag,
+ "(Measure) Child's min height is bigger than "
+ "parent's max height.")},
MeasureSize::NotSpecified()},
MeasureSize::NotSpecified());
const auto size = child->GetSize();
diff --git a/src/ui/render/TextRenderObject.cpp b/src/ui/render/TextRenderObject.cpp
index ce1c3fa3..87a3c352 100644
--- a/src/ui/render/TextRenderObject.cpp
+++ b/src/ui/render/TextRenderObject.cpp
@@ -170,8 +170,8 @@ Size TextRenderObject::OnMeasureContent(const MeasureRequirement& requirement,
if (requirement.max.width.IsSpecified() &&
text_size.width > requirement.max.width.GetLengthOrUndefined()) {
- log::Warn(
- "TextRenderObject: Text actual width exceeds the required max width.");
+ log::TagWarn(log_tag,
+ "(Measure) Text actual width exceeds the required max width.");
result.width = requirement.max.width.GetLengthOrUndefined();
} else {
result.width = std::max(result.width, preferred_size.width.GetLengthOr0());
@@ -180,9 +180,9 @@ Size TextRenderObject::OnMeasureContent(const MeasureRequirement& requirement,
if (requirement.max.height.IsSpecified() &&
text_size.height > requirement.max.height.GetLengthOrUndefined()) {
- log::Warn(
- "TextRenderObject: Text actual height exceeds the required max "
- "height.");
+ log::TagWarn(
+ log_tag,
+ "(Measure) Text actual height exceeds the required max height.");
result.height = requirement.max.height.GetLengthOrUndefined();
} else {
result.height =
diff --git a/src/win/DebugLogger.hpp b/src/win/DebugLogger.hpp
index 381803bc..4ca1567b 100644
--- a/src/win/DebugLogger.hpp
+++ b/src/win/DebugLogger.hpp
@@ -14,7 +14,7 @@ class WinDebugLoggerSource : public ::cru::log::ILogSource {
~WinDebugLoggerSource() = default;
- void Write(::cru::log::LogLevel level, const std::string_view& s) override {
+ void Write(::cru::log::LogLevel level, std::string_view s) override {
CRU_UNUSED(level)
const std::wstring&& ws = ToUtf16String(s);
diff --git a/src/win/native/Cursor.cpp b/src/win/native/Cursor.cpp
index ca8bb1cd..a6ab5bfc 100644
--- a/src/win/native/Cursor.cpp
+++ b/src/win/native/Cursor.cpp
@@ -16,8 +16,8 @@ WinCursor::~WinCursor() {
if (!::DestroyCursor(handle_)) {
// This is not a fetal error but might still need notice because it may
// cause leak.
- log::Warn("Failed to destroy a cursor. Last error code: {}",
- ::GetLastError());
+ log::TagWarn(log_tag, "Failed to destroy a cursor. Last error code: {}",
+ ::GetLastError());
}
}
}
diff --git a/src/win/native/GodWindow.cpp b/src/win/native/GodWindow.cpp
index 076954d4..8ef2788e 100644
--- a/src/win/native/GodWindow.cpp
+++ b/src/win/native/GodWindow.cpp
@@ -1,11 +1,11 @@
#include "cru/win/native/GodWindow.hpp"
+#include "GodWindowMessage.hpp"
+#include "Timer.hpp"
#include "cru/common/Logger.hpp"
#include "cru/win/native/Exception.hpp"
#include "cru/win/native/UiApplication.hpp"
#include "cru/win/native/WindowClass.hpp"
-#include "GodWindowMessage.hpp"
-#include "Timer.hpp"
namespace cru::platform::native::win {
constexpr auto god_window_class_name = L"GodWindowClass";
@@ -45,7 +45,7 @@ GodWindow::GodWindow(WinUiApplication* application) {
GodWindow::~GodWindow() {
if (!::DestroyWindow(hwnd_)) {
// Although this could be "safely" ignore.
- log::Warn("Failed to destroy god window.");
+ log::TagWarn(log_tag, "Failed to destroy god window.");
}
}
diff --git a/src/win/native/InputMethod.cpp b/src/win/native/InputMethod.cpp
index 2e31108e..d3d989f3 100644
--- a/src/win/native/InputMethod.cpp
+++ b/src/win/native/InputMethod.cpp
@@ -1,11 +1,11 @@
#include "cru/win/native/InputMethod.hpp"
+#include "DpiUtil.hpp"
#include "cru/common/Logger.hpp"
#include "cru/platform/Check.hpp"
#include "cru/win/Exception.hpp"
-#include "cru/win/native/Window.hpp"
#include "cru/win/String.hpp"
-#include "DpiUtil.hpp"
+#include "cru/win/native/Window.hpp"
#include <vector>
@@ -35,7 +35,7 @@ AutoHIMC& AutoHIMC::operator=(AutoHIMC&& other) {
AutoHIMC::~AutoHIMC() {
if (handle_) {
if (!::ImmReleaseContext(hwnd_, handle_))
- log::Warn("AutoHIMC: Failed to release HIMC.");
+ log::TagWarn(log_tag, "Failed to release HIMC.");
}
}
@@ -169,7 +169,7 @@ void WinInputMethodContext::EnableIME() {
const auto hwnd = native_window->GetWindowHandle();
if (::ImmAssociateContextEx(hwnd, nullptr, IACE_DEFAULT) == FALSE) {
- log::Warn("WinInputMethodContext: Failed to enable ime.");
+ log::TagWarn(log_tag, "Failed to enable ime.");
}
}
@@ -181,13 +181,11 @@ void WinInputMethodContext::DisableIME() {
AutoHIMC himc{hwnd};
if (!::ImmNotifyIME(himc.Get(), NI_COMPOSITIONSTR, CPS_COMPLETE, 0)) {
- log::Warn(
- "WinInputMethodContext: Failed to complete composition before disable "
- "ime.");
+ log::TagWarn(log_tag, "Failed to complete composition before disable ime.");
}
if (::ImmAssociateContextEx(hwnd, nullptr, 0) == FALSE) {
- log::Warn("WinInputMethodContext: Failed to disable ime.");
+ log::TagWarn(log_tag, "Failed to disable ime.");
}
}
@@ -197,7 +195,7 @@ void WinInputMethodContext::CompleteComposition() {
auto himc = *std::move(optional_himc);
if (!::ImmNotifyIME(himc.Get(), NI_COMPOSITIONSTR, CPS_COMPLETE, 0)) {
- log::Warn("WinInputMethodContext: Failed to complete composition.");
+ log::TagWarn(log_tag, "Failed to complete composition.");
}
}
@@ -207,7 +205,7 @@ void WinInputMethodContext::CancelComposition() {
auto himc = *std::move(optional_himc);
if (!::ImmNotifyIME(himc.Get(), NI_COMPOSITIONSTR, CPS_CANCEL, 0)) {
- log::Warn("WinInputMethodContext: Failed to complete composition.");
+ log::TagWarn(log_tag, "Failed to complete composition.");
}
}
@@ -230,9 +228,8 @@ void WinInputMethodContext::SetCandidateWindowPosition(const Point& point) {
form.ptCurrentPos = DipToPi(point);
if (!::ImmSetCandidateWindow(himc.Get(), &form))
- log::Debug(
- "WinInputMethodContext: Failed to set input method candidate window "
- "position.");
+ log::TagDebug(log_tag,
+ "Failed to set input method candidate window position.");
}
IEvent<std::nullptr_t>* WinInputMethodContext::CompositionStartEvent() {
@@ -261,9 +258,9 @@ void WinInputMethodContext::OnWindowNativeMessage(
// I don't think this will happen because normal key strike without ime
// should only trigger ascci character. If it is a charater from
// supplementary planes, it should be handled with ime messages.
- log::Warn(
- "WinInputMethodContext: A WM_CHAR message for character from "
- "supplementary planes is ignored.");
+ log::TagWarn(log_tag,
+ "A WM_CHAR message for character from supplementary "
+ "planes is ignored.");
} else {
wchar_t s[1] = {c};
auto str = platform::win::ToUtf8String({s, 1});
@@ -275,9 +272,8 @@ void WinInputMethodContext::OnWindowNativeMessage(
case WM_IME_COMPOSITION: {
composition_event_.Raise(nullptr);
auto composition_text = GetCompositionText();
- log::Debug(
- "WinInputMethodContext: WM_IME_COMPOSITION composition text:\n{}",
- composition_text);
+ log::TagDebug(log_tag, "WM_IME_COMPOSITION composition text:\n{}",
+ composition_text);
if (message.l_param & GCS_RESULTSTR) {
auto result_string = GetResultString();
text_event_.Raise(result_string);
diff --git a/src/win/native/Window.cpp b/src/win/native/Window.cpp
index 9dde1af3..22505bd6 100644
--- a/src/win/native/Window.cpp
+++ b/src/win/native/Window.cpp
@@ -1,17 +1,17 @@
#include "cru/win/native/Window.hpp"
+#include "DpiUtil.hpp"
+#include "WindowD2DPainter.hpp"
+#include "WindowManager.hpp"
#include "cru/common/Logger.hpp"
#include "cru/platform/Check.hpp"
+#include "cru/win/String.hpp"
#include "cru/win/native/Cursor.hpp"
#include "cru/win/native/Exception.hpp"
#include "cru/win/native/Keyboard.hpp"
#include "cru/win/native/UiApplication.hpp"
#include "cru/win/native/WindowClass.hpp"
#include "cru/win/native/WindowRenderTarget.hpp"
-#include "cru/win/String.hpp"
-#include "DpiUtil.hpp"
-#include "WindowD2DPainter.hpp"
-#include "WindowManager.hpp"
#include <imm.h>
#include <windowsx.h>
@@ -124,7 +124,7 @@ bool WinNativeWindow::ReleaseMouse() {
}
void WinNativeWindow::RequestRepaint() {
- log::Debug("A repaint is requested.");
+ log::TagDebug(log_tag, "A repaint is requested.");
if (!::InvalidateRect(hwnd_, nullptr, FALSE))
throw Win32Error(::GetLastError(), "Failed to invalidate window.");
if (!::UpdateWindow(hwnd_))
@@ -144,19 +144,20 @@ void WinNativeWindow::SetCursor(std::shared_ptr<ICursor> cursor) {
if (!::SetClassLongPtrW(hwnd_, GCLP_HCURSOR,
reinterpret_cast<LONG_PTR>(cursor_->GetHandle()))) {
- log::Warn(
- "Failed to set cursor because failed to set class long. Last error "
- "code: {}.",
- ::GetLastError());
+ log::TagWarn(log_tag,
+ "Failed to set cursor because failed to set class long. Last "
+ "error code: {}.",
+ ::GetLastError());
return;
}
if (!IsVisible()) return;
auto lg = [](const std::string_view& reason) {
- log::Warn(
- "Failed to set cursor because {} when window is visible. (We need "
- "to update cursor if it is inside the window.) Last error code: {}.",
+ log::TagWarn(
+ log_tag,
+ "Failed to set cursor because {} when window is visible. (We need to "
+ "update cursor if it is inside the window.) Last error code: {}.",
reason, ::GetLastError());
};
@@ -353,6 +354,7 @@ void WinNativeWindow::OnDestroyInternal() {
void WinNativeWindow::OnPaintInternal() {
paint_event_.Raise(nullptr);
ValidateRect(hwnd_, nullptr);
+ log::TagDebug(log_tag, "A repaint is finished.");
}
void WinNativeWindow::OnResizeInternal(const int new_width,