Files
XCEngine/new_editor/app/Application.h

103 lines
3.6 KiB
C
Raw Normal View History

2026-04-05 04:55:25 +08:00
#pragma once
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <Host/AutoScreenshot.h>
#include <Host/D3D12WindowRenderer.h>
2026-04-13 19:37:10 +08:00
#include <Host/D3D12WindowRenderLoop.h>
#include <Host/HostRuntimeState.h>
#include <Host/InputModifierTracker.h>
#include <Host/NativeRenderer.h>
#include "Core/ProductEditorContext.h"
#include "Workspace/ProductEditorWorkspace.h"
2026-04-10 16:40:11 +08:00
#include <XCEditor/Shell/UIEditorShellInteraction.h>
#include <windows.h>
#include <windowsx.h>
2026-04-05 04:55:25 +08:00
#include <cstdint>
#include <filesystem>
2026-04-05 04:55:25 +08:00
#include <string>
2026-04-10 16:40:11 +08:00
#include <string_view>
2026-04-05 04:55:25 +08:00
#include <vector>
2026-04-13 19:37:10 +08:00
namespace XCEngine::UI::Editor::Host {
class WindowMessageDispatcher;
}
namespace XCEngine::UI::Editor {
2026-04-05 04:55:25 +08:00
class Application {
2026-04-05 04:55:25 +08:00
public:
2026-04-10 16:40:11 +08:00
Application() = default;
int Run(HINSTANCE hInstance, int nCmdShow);
2026-04-05 04:55:25 +08:00
2026-04-10 16:40:11 +08:00
private:
2026-04-13 19:37:10 +08:00
friend class ::XCEngine::UI::Editor::Host::WindowMessageDispatcher;
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
2026-04-05 04:55:25 +08:00
bool Initialize(HINSTANCE hInstance, int nCmdShow);
void Shutdown();
void RenderFrame();
2026-04-13 19:37:10 +08:00
void OnDeferredRenderMessage();
void OnPaintMessage();
void OnResize();
void OnEnterSizeMove();
void OnExitSizeMove();
void OnDpiChanged(UINT dpi, const RECT& suggestedRect);
void QueueWindowResize(UINT width, UINT height);
void QueueCurrentClientResize();
bool ApplyPendingWindowResize();
bool QueryCurrentClientPixelSize(UINT& outWidth, UINT& outHeight) const;
bool IsPointerInsideClientArea() const;
bool ApplyCurrentCursor() const;
LPCWSTR ResolveCurrentCursorResource() const;
float GetDpiScale() const;
float PixelsToDips(float pixels) const;
::XCEngine::UI::UIPoint ConvertClientPixelsToDips(LONG x, LONG y) const;
std::string BuildCaptureStatusText() const;
void LogRuntimeTrace(std::string_view channel, std::string_view message) const;
2026-04-10 16:40:11 +08:00
void ApplyHostCaptureRequests(const UIEditorShellInteractionResult& result);
void ApplyHostedContentCaptureRequests();
2026-04-10 16:40:11 +08:00
bool HasInteractiveCaptureState() const;
std::string DescribeInputEvents(
const std::vector<::XCEngine::UI::UIInputEvent>& events) const;
2026-04-10 16:40:11 +08:00
void QueuePointerEvent(
::XCEngine::UI::UIInputEventType type,
::XCEngine::UI::UIPointerButton button,
WPARAM wParam,
LPARAM lParam);
void QueuePointerLeaveEvent();
void QueuePointerWheelEvent(short wheelDelta, WPARAM wParam, LPARAM lParam);
void QueueKeyEvent(::XCEngine::UI::UIInputEventType type, WPARAM wParam, LPARAM lParam);
void QueueCharacterEvent(WPARAM wParam, LPARAM lParam);
void QueueWindowFocusEvent(::XCEngine::UI::UIInputEventType type);
static std::filesystem::path ResolveRepoRootPath();
static LONG WINAPI HandleUnhandledException(EXCEPTION_POINTERS* exceptionInfo);
static bool IsVerboseRuntimeTraceEnabled();
2026-04-05 04:55:25 +08:00
HWND m_hwnd = nullptr;
HINSTANCE m_hInstance = nullptr;
ATOM m_windowClassAtom = 0;
2026-04-10 16:40:11 +08:00
::XCEngine::UI::Editor::Host::NativeRenderer m_renderer = {};
::XCEngine::UI::Editor::Host::D3D12WindowRenderer m_windowRenderer = {};
2026-04-13 19:37:10 +08:00
::XCEngine::UI::Editor::Host::D3D12WindowRenderLoop m_windowRenderLoop = {};
2026-04-10 16:40:11 +08:00
::XCEngine::UI::Editor::Host::AutoScreenshotController m_autoScreenshot = {};
::XCEngine::UI::Editor::Host::InputModifierTracker m_inputModifierTracker = {};
App::ProductEditorContext m_editorContext = {};
App::ProductEditorWorkspace m_editorWorkspace = {};
std::vector<::XCEngine::UI::UIInputEvent> m_pendingInputEvents = {};
bool m_trackingMouseLeave = false;
2026-04-13 19:37:10 +08:00
::XCEngine::UI::Editor::Host::HostRuntimeState m_hostRuntime = {};
2026-04-05 04:55:25 +08:00
};
int RunXCUIEditorApp(HINSTANCE hInstance, int nCmdShow);
} // namespace XCEngine::UI::Editor