关键节点
This commit is contained in:
222
editor/include/XCEditor/Docking/UIEditorDockHost.h
Normal file
222
editor/include/XCEditor/Docking/UIEditorDockHost.h
Normal file
@@ -0,0 +1,222 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Foundation/UIEditorTextMeasurement.h>
|
||||
#include <XCEditor/Panels/UIEditorPanelRegistry.h>
|
||||
#include <XCEditor/Workspace/UIEditorWorkspaceModel.h>
|
||||
#include <XCEditor/Workspace/UIEditorWorkspaceSession.h>
|
||||
#include <XCEditor/Panels/UIEditorPanelFrame.h>
|
||||
#include <XCEditor/Collections/UIEditorTabStrip.h>
|
||||
|
||||
#include <XCEngine/UI/Layout/UISplitterLayout.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
enum class UIEditorDockHostHitTargetKind : std::uint8_t {
|
||||
None = 0,
|
||||
SplitterHandle,
|
||||
TabStripBackground,
|
||||
Tab,
|
||||
PanelHeader,
|
||||
PanelBody,
|
||||
PanelFooter
|
||||
};
|
||||
|
||||
struct UIEditorDockHostHitTarget {
|
||||
UIEditorDockHostHitTargetKind kind = UIEditorDockHostHitTargetKind::None;
|
||||
std::string nodeId = {};
|
||||
std::string panelId = {};
|
||||
std::size_t index = UIEditorTabStripInvalidIndex;
|
||||
};
|
||||
|
||||
struct UIEditorDockHostTabStripVisualState {
|
||||
std::string nodeId = {};
|
||||
UIEditorTabStripState state = {};
|
||||
};
|
||||
|
||||
struct UIEditorDockHostDropPreviewState {
|
||||
bool visible = false;
|
||||
std::string sourceNodeId = {};
|
||||
std::string sourcePanelId = {};
|
||||
std::string targetNodeId = {};
|
||||
UIEditorWorkspaceDockPlacement placement =
|
||||
UIEditorWorkspaceDockPlacement::Center;
|
||||
std::size_t insertionIndex = UIEditorTabStripInvalidIndex;
|
||||
};
|
||||
|
||||
struct UIEditorDockHostState {
|
||||
bool focused = false;
|
||||
UIEditorDockHostHitTarget hoveredTarget = {};
|
||||
std::string activeSplitterNodeId = {};
|
||||
std::vector<UIEditorDockHostTabStripVisualState> tabStripStates = {};
|
||||
UIEditorDockHostDropPreviewState dropPreview = {};
|
||||
};
|
||||
|
||||
struct UIEditorDockHostMetrics {
|
||||
::XCEngine::UI::Layout::UISplitterMetrics splitterMetrics =
|
||||
::XCEngine::UI::Layout::UISplitterMetrics{ 2.0f, 10.0f };
|
||||
UIEditorTabStripMetrics tabStripMetrics = {};
|
||||
UIEditorPanelFrameMetrics panelFrameMetrics = {};
|
||||
::XCEngine::UI::UISize minimumStandalonePanelBodySize =
|
||||
::XCEngine::UI::UISize(180.0f, 140.0f);
|
||||
::XCEngine::UI::UISize minimumTabContentBodySize =
|
||||
::XCEngine::UI::UISize(260.0f, 180.0f);
|
||||
float splitterHandleRounding = 0.0f;
|
||||
float placeholderLineGap = 22.0f;
|
||||
};
|
||||
|
||||
struct UIEditorDockHostPalette {
|
||||
UIEditorTabStripPalette tabStripPalette = {};
|
||||
UIEditorPanelFramePalette panelFramePalette = {};
|
||||
::XCEngine::UI::UIColor splitterColor =
|
||||
::XCEngine::UI::UIColor(0.13f, 0.13f, 0.13f, 1.0f);
|
||||
::XCEngine::UI::UIColor splitterHoveredColor =
|
||||
::XCEngine::UI::UIColor(0.13f, 0.13f, 0.13f, 1.0f);
|
||||
::XCEngine::UI::UIColor splitterActiveColor =
|
||||
::XCEngine::UI::UIColor(0.13f, 0.13f, 0.13f, 1.0f);
|
||||
::XCEngine::UI::UIColor placeholderTitleColor =
|
||||
::XCEngine::UI::UIColor(0.93f, 0.94f, 0.96f, 1.0f);
|
||||
::XCEngine::UI::UIColor placeholderTextColor =
|
||||
::XCEngine::UI::UIColor(0.70f, 0.72f, 0.74f, 1.0f);
|
||||
::XCEngine::UI::UIColor placeholderMutedColor =
|
||||
::XCEngine::UI::UIColor(0.58f, 0.59f, 0.62f, 1.0f);
|
||||
::XCEngine::UI::UIColor dropPreviewFillColor =
|
||||
::XCEngine::UI::UIColor(0.88f, 0.88f, 0.88f, 0.14f);
|
||||
::XCEngine::UI::UIColor dropPreviewBorderColor =
|
||||
::XCEngine::UI::UIColor(0.94f, 0.94f, 0.94f, 0.78f);
|
||||
};
|
||||
|
||||
struct UIEditorDockHostTabItemLayout {
|
||||
std::string panelId = {};
|
||||
std::string title = {};
|
||||
// Cached title measurement used consistently by layout, hit testing and rendering.
|
||||
float measuredLabelWidth = 0.0f;
|
||||
bool active = false;
|
||||
};
|
||||
|
||||
struct UIEditorDockHostSplitterLayout {
|
||||
std::string nodeId = {};
|
||||
UIEditorWorkspaceSplitAxis axis = UIEditorWorkspaceSplitAxis::Horizontal;
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
::XCEngine::UI::UIRect handleHitRect = {};
|
||||
::XCEngine::UI::Layout::UISplitterConstraints constraints = {};
|
||||
::XCEngine::UI::Layout::UISplitterMetrics metrics = {};
|
||||
::XCEngine::UI::Layout::UISplitterLayoutResult splitterLayout = {};
|
||||
bool hovered = false;
|
||||
bool active = false;
|
||||
};
|
||||
|
||||
struct UIEditorDockHostTabStackLayout {
|
||||
std::string nodeId = {};
|
||||
std::string selectedPanelId = {};
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
std::vector<UIEditorDockHostTabItemLayout> items = {};
|
||||
UIEditorTabStripState tabStripState = {};
|
||||
UIEditorTabStripLayout tabStripLayout = {};
|
||||
UIEditorPanelFrameState contentFrameState = {};
|
||||
UIEditorPanelFrameLayout contentFrameLayout = {};
|
||||
};
|
||||
|
||||
struct UIEditorDockHostDropPreviewLayout {
|
||||
bool visible = false;
|
||||
std::string targetNodeId = {};
|
||||
UIEditorWorkspaceDockPlacement placement =
|
||||
UIEditorWorkspaceDockPlacement::Center;
|
||||
std::size_t insertionIndex = UIEditorTabStripInvalidIndex;
|
||||
::XCEngine::UI::UIRect previewRect = {};
|
||||
};
|
||||
|
||||
struct UIEditorDockHostLayout {
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
std::vector<UIEditorDockHostSplitterLayout> splitters = {};
|
||||
std::vector<UIEditorDockHostTabStackLayout> tabStacks = {};
|
||||
UIEditorDockHostDropPreviewLayout dropPreview = {};
|
||||
};
|
||||
|
||||
enum class UIEditorDockHostCursorKind : std::uint8_t {
|
||||
Arrow = 0,
|
||||
ResizeEW,
|
||||
ResizeNS
|
||||
};
|
||||
|
||||
// Allows higher-level compose to own panel body presentation while DockHost
|
||||
// keeps drawing the surrounding chrome/frame.
|
||||
struct UIEditorDockHostForegroundOptions {
|
||||
std::vector<std::string> externalBodyPanelIds = {};
|
||||
bool deferDropPreviewOverlay = false;
|
||||
};
|
||||
|
||||
const UIEditorDockHostSplitterLayout* FindUIEditorDockHostSplitterLayout(
|
||||
const UIEditorDockHostLayout& layout,
|
||||
std::string_view nodeId);
|
||||
|
||||
UIEditorDockHostCursorKind ResolveUIEditorDockHostCursorKind(
|
||||
const UIEditorDockHostLayout& layout);
|
||||
|
||||
UIEditorDockHostLayout BuildUIEditorDockHostLayout(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session,
|
||||
const UIEditorDockHostState& state = {},
|
||||
const UIEditorDockHostMetrics& metrics = {},
|
||||
const UIEditorTextMeasurer* textMeasurer = nullptr);
|
||||
|
||||
UIEditorDockHostHitTarget HitTestUIEditorDockHost(
|
||||
const UIEditorDockHostLayout& layout,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
void AppendUIEditorDockHostBackground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorDockHostLayout& layout,
|
||||
const UIEditorDockHostPalette& palette = {},
|
||||
const UIEditorDockHostMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorDockHostForeground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorDockHostLayout& layout,
|
||||
const UIEditorDockHostForegroundOptions& options = {},
|
||||
const UIEditorDockHostPalette& palette = {},
|
||||
const UIEditorDockHostMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorDockHostForeground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorDockHostLayout& layout,
|
||||
const UIEditorDockHostPalette& palette,
|
||||
const UIEditorDockHostMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorDockHostOverlay(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorDockHostLayout& layout,
|
||||
const UIEditorDockHostPalette& palette = {},
|
||||
const UIEditorDockHostMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorDockHost(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session,
|
||||
const UIEditorDockHostState& state = {},
|
||||
const UIEditorDockHostForegroundOptions& foregroundOptions = {},
|
||||
const UIEditorDockHostPalette& palette = {},
|
||||
const UIEditorDockHostMetrics& metrics = {},
|
||||
const UIEditorTextMeasurer* textMeasurer = nullptr);
|
||||
|
||||
void AppendUIEditorDockHost(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorPanelRegistry& panelRegistry,
|
||||
const UIEditorWorkspaceModel& workspace,
|
||||
const UIEditorWorkspaceSession& session,
|
||||
const UIEditorDockHostState& state,
|
||||
const UIEditorDockHostPalette& palette,
|
||||
const UIEditorDockHostMetrics& metrics = {},
|
||||
const UIEditorTextMeasurer* textMeasurer = nullptr);
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Collections/UIEditorTabStripInteraction.h>
|
||||
#include <XCEditor/Workspace/UIEditorWorkspaceController.h>
|
||||
#include <XCEditor/Docking/UIEditorDockHost.h>
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
#include <XCEngine/UI/Widgets/UISplitterInteraction.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorDockHostTabStripInteractionEntry {
|
||||
std::string nodeId = {};
|
||||
UIEditorTabStripInteractionState state = {};
|
||||
};
|
||||
|
||||
struct UIEditorDockHostInteractionState {
|
||||
Widgets::UIEditorDockHostState dockHostState = {};
|
||||
::XCEngine::UI::Widgets::UISplitterDragState splitterDragState = {};
|
||||
std::vector<UIEditorDockHostTabStripInteractionEntry> tabStripInteractions = {};
|
||||
std::string activeTabDragNodeId = {};
|
||||
std::string activeTabDragPanelId = {};
|
||||
::XCEngine::UI::UIPoint pointerPosition = {};
|
||||
bool hasPointerPosition = false;
|
||||
};
|
||||
|
||||
struct UIEditorDockHostInteractionResult {
|
||||
bool consumed = false;
|
||||
bool commandExecuted = false;
|
||||
bool layoutChanged = false;
|
||||
bool detachRequested = false;
|
||||
bool requestPointerCapture = false;
|
||||
bool releasePointerCapture = false;
|
||||
Widgets::UIEditorDockHostHitTarget hitTarget = {};
|
||||
std::string activeSplitterNodeId = {};
|
||||
std::string detachedNodeId = {};
|
||||
std::string detachedPanelId = {};
|
||||
UIEditorWorkspaceCommandResult commandResult = {};
|
||||
UIEditorWorkspaceLayoutOperationResult layoutResult = {};
|
||||
};
|
||||
|
||||
struct UIEditorDockHostInteractionFrame {
|
||||
Widgets::UIEditorDockHostLayout layout = {};
|
||||
UIEditorDockHostInteractionResult result = {};
|
||||
bool focused = false;
|
||||
};
|
||||
|
||||
UIEditorDockHostInteractionFrame UpdateUIEditorDockHostInteraction(
|
||||
UIEditorDockHostInteractionState& state,
|
||||
UIEditorWorkspaceController& controller,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
|
||||
const Widgets::UIEditorDockHostMetrics& metrics = {},
|
||||
const UIEditorTextMeasurer* textMeasurer = nullptr);
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
30
editor/include/XCEditor/Docking/UIEditorDockHostTransfer.h
Normal file
30
editor/include/XCEditor/Docking/UIEditorDockHostTransfer.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Docking/UIEditorDockHost.h>
|
||||
|
||||
#include <XCEngine/UI/Types.h>
|
||||
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorDockHostTabDropTarget {
|
||||
bool valid = false;
|
||||
std::string nodeId = {};
|
||||
UIEditorWorkspaceDockPlacement placement = UIEditorWorkspaceDockPlacement::Center;
|
||||
std::size_t insertionIndex = Widgets::UIEditorTabStripInvalidIndex;
|
||||
};
|
||||
|
||||
bool TryResolveUIEditorDockHostTabDragHotspot(
|
||||
const Widgets::UIEditorDockHostLayout& layout,
|
||||
std::string_view nodeId,
|
||||
std::string_view panelId,
|
||||
const ::XCEngine::UI::UIPoint& point,
|
||||
::XCEngine::UI::UIPoint& outHotspot);
|
||||
|
||||
UIEditorDockHostTabDropTarget ResolveUIEditorDockHostTabDropTarget(
|
||||
const Widgets::UIEditorDockHostLayout& layout,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
Reference in New Issue
Block a user