关键节点
This commit is contained in:
@@ -0,0 +1,99 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/UI/Types.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorViewportInputBridgeConfig {
|
||||
bool focusOnPointerDownInside = true;
|
||||
bool clearFocusOnPointerDownOutside = true;
|
||||
bool capturePointerOnPointerDownInside = true;
|
||||
};
|
||||
|
||||
enum class UIEditorViewportInputBridgeFocusMode : std::uint8_t {
|
||||
SelfManaged = 0,
|
||||
External
|
||||
};
|
||||
|
||||
struct UIEditorViewportInputBridgeRequest {
|
||||
UIEditorViewportInputBridgeFocusMode focusMode =
|
||||
UIEditorViewportInputBridgeFocusMode::SelfManaged;
|
||||
bool focused = false;
|
||||
};
|
||||
|
||||
struct UIEditorViewportInputBridgeState {
|
||||
bool hovered = false;
|
||||
bool focused = false;
|
||||
bool captured = false;
|
||||
::XCEngine::UI::UIPointerButton captureButton = ::XCEngine::UI::UIPointerButton::None;
|
||||
::XCEngine::UI::UIPoint lastScreenPointerPosition = {};
|
||||
::XCEngine::UI::UIPoint lastLocalPointerPosition = {};
|
||||
bool hasPointerPosition = false;
|
||||
::XCEngine::UI::UIInputModifiers modifiers = {};
|
||||
std::unordered_set<std::int32_t> pressedKeys = {};
|
||||
std::uint8_t pointerButtonsDownMask = 0;
|
||||
};
|
||||
|
||||
struct UIEditorViewportPointerButtonTransition {
|
||||
::XCEngine::UI::UIPointerButton button =
|
||||
::XCEngine::UI::UIPointerButton::None;
|
||||
bool pressed = false;
|
||||
bool inside = false;
|
||||
::XCEngine::UI::UIPoint screenPosition = {};
|
||||
::XCEngine::UI::UIPoint localPointerPosition = {};
|
||||
::XCEngine::UI::UIInputModifiers modifiers = {};
|
||||
};
|
||||
|
||||
struct UIEditorViewportInputBridgeFrame {
|
||||
bool hasPointerPosition = false;
|
||||
bool hovered = false;
|
||||
bool focused = false;
|
||||
bool captured = false;
|
||||
bool pointerInside = false;
|
||||
bool pointerMoved = false;
|
||||
bool pointerPressedInside = false;
|
||||
bool pointerReleasedInside = false;
|
||||
bool focusGained = false;
|
||||
bool focusLost = false;
|
||||
bool captureStarted = false;
|
||||
bool captureEnded = false;
|
||||
::XCEngine::UI::UIPointerButton changedPointerButton = ::XCEngine::UI::UIPointerButton::None;
|
||||
::XCEngine::UI::UIPoint screenPointerPosition = {};
|
||||
::XCEngine::UI::UIPoint localPointerPosition = {};
|
||||
::XCEngine::UI::UIPoint pointerDelta = {};
|
||||
float wheelDelta = 0.0f;
|
||||
::XCEngine::UI::UIInputModifiers modifiers = {};
|
||||
std::vector<std::int32_t> pressedKeyCodes = {};
|
||||
std::vector<std::int32_t> releasedKeyCodes = {};
|
||||
std::vector<std::uint32_t> characters = {};
|
||||
std::vector<UIEditorViewportPointerButtonTransition> pointerButtonTransitions = {};
|
||||
};
|
||||
|
||||
bool IsUIEditorViewportInputBridgeKeyDown(
|
||||
const UIEditorViewportInputBridgeState& state,
|
||||
std::int32_t keyCode);
|
||||
|
||||
bool IsUIEditorViewportInputBridgePointerButtonDown(
|
||||
const UIEditorViewportInputBridgeState& state,
|
||||
::XCEngine::UI::UIPointerButton button);
|
||||
|
||||
UIEditorViewportInputBridgeFrame UpdateUIEditorViewportInputBridge(
|
||||
UIEditorViewportInputBridgeState& state,
|
||||
const ::XCEngine::UI::UIRect& inputRect,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& events,
|
||||
const UIEditorViewportInputBridgeConfig& config = {},
|
||||
const UIEditorViewportInputBridgeRequest& request = {});
|
||||
|
||||
UIEditorViewportInputBridgeFrame UpdateUIEditorViewportInputBridge(
|
||||
UIEditorViewportInputBridgeState& state,
|
||||
const ::XCEngine::UI::UIRect& interactionRect,
|
||||
const ::XCEngine::UI::UIRect& localRect,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& events,
|
||||
const UIEditorViewportInputBridgeConfig& config = {},
|
||||
const UIEditorViewportInputBridgeRequest& request = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
71
editor/include/XCEditor/Viewport/UIEditorViewportShell.h
Normal file
71
editor/include/XCEditor/Viewport/UIEditorViewportShell.h
Normal file
@@ -0,0 +1,71 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Foundation/UIEditorTextMeasurement.h>
|
||||
#include <XCEditor/Viewport/UIEditorViewportInputBridge.h>
|
||||
#include <XCEditor/Viewport/UIEditorViewportSlot.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorViewportShellVisualState {
|
||||
std::size_t hoveredToolIndex = Widgets::UIEditorViewportSlotInvalidIndex;
|
||||
std::size_t activeToolIndex = Widgets::UIEditorViewportSlotInvalidIndex;
|
||||
Widgets::UIEditorStatusBarState statusBarState = {};
|
||||
};
|
||||
|
||||
struct UIEditorViewportShellSpec {
|
||||
Widgets::UIEditorViewportSlotChrome chrome = {};
|
||||
std::vector<Widgets::UIEditorViewportSlotToolItem> toolItems = {};
|
||||
std::vector<Widgets::UIEditorStatusBarSegment> statusSegments = {};
|
||||
UIEditorViewportInputBridgeConfig inputBridgeConfig = {};
|
||||
UIEditorViewportShellVisualState visualState = {};
|
||||
};
|
||||
|
||||
struct UIEditorViewportShellModel {
|
||||
UIEditorViewportShellSpec spec = {};
|
||||
Widgets::UIEditorViewportSlotFrame frame = {};
|
||||
};
|
||||
|
||||
struct UIEditorViewportShellRequest {
|
||||
Widgets::UIEditorViewportSlotLayout slotLayout = {};
|
||||
::XCEngine::UI::UISize requestedViewportSize = {};
|
||||
};
|
||||
|
||||
struct UIEditorViewportShellState {
|
||||
UIEditorViewportInputBridgeState inputBridgeState = {};
|
||||
};
|
||||
|
||||
struct UIEditorViewportShellFrame {
|
||||
Widgets::UIEditorViewportSlotLayout slotLayout = {};
|
||||
Widgets::UIEditorViewportSlotState slotState = {};
|
||||
UIEditorViewportInputBridgeFrame inputFrame = {};
|
||||
::XCEngine::UI::UISize requestedViewportSize = {};
|
||||
};
|
||||
|
||||
UIEditorViewportShellModel ResolveUIEditorViewportShellMeasuredModel(
|
||||
const UIEditorViewportShellModel& model,
|
||||
const Widgets::UIEditorViewportSlotMetrics& metrics = {},
|
||||
const UIEditorTextMeasurer* textMeasurer = nullptr);
|
||||
|
||||
UIEditorViewportShellRequest ResolveUIEditorViewportShellRequest(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorViewportShellSpec& spec,
|
||||
const Widgets::UIEditorViewportSlotMetrics& metrics = {});
|
||||
|
||||
UIEditorViewportShellFrame UpdateUIEditorViewportShell(
|
||||
UIEditorViewportShellState& state,
|
||||
const UIEditorViewportShellRequest& request,
|
||||
const UIEditorViewportShellModel& model,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
|
||||
const UIEditorViewportInputBridgeRequest& inputRequest = {});
|
||||
|
||||
UIEditorViewportShellFrame UpdateUIEditorViewportShell(
|
||||
UIEditorViewportShellState& state,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorViewportShellModel& model,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
|
||||
const Widgets::UIEditorViewportSlotMetrics& metrics = {},
|
||||
const UIEditorViewportInputBridgeRequest& inputRequest = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
225
editor/include/XCEditor/Viewport/UIEditorViewportSlot.h
Normal file
225
editor/include/XCEditor/Viewport/UIEditorViewportSlot.h
Normal file
@@ -0,0 +1,225 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
#include <XCEditor/Shell/UIEditorStatusBar.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
inline constexpr std::size_t UIEditorViewportSlotInvalidIndex =
|
||||
static_cast<std::size_t>(-1);
|
||||
|
||||
enum class UIEditorViewportSlotToolSlot : std::uint8_t {
|
||||
Leading = 0,
|
||||
Trailing
|
||||
};
|
||||
|
||||
enum class UIEditorViewportSlotHitTargetKind : std::uint8_t {
|
||||
None = 0,
|
||||
TopBar,
|
||||
Title,
|
||||
ToolItem,
|
||||
Surface,
|
||||
BottomBar,
|
||||
StatusSegment,
|
||||
StatusSeparator
|
||||
};
|
||||
|
||||
struct UIEditorViewportSlotFrame {
|
||||
::XCEngine::UI::UITextureHandle texture = {};
|
||||
::XCEngine::UI::UISize requestedSize = {};
|
||||
::XCEngine::UI::UISize presentedSize = {};
|
||||
bool hasTexture = false;
|
||||
std::string statusText = {};
|
||||
};
|
||||
|
||||
struct UIEditorViewportSlotChrome {
|
||||
std::string title = {};
|
||||
std::string subtitle = {};
|
||||
bool showTopBar = true;
|
||||
bool showBottomBar = true;
|
||||
float topBarHeight = 24.0f;
|
||||
float bottomBarHeight = 22.0f;
|
||||
};
|
||||
|
||||
struct UIEditorViewportSlotToolItem {
|
||||
std::string itemId = {};
|
||||
std::string label = {};
|
||||
UIEditorViewportSlotToolSlot slot = UIEditorViewportSlotToolSlot::Trailing;
|
||||
bool enabled = true;
|
||||
bool selected = false;
|
||||
// Pure measured tool-label width. Tool button padding is applied only in layout.
|
||||
float measuredLabelWidth = 0.0f;
|
||||
};
|
||||
|
||||
struct UIEditorViewportSlotState {
|
||||
bool focused = false;
|
||||
bool surfaceHovered = false;
|
||||
bool surfaceActive = false;
|
||||
bool inputCaptured = false;
|
||||
std::size_t hoveredToolIndex = UIEditorViewportSlotInvalidIndex;
|
||||
std::size_t activeToolIndex = UIEditorViewportSlotInvalidIndex;
|
||||
UIEditorStatusBarState statusBarState = {};
|
||||
};
|
||||
|
||||
struct UIEditorViewportSlotMetrics {
|
||||
float cornerRounding = 0.0f;
|
||||
float outerBorderThickness = 1.0f;
|
||||
float focusedBorderThickness = 1.0f;
|
||||
float topBarPaddingX = 8.0f;
|
||||
float topBarPaddingY = 0.0f;
|
||||
float toolPaddingX = 8.0f;
|
||||
float toolGap = 4.0f;
|
||||
float toolCornerRounding = 2.0f;
|
||||
float toolLabelFontSize = 11.0f;
|
||||
float toolLabelInsetY = 3.0f;
|
||||
float titleGap = 6.0f;
|
||||
float titleFontSize = 13.0f;
|
||||
float titleInsetY = 5.0f;
|
||||
float subtitleFontSize = 10.0f;
|
||||
float subtitleInsetY = 14.0f;
|
||||
float estimatedGlyphWidth = 6.5f;
|
||||
float surfaceInset = 0.0f;
|
||||
float surfaceBorderThickness = 1.0f;
|
||||
float focusedSurfaceBorderThickness = 1.0f;
|
||||
UIEditorStatusBarMetrics statusBarMetrics = {};
|
||||
};
|
||||
|
||||
struct UIEditorViewportSlotPalette {
|
||||
::XCEngine::UI::UIColor frameColor =
|
||||
::XCEngine::UI::UIColor(0.09f, 0.09f, 0.09f, 1.0f);
|
||||
::XCEngine::UI::UIColor topBarColor =
|
||||
::XCEngine::UI::UIColor(0.10f, 0.10f, 0.10f, 1.0f);
|
||||
::XCEngine::UI::UIColor surfaceColor =
|
||||
::XCEngine::UI::UIColor(0.09f, 0.09f, 0.09f, 1.0f);
|
||||
::XCEngine::UI::UIColor surfaceHoverOverlayColor =
|
||||
::XCEngine::UI::UIColor(0.18f, 0.18f, 0.18f, 0.08f);
|
||||
::XCEngine::UI::UIColor surfaceActiveOverlayColor =
|
||||
::XCEngine::UI::UIColor(0.22f, 0.22f, 0.22f, 0.08f);
|
||||
::XCEngine::UI::UIColor captureOverlayColor =
|
||||
::XCEngine::UI::UIColor(0.92f, 0.92f, 0.92f, 0.05f);
|
||||
::XCEngine::UI::UIColor borderColor =
|
||||
::XCEngine::UI::UIColor(0.15f, 0.15f, 0.15f, 1.0f);
|
||||
::XCEngine::UI::UIColor focusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.19f, 0.19f, 0.19f, 1.0f);
|
||||
::XCEngine::UI::UIColor surfaceBorderColor =
|
||||
::XCEngine::UI::UIColor(0.15f, 0.15f, 0.15f, 1.0f);
|
||||
::XCEngine::UI::UIColor surfaceHoveredBorderColor =
|
||||
::XCEngine::UI::UIColor(0.17f, 0.17f, 0.17f, 1.0f);
|
||||
::XCEngine::UI::UIColor surfaceActiveBorderColor =
|
||||
::XCEngine::UI::UIColor(0.19f, 0.19f, 0.19f, 1.0f);
|
||||
::XCEngine::UI::UIColor surfaceCapturedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.19f, 0.19f, 0.19f, 1.0f);
|
||||
::XCEngine::UI::UIColor toolColor =
|
||||
::XCEngine::UI::UIColor(0.12f, 0.12f, 0.12f, 1.0f);
|
||||
::XCEngine::UI::UIColor toolHoveredColor =
|
||||
::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f);
|
||||
::XCEngine::UI::UIColor toolSelectedColor =
|
||||
::XCEngine::UI::UIColor(0.17f, 0.17f, 0.17f, 1.0f);
|
||||
::XCEngine::UI::UIColor toolDisabledColor =
|
||||
::XCEngine::UI::UIColor(0.09f, 0.09f, 0.09f, 1.0f);
|
||||
::XCEngine::UI::UIColor toolBorderColor =
|
||||
::XCEngine::UI::UIColor(0.15f, 0.15f, 0.15f, 1.0f);
|
||||
::XCEngine::UI::UIColor textPrimary =
|
||||
::XCEngine::UI::UIColor(0.92f, 0.92f, 0.92f, 1.0f);
|
||||
::XCEngine::UI::UIColor textSecondary =
|
||||
::XCEngine::UI::UIColor(0.72f, 0.72f, 0.72f, 1.0f);
|
||||
::XCEngine::UI::UIColor textMuted =
|
||||
::XCEngine::UI::UIColor(0.62f, 0.62f, 0.62f, 1.0f);
|
||||
::XCEngine::UI::UIColor imageTint =
|
||||
::XCEngine::UI::UIColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
UIEditorStatusBarPalette statusBarPalette = {};
|
||||
};
|
||||
|
||||
struct UIEditorViewportSlotLayout {
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
::XCEngine::UI::UIRect topBarRect = {};
|
||||
::XCEngine::UI::UIRect titleRect = {};
|
||||
::XCEngine::UI::UIRect subtitleRect = {};
|
||||
::XCEngine::UI::UIRect toolbarLeadingRect = {};
|
||||
::XCEngine::UI::UIRect toolbarTrailingRect = {};
|
||||
::XCEngine::UI::UIRect surfaceRect = {};
|
||||
::XCEngine::UI::UIRect textureRect = {};
|
||||
::XCEngine::UI::UIRect inputRect = {};
|
||||
::XCEngine::UI::UIRect bottomBarRect = {};
|
||||
std::vector<::XCEngine::UI::UIRect> toolItemRects = {};
|
||||
UIEditorStatusBarLayout statusBarLayout = {};
|
||||
::XCEngine::UI::UISize requestedSurfaceSize = {};
|
||||
bool hasTopBar = false;
|
||||
bool hasBottomBar = false;
|
||||
};
|
||||
|
||||
struct UIEditorViewportSlotHitTarget {
|
||||
UIEditorViewportSlotHitTargetKind kind = UIEditorViewportSlotHitTargetKind::None;
|
||||
std::size_t index = UIEditorViewportSlotInvalidIndex;
|
||||
};
|
||||
|
||||
struct UIEditorViewportSlotForegroundAppendOptions {
|
||||
bool includeSurfaceTexture = true;
|
||||
};
|
||||
|
||||
float ResolveUIEditorViewportSlotMeasuredToolLabelWidth(
|
||||
const UIEditorViewportSlotToolItem& item,
|
||||
const UIEditorViewportSlotMetrics& metrics = {},
|
||||
const UIEditorTextMeasurer* textMeasurer = nullptr);
|
||||
|
||||
float ResolveUIEditorViewportSlotDesiredToolWidth(
|
||||
const UIEditorViewportSlotToolItem& item,
|
||||
const UIEditorViewportSlotMetrics& metrics = {});
|
||||
|
||||
UIEditorViewportSlotLayout BuildUIEditorViewportSlotLayout(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorViewportSlotChrome& chrome,
|
||||
const UIEditorViewportSlotFrame& frame,
|
||||
const std::vector<UIEditorViewportSlotToolItem>& toolItems,
|
||||
const std::vector<UIEditorStatusBarSegment>& statusSegments,
|
||||
const UIEditorViewportSlotMetrics& metrics = {});
|
||||
|
||||
UIEditorViewportSlotHitTarget HitTestUIEditorViewportSlot(
|
||||
const UIEditorViewportSlotLayout& layout,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
void AppendUIEditorViewportSlotBackground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorViewportSlotLayout& layout,
|
||||
const std::vector<UIEditorViewportSlotToolItem>& toolItems,
|
||||
const std::vector<UIEditorStatusBarSegment>& statusSegments,
|
||||
const UIEditorViewportSlotState& state,
|
||||
const UIEditorViewportSlotPalette& palette = {},
|
||||
const UIEditorViewportSlotMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorViewportSlotForeground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorViewportSlotLayout& layout,
|
||||
const UIEditorViewportSlotChrome& chrome,
|
||||
const UIEditorViewportSlotFrame& frame,
|
||||
const std::vector<UIEditorViewportSlotToolItem>& toolItems,
|
||||
const std::vector<UIEditorStatusBarSegment>& statusSegments,
|
||||
const UIEditorViewportSlotState& state,
|
||||
const UIEditorViewportSlotPalette& palette = {},
|
||||
const UIEditorViewportSlotMetrics& metrics = {},
|
||||
const UIEditorViewportSlotForegroundAppendOptions& options = {});
|
||||
|
||||
void AppendUIEditorViewportSlotSurfaceTexture(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorViewportSlotLayout& layout,
|
||||
const UIEditorViewportSlotFrame& frame,
|
||||
const UIEditorViewportSlotPalette& palette = {});
|
||||
|
||||
void AppendUIEditorViewportSlot(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorViewportSlotChrome& chrome,
|
||||
const UIEditorViewportSlotFrame& frame,
|
||||
const std::vector<UIEditorViewportSlotToolItem>& toolItems,
|
||||
const std::vector<UIEditorStatusBarSegment>& statusSegments,
|
||||
const UIEditorViewportSlotState& state,
|
||||
const UIEditorViewportSlotPalette& palette = {},
|
||||
const UIEditorViewportSlotMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
Reference in New Issue
Block a user