Refine editor host boundary
This commit is contained in:
200
editor/app/Host/Win32/Windowing/EditorWindow.h
Normal file
200
editor/app/Host/Win32/Windowing/EditorWindow.h
Normal file
@@ -0,0 +1,200 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
|
||||
#include "Windowing/EditorWindowSession.h"
|
||||
#include "EditorWindowHostInterfaces.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI {
|
||||
|
||||
class UIDrawData;
|
||||
class UIDrawList;
|
||||
|
||||
struct UIPoint;
|
||||
struct UIRect;
|
||||
struct UIInputEvent;
|
||||
struct UIInputModifiers;
|
||||
|
||||
enum class UIPointerButton : std::uint8_t;
|
||||
enum class UIInputEventType : std::uint8_t;
|
||||
|
||||
} // namespace XCEngine::UI
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorDockHostTabDropTarget;
|
||||
class UIEditorWorkspaceController;
|
||||
|
||||
struct UIEditorDockHostInteractionState;
|
||||
struct UIEditorShellInteractionFrame;
|
||||
struct UIEditorShellInteractionState;
|
||||
struct UIEditorShellInteractionResult;
|
||||
|
||||
namespace Widgets {
|
||||
struct UIEditorDockHostDropPreviewState;
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
|
||||
namespace XCEngine::UI::Editor::App {
|
||||
|
||||
class EditorWindowChromeController;
|
||||
class EditorWindowDockHostBinding;
|
||||
class EditorWindowHostRuntime;
|
||||
class EditorWindowInputController;
|
||||
class EditorWindowLifecycleCoordinator;
|
||||
class EditorWindowMessageDispatcher;
|
||||
class EditorWindowWorkspaceCoordinator;
|
||||
class EditorWindowSession;
|
||||
|
||||
class EditorWindow final : public EditorWindowNativePeer {
|
||||
public:
|
||||
explicit EditorWindow(EditorHostWindow& owner);
|
||||
~EditorWindow();
|
||||
|
||||
EditorWindow(const EditorWindow&) = delete;
|
||||
EditorWindow& operator=(const EditorWindow&) = delete;
|
||||
EditorWindow(EditorWindow&&) = delete;
|
||||
EditorWindow& operator=(EditorWindow&&) = delete;
|
||||
|
||||
EditorHostWindow& GetOwner();
|
||||
const EditorHostWindow& GetOwner() const;
|
||||
std::string_view GetWindowId() const;
|
||||
HWND GetHwnd() const;
|
||||
bool HasHwnd() const;
|
||||
EditorWindowCategory GetCategory() const;
|
||||
const EditorWindowChromePolicy& GetChromePolicy() const;
|
||||
EditorWindowLifecycleState GetLifecycleState() const;
|
||||
bool IsPrimary() const;
|
||||
bool IsWorkspaceWindow() const;
|
||||
bool IsUtilityWindow() const;
|
||||
bool IsClosing() const;
|
||||
bool IsDestroyed() const;
|
||||
bool HasLiveHostWindow() const override;
|
||||
EditorNativeWindowMetrics CaptureMetrics() const override;
|
||||
bool CaptureRuntimeSurface(
|
||||
const EditorHostWindow& window,
|
||||
EditorNativeWindowRuntimeSurface& outSurface) override;
|
||||
bool CaptureFrameSnapshot(
|
||||
const EditorHostWindow& window,
|
||||
const UIEditorShellInteractionState& shellState,
|
||||
EditorNativeWindowFrameSnapshot& outSnapshot) override;
|
||||
void ApplyFrameCommands(
|
||||
const EditorHostWindow& window,
|
||||
const EditorNativeWindowFrameCommands& commands) override;
|
||||
const std::wstring& GetTitle() const;
|
||||
std::string_view GetCachedTitleText() const;
|
||||
const EditorWorkspaceWindowProjection* TryGetWorkspaceProjection() const;
|
||||
EditorWindowDockHostBinding* TryGetDockHostBinding();
|
||||
const EditorWindowDockHostBinding* TryGetDockHostBinding() const;
|
||||
void AppendChrome(
|
||||
const EditorHostWindow& window,
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
float clientWidthDips) const override;
|
||||
void PrepareRuntimeInitialization(EditorHostWindow& window) override;
|
||||
void ShutdownNativeInteraction() override;
|
||||
void ResetNativeInteractionState() override;
|
||||
::XCEngine::UI::UIPoint ConvertScreenPixelsToClientDips(
|
||||
const EditorWindowScreenPoint& screenPoint) const override;
|
||||
|
||||
private:
|
||||
friend class EditorWindowChromeController;
|
||||
friend class EditorWindowHostRuntime;
|
||||
friend class EditorWindowMessageDispatcher;
|
||||
friend class EditorWindowLifecycleCoordinator;
|
||||
friend class EditorWindowWorkspaceCoordinator;
|
||||
|
||||
bool TryResolveDockTabDragHotspot(
|
||||
std::string_view nodeId,
|
||||
std::string_view panelId,
|
||||
const EditorWindowScreenPoint& screenPoint,
|
||||
EditorWindowScreenPoint& outHotspot) const;
|
||||
bool TryResolveDockTabDropTarget(
|
||||
const EditorWindowScreenPoint& screenPoint,
|
||||
UIEditorDockHostTabDropTarget& outTarget) const;
|
||||
void InvalidateHostWindow() const override;
|
||||
|
||||
void AttachHwnd(HWND hwnd);
|
||||
void ApplyHostWindowTitle(const std::wstring& title) override;
|
||||
bool TryGetHostScreenRect(EditorWindowScreenRect& outRect) const override;
|
||||
void SetHostScreenPosition(const EditorWindowScreenPoint& screenPoint) override;
|
||||
void FocusHostWindow() override;
|
||||
void PostCloseToHost() override;
|
||||
void DestroyHostWindow() override;
|
||||
void ValidateHostFrame() const override;
|
||||
void QueueCompletedImmediateFrame(
|
||||
EditorWindowFrameTransferRequests transferRequests);
|
||||
bool HasQueuedCompletedImmediateFrame() const;
|
||||
EditorWindowFrameTransferRequests ConsumeQueuedCompletedImmediateFrameTransferRequests();
|
||||
void RequestSkipNextSteadyStateFrame() override;
|
||||
bool ConsumeSkipNextSteadyStateFrame() override;
|
||||
bool QueryCurrentClientPixelSize(
|
||||
std::uint32_t& outWidth,
|
||||
std::uint32_t& outHeight) const;
|
||||
bool ResolveRenderClientPixelSize(
|
||||
std::uint32_t& outWidth,
|
||||
std::uint32_t& outHeight) const;
|
||||
float GetDpiScale() const;
|
||||
float PixelsToDips(float pixels) const;
|
||||
::XCEngine::UI::UIRect ResolveWorkspaceBounds(
|
||||
const EditorHostWindow& window,
|
||||
float clientWidthDips,
|
||||
float clientHeightDips) const;
|
||||
bool ShouldUseDetachedTitleBarTabStrip(
|
||||
const EditorHostWindow& window) const;
|
||||
std::vector<::XCEngine::UI::UIInputEvent> TakePendingInputEvents();
|
||||
std::optional<EditorWindowScreenPoint> QueryCursorScreenPoint() const;
|
||||
void SyncShellCapturedPointerButtonsFromSystemState(
|
||||
const UIEditorShellInteractionState& shellState);
|
||||
void ApplyShellRuntimePointerCapture(const EditorHostWindow& window);
|
||||
bool ApplyCurrentCursor() const;
|
||||
bool OnResize(UINT width, UINT height);
|
||||
void OnEnterSizeMove();
|
||||
bool OnExitSizeMove();
|
||||
void OnDpiChanged(UINT dpi, const RECT& suggestedRect);
|
||||
|
||||
bool HasInteractiveCaptureState() const;
|
||||
bool OwnsPointerCapture(EditorWindowPointerCaptureOwner owner) const;
|
||||
void AcquirePointerCapture(EditorWindowPointerCaptureOwner owner) override;
|
||||
void ReleasePointerCapture(EditorWindowPointerCaptureOwner owner) override;
|
||||
void ForceReleasePointerCapture();
|
||||
void TryStartImmediateShellPointerCapture(LPARAM lParam);
|
||||
|
||||
void QueuePointerEvent(
|
||||
::XCEngine::UI::UIInputEventType type,
|
||||
::XCEngine::UI::UIPointerButton button,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam,
|
||||
bool doubleClick = false);
|
||||
void QueueSyntheticPointerStateSyncEvent(
|
||||
const ::XCEngine::UI::UIInputModifiers& modifiers);
|
||||
void QueuePointerLeaveEvent();
|
||||
void QueuePointerWheelEvent(short wheelDelta, WPARAM wParam, LPARAM lParam);
|
||||
bool ApplyWindowResize(UINT width, UINT height);
|
||||
static POINT ToNativePoint(const EditorWindowScreenPoint& screenPoint);
|
||||
static EditorWindowScreenPoint FromNativePoint(const POINT& screenPoint);
|
||||
bool IsPointerInsideClientArea() const;
|
||||
LPCWSTR ResolveCurrentCursorResource() const;
|
||||
::XCEngine::UI::UIPoint ConvertClientPixelsToDips(LONG x, LONG y) const;
|
||||
static bool IsVerboseRuntimeTraceEnabled();
|
||||
|
||||
EditorHostWindow& m_owner;
|
||||
std::unique_ptr<EditorWindowSession> m_session = {};
|
||||
std::unique_ptr<EditorWindowChromeController> m_chromeController = {};
|
||||
std::unique_ptr<EditorWindowInputController> m_inputController = {};
|
||||
};
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
|
||||
Reference in New Issue
Block a user