Files
XCEngine/new_editor/app/Application.h

107 lines
4.0 KiB
C++

#pragma once
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <Host/AutoScreenshot.h>
#include <Host/InputModifierTracker.h>
#include <Host/NativeRenderer.h>
#include "Icons/ProductBuiltInIcons.h"
#include "Panels/ProductHierarchyPanel.h"
#include "Panels/ProductProjectPanel.h"
#include <XCEditor/Foundation/UIEditorShortcutManager.h>
#include <XCEditor/Shell/UIEditorShellAsset.h>
#include <XCEditor/Shell/UIEditorShellInteraction.h>
#include <XCEditor/Shell/UIEditorWorkspaceController.h>
#include <windows.h>
#include <windowsx.h>
#include <cstdint>
#include <filesystem>
#include <string>
#include <string_view>
#include <vector>
namespace XCEngine::UI::Editor {
class Application : public UIEditorHostCommandHandler {
public:
Application() = default;
int Run(HINSTANCE hInstance, int nCmdShow);
UIEditorHostCommandEvaluationResult EvaluateHostCommand(
std::string_view commandId) const override;
UIEditorHostCommandDispatchResult DispatchHostCommand(
std::string_view commandId) override;
private:
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
bool Initialize(HINSTANCE hInstance, int nCmdShow);
void Shutdown();
void RenderFrame();
void OnResize(UINT width, UINT height);
void OnDpiChanged(UINT dpi, const RECT& suggestedRect);
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;
void LogRuntimeTrace(std::string_view channel, std::string_view message) const;
void ApplyHostCaptureRequests(const UIEditorShellInteractionResult& result);
void ApplyHostedContentCaptureRequests();
bool HasShellInteractiveCaptureState() const;
bool HasInteractiveCaptureState() const;
UIEditorShellInteractionDefinition BuildShellDefinition() const;
void UpdateLastStatus(const UIEditorShellInteractionResult& result);
std::string DescribeWorkspaceState() const;
std::string DescribeInputEvents(
const std::vector<::XCEngine::UI::UIInputEvent>& events) const;
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);
HWND m_hwnd = nullptr;
HINSTANCE m_hInstance = nullptr;
ATOM m_windowClassAtom = 0;
::XCEngine::UI::Editor::Host::NativeRenderer m_renderer = {};
::XCEngine::UI::Editor::Host::AutoScreenshotController m_autoScreenshot = {};
::XCEngine::UI::Editor::Host::InputModifierTracker m_inputModifierTracker = {};
EditorShellAsset m_shellAsset = {};
EditorShellAssetValidationResult m_shellValidation = {};
UIEditorWorkspaceController m_workspaceController = {};
UIEditorShortcutManager m_shortcutManager = {};
App::ProductBuiltInIcons m_builtInIcons = {};
App::ProductHierarchyPanel m_hierarchyPanel = {};
App::ProductProjectPanel m_projectPanel = {};
UIEditorShellInteractionServices m_shellServices = {};
UIEditorShellInteractionState m_shellInteractionState = {};
UIEditorShellInteractionFrame m_shellFrame = {};
std::vector<::XCEngine::UI::UIInputEvent> m_pendingInputEvents = {};
bool m_trackingMouseLeave = false;
std::string m_validationMessage = {};
std::string m_lastStatus = {};
std::string m_lastMessage = {};
UINT m_windowDpi = 96u;
float m_dpiScale = 1.0f;
};
int RunXCUIEditorApp(HINSTANCE hInstance, int nCmdShow);
} // namespace XCEngine::UI::Editor