Files
XCEngine/new_editor/app/Platform/Win32/WindowMessageDispatcherLifecycle.cpp

78 lines
2.2 KiB
C++

#include "WindowMessageDispatchHandlers.h"
#include "Platform/Win32/EditorWindow.h"
#include "WindowMessageHost.h"
namespace XCEngine::UI::Editor::Host {
void RenderAndValidateWindow(const WindowMessageDispatchContext& context) {
if (!context.window.IsRenderReady()) {
return;
}
context.window.RenderFrame(
context.windowHost.GetEditorContext(),
context.windowHost.IsGlobalTabDragActive());
if (context.hwnd != nullptr && IsWindow(context.hwnd)) {
ValidateRect(context.hwnd, nullptr);
}
}
bool TryDispatchWindowLifecycleMessage(
const WindowMessageDispatchContext& context,
UINT message,
WPARAM wParam,
LPARAM lParam,
LRESULT& outResult) {
switch (message) {
case WM_DPICHANGED:
if (lParam == 0) {
return false;
}
context.window.OnDpiChanged(
static_cast<UINT>(LOWORD(wParam)),
*reinterpret_cast<const RECT*>(lParam));
RenderAndValidateWindow(context);
outResult = 0;
return true;
case WM_ENTERSIZEMOVE:
context.window.OnEnterSizeMove();
outResult = 0;
return true;
case WM_EXITSIZEMOVE:
context.window.OnExitSizeMove();
RenderAndValidateWindow(context);
outResult = 0;
return true;
case WM_SIZE:
if (wParam != SIZE_MINIMIZED) {
context.window.OnResize(
static_cast<UINT>(LOWORD(lParam)),
static_cast<UINT>(HIWORD(lParam)));
RenderAndValidateWindow(context);
}
outResult = 0;
return true;
case WM_PAINT:
context.window.OnPaintMessage(
context.windowHost.GetEditorContext(),
context.windowHost.IsGlobalTabDragActive());
outResult = 0;
return true;
case WM_ERASEBKGND:
outResult = 1;
return true;
case WM_DESTROY:
if (context.windowHost.OwnsActiveGlobalTabDrag(context.window.GetWindowId())) {
context.windowHost.EndGlobalTabDragSession();
}
context.windowHost.HandleDestroyedWindow(context.hwnd);
outResult = 0;
return true;
default:
return false;
}
}
} // namespace XCEngine::UI::Editor::Host