Refactor XCUI editor module layout
This commit is contained in:
188
new_editor/include/XCEditor/Fields/UIEditorAssetField.h
Normal file
188
new_editor/include/XCEditor/Fields/UIEditorAssetField.h
Normal file
@@ -0,0 +1,188 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
enum class UIEditorAssetFieldHitTargetKind : std::uint8_t {
|
||||
None = 0,
|
||||
Row,
|
||||
ValueBox,
|
||||
PickerButton,
|
||||
ClearButton
|
||||
};
|
||||
|
||||
struct UIEditorAssetFieldSpec {
|
||||
std::string fieldId = {};
|
||||
std::string label = {};
|
||||
std::string assetId = {};
|
||||
std::string displayName = {};
|
||||
std::string statusText = {};
|
||||
std::string emptyText = "None";
|
||||
::XCEngine::UI::UIColor tint = ::XCEngine::UI::UIColor(0.28f, 0.50f, 0.83f, 1.0f);
|
||||
bool readOnly = false;
|
||||
bool showPickerButton = true;
|
||||
bool allowClear = true;
|
||||
bool showStatusBadge = true;
|
||||
};
|
||||
|
||||
struct UIEditorAssetFieldState {
|
||||
UIEditorAssetFieldHitTargetKind hoveredTarget = UIEditorAssetFieldHitTargetKind::None;
|
||||
UIEditorAssetFieldHitTargetKind activeTarget = UIEditorAssetFieldHitTargetKind::None;
|
||||
bool focused = false;
|
||||
};
|
||||
|
||||
struct UIEditorAssetFieldMetrics {
|
||||
float rowHeight = 22.0f;
|
||||
float horizontalPadding = 12.0f;
|
||||
float labelControlGap = 20.0f;
|
||||
float controlColumnStart = 236.0f;
|
||||
float controlTrailingInset = 8.0f;
|
||||
float valueBoxMinWidth = 116.0f;
|
||||
float controlInsetY = 1.0f;
|
||||
float labelTextInsetY = 0.0f;
|
||||
float labelFontSize = 11.0f;
|
||||
float valueTextInsetX = 6.0f;
|
||||
float valueTextInsetY = 0.0f;
|
||||
float valueFontSize = 12.0f;
|
||||
float previewSize = 16.0f;
|
||||
float previewInsetX = 4.0f;
|
||||
float previewGap = 6.0f;
|
||||
float previewGlyphFontSize = 10.0f;
|
||||
float statusBadgeGap = 6.0f;
|
||||
float statusBadgeMinWidth = 44.0f;
|
||||
float statusBadgePaddingX = 6.0f;
|
||||
float statusBadgeHeight = 14.0f;
|
||||
float statusBadgeFontSize = 10.0f;
|
||||
float actionButtonGap = 2.0f;
|
||||
float actionButtonWidth = 20.0f;
|
||||
float actionGlyphFontSize = 10.0f;
|
||||
float actionGlyphInsetY = -1.0f;
|
||||
float cornerRounding = 0.0f;
|
||||
float valueBoxRounding = 2.0f;
|
||||
float previewRounding = 2.0f;
|
||||
float badgeRounding = 2.0f;
|
||||
float borderThickness = 1.0f;
|
||||
float focusedBorderThickness = 1.0f;
|
||||
};
|
||||
|
||||
struct UIEditorAssetFieldPalette {
|
||||
::XCEngine::UI::UIColor surfaceColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor borderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor focusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowHoverColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowActiveColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor valueBoxColor =
|
||||
::XCEngine::UI::UIColor(0.18f, 0.18f, 0.18f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxHoverColor =
|
||||
::XCEngine::UI::UIColor(0.22f, 0.22f, 0.22f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxActiveColor =
|
||||
::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f);
|
||||
::XCEngine::UI::UIColor readOnlyColor =
|
||||
::XCEngine::UI::UIColor(0.16f, 0.16f, 0.16f, 1.0f);
|
||||
::XCEngine::UI::UIColor controlBorderColor =
|
||||
::XCEngine::UI::UIColor(0.12f, 0.12f, 0.12f, 1.0f);
|
||||
::XCEngine::UI::UIColor controlFocusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.42f, 0.42f, 0.42f, 1.0f);
|
||||
::XCEngine::UI::UIColor labelColor =
|
||||
::XCEngine::UI::UIColor(0.80f, 0.80f, 0.80f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueColor =
|
||||
::XCEngine::UI::UIColor(0.92f, 0.92f, 0.92f, 1.0f);
|
||||
::XCEngine::UI::UIColor emptyValueColor =
|
||||
::XCEngine::UI::UIColor(0.60f, 0.60f, 0.60f, 1.0f);
|
||||
::XCEngine::UI::UIColor previewBaseColor =
|
||||
::XCEngine::UI::UIColor(0.23f, 0.25f, 0.28f, 1.0f);
|
||||
::XCEngine::UI::UIColor previewEmptyColor =
|
||||
::XCEngine::UI::UIColor(0.26f, 0.26f, 0.26f, 1.0f);
|
||||
::XCEngine::UI::UIColor previewBorderColor =
|
||||
::XCEngine::UI::UIColor(0.08f, 0.08f, 0.08f, 1.0f);
|
||||
::XCEngine::UI::UIColor previewGlyphColor =
|
||||
::XCEngine::UI::UIColor(0.94f, 0.94f, 0.94f, 1.0f);
|
||||
::XCEngine::UI::UIColor statusBadgeColor =
|
||||
::XCEngine::UI::UIColor(0.25f, 0.29f, 0.34f, 1.0f);
|
||||
::XCEngine::UI::UIColor statusBadgeBorderColor =
|
||||
::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f);
|
||||
::XCEngine::UI::UIColor statusBadgeTextColor =
|
||||
::XCEngine::UI::UIColor(0.82f, 0.87f, 0.96f, 1.0f);
|
||||
::XCEngine::UI::UIColor actionButtonHoverColor =
|
||||
::XCEngine::UI::UIColor(0.28f, 0.28f, 0.28f, 1.0f);
|
||||
::XCEngine::UI::UIColor actionButtonActiveColor =
|
||||
::XCEngine::UI::UIColor(0.32f, 0.32f, 0.32f, 1.0f);
|
||||
::XCEngine::UI::UIColor actionButtonColor =
|
||||
::XCEngine::UI::UIColor(0.16f, 0.16f, 0.16f, 1.0f);
|
||||
::XCEngine::UI::UIColor separatorColor =
|
||||
::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f);
|
||||
::XCEngine::UI::UIColor pickerGlyphColor =
|
||||
::XCEngine::UI::UIColor(0.88f, 0.88f, 0.88f, 1.0f);
|
||||
::XCEngine::UI::UIColor clearGlyphColor =
|
||||
::XCEngine::UI::UIColor(0.95f, 0.68f, 0.68f, 1.0f);
|
||||
};
|
||||
|
||||
struct UIEditorAssetFieldLayout {
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
::XCEngine::UI::UIRect labelRect = {};
|
||||
::XCEngine::UI::UIRect controlRect = {};
|
||||
::XCEngine::UI::UIRect valueRect = {};
|
||||
::XCEngine::UI::UIRect previewRect = {};
|
||||
::XCEngine::UI::UIRect textRect = {};
|
||||
::XCEngine::UI::UIRect statusBadgeRect = {};
|
||||
::XCEngine::UI::UIRect pickerRect = {};
|
||||
::XCEngine::UI::UIRect clearRect = {};
|
||||
};
|
||||
|
||||
struct UIEditorAssetFieldHitTarget {
|
||||
UIEditorAssetFieldHitTargetKind kind = UIEditorAssetFieldHitTargetKind::None;
|
||||
};
|
||||
|
||||
bool HasUIEditorAssetFieldValue(const UIEditorAssetFieldSpec& spec);
|
||||
|
||||
std::string ResolveUIEditorAssetFieldValueText(const UIEditorAssetFieldSpec& spec);
|
||||
|
||||
std::string ResolveUIEditorAssetFieldPreviewGlyph(const UIEditorAssetFieldSpec& spec);
|
||||
|
||||
bool IsUIEditorAssetFieldPointInside(
|
||||
const ::XCEngine::UI::UIRect& rect,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
UIEditorAssetFieldLayout BuildUIEditorAssetFieldLayout(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorAssetFieldSpec& spec,
|
||||
const UIEditorAssetFieldMetrics& metrics = {});
|
||||
|
||||
UIEditorAssetFieldHitTarget HitTestUIEditorAssetField(
|
||||
const UIEditorAssetFieldLayout& layout,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
void AppendUIEditorAssetFieldBackground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorAssetFieldLayout& layout,
|
||||
const UIEditorAssetFieldSpec& spec,
|
||||
const UIEditorAssetFieldState& state,
|
||||
const UIEditorAssetFieldPalette& palette = {},
|
||||
const UIEditorAssetFieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorAssetFieldForeground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorAssetFieldLayout& layout,
|
||||
const UIEditorAssetFieldSpec& spec,
|
||||
const UIEditorAssetFieldState& state,
|
||||
const UIEditorAssetFieldPalette& palette = {},
|
||||
const UIEditorAssetFieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorAssetField(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorAssetFieldSpec& spec,
|
||||
const UIEditorAssetFieldState& state,
|
||||
const UIEditorAssetFieldPalette& palette = {},
|
||||
const UIEditorAssetFieldMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Fields/UIEditorAssetField.h>
|
||||
|
||||
#include <XCEngine/UI/Types.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorAssetFieldInteractionState {
|
||||
Widgets::UIEditorAssetFieldState fieldState = {};
|
||||
::XCEngine::UI::UIPoint pointerPosition = {};
|
||||
bool hasPointerPosition = false;
|
||||
};
|
||||
|
||||
struct UIEditorAssetFieldInteractionResult {
|
||||
bool consumed = false;
|
||||
bool focusChanged = false;
|
||||
bool valueChanged = false;
|
||||
bool activateRequested = false;
|
||||
bool pickerRequested = false;
|
||||
bool clearRequested = false;
|
||||
Widgets::UIEditorAssetFieldHitTarget hitTarget = {};
|
||||
std::string assetIdBefore = {};
|
||||
std::string assetIdAfter = {};
|
||||
std::string displayNameBefore = {};
|
||||
std::string displayNameAfter = {};
|
||||
};
|
||||
|
||||
struct UIEditorAssetFieldInteractionFrame {
|
||||
Widgets::UIEditorAssetFieldLayout layout = {};
|
||||
UIEditorAssetFieldInteractionResult result = {};
|
||||
};
|
||||
|
||||
UIEditorAssetFieldInteractionFrame UpdateUIEditorAssetFieldInteraction(
|
||||
UIEditorAssetFieldInteractionState& state,
|
||||
Widgets::UIEditorAssetFieldSpec& spec,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
|
||||
const Widgets::UIEditorAssetFieldMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
116
new_editor/include/XCEditor/Fields/UIEditorBoolField.h
Normal file
116
new_editor/include/XCEditor/Fields/UIEditorBoolField.h
Normal file
@@ -0,0 +1,116 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
enum class UIEditorBoolFieldHitTargetKind : std::uint8_t {
|
||||
None = 0,
|
||||
Row,
|
||||
Checkbox
|
||||
};
|
||||
|
||||
struct UIEditorBoolFieldSpec {
|
||||
std::string fieldId = {};
|
||||
std::string label = {};
|
||||
bool value = false;
|
||||
bool readOnly = false;
|
||||
};
|
||||
|
||||
struct UIEditorBoolFieldState {
|
||||
UIEditorBoolFieldHitTargetKind hoveredTarget = UIEditorBoolFieldHitTargetKind::None;
|
||||
bool focused = false;
|
||||
bool active = false;
|
||||
};
|
||||
|
||||
struct UIEditorBoolFieldMetrics {
|
||||
float rowHeight = 22.0f;
|
||||
float horizontalPadding = 12.0f;
|
||||
float labelControlGap = 20.0f;
|
||||
float controlColumnStart = 236.0f;
|
||||
float controlTrailingInset = 8.0f;
|
||||
float checkboxSize = 18.0f;
|
||||
float labelTextInsetY = 0.0f;
|
||||
float labelFontSize = 11.0f;
|
||||
float checkboxGlyphInsetX = 2.0f;
|
||||
float checkboxGlyphInsetY = -1.0f;
|
||||
float checkboxGlyphFontSize = 10.0f;
|
||||
float cornerRounding = 0.0f;
|
||||
float checkboxRounding = 2.0f;
|
||||
float borderThickness = 1.0f;
|
||||
float focusedBorderThickness = 1.0f;
|
||||
};
|
||||
|
||||
struct UIEditorBoolFieldPalette {
|
||||
::XCEngine::UI::UIColor surfaceColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor borderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor focusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f);
|
||||
::XCEngine::UI::UIColor rowHoverColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowActiveColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor checkboxColor =
|
||||
::XCEngine::UI::UIColor(0.18f, 0.18f, 0.18f, 1.0f);
|
||||
::XCEngine::UI::UIColor checkboxHoverColor =
|
||||
::XCEngine::UI::UIColor(0.21f, 0.21f, 0.21f, 1.0f);
|
||||
::XCEngine::UI::UIColor checkboxReadOnlyColor =
|
||||
::XCEngine::UI::UIColor(0.17f, 0.17f, 0.17f, 1.0f);
|
||||
::XCEngine::UI::UIColor checkboxBorderColor =
|
||||
::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f);
|
||||
::XCEngine::UI::UIColor checkboxMarkColor =
|
||||
::XCEngine::UI::UIColor(0.72f, 0.72f, 0.72f, 1.0f);
|
||||
::XCEngine::UI::UIColor labelColor =
|
||||
::XCEngine::UI::UIColor(0.88f, 0.88f, 0.88f, 1.0f);
|
||||
};
|
||||
|
||||
struct UIEditorBoolFieldLayout {
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
::XCEngine::UI::UIRect labelRect = {};
|
||||
::XCEngine::UI::UIRect controlRect = {};
|
||||
::XCEngine::UI::UIRect checkboxRect = {};
|
||||
::XCEngine::UI::UIRect checkmarkRect = {};
|
||||
};
|
||||
|
||||
struct UIEditorBoolFieldHitTarget {
|
||||
UIEditorBoolFieldHitTargetKind kind = UIEditorBoolFieldHitTargetKind::None;
|
||||
};
|
||||
|
||||
UIEditorBoolFieldLayout BuildUIEditorBoolFieldLayout(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorBoolFieldSpec& spec,
|
||||
const UIEditorBoolFieldMetrics& metrics = {});
|
||||
|
||||
UIEditorBoolFieldHitTarget HitTestUIEditorBoolField(
|
||||
const UIEditorBoolFieldLayout& layout,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
void AppendUIEditorBoolFieldBackground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorBoolFieldLayout& layout,
|
||||
const UIEditorBoolFieldSpec& spec,
|
||||
const UIEditorBoolFieldState& state,
|
||||
const UIEditorBoolFieldPalette& palette = {},
|
||||
const UIEditorBoolFieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorBoolFieldForeground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorBoolFieldLayout& layout,
|
||||
const UIEditorBoolFieldSpec& spec,
|
||||
const UIEditorBoolFieldPalette& palette = {},
|
||||
const UIEditorBoolFieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorBoolField(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorBoolFieldSpec& spec,
|
||||
const UIEditorBoolFieldState& state,
|
||||
const UIEditorBoolFieldPalette& palette = {},
|
||||
const UIEditorBoolFieldMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Fields/UIEditorBoolField.h>
|
||||
|
||||
#include <XCEngine/UI/Types.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorBoolFieldInteractionState {
|
||||
Widgets::UIEditorBoolFieldState fieldState = {};
|
||||
::XCEngine::UI::UIPoint pointerPosition = {};
|
||||
bool hasPointerPosition = false;
|
||||
};
|
||||
|
||||
struct UIEditorBoolFieldInteractionResult {
|
||||
bool consumed = false;
|
||||
bool valueChanged = false;
|
||||
bool focusedChanged = false;
|
||||
bool newValue = false;
|
||||
Widgets::UIEditorBoolFieldHitTarget hitTarget = {};
|
||||
};
|
||||
|
||||
struct UIEditorBoolFieldInteractionFrame {
|
||||
Widgets::UIEditorBoolFieldLayout layout = {};
|
||||
UIEditorBoolFieldInteractionResult result = {};
|
||||
};
|
||||
|
||||
UIEditorBoolFieldInteractionFrame UpdateUIEditorBoolFieldInteraction(
|
||||
UIEditorBoolFieldInteractionState& state,
|
||||
bool& value,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const Widgets::UIEditorBoolFieldSpec& spec,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
|
||||
const Widgets::UIEditorBoolFieldMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
220
new_editor/include/XCEditor/Fields/UIEditorColorField.h
Normal file
220
new_editor/include/XCEditor/Fields/UIEditorColorField.h
Normal file
@@ -0,0 +1,220 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
enum class UIEditorColorFieldHitTargetKind : std::uint8_t {
|
||||
None = 0,
|
||||
Row,
|
||||
Swatch,
|
||||
PopupSurface,
|
||||
PopupCloseButton,
|
||||
HueWheel,
|
||||
SaturationValue,
|
||||
RedChannel,
|
||||
GreenChannel,
|
||||
BlueChannel,
|
||||
AlphaChannel
|
||||
};
|
||||
|
||||
struct UIEditorColorFieldSpec {
|
||||
std::string fieldId = {};
|
||||
std::string label = {};
|
||||
::XCEngine::UI::UIColor value = {};
|
||||
bool showAlpha = true;
|
||||
bool readOnly = false;
|
||||
};
|
||||
|
||||
struct UIEditorColorFieldState {
|
||||
UIEditorColorFieldHitTargetKind hoveredTarget = UIEditorColorFieldHitTargetKind::None;
|
||||
UIEditorColorFieldHitTargetKind activeTarget = UIEditorColorFieldHitTargetKind::None;
|
||||
bool focused = false;
|
||||
bool popupOpen = false;
|
||||
float hue = 0.0f;
|
||||
bool hueValid = false;
|
||||
};
|
||||
|
||||
struct UIEditorColorFieldMetrics {
|
||||
float rowHeight = 22.0f;
|
||||
float horizontalPadding = 12.0f;
|
||||
float labelControlGap = 20.0f;
|
||||
float controlColumnStart = 236.0f;
|
||||
float controlTrailingInset = 8.0f;
|
||||
float swatchWidth = 54.0f;
|
||||
float swatchInsetY = 1.0f;
|
||||
float labelTextInsetY = 0.0f;
|
||||
float labelFontSize = 11.0f;
|
||||
float popupWidth = 292.0f;
|
||||
float popupPadding = 10.0f;
|
||||
float popupGapY = 6.0f;
|
||||
float popupHeaderHeight = 30.0f;
|
||||
float popupTopRowHeight = 34.0f;
|
||||
float popupPreviewWidth = 96.0f;
|
||||
float popupPreviewHeight = 28.0f;
|
||||
float popupCloseButtonSize = 18.0f;
|
||||
float borderThickness = 1.0f;
|
||||
float focusedBorderThickness = 1.0f;
|
||||
float swatchRounding = 2.0f;
|
||||
float popupBorderRounding = 3.0f;
|
||||
float wheelOuterRadius = 110.0f;
|
||||
float wheelRingThickness = 24.0f;
|
||||
float saturationValueSize = 114.0f;
|
||||
float wheelRegionHeight = 220.0f;
|
||||
float channelRowHeight = 20.0f;
|
||||
float numericBoxWidth = 62.0f;
|
||||
float channelLabelWidth = 12.0f;
|
||||
float hexLabelWidth = 84.0f;
|
||||
float controlRowSpacing = 8.0f;
|
||||
float popupFieldInset = 6.0f;
|
||||
float titleFontSize = 12.0f;
|
||||
float valueFontSize = 11.0f;
|
||||
float valueTextInsetX = 6.0f;
|
||||
float valueTextInsetY = 0.0f;
|
||||
float checkerSize = 6.0f;
|
||||
float handleRadius = 8.0f;
|
||||
float ringHandleRadius = 12.0f;
|
||||
};
|
||||
|
||||
struct UIEditorColorFieldPalette {
|
||||
::XCEngine::UI::UIColor surfaceColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor borderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor focusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowHoverColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowActiveColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor swatchBorderColor =
|
||||
::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f);
|
||||
::XCEngine::UI::UIColor swatchHoverBorderColor =
|
||||
::XCEngine::UI::UIColor(0.34f, 0.34f, 0.34f, 1.0f);
|
||||
::XCEngine::UI::UIColor swatchReadOnlyOverlayColor =
|
||||
::XCEngine::UI::UIColor(0.08f, 0.08f, 0.08f, 0.18f);
|
||||
::XCEngine::UI::UIColor popupColor =
|
||||
::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f);
|
||||
::XCEngine::UI::UIColor popupBorderColor =
|
||||
::XCEngine::UI::UIColor(0.15f, 0.15f, 0.15f, 1.0f);
|
||||
::XCEngine::UI::UIColor popupHeaderColor =
|
||||
::XCEngine::UI::UIColor(0.43f, 0.24f, 0.05f, 1.0f);
|
||||
::XCEngine::UI::UIColor popupTitleColor =
|
||||
::XCEngine::UI::UIColor(0.95f, 0.95f, 0.95f, 1.0f);
|
||||
::XCEngine::UI::UIColor closeButtonColor =
|
||||
::XCEngine::UI::UIColor(0.76f, 0.35f, 0.34f, 1.0f);
|
||||
::XCEngine::UI::UIColor closeButtonHoverColor =
|
||||
::XCEngine::UI::UIColor(0.82f, 0.40f, 0.39f, 1.0f);
|
||||
::XCEngine::UI::UIColor closeGlyphColor =
|
||||
::XCEngine::UI::UIColor(0.95f, 0.95f, 0.95f, 1.0f);
|
||||
::XCEngine::UI::UIColor labelColor =
|
||||
::XCEngine::UI::UIColor(0.88f, 0.88f, 0.88f, 1.0f);
|
||||
::XCEngine::UI::UIColor popupTextColor =
|
||||
::XCEngine::UI::UIColor(0.86f, 0.86f, 0.86f, 1.0f);
|
||||
::XCEngine::UI::UIColor popupTextMutedColor =
|
||||
::XCEngine::UI::UIColor(0.72f, 0.72f, 0.72f, 1.0f);
|
||||
::XCEngine::UI::UIColor previewBorderColor =
|
||||
::XCEngine::UI::UIColor(0.12f, 0.12f, 0.12f, 1.0f);
|
||||
::XCEngine::UI::UIColor previewBaseColor =
|
||||
::XCEngine::UI::UIColor(0.19f, 0.19f, 0.19f, 1.0f);
|
||||
::XCEngine::UI::UIColor checkerLightColor =
|
||||
::XCEngine::UI::UIColor(0.84f, 0.84f, 0.84f, 1.0f);
|
||||
::XCEngine::UI::UIColor checkerDarkColor =
|
||||
::XCEngine::UI::UIColor(0.55f, 0.55f, 0.55f, 1.0f);
|
||||
::XCEngine::UI::UIColor sliderBorderColor =
|
||||
::XCEngine::UI::UIColor(0.12f, 0.12f, 0.12f, 1.0f);
|
||||
::XCEngine::UI::UIColor numericBoxColor =
|
||||
::XCEngine::UI::UIColor(0.19f, 0.19f, 0.19f, 1.0f);
|
||||
::XCEngine::UI::UIColor numericBoxBorderColor =
|
||||
::XCEngine::UI::UIColor(0.12f, 0.12f, 0.12f, 1.0f);
|
||||
::XCEngine::UI::UIColor numericBoxTextColor =
|
||||
::XCEngine::UI::UIColor(0.90f, 0.90f, 0.90f, 1.0f);
|
||||
::XCEngine::UI::UIColor handleFillColor =
|
||||
::XCEngine::UI::UIColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
::XCEngine::UI::UIColor handleStrokeColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.4f);
|
||||
};
|
||||
|
||||
struct UIEditorColorFieldLayout {
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
::XCEngine::UI::UIRect labelRect = {};
|
||||
::XCEngine::UI::UIRect controlRect = {};
|
||||
::XCEngine::UI::UIRect swatchRect = {};
|
||||
::XCEngine::UI::UIRect popupRect = {};
|
||||
::XCEngine::UI::UIRect popupHeaderRect = {};
|
||||
::XCEngine::UI::UIRect popupTitleRect = {};
|
||||
::XCEngine::UI::UIRect popupCloseButtonRect = {};
|
||||
::XCEngine::UI::UIRect popupBodyRect = {};
|
||||
::XCEngine::UI::UIRect popupTopRowRect = {};
|
||||
::XCEngine::UI::UIRect popupPreviewRect = {};
|
||||
::XCEngine::UI::UIRect popupWheelRect = {};
|
||||
::XCEngine::UI::UIPoint hueWheelCenter = {};
|
||||
float hueWheelOuterRadius = 0.0f;
|
||||
float hueWheelInnerRadius = 0.0f;
|
||||
::XCEngine::UI::UIRect saturationValueRect = {};
|
||||
::XCEngine::UI::UIRect redLabelRect = {};
|
||||
::XCEngine::UI::UIRect redSliderRect = {};
|
||||
::XCEngine::UI::UIRect redValueRect = {};
|
||||
::XCEngine::UI::UIRect greenLabelRect = {};
|
||||
::XCEngine::UI::UIRect greenSliderRect = {};
|
||||
::XCEngine::UI::UIRect greenValueRect = {};
|
||||
::XCEngine::UI::UIRect blueLabelRect = {};
|
||||
::XCEngine::UI::UIRect blueSliderRect = {};
|
||||
::XCEngine::UI::UIRect blueValueRect = {};
|
||||
::XCEngine::UI::UIRect alphaLabelRect = {};
|
||||
::XCEngine::UI::UIRect alphaSliderRect = {};
|
||||
::XCEngine::UI::UIRect alphaValueRect = {};
|
||||
::XCEngine::UI::UIRect hexLabelRect = {};
|
||||
::XCEngine::UI::UIRect hexValueRect = {};
|
||||
};
|
||||
|
||||
struct UIEditorColorFieldHitTarget {
|
||||
UIEditorColorFieldHitTargetKind kind = UIEditorColorFieldHitTargetKind::None;
|
||||
};
|
||||
|
||||
std::string FormatUIEditorColorFieldRgbaText(
|
||||
const UIEditorColorFieldSpec& spec);
|
||||
|
||||
std::string FormatUIEditorColorFieldHexText(
|
||||
const UIEditorColorFieldSpec& spec);
|
||||
|
||||
UIEditorColorFieldLayout BuildUIEditorColorFieldLayout(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorColorFieldSpec& spec,
|
||||
const UIEditorColorFieldMetrics& metrics = {},
|
||||
const ::XCEngine::UI::UIRect& viewportRect = {});
|
||||
|
||||
UIEditorColorFieldHitTarget HitTestUIEditorColorField(
|
||||
const UIEditorColorFieldLayout& layout,
|
||||
bool popupOpen,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
void AppendUIEditorColorFieldBackground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorColorFieldLayout& layout,
|
||||
const UIEditorColorFieldSpec& spec,
|
||||
const UIEditorColorFieldState& state,
|
||||
const UIEditorColorFieldPalette& palette = {},
|
||||
const UIEditorColorFieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorColorFieldForeground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorColorFieldLayout& layout,
|
||||
const UIEditorColorFieldSpec& spec,
|
||||
const UIEditorColorFieldState& state,
|
||||
const UIEditorColorFieldPalette& palette = {},
|
||||
const UIEditorColorFieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorColorField(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorColorFieldSpec& spec,
|
||||
const UIEditorColorFieldState& state,
|
||||
const UIEditorColorFieldPalette& palette = {},
|
||||
const UIEditorColorFieldMetrics& metrics = {},
|
||||
const ::XCEngine::UI::UIRect& viewportRect = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Fields/UIEditorColorField.h>
|
||||
|
||||
#include <XCEngine/UI/Types.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorColorFieldInteractionState {
|
||||
Widgets::UIEditorColorFieldState colorFieldState = {};
|
||||
::XCEngine::UI::UIPoint pointerPosition = {};
|
||||
bool hasPointerPosition = false;
|
||||
};
|
||||
|
||||
struct UIEditorColorFieldInteractionResult {
|
||||
bool consumed = false;
|
||||
bool focusChanged = false;
|
||||
bool popupOpened = false;
|
||||
bool popupClosed = false;
|
||||
bool colorChanged = false;
|
||||
Widgets::UIEditorColorFieldHitTarget hitTarget = {};
|
||||
::XCEngine::UI::UIColor valueBefore = {};
|
||||
::XCEngine::UI::UIColor valueAfter = {};
|
||||
};
|
||||
|
||||
struct UIEditorColorFieldInteractionFrame {
|
||||
Widgets::UIEditorColorFieldLayout layout = {};
|
||||
UIEditorColorFieldInteractionResult result = {};
|
||||
};
|
||||
|
||||
UIEditorColorFieldInteractionFrame UpdateUIEditorColorFieldInteraction(
|
||||
UIEditorColorFieldInteractionState& state,
|
||||
Widgets::UIEditorColorFieldSpec& spec,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
|
||||
const Widgets::UIEditorColorFieldMetrics& metrics = {},
|
||||
const ::XCEngine::UI::UIRect& viewportRect = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
130
new_editor/include/XCEditor/Fields/UIEditorEnumField.h
Normal file
130
new_editor/include/XCEditor/Fields/UIEditorEnumField.h
Normal file
@@ -0,0 +1,130 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
enum class UIEditorEnumFieldHitTargetKind : std::uint8_t {
|
||||
None = 0,
|
||||
Row,
|
||||
ValueBox,
|
||||
DropdownArrow
|
||||
};
|
||||
|
||||
struct UIEditorEnumFieldSpec {
|
||||
std::string fieldId = {};
|
||||
std::string label = {};
|
||||
std::vector<std::string> options = {};
|
||||
std::size_t selectedIndex = 0u;
|
||||
bool readOnly = false;
|
||||
};
|
||||
|
||||
struct UIEditorEnumFieldState {
|
||||
UIEditorEnumFieldHitTargetKind hoveredTarget = UIEditorEnumFieldHitTargetKind::None;
|
||||
bool focused = false;
|
||||
bool active = false;
|
||||
bool popupOpen = false;
|
||||
};
|
||||
|
||||
struct UIEditorEnumFieldMetrics {
|
||||
float rowHeight = 22.0f;
|
||||
float horizontalPadding = 12.0f;
|
||||
float labelControlGap = 20.0f;
|
||||
float controlColumnStart = 236.0f;
|
||||
float controlTrailingInset = 8.0f;
|
||||
float valueBoxMinWidth = 96.0f;
|
||||
float controlInsetY = 1.0f;
|
||||
float labelTextInsetY = 0.0f;
|
||||
float labelFontSize = 11.0f;
|
||||
float valueTextInsetX = 3.0f;
|
||||
float valueTextInsetY = 0.0f;
|
||||
float valueFontSize = 12.0f;
|
||||
float dropdownArrowWidth = 20.0f;
|
||||
float dropdownArrowInsetX = 0.0f;
|
||||
float dropdownArrowInsetY = -1.0f;
|
||||
float dropdownArrowFontSize = 10.0f;
|
||||
float cornerRounding = 0.0f;
|
||||
float valueBoxRounding = 2.0f;
|
||||
float borderThickness = 1.0f;
|
||||
float focusedBorderThickness = 1.0f;
|
||||
};
|
||||
|
||||
struct UIEditorEnumFieldPalette {
|
||||
::XCEngine::UI::UIColor surfaceColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor borderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor focusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f);
|
||||
::XCEngine::UI::UIColor rowHoverColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowActiveColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor valueBoxColor =
|
||||
::XCEngine::UI::UIColor(0.18f, 0.18f, 0.18f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxHoverColor =
|
||||
::XCEngine::UI::UIColor(0.21f, 0.21f, 0.21f, 1.0f);
|
||||
::XCEngine::UI::UIColor readOnlyColor =
|
||||
::XCEngine::UI::UIColor(0.17f, 0.17f, 0.17f, 1.0f);
|
||||
::XCEngine::UI::UIColor controlBorderColor =
|
||||
::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f);
|
||||
::XCEngine::UI::UIColor labelColor =
|
||||
::XCEngine::UI::UIColor(0.88f, 0.88f, 0.88f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueColor =
|
||||
::XCEngine::UI::UIColor(0.88f, 0.88f, 0.88f, 1.0f);
|
||||
::XCEngine::UI::UIColor arrowColor =
|
||||
::XCEngine::UI::UIColor(0.88f, 0.88f, 0.88f, 1.0f);
|
||||
};
|
||||
|
||||
struct UIEditorEnumFieldLayout {
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
::XCEngine::UI::UIRect labelRect = {};
|
||||
::XCEngine::UI::UIRect controlRect = {};
|
||||
::XCEngine::UI::UIRect valueRect = {};
|
||||
::XCEngine::UI::UIRect arrowRect = {};
|
||||
};
|
||||
|
||||
struct UIEditorEnumFieldHitTarget {
|
||||
UIEditorEnumFieldHitTargetKind kind = UIEditorEnumFieldHitTargetKind::None;
|
||||
};
|
||||
|
||||
std::string ResolveUIEditorEnumFieldValueText(const UIEditorEnumFieldSpec& spec);
|
||||
|
||||
UIEditorEnumFieldLayout BuildUIEditorEnumFieldLayout(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorEnumFieldSpec& spec,
|
||||
const UIEditorEnumFieldMetrics& metrics = {});
|
||||
|
||||
UIEditorEnumFieldHitTarget HitTestUIEditorEnumField(
|
||||
const UIEditorEnumFieldLayout& layout,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
void AppendUIEditorEnumFieldBackground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorEnumFieldLayout& layout,
|
||||
const UIEditorEnumFieldSpec& spec,
|
||||
const UIEditorEnumFieldState& state,
|
||||
const UIEditorEnumFieldPalette& palette = {},
|
||||
const UIEditorEnumFieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorEnumFieldForeground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorEnumFieldLayout& layout,
|
||||
const UIEditorEnumFieldSpec& spec,
|
||||
const UIEditorEnumFieldPalette& palette = {},
|
||||
const UIEditorEnumFieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorEnumField(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorEnumFieldSpec& spec,
|
||||
const UIEditorEnumFieldState& state,
|
||||
const UIEditorEnumFieldPalette& palette = {},
|
||||
const UIEditorEnumFieldMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Shell/UIEditorMenuPopup.h>
|
||||
#include <XCEditor/Fields/UIEditorEnumField.h>
|
||||
|
||||
#include <XCEngine/UI/Types.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorEnumFieldInteractionState {
|
||||
Widgets::UIEditorEnumFieldState fieldState = {};
|
||||
::XCEngine::UI::UIPoint pointerPosition = {};
|
||||
std::size_t highlightedIndex = Widgets::UIEditorMenuPopupInvalidIndex;
|
||||
std::size_t pressedPopupIndex = Widgets::UIEditorMenuPopupInvalidIndex;
|
||||
bool hasPointerPosition = false;
|
||||
bool popupOpen = false;
|
||||
};
|
||||
|
||||
struct UIEditorEnumFieldInteractionResult {
|
||||
bool consumed = false;
|
||||
bool selectionChanged = false;
|
||||
bool focusedChanged = false;
|
||||
bool popupOpened = false;
|
||||
bool popupClosed = false;
|
||||
std::size_t selectedIndex = 0u;
|
||||
Widgets::UIEditorEnumFieldHitTarget hitTarget = {};
|
||||
std::size_t popupItemIndex = Widgets::UIEditorMenuPopupInvalidIndex;
|
||||
};
|
||||
|
||||
struct UIEditorEnumFieldInteractionFrame {
|
||||
Widgets::UIEditorEnumFieldLayout layout = {};
|
||||
Widgets::UIEditorMenuPopupLayout popupLayout = {};
|
||||
Widgets::UIEditorMenuPopupState popupState = {};
|
||||
std::vector<Widgets::UIEditorMenuPopupItem> popupItems = {};
|
||||
bool popupOpen = false;
|
||||
UIEditorEnumFieldInteractionResult result = {};
|
||||
};
|
||||
|
||||
UIEditorEnumFieldInteractionFrame UpdateUIEditorEnumFieldInteraction(
|
||||
UIEditorEnumFieldInteractionState& state,
|
||||
std::size_t& selectedIndex,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const Widgets::UIEditorEnumFieldSpec& spec,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
|
||||
const Widgets::UIEditorEnumFieldMetrics& metrics = {},
|
||||
const Widgets::UIEditorMenuPopupMetrics& popupMetrics = {},
|
||||
const ::XCEngine::UI::UIRect& viewportRect = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
101
new_editor/include/XCEditor/Fields/UIEditorFieldStyle.h
Normal file
101
new_editor/include/XCEditor/Fields/UIEditorFieldStyle.h
Normal file
@@ -0,0 +1,101 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Fields/UIEditorAssetField.h>
|
||||
#include <XCEditor/Fields/UIEditorBoolField.h>
|
||||
#include <XCEditor/Fields/UIEditorColorField.h>
|
||||
#include <XCEditor/Fields/UIEditorEnumField.h>
|
||||
#include <XCEditor/Fields/UIEditorNumberField.h>
|
||||
#include <XCEditor/Fields/UIEditorObjectField.h>
|
||||
#include <XCEditor/Fields/UIEditorPropertyGrid.h>
|
||||
#include <XCEditor/Fields/UIEditorTextField.h>
|
||||
#include <XCEditor/Fields/UIEditorVector2Field.h>
|
||||
#include <XCEditor/Fields/UIEditorVector3Field.h>
|
||||
#include <XCEditor/Fields/UIEditorVector4Field.h>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
const Widgets::UIEditorPropertyGridMetrics& GetUIEditorFixedPropertyGridMetrics();
|
||||
|
||||
const Widgets::UIEditorPropertyGridPalette& GetUIEditorFixedPropertyGridPalette();
|
||||
|
||||
Widgets::UIEditorBoolFieldMetrics BuildUIEditorPropertyGridBoolFieldMetrics(
|
||||
const Widgets::UIEditorPropertyGridMetrics& propertyGridMetrics,
|
||||
const Widgets::UIEditorBoolFieldMetrics& fallback = {});
|
||||
|
||||
Widgets::UIEditorBoolFieldPalette BuildUIEditorPropertyGridBoolFieldPalette(
|
||||
const Widgets::UIEditorPropertyGridPalette& propertyGridPalette,
|
||||
const Widgets::UIEditorBoolFieldPalette& fallback = {});
|
||||
|
||||
Widgets::UIEditorNumberFieldMetrics BuildUIEditorPropertyGridNumberFieldMetrics(
|
||||
const Widgets::UIEditorPropertyGridMetrics& propertyGridMetrics,
|
||||
const Widgets::UIEditorNumberFieldMetrics& fallback = {});
|
||||
|
||||
Widgets::UIEditorNumberFieldPalette BuildUIEditorPropertyGridNumberFieldPalette(
|
||||
const Widgets::UIEditorPropertyGridPalette& propertyGridPalette,
|
||||
const Widgets::UIEditorNumberFieldPalette& fallback = {});
|
||||
|
||||
Widgets::UIEditorTextFieldMetrics BuildUIEditorPropertyGridTextFieldMetrics(
|
||||
const Widgets::UIEditorPropertyGridMetrics& propertyGridMetrics,
|
||||
const Widgets::UIEditorTextFieldMetrics& fallback = {});
|
||||
|
||||
Widgets::UIEditorTextFieldPalette BuildUIEditorPropertyGridTextFieldPalette(
|
||||
const Widgets::UIEditorPropertyGridPalette& propertyGridPalette,
|
||||
const Widgets::UIEditorTextFieldPalette& fallback = {});
|
||||
|
||||
Widgets::UIEditorVector2FieldMetrics BuildUIEditorPropertyGridVector2FieldMetrics(
|
||||
const Widgets::UIEditorPropertyGridMetrics& propertyGridMetrics,
|
||||
const Widgets::UIEditorVector2FieldMetrics& fallback = {});
|
||||
|
||||
Widgets::UIEditorVector2FieldPalette BuildUIEditorPropertyGridVector2FieldPalette(
|
||||
const Widgets::UIEditorPropertyGridPalette& propertyGridPalette,
|
||||
const Widgets::UIEditorVector2FieldPalette& fallback = {});
|
||||
|
||||
Widgets::UIEditorVector3FieldMetrics BuildUIEditorPropertyGridVector3FieldMetrics(
|
||||
const Widgets::UIEditorPropertyGridMetrics& propertyGridMetrics,
|
||||
const Widgets::UIEditorVector3FieldMetrics& fallback = {});
|
||||
|
||||
Widgets::UIEditorVector3FieldPalette BuildUIEditorPropertyGridVector3FieldPalette(
|
||||
const Widgets::UIEditorPropertyGridPalette& propertyGridPalette,
|
||||
const Widgets::UIEditorVector3FieldPalette& fallback = {});
|
||||
|
||||
Widgets::UIEditorVector4FieldMetrics BuildUIEditorPropertyGridVector4FieldMetrics(
|
||||
const Widgets::UIEditorPropertyGridMetrics& propertyGridMetrics,
|
||||
const Widgets::UIEditorVector4FieldMetrics& fallback = {});
|
||||
|
||||
Widgets::UIEditorVector4FieldPalette BuildUIEditorPropertyGridVector4FieldPalette(
|
||||
const Widgets::UIEditorPropertyGridPalette& propertyGridPalette,
|
||||
const Widgets::UIEditorVector4FieldPalette& fallback = {});
|
||||
|
||||
Widgets::UIEditorEnumFieldMetrics BuildUIEditorPropertyGridEnumFieldMetrics(
|
||||
const Widgets::UIEditorPropertyGridMetrics& propertyGridMetrics,
|
||||
const Widgets::UIEditorEnumFieldMetrics& fallback = {});
|
||||
|
||||
Widgets::UIEditorEnumFieldPalette BuildUIEditorPropertyGridEnumFieldPalette(
|
||||
const Widgets::UIEditorPropertyGridPalette& propertyGridPalette,
|
||||
const Widgets::UIEditorEnumFieldPalette& fallback = {});
|
||||
|
||||
Widgets::UIEditorColorFieldMetrics BuildUIEditorPropertyGridColorFieldMetrics(
|
||||
const Widgets::UIEditorPropertyGridMetrics& propertyGridMetrics,
|
||||
const Widgets::UIEditorColorFieldMetrics& fallback = {});
|
||||
|
||||
Widgets::UIEditorColorFieldPalette BuildUIEditorPropertyGridColorFieldPalette(
|
||||
const Widgets::UIEditorPropertyGridPalette& propertyGridPalette,
|
||||
const Widgets::UIEditorColorFieldPalette& fallback = {});
|
||||
|
||||
Widgets::UIEditorObjectFieldMetrics BuildUIEditorPropertyGridObjectFieldMetrics(
|
||||
const Widgets::UIEditorPropertyGridMetrics& propertyGridMetrics,
|
||||
const Widgets::UIEditorObjectFieldMetrics& fallback = {});
|
||||
|
||||
Widgets::UIEditorObjectFieldPalette BuildUIEditorPropertyGridObjectFieldPalette(
|
||||
const Widgets::UIEditorPropertyGridPalette& propertyGridPalette,
|
||||
const Widgets::UIEditorObjectFieldPalette& fallback = {});
|
||||
|
||||
Widgets::UIEditorAssetFieldMetrics BuildUIEditorPropertyGridAssetFieldMetrics(
|
||||
const Widgets::UIEditorPropertyGridMetrics& propertyGridMetrics,
|
||||
const Widgets::UIEditorAssetFieldMetrics& fallback = {});
|
||||
|
||||
Widgets::UIEditorAssetFieldPalette BuildUIEditorPropertyGridAssetFieldPalette(
|
||||
const Widgets::UIEditorPropertyGridPalette& propertyGridPalette,
|
||||
const Widgets::UIEditorAssetFieldPalette& fallback = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
146
new_editor/include/XCEditor/Fields/UIEditorNumberField.h
Normal file
146
new_editor/include/XCEditor/Fields/UIEditorNumberField.h
Normal file
@@ -0,0 +1,146 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
enum class UIEditorNumberFieldHitTargetKind : std::uint8_t {
|
||||
None = 0,
|
||||
Row,
|
||||
ValueBox
|
||||
};
|
||||
|
||||
struct UIEditorNumberFieldSpec {
|
||||
std::string fieldId = {};
|
||||
std::string label = {};
|
||||
double value = 0.0;
|
||||
double step = 1.0;
|
||||
double minValue = 0.0;
|
||||
double maxValue = 100.0;
|
||||
bool integerMode = true;
|
||||
bool readOnly = false;
|
||||
};
|
||||
|
||||
struct UIEditorNumberFieldState {
|
||||
UIEditorNumberFieldHitTargetKind hoveredTarget = UIEditorNumberFieldHitTargetKind::None;
|
||||
UIEditorNumberFieldHitTargetKind activeTarget = UIEditorNumberFieldHitTargetKind::None;
|
||||
bool focused = false;
|
||||
bool editing = false;
|
||||
std::string displayText = {};
|
||||
};
|
||||
|
||||
struct UIEditorNumberFieldMetrics {
|
||||
float rowHeight = 22.0f;
|
||||
float horizontalPadding = 12.0f;
|
||||
float labelControlGap = 20.0f;
|
||||
float controlColumnStart = 236.0f;
|
||||
float controlTrailingInset = 8.0f;
|
||||
float valueBoxMinWidth = 96.0f;
|
||||
float controlInsetY = 1.0f;
|
||||
float labelTextInsetY = 0.0f;
|
||||
float labelFontSize = 11.0f;
|
||||
float valueTextInsetX = 5.0f;
|
||||
float valueTextInsetY = 0.0f;
|
||||
float valueFontSize = 12.0f;
|
||||
float cornerRounding = 0.0f;
|
||||
float valueBoxRounding = 2.0f;
|
||||
float borderThickness = 1.0f;
|
||||
float focusedBorderThickness = 1.0f;
|
||||
};
|
||||
|
||||
struct UIEditorNumberFieldPalette {
|
||||
::XCEngine::UI::UIColor surfaceColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor borderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor focusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowHoverColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowActiveColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor valueBoxColor =
|
||||
::XCEngine::UI::UIColor(0.18f, 0.18f, 0.18f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxHoverColor =
|
||||
::XCEngine::UI::UIColor(0.21f, 0.21f, 0.21f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxEditingColor =
|
||||
::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f);
|
||||
::XCEngine::UI::UIColor readOnlyColor =
|
||||
::XCEngine::UI::UIColor(0.17f, 0.17f, 0.17f, 1.0f);
|
||||
::XCEngine::UI::UIColor controlBorderColor =
|
||||
::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f);
|
||||
::XCEngine::UI::UIColor controlFocusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.46f, 0.46f, 0.46f, 1.0f);
|
||||
::XCEngine::UI::UIColor labelColor =
|
||||
::XCEngine::UI::UIColor(0.80f, 0.80f, 0.80f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueColor =
|
||||
::XCEngine::UI::UIColor(0.92f, 0.92f, 0.92f, 1.0f);
|
||||
::XCEngine::UI::UIColor readOnlyValueColor =
|
||||
::XCEngine::UI::UIColor(0.62f, 0.62f, 0.62f, 1.0f);
|
||||
};
|
||||
|
||||
struct UIEditorNumberFieldLayout {
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
::XCEngine::UI::UIRect labelRect = {};
|
||||
::XCEngine::UI::UIRect controlRect = {};
|
||||
::XCEngine::UI::UIRect valueRect = {};
|
||||
};
|
||||
|
||||
struct UIEditorNumberFieldHitTarget {
|
||||
UIEditorNumberFieldHitTargetKind kind = UIEditorNumberFieldHitTargetKind::None;
|
||||
};
|
||||
|
||||
bool IsUIEditorNumberFieldPointInside(
|
||||
const ::XCEngine::UI::UIRect& rect,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
double NormalizeUIEditorNumberFieldValue(
|
||||
const UIEditorNumberFieldSpec& spec,
|
||||
double value);
|
||||
|
||||
bool TryParseUIEditorNumberFieldValue(
|
||||
const UIEditorNumberFieldSpec& spec,
|
||||
std::string_view text,
|
||||
double& outValue);
|
||||
|
||||
std::string FormatUIEditorNumberFieldValue(const UIEditorNumberFieldSpec& spec);
|
||||
|
||||
UIEditorNumberFieldLayout BuildUIEditorNumberFieldLayout(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorNumberFieldSpec& spec,
|
||||
const UIEditorNumberFieldMetrics& metrics = {});
|
||||
|
||||
UIEditorNumberFieldHitTarget HitTestUIEditorNumberField(
|
||||
const UIEditorNumberFieldLayout& layout,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
void AppendUIEditorNumberFieldBackground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorNumberFieldLayout& layout,
|
||||
const UIEditorNumberFieldSpec& spec,
|
||||
const UIEditorNumberFieldState& state,
|
||||
const UIEditorNumberFieldPalette& palette = {},
|
||||
const UIEditorNumberFieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorNumberFieldForeground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorNumberFieldLayout& layout,
|
||||
const UIEditorNumberFieldSpec& spec,
|
||||
const UIEditorNumberFieldState& state,
|
||||
const UIEditorNumberFieldPalette& palette = {},
|
||||
const UIEditorNumberFieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorNumberField(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorNumberFieldSpec& spec,
|
||||
const UIEditorNumberFieldState& state,
|
||||
const UIEditorNumberFieldPalette& palette = {},
|
||||
const UIEditorNumberFieldMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Fields/UIEditorNumberField.h>
|
||||
|
||||
#include <XCEngine/UI/Text/UITextInputController.h>
|
||||
#include <XCEngine/UI/Types.h>
|
||||
#include <XCEngine/UI/Widgets/UIPropertyEditModel.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorNumberFieldInteractionState {
|
||||
Widgets::UIEditorNumberFieldState numberFieldState = {};
|
||||
::XCEngine::UI::Text::UITextInputState textInputState = {};
|
||||
::XCEngine::UI::Widgets::UIPropertyEditModel editModel = {};
|
||||
::XCEngine::UI::UIPoint pointerPosition = {};
|
||||
bool hasPointerPosition = false;
|
||||
};
|
||||
|
||||
struct UIEditorNumberFieldInteractionResult {
|
||||
bool consumed = false;
|
||||
bool focusChanged = false;
|
||||
bool valueChanged = false;
|
||||
bool stepApplied = false;
|
||||
bool editStarted = false;
|
||||
bool editCommitted = false;
|
||||
bool editCommitRejected = false;
|
||||
bool editCanceled = false;
|
||||
Widgets::UIEditorNumberFieldHitTarget hitTarget = {};
|
||||
double valueBefore = 0.0;
|
||||
double valueAfter = 0.0;
|
||||
double stepDelta = 0.0;
|
||||
std::string committedText = {};
|
||||
};
|
||||
|
||||
struct UIEditorNumberFieldInteractionFrame {
|
||||
Widgets::UIEditorNumberFieldLayout layout = {};
|
||||
UIEditorNumberFieldInteractionResult result = {};
|
||||
};
|
||||
|
||||
UIEditorNumberFieldInteractionFrame UpdateUIEditorNumberFieldInteraction(
|
||||
UIEditorNumberFieldInteractionState& state,
|
||||
Widgets::UIEditorNumberFieldSpec& spec,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
|
||||
const Widgets::UIEditorNumberFieldMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
153
new_editor/include/XCEditor/Fields/UIEditorObjectField.h
Normal file
153
new_editor/include/XCEditor/Fields/UIEditorObjectField.h
Normal file
@@ -0,0 +1,153 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
enum class UIEditorObjectFieldHitTargetKind : std::uint8_t {
|
||||
None = 0,
|
||||
Row,
|
||||
ValueBox,
|
||||
ClearButton,
|
||||
PickerButton
|
||||
};
|
||||
|
||||
struct UIEditorObjectFieldSpec {
|
||||
std::string fieldId = {};
|
||||
std::string label = {};
|
||||
std::string objectName = {};
|
||||
std::string objectTypeName = {};
|
||||
std::string emptyText = "(none)";
|
||||
bool hasValue = false;
|
||||
bool readOnly = false;
|
||||
bool showClearButton = true;
|
||||
bool showPickerButton = true;
|
||||
};
|
||||
|
||||
struct UIEditorObjectFieldState {
|
||||
UIEditorObjectFieldHitTargetKind hoveredTarget = UIEditorObjectFieldHitTargetKind::None;
|
||||
UIEditorObjectFieldHitTargetKind activeTarget = UIEditorObjectFieldHitTargetKind::None;
|
||||
bool focused = false;
|
||||
};
|
||||
|
||||
struct UIEditorObjectFieldMetrics {
|
||||
float rowHeight = 22.0f;
|
||||
float horizontalPadding = 12.0f;
|
||||
float labelControlGap = 20.0f;
|
||||
float controlColumnStart = 236.0f;
|
||||
float controlTrailingInset = 8.0f;
|
||||
float valueBoxMinWidth = 96.0f;
|
||||
float controlInsetY = 1.0f;
|
||||
float labelTextInsetY = 0.0f;
|
||||
float labelFontSize = 11.0f;
|
||||
float valueTextInsetX = 5.0f;
|
||||
float valueTextInsetY = 0.0f;
|
||||
float valueFontSize = 12.0f;
|
||||
float typeTextInsetX = 5.0f;
|
||||
float typeTextInsetY = 0.0f;
|
||||
float typeFontSize = 10.0f;
|
||||
float typeMaxWidth = 96.0f;
|
||||
float typeMinWidth = 44.0f;
|
||||
float valueTypeGap = 6.0f;
|
||||
float buttonWidth = 20.0f;
|
||||
float buttonGlyphInsetY = -1.0f;
|
||||
float buttonGlyphFontSize = 10.0f;
|
||||
float cornerRounding = 0.0f;
|
||||
float valueBoxRounding = 2.0f;
|
||||
float borderThickness = 1.0f;
|
||||
float focusedBorderThickness = 1.0f;
|
||||
};
|
||||
|
||||
struct UIEditorObjectFieldPalette {
|
||||
::XCEngine::UI::UIColor surfaceColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor borderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor focusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowHoverColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowActiveColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor valueBoxColor =
|
||||
::XCEngine::UI::UIColor(0.18f, 0.18f, 0.18f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxHoverColor =
|
||||
::XCEngine::UI::UIColor(0.21f, 0.21f, 0.21f, 1.0f);
|
||||
::XCEngine::UI::UIColor readOnlyColor =
|
||||
::XCEngine::UI::UIColor(0.17f, 0.17f, 0.17f, 1.0f);
|
||||
::XCEngine::UI::UIColor controlBorderColor =
|
||||
::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f);
|
||||
::XCEngine::UI::UIColor controlFocusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.46f, 0.46f, 0.46f, 1.0f);
|
||||
::XCEngine::UI::UIColor buttonColor =
|
||||
::XCEngine::UI::UIColor(0.16f, 0.16f, 0.16f, 1.0f);
|
||||
::XCEngine::UI::UIColor buttonHoverColor =
|
||||
::XCEngine::UI::UIColor(0.22f, 0.22f, 0.22f, 1.0f);
|
||||
::XCEngine::UI::UIColor buttonActiveColor =
|
||||
::XCEngine::UI::UIColor(0.26f, 0.26f, 0.26f, 1.0f);
|
||||
::XCEngine::UI::UIColor buttonGlyphColor =
|
||||
::XCEngine::UI::UIColor(0.86f, 0.86f, 0.86f, 1.0f);
|
||||
::XCEngine::UI::UIColor separatorColor =
|
||||
::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f);
|
||||
::XCEngine::UI::UIColor labelColor =
|
||||
::XCEngine::UI::UIColor(0.80f, 0.80f, 0.80f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueColor =
|
||||
::XCEngine::UI::UIColor(0.92f, 0.92f, 0.92f, 1.0f);
|
||||
::XCEngine::UI::UIColor emptyValueColor =
|
||||
::XCEngine::UI::UIColor(0.62f, 0.62f, 0.62f, 1.0f);
|
||||
::XCEngine::UI::UIColor typeColor =
|
||||
::XCEngine::UI::UIColor(0.68f, 0.68f, 0.68f, 1.0f);
|
||||
};
|
||||
|
||||
struct UIEditorObjectFieldLayout {
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
::XCEngine::UI::UIRect labelRect = {};
|
||||
::XCEngine::UI::UIRect controlRect = {};
|
||||
::XCEngine::UI::UIRect valueRect = {};
|
||||
::XCEngine::UI::UIRect typeRect = {};
|
||||
::XCEngine::UI::UIRect clearButtonRect = {};
|
||||
::XCEngine::UI::UIRect pickerButtonRect = {};
|
||||
};
|
||||
|
||||
struct UIEditorObjectFieldHitTarget {
|
||||
UIEditorObjectFieldHitTargetKind kind = UIEditorObjectFieldHitTargetKind::None;
|
||||
};
|
||||
|
||||
std::string ResolveUIEditorObjectFieldDisplayText(const UIEditorObjectFieldSpec& spec);
|
||||
|
||||
UIEditorObjectFieldLayout BuildUIEditorObjectFieldLayout(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorObjectFieldSpec& spec,
|
||||
const UIEditorObjectFieldMetrics& metrics = {});
|
||||
|
||||
UIEditorObjectFieldHitTarget HitTestUIEditorObjectField(
|
||||
const UIEditorObjectFieldLayout& layout,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
void AppendUIEditorObjectFieldBackground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorObjectFieldLayout& layout,
|
||||
const UIEditorObjectFieldSpec& spec,
|
||||
const UIEditorObjectFieldState& state,
|
||||
const UIEditorObjectFieldPalette& palette = {},
|
||||
const UIEditorObjectFieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorObjectFieldForeground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorObjectFieldLayout& layout,
|
||||
const UIEditorObjectFieldSpec& spec,
|
||||
const UIEditorObjectFieldPalette& palette = {},
|
||||
const UIEditorObjectFieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorObjectField(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorObjectFieldSpec& spec,
|
||||
const UIEditorObjectFieldState& state,
|
||||
const UIEditorObjectFieldPalette& palette = {},
|
||||
const UIEditorObjectFieldMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Fields/UIEditorObjectField.h>
|
||||
|
||||
#include <XCEngine/UI/Types.h>
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorObjectFieldInteractionState {
|
||||
Widgets::UIEditorObjectFieldState fieldState = {};
|
||||
::XCEngine::UI::UIPoint pointerPosition = {};
|
||||
bool hasPointerPosition = false;
|
||||
};
|
||||
|
||||
struct UIEditorObjectFieldInteractionResult {
|
||||
bool consumed = false;
|
||||
bool focusChanged = false;
|
||||
bool activateRequested = false;
|
||||
bool clearRequested = false;
|
||||
Widgets::UIEditorObjectFieldHitTarget hitTarget = {};
|
||||
};
|
||||
|
||||
struct UIEditorObjectFieldInteractionFrame {
|
||||
Widgets::UIEditorObjectFieldLayout layout = {};
|
||||
UIEditorObjectFieldInteractionResult result = {};
|
||||
};
|
||||
|
||||
UIEditorObjectFieldInteractionFrame UpdateUIEditorObjectFieldInteraction(
|
||||
UIEditorObjectFieldInteractionState& state,
|
||||
const Widgets::UIEditorObjectFieldSpec& spec,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
|
||||
const Widgets::UIEditorObjectFieldMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
302
new_editor/include/XCEditor/Fields/UIEditorPropertyGrid.h
Normal file
302
new_editor/include/XCEditor/Fields/UIEditorPropertyGrid.h
Normal file
@@ -0,0 +1,302 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
#include <XCEngine/UI/Widgets/UIExpansionModel.h>
|
||||
#include <XCEngine/UI/Widgets/UIPropertyEditModel.h>
|
||||
#include <XCEngine/UI/Widgets/UISelectionModel.h>
|
||||
|
||||
#include <XCEditor/Fields/UIEditorColorField.h>
|
||||
#include <XCEditor/Shell/UIEditorMenuPopup.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
inline constexpr std::size_t UIEditorPropertyGridInvalidIndex = static_cast<std::size_t>(-1);
|
||||
|
||||
enum class UIEditorPropertyGridFieldKind : std::uint8_t {
|
||||
Text = 0,
|
||||
Bool,
|
||||
Number,
|
||||
Enum,
|
||||
Color,
|
||||
Vector2,
|
||||
Vector3,
|
||||
Vector4
|
||||
};
|
||||
|
||||
enum class UIEditorPropertyGridHitTargetKind : std::uint8_t {
|
||||
None = 0,
|
||||
SectionHeader,
|
||||
FieldRow,
|
||||
ValueBox
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridFieldLocation {
|
||||
std::size_t sectionIndex = UIEditorPropertyGridInvalidIndex;
|
||||
std::size_t fieldIndex = UIEditorPropertyGridInvalidIndex;
|
||||
|
||||
constexpr bool IsValid() const {
|
||||
return sectionIndex != UIEditorPropertyGridInvalidIndex &&
|
||||
fieldIndex != UIEditorPropertyGridInvalidIndex;
|
||||
}
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridNumberFieldValue {
|
||||
double value = 0.0;
|
||||
double step = 1.0;
|
||||
double minValue = 0.0;
|
||||
double maxValue = 100.0;
|
||||
bool integerMode = true;
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridEnumFieldValue {
|
||||
std::vector<std::string> options = {};
|
||||
std::size_t selectedIndex = 0u;
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridColorFieldValue {
|
||||
::XCEngine::UI::UIColor value = {};
|
||||
bool showAlpha = true;
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridVector2FieldValue {
|
||||
std::array<double, 2u> values = { 0.0, 0.0 };
|
||||
std::array<std::string, 2u> componentLabels = { std::string("X"), std::string("Y") };
|
||||
double step = 0.1;
|
||||
double minValue = -1000000.0;
|
||||
double maxValue = 1000000.0;
|
||||
bool integerMode = false;
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridVector3FieldValue {
|
||||
std::array<double, 3u> values = { 0.0, 0.0, 0.0 };
|
||||
std::array<std::string, 3u> componentLabels = {
|
||||
std::string("X"),
|
||||
std::string("Y"),
|
||||
std::string("Z")
|
||||
};
|
||||
double step = 0.1;
|
||||
double minValue = -1000000.0;
|
||||
double maxValue = 1000000.0;
|
||||
bool integerMode = false;
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridVector4FieldValue {
|
||||
std::array<double, 4u> values = { 0.0, 0.0, 0.0, 0.0 };
|
||||
std::array<std::string, 4u> componentLabels = {
|
||||
std::string("X"),
|
||||
std::string("Y"),
|
||||
std::string("Z"),
|
||||
std::string("W")
|
||||
};
|
||||
double step = 0.1;
|
||||
double minValue = -1000000.0;
|
||||
double maxValue = 1000000.0;
|
||||
bool integerMode = false;
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridField {
|
||||
std::string fieldId = {};
|
||||
std::string label = {};
|
||||
std::string valueText = {};
|
||||
bool readOnly = false;
|
||||
float desiredHeight = 0.0f;
|
||||
UIEditorPropertyGridFieldKind kind = UIEditorPropertyGridFieldKind::Text;
|
||||
bool boolValue = false;
|
||||
UIEditorPropertyGridNumberFieldValue numberValue = {};
|
||||
UIEditorPropertyGridEnumFieldValue enumValue = {};
|
||||
UIEditorPropertyGridColorFieldValue colorValue = {};
|
||||
UIEditorPropertyGridVector2FieldValue vector2Value = {};
|
||||
UIEditorPropertyGridVector3FieldValue vector3Value = {};
|
||||
UIEditorPropertyGridVector4FieldValue vector4Value = {};
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridSection {
|
||||
std::string sectionId = {};
|
||||
std::string title = {};
|
||||
std::vector<UIEditorPropertyGridField> fields = {};
|
||||
float desiredHeaderHeight = 0.0f;
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridColorFieldVisualState {
|
||||
std::string fieldId = {};
|
||||
UIEditorColorFieldState state = {};
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridState {
|
||||
std::string hoveredSectionId = {};
|
||||
std::string hoveredFieldId = {};
|
||||
UIEditorPropertyGridHitTargetKind hoveredHitTarget = UIEditorPropertyGridHitTargetKind::None;
|
||||
bool focused = false;
|
||||
std::string pressedFieldId = {};
|
||||
std::string popupFieldId = {};
|
||||
std::size_t popupHighlightedIndex = UIEditorPropertyGridInvalidIndex;
|
||||
std::vector<UIEditorPropertyGridColorFieldVisualState> colorFieldStates = {};
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridMetrics {
|
||||
float contentInset = 8.0f;
|
||||
float sectionGap = 8.0f;
|
||||
float sectionHeaderHeight = 32.0f;
|
||||
float fieldRowHeight = 32.0f;
|
||||
float rowGap = 2.0f;
|
||||
float horizontalPadding = 12.0f;
|
||||
float controlColumnStart = 236.0f;
|
||||
float labelControlGap = 20.0f;
|
||||
float disclosureExtent = 12.0f;
|
||||
float disclosureLabelGap = 8.0f;
|
||||
float sectionTextInsetY = 8.0f;
|
||||
float sectionFontSize = 12.0f;
|
||||
float disclosureGlyphInsetX = 2.0f;
|
||||
float disclosureGlyphInsetY = -1.0f;
|
||||
float disclosureGlyphFontSize = 12.0f;
|
||||
float labelTextInsetY = 8.0f;
|
||||
float labelFontSize = 12.0f;
|
||||
float valueTextInsetY = 8.0f;
|
||||
float valueFontSize = 12.0f;
|
||||
float valueBoxInsetY = 4.0f;
|
||||
float valueBoxInsetX = 8.0f;
|
||||
float tagFontSize = 11.0f;
|
||||
float cornerRounding = 6.0f;
|
||||
float valueBoxRounding = 5.0f;
|
||||
float borderThickness = 1.0f;
|
||||
float focusedBorderThickness = 2.0f;
|
||||
float editOutlineThickness = 1.0f;
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridPalette {
|
||||
::XCEngine::UI::UIColor surfaceColor =
|
||||
::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f);
|
||||
::XCEngine::UI::UIColor borderColor =
|
||||
::XCEngine::UI::UIColor(0.29f, 0.29f, 0.29f, 1.0f);
|
||||
::XCEngine::UI::UIColor focusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.84f, 0.84f, 0.84f, 1.0f);
|
||||
::XCEngine::UI::UIColor sectionHeaderColor =
|
||||
::XCEngine::UI::UIColor(0.19f, 0.19f, 0.19f, 1.0f);
|
||||
::XCEngine::UI::UIColor sectionHeaderHoverColor =
|
||||
::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f);
|
||||
::XCEngine::UI::UIColor fieldHoverColor =
|
||||
::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f);
|
||||
::XCEngine::UI::UIColor fieldSelectedColor =
|
||||
::XCEngine::UI::UIColor(0.31f, 0.31f, 0.31f, 1.0f);
|
||||
::XCEngine::UI::UIColor fieldSelectedFocusedColor =
|
||||
::XCEngine::UI::UIColor(0.40f, 0.40f, 0.40f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxColor =
|
||||
::XCEngine::UI::UIColor(0.17f, 0.17f, 0.17f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxHoverColor =
|
||||
::XCEngine::UI::UIColor(0.22f, 0.22f, 0.22f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxEditingColor =
|
||||
::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxReadOnlyColor =
|
||||
::XCEngine::UI::UIColor(0.15f, 0.15f, 0.15f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxBorderColor =
|
||||
::XCEngine::UI::UIColor(0.32f, 0.32f, 0.32f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxEditingBorderColor =
|
||||
::XCEngine::UI::UIColor(0.75f, 0.75f, 0.75f, 1.0f);
|
||||
::XCEngine::UI::UIColor disclosureColor =
|
||||
::XCEngine::UI::UIColor(0.74f, 0.74f, 0.74f, 1.0f);
|
||||
::XCEngine::UI::UIColor sectionTextColor =
|
||||
::XCEngine::UI::UIColor(0.94f, 0.94f, 0.94f, 1.0f);
|
||||
::XCEngine::UI::UIColor labelTextColor =
|
||||
::XCEngine::UI::UIColor(0.84f, 0.84f, 0.84f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueTextColor =
|
||||
::XCEngine::UI::UIColor(0.94f, 0.94f, 0.94f, 1.0f);
|
||||
::XCEngine::UI::UIColor readOnlyValueTextColor =
|
||||
::XCEngine::UI::UIColor(0.60f, 0.60f, 0.60f, 1.0f);
|
||||
::XCEngine::UI::UIColor editTagColor =
|
||||
::XCEngine::UI::UIColor(0.62f, 0.78f, 0.96f, 1.0f);
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridLayout {
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
std::vector<std::size_t> sectionIndices = {};
|
||||
std::vector<::XCEngine::UI::UIRect> sectionHeaderRects = {};
|
||||
std::vector<::XCEngine::UI::UIRect> sectionDisclosureRects = {};
|
||||
std::vector<::XCEngine::UI::UIRect> sectionTitleRects = {};
|
||||
std::vector<bool> sectionExpanded = {};
|
||||
std::vector<std::size_t> visibleFieldSectionIndices = {};
|
||||
std::vector<std::size_t> visibleFieldIndices = {};
|
||||
std::vector<::XCEngine::UI::UIRect> fieldRowRects = {};
|
||||
std::vector<::XCEngine::UI::UIRect> fieldLabelRects = {};
|
||||
std::vector<::XCEngine::UI::UIRect> fieldValueRects = {};
|
||||
std::vector<bool> fieldReadOnly = {};
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridHitTarget {
|
||||
UIEditorPropertyGridHitTargetKind kind = UIEditorPropertyGridHitTargetKind::None;
|
||||
std::size_t sectionIndex = UIEditorPropertyGridInvalidIndex;
|
||||
std::size_t fieldIndex = UIEditorPropertyGridInvalidIndex;
|
||||
std::size_t visibleFieldIndex = UIEditorPropertyGridInvalidIndex;
|
||||
};
|
||||
|
||||
bool IsUIEditorPropertyGridPointInside(
|
||||
const ::XCEngine::UI::UIRect& rect,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
std::size_t FindUIEditorPropertyGridSectionIndex(
|
||||
const std::vector<UIEditorPropertyGridSection>& sections,
|
||||
std::string_view sectionId);
|
||||
|
||||
UIEditorPropertyGridFieldLocation FindUIEditorPropertyGridFieldLocation(
|
||||
const std::vector<UIEditorPropertyGridSection>& sections,
|
||||
std::string_view fieldId);
|
||||
|
||||
std::string ResolveUIEditorPropertyGridFieldValueText(
|
||||
const UIEditorPropertyGridField& field);
|
||||
|
||||
std::size_t FindUIEditorPropertyGridVisibleFieldIndex(
|
||||
const UIEditorPropertyGridLayout& layout,
|
||||
std::string_view fieldId,
|
||||
const std::vector<UIEditorPropertyGridSection>& sections);
|
||||
|
||||
UIEditorPropertyGridLayout BuildUIEditorPropertyGridLayout(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const std::vector<UIEditorPropertyGridSection>& sections,
|
||||
const ::XCEngine::UI::Widgets::UIExpansionModel& expansionModel,
|
||||
const UIEditorPropertyGridMetrics& metrics = {});
|
||||
|
||||
UIEditorPropertyGridHitTarget HitTestUIEditorPropertyGrid(
|
||||
const UIEditorPropertyGridLayout& layout,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
void AppendUIEditorPropertyGridBackground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorPropertyGridLayout& layout,
|
||||
const std::vector<UIEditorPropertyGridSection>& sections,
|
||||
const ::XCEngine::UI::Widgets::UISelectionModel& selectionModel,
|
||||
const ::XCEngine::UI::Widgets::UIPropertyEditModel& propertyEditModel,
|
||||
const UIEditorPropertyGridState& state,
|
||||
const UIEditorPropertyGridPalette& palette = {},
|
||||
const UIEditorPropertyGridMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorPropertyGridForeground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorPropertyGridLayout& layout,
|
||||
const std::vector<UIEditorPropertyGridSection>& sections,
|
||||
const UIEditorPropertyGridState& state,
|
||||
const ::XCEngine::UI::Widgets::UIPropertyEditModel& propertyEditModel,
|
||||
const UIEditorPropertyGridPalette& palette = {},
|
||||
const UIEditorPropertyGridMetrics& metrics = {},
|
||||
const UIEditorMenuPopupPalette& popupPalette = {},
|
||||
const UIEditorMenuPopupMetrics& popupMetrics = {});
|
||||
|
||||
void AppendUIEditorPropertyGrid(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const std::vector<UIEditorPropertyGridSection>& sections,
|
||||
const ::XCEngine::UI::Widgets::UISelectionModel& selectionModel,
|
||||
const ::XCEngine::UI::Widgets::UIExpansionModel& expansionModel,
|
||||
const ::XCEngine::UI::Widgets::UIPropertyEditModel& propertyEditModel,
|
||||
const UIEditorPropertyGridState& state,
|
||||
const UIEditorPropertyGridPalette& palette = {},
|
||||
const UIEditorPropertyGridMetrics& metrics = {},
|
||||
const UIEditorMenuPopupPalette& popupPalette = {},
|
||||
const UIEditorMenuPopupMetrics& popupMetrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Fields/UIEditorPropertyGrid.h>
|
||||
|
||||
#include <XCEngine/UI/Text/UITextInputController.h>
|
||||
#include <XCEngine/UI/Types.h>
|
||||
#include <XCEngine/UI/Widgets/UIExpansionModel.h>
|
||||
#include <XCEngine/UI/Widgets/UIKeyboardNavigationModel.h>
|
||||
#include <XCEngine/UI/Widgets/UIPropertyEditModel.h>
|
||||
#include <XCEngine/UI/Widgets/UISelectionModel.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorPropertyGridInteractionState {
|
||||
Widgets::UIEditorPropertyGridState propertyGridState = {};
|
||||
::XCEngine::UI::Widgets::UIKeyboardNavigationModel keyboardNavigation = {};
|
||||
::XCEngine::UI::Text::UITextInputState textInputState = {};
|
||||
::XCEngine::UI::UIPoint pointerPosition = {};
|
||||
std::size_t pressedPopupIndex = Widgets::UIEditorPropertyGridInvalidIndex;
|
||||
bool hasPointerPosition = false;
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridInteractionResult {
|
||||
bool consumed = false;
|
||||
bool sectionToggled = false;
|
||||
bool selectionChanged = false;
|
||||
bool keyboardNavigated = false;
|
||||
bool editStarted = false;
|
||||
bool editValueChanged = false;
|
||||
bool editCommitted = false;
|
||||
bool editCommitRejected = false;
|
||||
bool editCanceled = false;
|
||||
bool popupOpened = false;
|
||||
bool popupClosed = false;
|
||||
bool fieldValueChanged = false;
|
||||
bool secondaryClicked = false;
|
||||
Widgets::UIEditorPropertyGridHitTarget hitTarget = {};
|
||||
std::string toggledSectionId = {};
|
||||
std::string selectedFieldId = {};
|
||||
std::string activeFieldId = {};
|
||||
std::string committedFieldId = {};
|
||||
std::string committedValue = {};
|
||||
std::string changedFieldId = {};
|
||||
std::string changedValue = {};
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridInteractionFrame {
|
||||
Widgets::UIEditorPropertyGridLayout layout = {};
|
||||
UIEditorPropertyGridInteractionResult result = {};
|
||||
};
|
||||
|
||||
UIEditorPropertyGridInteractionFrame UpdateUIEditorPropertyGridInteraction(
|
||||
UIEditorPropertyGridInteractionState& state,
|
||||
::XCEngine::UI::Widgets::UISelectionModel& selectionModel,
|
||||
::XCEngine::UI::Widgets::UIExpansionModel& expansionModel,
|
||||
::XCEngine::UI::Widgets::UIPropertyEditModel& propertyEditModel,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
std::vector<Widgets::UIEditorPropertyGridSection>& sections,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
|
||||
const Widgets::UIEditorPropertyGridMetrics& metrics = {},
|
||||
const Widgets::UIEditorMenuPopupMetrics& popupMetrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
130
new_editor/include/XCEditor/Fields/UIEditorTextField.h
Normal file
130
new_editor/include/XCEditor/Fields/UIEditorTextField.h
Normal file
@@ -0,0 +1,130 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
enum class UIEditorTextFieldHitTargetKind : std::uint8_t {
|
||||
None = 0,
|
||||
Row,
|
||||
ValueBox
|
||||
};
|
||||
|
||||
struct UIEditorTextFieldSpec {
|
||||
std::string fieldId = {};
|
||||
std::string label = {};
|
||||
std::string value = {};
|
||||
bool readOnly = false;
|
||||
};
|
||||
|
||||
struct UIEditorTextFieldState {
|
||||
UIEditorTextFieldHitTargetKind hoveredTarget = UIEditorTextFieldHitTargetKind::None;
|
||||
UIEditorTextFieldHitTargetKind activeTarget = UIEditorTextFieldHitTargetKind::None;
|
||||
bool focused = false;
|
||||
bool editing = false;
|
||||
std::string displayText = {};
|
||||
};
|
||||
|
||||
struct UIEditorTextFieldMetrics {
|
||||
float rowHeight = 22.0f;
|
||||
float horizontalPadding = 12.0f;
|
||||
float labelControlGap = 20.0f;
|
||||
float controlColumnStart = 236.0f;
|
||||
float controlTrailingInset = 8.0f;
|
||||
float valueBoxMinWidth = 96.0f;
|
||||
float controlInsetY = 1.0f;
|
||||
float labelTextInsetY = 0.0f;
|
||||
float labelFontSize = 11.0f;
|
||||
float valueTextInsetX = 5.0f;
|
||||
float valueTextInsetY = 0.0f;
|
||||
float valueFontSize = 12.0f;
|
||||
float cornerRounding = 0.0f;
|
||||
float valueBoxRounding = 2.0f;
|
||||
float borderThickness = 1.0f;
|
||||
float focusedBorderThickness = 1.0f;
|
||||
};
|
||||
|
||||
struct UIEditorTextFieldPalette {
|
||||
::XCEngine::UI::UIColor surfaceColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor borderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor focusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowHoverColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowActiveColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor valueBoxColor =
|
||||
::XCEngine::UI::UIColor(0.18f, 0.18f, 0.18f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxHoverColor =
|
||||
::XCEngine::UI::UIColor(0.21f, 0.21f, 0.21f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxEditingColor =
|
||||
::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f);
|
||||
::XCEngine::UI::UIColor readOnlyColor =
|
||||
::XCEngine::UI::UIColor(0.17f, 0.17f, 0.17f, 1.0f);
|
||||
::XCEngine::UI::UIColor controlBorderColor =
|
||||
::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f);
|
||||
::XCEngine::UI::UIColor controlFocusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.46f, 0.46f, 0.46f, 1.0f);
|
||||
::XCEngine::UI::UIColor labelColor =
|
||||
::XCEngine::UI::UIColor(0.80f, 0.80f, 0.80f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueColor =
|
||||
::XCEngine::UI::UIColor(0.92f, 0.92f, 0.92f, 1.0f);
|
||||
::XCEngine::UI::UIColor readOnlyValueColor =
|
||||
::XCEngine::UI::UIColor(0.62f, 0.62f, 0.62f, 1.0f);
|
||||
};
|
||||
|
||||
struct UIEditorTextFieldLayout {
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
::XCEngine::UI::UIRect labelRect = {};
|
||||
::XCEngine::UI::UIRect controlRect = {};
|
||||
::XCEngine::UI::UIRect valueRect = {};
|
||||
};
|
||||
|
||||
struct UIEditorTextFieldHitTarget {
|
||||
UIEditorTextFieldHitTargetKind kind = UIEditorTextFieldHitTargetKind::None;
|
||||
};
|
||||
|
||||
bool IsUIEditorTextFieldPointInside(
|
||||
const ::XCEngine::UI::UIRect& rect,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
UIEditorTextFieldLayout BuildUIEditorTextFieldLayout(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorTextFieldSpec& spec,
|
||||
const UIEditorTextFieldMetrics& metrics = {});
|
||||
|
||||
UIEditorTextFieldHitTarget HitTestUIEditorTextField(
|
||||
const UIEditorTextFieldLayout& layout,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
void AppendUIEditorTextFieldBackground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorTextFieldLayout& layout,
|
||||
const UIEditorTextFieldSpec& spec,
|
||||
const UIEditorTextFieldState& state,
|
||||
const UIEditorTextFieldPalette& palette = {},
|
||||
const UIEditorTextFieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorTextFieldForeground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorTextFieldLayout& layout,
|
||||
const UIEditorTextFieldSpec& spec,
|
||||
const UIEditorTextFieldState& state,
|
||||
const UIEditorTextFieldPalette& palette = {},
|
||||
const UIEditorTextFieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorTextField(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorTextFieldSpec& spec,
|
||||
const UIEditorTextFieldState& state,
|
||||
const UIEditorTextFieldPalette& palette = {},
|
||||
const UIEditorTextFieldMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Fields/UIEditorTextField.h>
|
||||
|
||||
#include <XCEngine/UI/Text/UITextInputController.h>
|
||||
#include <XCEngine/UI/Types.h>
|
||||
#include <XCEngine/UI/Widgets/UIPropertyEditModel.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorTextFieldInteractionState {
|
||||
Widgets::UIEditorTextFieldState textFieldState = {};
|
||||
::XCEngine::UI::Text::UITextInputState textInputState = {};
|
||||
::XCEngine::UI::Widgets::UIPropertyEditModel editModel = {};
|
||||
::XCEngine::UI::UIPoint pointerPosition = {};
|
||||
bool hasPointerPosition = false;
|
||||
};
|
||||
|
||||
struct UIEditorTextFieldInteractionResult {
|
||||
bool consumed = false;
|
||||
bool focusChanged = false;
|
||||
bool valueChanged = false;
|
||||
bool editStarted = false;
|
||||
bool editCommitted = false;
|
||||
bool editCanceled = false;
|
||||
Widgets::UIEditorTextFieldHitTarget hitTarget = {};
|
||||
std::string valueBefore = {};
|
||||
std::string valueAfter = {};
|
||||
std::string committedText = {};
|
||||
};
|
||||
|
||||
struct UIEditorTextFieldInteractionFrame {
|
||||
Widgets::UIEditorTextFieldLayout layout = {};
|
||||
UIEditorTextFieldInteractionResult result = {};
|
||||
};
|
||||
|
||||
UIEditorTextFieldInteractionFrame UpdateUIEditorTextFieldInteraction(
|
||||
UIEditorTextFieldInteractionState& state,
|
||||
Widgets::UIEditorTextFieldSpec& spec,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
|
||||
const Widgets::UIEditorTextFieldMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
171
new_editor/include/XCEditor/Fields/UIEditorVector2Field.h
Normal file
171
new_editor/include/XCEditor/Fields/UIEditorVector2Field.h
Normal file
@@ -0,0 +1,171 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
inline constexpr std::size_t UIEditorVector2FieldInvalidComponentIndex = static_cast<std::size_t>(-1);
|
||||
|
||||
enum class UIEditorVector2FieldHitTargetKind : std::uint8_t {
|
||||
None = 0,
|
||||
Row,
|
||||
Component
|
||||
};
|
||||
|
||||
struct UIEditorVector2FieldSpec {
|
||||
std::string fieldId = {};
|
||||
std::string label = {};
|
||||
std::array<double, 2u> values = { 0.0, 0.0 };
|
||||
std::array<std::string, 2u> componentLabels = { std::string("X"), std::string("Y") };
|
||||
double step = 0.1;
|
||||
double minValue = -1000000.0;
|
||||
double maxValue = 1000000.0;
|
||||
bool integerMode = false;
|
||||
bool readOnly = false;
|
||||
};
|
||||
|
||||
struct UIEditorVector2FieldState {
|
||||
UIEditorVector2FieldHitTargetKind hoveredTarget = UIEditorVector2FieldHitTargetKind::None;
|
||||
UIEditorVector2FieldHitTargetKind activeTarget = UIEditorVector2FieldHitTargetKind::None;
|
||||
std::size_t hoveredComponentIndex = UIEditorVector2FieldInvalidComponentIndex;
|
||||
std::size_t activeComponentIndex = UIEditorVector2FieldInvalidComponentIndex;
|
||||
std::size_t selectedComponentIndex = UIEditorVector2FieldInvalidComponentIndex;
|
||||
bool focused = false;
|
||||
bool editing = false;
|
||||
std::array<std::string, 2u> displayTexts = { std::string(), std::string() };
|
||||
};
|
||||
|
||||
struct UIEditorVector2FieldMetrics {
|
||||
float rowHeight = 22.0f;
|
||||
float horizontalPadding = 12.0f;
|
||||
float labelControlGap = 20.0f;
|
||||
float controlColumnStart = 236.0f;
|
||||
float controlTrailingInset = 8.0f;
|
||||
float controlInsetY = 1.0f;
|
||||
float componentGap = 6.0f;
|
||||
float componentMinWidth = 72.0f;
|
||||
float componentPrefixWidth = 9.0f;
|
||||
float componentLabelGap = 4.0f;
|
||||
float labelTextInsetY = 0.0f;
|
||||
float labelFontSize = 11.0f;
|
||||
float valueTextInsetX = 5.0f;
|
||||
float valueTextInsetY = 0.0f;
|
||||
float valueFontSize = 12.0f;
|
||||
float prefixTextInsetX = 0.0f;
|
||||
float prefixTextInsetY = -1.0f;
|
||||
float prefixFontSize = 11.0f;
|
||||
float cornerRounding = 0.0f;
|
||||
float componentRounding = 2.0f;
|
||||
float borderThickness = 1.0f;
|
||||
float focusedBorderThickness = 1.0f;
|
||||
};
|
||||
|
||||
struct UIEditorVector2FieldPalette {
|
||||
::XCEngine::UI::UIColor surfaceColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor borderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor focusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowHoverColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowActiveColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor componentColor =
|
||||
::XCEngine::UI::UIColor(0.18f, 0.18f, 0.18f, 1.0f);
|
||||
::XCEngine::UI::UIColor componentHoverColor =
|
||||
::XCEngine::UI::UIColor(0.21f, 0.21f, 0.21f, 1.0f);
|
||||
::XCEngine::UI::UIColor componentEditingColor =
|
||||
::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f);
|
||||
::XCEngine::UI::UIColor readOnlyColor =
|
||||
::XCEngine::UI::UIColor(0.17f, 0.17f, 0.17f, 1.0f);
|
||||
::XCEngine::UI::UIColor componentBorderColor =
|
||||
::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f);
|
||||
::XCEngine::UI::UIColor componentFocusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.20f, 0.20f, 0.20f, 1.0f);
|
||||
::XCEngine::UI::UIColor prefixColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor prefixBorderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor labelColor =
|
||||
::XCEngine::UI::UIColor(0.80f, 0.80f, 0.80f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueColor =
|
||||
::XCEngine::UI::UIColor(0.92f, 0.92f, 0.92f, 1.0f);
|
||||
::XCEngine::UI::UIColor readOnlyValueColor =
|
||||
::XCEngine::UI::UIColor(0.62f, 0.62f, 0.62f, 1.0f);
|
||||
::XCEngine::UI::UIColor axisXColor =
|
||||
::XCEngine::UI::UIColor(0.67f, 0.67f, 0.67f, 1.0f);
|
||||
::XCEngine::UI::UIColor axisYColor =
|
||||
::XCEngine::UI::UIColor(0.67f, 0.67f, 0.67f, 1.0f);
|
||||
};
|
||||
|
||||
struct UIEditorVector2FieldLayout {
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
::XCEngine::UI::UIRect labelRect = {};
|
||||
::XCEngine::UI::UIRect controlRect = {};
|
||||
std::array<::XCEngine::UI::UIRect, 2u> componentRects = {};
|
||||
std::array<::XCEngine::UI::UIRect, 2u> componentPrefixRects = {};
|
||||
std::array<::XCEngine::UI::UIRect, 2u> componentValueRects = {};
|
||||
};
|
||||
|
||||
struct UIEditorVector2FieldHitTarget {
|
||||
UIEditorVector2FieldHitTargetKind kind = UIEditorVector2FieldHitTargetKind::None;
|
||||
std::size_t componentIndex = UIEditorVector2FieldInvalidComponentIndex;
|
||||
};
|
||||
|
||||
bool IsUIEditorVector2FieldPointInside(
|
||||
const ::XCEngine::UI::UIRect& rect,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
double NormalizeUIEditorVector2FieldComponentValue(
|
||||
const UIEditorVector2FieldSpec& spec,
|
||||
double value);
|
||||
|
||||
bool TryParseUIEditorVector2FieldComponentValue(
|
||||
const UIEditorVector2FieldSpec& spec,
|
||||
std::string_view text,
|
||||
double& outValue);
|
||||
|
||||
std::string FormatUIEditorVector2FieldComponentValue(
|
||||
const UIEditorVector2FieldSpec& spec,
|
||||
std::size_t componentIndex);
|
||||
|
||||
UIEditorVector2FieldLayout BuildUIEditorVector2FieldLayout(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorVector2FieldSpec& spec,
|
||||
const UIEditorVector2FieldMetrics& metrics = {});
|
||||
|
||||
UIEditorVector2FieldHitTarget HitTestUIEditorVector2Field(
|
||||
const UIEditorVector2FieldLayout& layout,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
void AppendUIEditorVector2FieldBackground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorVector2FieldLayout& layout,
|
||||
const UIEditorVector2FieldSpec& spec,
|
||||
const UIEditorVector2FieldState& state,
|
||||
const UIEditorVector2FieldPalette& palette = {},
|
||||
const UIEditorVector2FieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorVector2FieldForeground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorVector2FieldLayout& layout,
|
||||
const UIEditorVector2FieldSpec& spec,
|
||||
const UIEditorVector2FieldState& state,
|
||||
const UIEditorVector2FieldPalette& palette = {},
|
||||
const UIEditorVector2FieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorVector2Field(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorVector2FieldSpec& spec,
|
||||
const UIEditorVector2FieldState& state,
|
||||
const UIEditorVector2FieldPalette& palette = {},
|
||||
const UIEditorVector2FieldMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Fields/UIEditorVector2Field.h>
|
||||
|
||||
#include <XCEngine/UI/Text/UITextInputController.h>
|
||||
#include <XCEngine/UI/Types.h>
|
||||
#include <XCEngine/UI/Widgets/UIPropertyEditModel.h>
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorVector2FieldInteractionState {
|
||||
Widgets::UIEditorVector2FieldState vector2FieldState = {};
|
||||
::XCEngine::UI::Text::UITextInputState textInputState = {};
|
||||
::XCEngine::UI::Widgets::UIPropertyEditModel editModel = {};
|
||||
::XCEngine::UI::UIPoint pointerPosition = {};
|
||||
bool hasPointerPosition = false;
|
||||
};
|
||||
|
||||
struct UIEditorVector2FieldInteractionResult {
|
||||
bool consumed = false;
|
||||
bool focusChanged = false;
|
||||
bool valueChanged = false;
|
||||
bool stepApplied = false;
|
||||
bool selectionChanged = false;
|
||||
bool editStarted = false;
|
||||
bool editCommitted = false;
|
||||
bool editCommitRejected = false;
|
||||
bool editCanceled = false;
|
||||
Widgets::UIEditorVector2FieldHitTarget hitTarget = {};
|
||||
std::size_t selectedComponentIndex = Widgets::UIEditorVector2FieldInvalidComponentIndex;
|
||||
std::size_t changedComponentIndex = Widgets::UIEditorVector2FieldInvalidComponentIndex;
|
||||
std::array<double, 2u> valuesBefore = { 0.0, 0.0 };
|
||||
std::array<double, 2u> valuesAfter = { 0.0, 0.0 };
|
||||
double stepDelta = 0.0;
|
||||
std::string committedText = {};
|
||||
};
|
||||
|
||||
struct UIEditorVector2FieldInteractionFrame {
|
||||
Widgets::UIEditorVector2FieldLayout layout = {};
|
||||
UIEditorVector2FieldInteractionResult result = {};
|
||||
};
|
||||
|
||||
UIEditorVector2FieldInteractionFrame UpdateUIEditorVector2FieldInteraction(
|
||||
UIEditorVector2FieldInteractionState& state,
|
||||
Widgets::UIEditorVector2FieldSpec& spec,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
|
||||
const Widgets::UIEditorVector2FieldMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
173
new_editor/include/XCEditor/Fields/UIEditorVector3Field.h
Normal file
173
new_editor/include/XCEditor/Fields/UIEditorVector3Field.h
Normal file
@@ -0,0 +1,173 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
inline constexpr std::size_t UIEditorVector3FieldInvalidComponentIndex = static_cast<std::size_t>(-1);
|
||||
|
||||
enum class UIEditorVector3FieldHitTargetKind : std::uint8_t {
|
||||
None = 0,
|
||||
Row,
|
||||
Component
|
||||
};
|
||||
|
||||
struct UIEditorVector3FieldSpec {
|
||||
std::string fieldId = {};
|
||||
std::string label = {};
|
||||
std::array<double, 3u> values = { 0.0, 0.0, 0.0 };
|
||||
std::array<std::string, 3u> componentLabels = { std::string("X"), std::string("Y"), std::string("Z") };
|
||||
double step = 0.1;
|
||||
double minValue = -1000000.0;
|
||||
double maxValue = 1000000.0;
|
||||
bool integerMode = false;
|
||||
bool readOnly = false;
|
||||
};
|
||||
|
||||
struct UIEditorVector3FieldState {
|
||||
UIEditorVector3FieldHitTargetKind hoveredTarget = UIEditorVector3FieldHitTargetKind::None;
|
||||
UIEditorVector3FieldHitTargetKind activeTarget = UIEditorVector3FieldHitTargetKind::None;
|
||||
std::size_t hoveredComponentIndex = UIEditorVector3FieldInvalidComponentIndex;
|
||||
std::size_t activeComponentIndex = UIEditorVector3FieldInvalidComponentIndex;
|
||||
std::size_t selectedComponentIndex = UIEditorVector3FieldInvalidComponentIndex;
|
||||
bool focused = false;
|
||||
bool editing = false;
|
||||
std::array<std::string, 3u> displayTexts = { std::string(), std::string(), std::string() };
|
||||
};
|
||||
|
||||
struct UIEditorVector3FieldMetrics {
|
||||
float rowHeight = 22.0f;
|
||||
float horizontalPadding = 12.0f;
|
||||
float labelControlGap = 20.0f;
|
||||
float controlColumnStart = 236.0f;
|
||||
float controlTrailingInset = 8.0f;
|
||||
float controlInsetY = 1.0f;
|
||||
float componentGap = 6.0f;
|
||||
float componentMinWidth = 72.0f;
|
||||
float componentPrefixWidth = 9.0f;
|
||||
float componentLabelGap = 4.0f;
|
||||
float labelTextInsetY = 0.0f;
|
||||
float labelFontSize = 11.0f;
|
||||
float valueTextInsetX = 5.0f;
|
||||
float valueTextInsetY = 0.0f;
|
||||
float valueFontSize = 12.0f;
|
||||
float prefixTextInsetX = 0.0f;
|
||||
float prefixTextInsetY = -1.0f;
|
||||
float prefixFontSize = 11.0f;
|
||||
float cornerRounding = 0.0f;
|
||||
float componentRounding = 2.0f;
|
||||
float borderThickness = 1.0f;
|
||||
float focusedBorderThickness = 1.0f;
|
||||
};
|
||||
|
||||
struct UIEditorVector3FieldPalette {
|
||||
::XCEngine::UI::UIColor surfaceColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor borderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor focusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowHoverColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowActiveColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor componentColor =
|
||||
::XCEngine::UI::UIColor(0.18f, 0.18f, 0.18f, 1.0f);
|
||||
::XCEngine::UI::UIColor componentHoverColor =
|
||||
::XCEngine::UI::UIColor(0.21f, 0.21f, 0.21f, 1.0f);
|
||||
::XCEngine::UI::UIColor componentEditingColor =
|
||||
::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f);
|
||||
::XCEngine::UI::UIColor readOnlyColor =
|
||||
::XCEngine::UI::UIColor(0.17f, 0.17f, 0.17f, 1.0f);
|
||||
::XCEngine::UI::UIColor componentBorderColor =
|
||||
::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f);
|
||||
::XCEngine::UI::UIColor componentFocusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.20f, 0.20f, 0.20f, 1.0f);
|
||||
::XCEngine::UI::UIColor prefixColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor prefixBorderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor labelColor =
|
||||
::XCEngine::UI::UIColor(0.80f, 0.80f, 0.80f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueColor =
|
||||
::XCEngine::UI::UIColor(0.92f, 0.92f, 0.92f, 1.0f);
|
||||
::XCEngine::UI::UIColor readOnlyValueColor =
|
||||
::XCEngine::UI::UIColor(0.62f, 0.62f, 0.62f, 1.0f);
|
||||
::XCEngine::UI::UIColor axisXColor =
|
||||
::XCEngine::UI::UIColor(0.67f, 0.67f, 0.67f, 1.0f);
|
||||
::XCEngine::UI::UIColor axisYColor =
|
||||
::XCEngine::UI::UIColor(0.67f, 0.67f, 0.67f, 1.0f);
|
||||
::XCEngine::UI::UIColor axisZColor =
|
||||
::XCEngine::UI::UIColor(0.67f, 0.67f, 0.67f, 1.0f);
|
||||
};
|
||||
|
||||
struct UIEditorVector3FieldLayout {
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
::XCEngine::UI::UIRect labelRect = {};
|
||||
::XCEngine::UI::UIRect controlRect = {};
|
||||
std::array<::XCEngine::UI::UIRect, 3u> componentRects = {};
|
||||
std::array<::XCEngine::UI::UIRect, 3u> componentPrefixRects = {};
|
||||
std::array<::XCEngine::UI::UIRect, 3u> componentValueRects = {};
|
||||
};
|
||||
|
||||
struct UIEditorVector3FieldHitTarget {
|
||||
UIEditorVector3FieldHitTargetKind kind = UIEditorVector3FieldHitTargetKind::None;
|
||||
std::size_t componentIndex = UIEditorVector3FieldInvalidComponentIndex;
|
||||
};
|
||||
|
||||
bool IsUIEditorVector3FieldPointInside(
|
||||
const ::XCEngine::UI::UIRect& rect,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
double NormalizeUIEditorVector3FieldComponentValue(
|
||||
const UIEditorVector3FieldSpec& spec,
|
||||
double value);
|
||||
|
||||
bool TryParseUIEditorVector3FieldComponentValue(
|
||||
const UIEditorVector3FieldSpec& spec,
|
||||
std::string_view text,
|
||||
double& outValue);
|
||||
|
||||
std::string FormatUIEditorVector3FieldComponentValue(
|
||||
const UIEditorVector3FieldSpec& spec,
|
||||
std::size_t componentIndex);
|
||||
|
||||
UIEditorVector3FieldLayout BuildUIEditorVector3FieldLayout(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorVector3FieldSpec& spec,
|
||||
const UIEditorVector3FieldMetrics& metrics = {});
|
||||
|
||||
UIEditorVector3FieldHitTarget HitTestUIEditorVector3Field(
|
||||
const UIEditorVector3FieldLayout& layout,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
void AppendUIEditorVector3FieldBackground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorVector3FieldLayout& layout,
|
||||
const UIEditorVector3FieldSpec& spec,
|
||||
const UIEditorVector3FieldState& state,
|
||||
const UIEditorVector3FieldPalette& palette = {},
|
||||
const UIEditorVector3FieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorVector3FieldForeground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorVector3FieldLayout& layout,
|
||||
const UIEditorVector3FieldSpec& spec,
|
||||
const UIEditorVector3FieldState& state,
|
||||
const UIEditorVector3FieldPalette& palette = {},
|
||||
const UIEditorVector3FieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorVector3Field(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorVector3FieldSpec& spec,
|
||||
const UIEditorVector3FieldState& state,
|
||||
const UIEditorVector3FieldPalette& palette = {},
|
||||
const UIEditorVector3FieldMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Fields/UIEditorVector3Field.h>
|
||||
|
||||
#include <XCEngine/UI/Text/UITextInputController.h>
|
||||
#include <XCEngine/UI/Types.h>
|
||||
#include <XCEngine/UI/Widgets/UIPropertyEditModel.h>
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorVector3FieldInteractionState {
|
||||
Widgets::UIEditorVector3FieldState vector3FieldState = {};
|
||||
::XCEngine::UI::Text::UITextInputState textInputState = {};
|
||||
::XCEngine::UI::Widgets::UIPropertyEditModel editModel = {};
|
||||
::XCEngine::UI::UIPoint pointerPosition = {};
|
||||
bool hasPointerPosition = false;
|
||||
};
|
||||
|
||||
struct UIEditorVector3FieldInteractionResult {
|
||||
bool consumed = false;
|
||||
bool focusChanged = false;
|
||||
bool valueChanged = false;
|
||||
bool stepApplied = false;
|
||||
bool selectionChanged = false;
|
||||
bool editStarted = false;
|
||||
bool editCommitted = false;
|
||||
bool editCommitRejected = false;
|
||||
bool editCanceled = false;
|
||||
Widgets::UIEditorVector3FieldHitTarget hitTarget = {};
|
||||
std::size_t selectedComponentIndex = Widgets::UIEditorVector3FieldInvalidComponentIndex;
|
||||
std::size_t changedComponentIndex = Widgets::UIEditorVector3FieldInvalidComponentIndex;
|
||||
std::array<double, 3u> valuesBefore = { 0.0, 0.0, 0.0 };
|
||||
std::array<double, 3u> valuesAfter = { 0.0, 0.0, 0.0 };
|
||||
double stepDelta = 0.0;
|
||||
std::string committedText = {};
|
||||
};
|
||||
|
||||
struct UIEditorVector3FieldInteractionFrame {
|
||||
Widgets::UIEditorVector3FieldLayout layout = {};
|
||||
UIEditorVector3FieldInteractionResult result = {};
|
||||
};
|
||||
|
||||
UIEditorVector3FieldInteractionFrame UpdateUIEditorVector3FieldInteraction(
|
||||
UIEditorVector3FieldInteractionState& state,
|
||||
Widgets::UIEditorVector3FieldSpec& spec,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
|
||||
const Widgets::UIEditorVector3FieldMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
186
new_editor/include/XCEditor/Fields/UIEditorVector4Field.h
Normal file
186
new_editor/include/XCEditor/Fields/UIEditorVector4Field.h
Normal file
@@ -0,0 +1,186 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
inline constexpr std::size_t UIEditorVector4FieldInvalidComponentIndex = static_cast<std::size_t>(-1);
|
||||
|
||||
enum class UIEditorVector4FieldHitTargetKind : std::uint8_t {
|
||||
None = 0,
|
||||
Row,
|
||||
Component
|
||||
};
|
||||
|
||||
struct UIEditorVector4FieldSpec {
|
||||
std::string fieldId = {};
|
||||
std::string label = {};
|
||||
std::array<double, 4u> values = { 0.0, 0.0, 0.0, 0.0 };
|
||||
std::array<std::string, 4u> componentLabels = {
|
||||
std::string("X"),
|
||||
std::string("Y"),
|
||||
std::string("Z"),
|
||||
std::string("W")
|
||||
};
|
||||
double step = 0.1;
|
||||
double minValue = -1000000.0;
|
||||
double maxValue = 1000000.0;
|
||||
bool integerMode = false;
|
||||
bool readOnly = false;
|
||||
};
|
||||
|
||||
struct UIEditorVector4FieldState {
|
||||
UIEditorVector4FieldHitTargetKind hoveredTarget = UIEditorVector4FieldHitTargetKind::None;
|
||||
UIEditorVector4FieldHitTargetKind activeTarget = UIEditorVector4FieldHitTargetKind::None;
|
||||
std::size_t hoveredComponentIndex = UIEditorVector4FieldInvalidComponentIndex;
|
||||
std::size_t activeComponentIndex = UIEditorVector4FieldInvalidComponentIndex;
|
||||
std::size_t selectedComponentIndex = UIEditorVector4FieldInvalidComponentIndex;
|
||||
bool focused = false;
|
||||
bool editing = false;
|
||||
std::array<std::string, 4u> displayTexts = {
|
||||
std::string(),
|
||||
std::string(),
|
||||
std::string(),
|
||||
std::string()
|
||||
};
|
||||
};
|
||||
|
||||
struct UIEditorVector4FieldMetrics {
|
||||
float rowHeight = 22.0f;
|
||||
float horizontalPadding = 12.0f;
|
||||
float labelControlGap = 20.0f;
|
||||
float controlColumnStart = 236.0f;
|
||||
float controlTrailingInset = 8.0f;
|
||||
float controlInsetY = 1.0f;
|
||||
float componentGap = 6.0f;
|
||||
float componentMinWidth = 72.0f;
|
||||
float componentPrefixWidth = 9.0f;
|
||||
float componentLabelGap = 4.0f;
|
||||
float labelTextInsetY = 0.0f;
|
||||
float labelFontSize = 11.0f;
|
||||
float valueTextInsetX = 5.0f;
|
||||
float valueTextInsetY = 0.0f;
|
||||
float valueFontSize = 12.0f;
|
||||
float prefixTextInsetX = 0.0f;
|
||||
float prefixTextInsetY = -1.0f;
|
||||
float prefixFontSize = 11.0f;
|
||||
float cornerRounding = 0.0f;
|
||||
float componentRounding = 2.0f;
|
||||
float borderThickness = 1.0f;
|
||||
float focusedBorderThickness = 1.0f;
|
||||
};
|
||||
|
||||
struct UIEditorVector4FieldPalette {
|
||||
::XCEngine::UI::UIColor surfaceColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor borderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor focusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowHoverColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor rowActiveColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor componentColor =
|
||||
::XCEngine::UI::UIColor(0.18f, 0.18f, 0.18f, 1.0f);
|
||||
::XCEngine::UI::UIColor componentHoverColor =
|
||||
::XCEngine::UI::UIColor(0.21f, 0.21f, 0.21f, 1.0f);
|
||||
::XCEngine::UI::UIColor componentEditingColor =
|
||||
::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f);
|
||||
::XCEngine::UI::UIColor readOnlyColor =
|
||||
::XCEngine::UI::UIColor(0.17f, 0.17f, 0.17f, 1.0f);
|
||||
::XCEngine::UI::UIColor componentBorderColor =
|
||||
::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f);
|
||||
::XCEngine::UI::UIColor componentFocusedBorderColor =
|
||||
::XCEngine::UI::UIColor(0.20f, 0.20f, 0.20f, 1.0f);
|
||||
::XCEngine::UI::UIColor prefixColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor prefixBorderColor =
|
||||
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
::XCEngine::UI::UIColor labelColor =
|
||||
::XCEngine::UI::UIColor(0.80f, 0.80f, 0.80f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueColor =
|
||||
::XCEngine::UI::UIColor(0.92f, 0.92f, 0.92f, 1.0f);
|
||||
::XCEngine::UI::UIColor readOnlyValueColor =
|
||||
::XCEngine::UI::UIColor(0.62f, 0.62f, 0.62f, 1.0f);
|
||||
::XCEngine::UI::UIColor axisXColor =
|
||||
::XCEngine::UI::UIColor(0.67f, 0.67f, 0.67f, 1.0f);
|
||||
::XCEngine::UI::UIColor axisYColor =
|
||||
::XCEngine::UI::UIColor(0.67f, 0.67f, 0.67f, 1.0f);
|
||||
::XCEngine::UI::UIColor axisZColor =
|
||||
::XCEngine::UI::UIColor(0.67f, 0.67f, 0.67f, 1.0f);
|
||||
::XCEngine::UI::UIColor axisWColor =
|
||||
::XCEngine::UI::UIColor(0.67f, 0.67f, 0.67f, 1.0f);
|
||||
};
|
||||
|
||||
struct UIEditorVector4FieldLayout {
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
::XCEngine::UI::UIRect labelRect = {};
|
||||
::XCEngine::UI::UIRect controlRect = {};
|
||||
std::array<::XCEngine::UI::UIRect, 4u> componentRects = {};
|
||||
std::array<::XCEngine::UI::UIRect, 4u> componentPrefixRects = {};
|
||||
std::array<::XCEngine::UI::UIRect, 4u> componentValueRects = {};
|
||||
};
|
||||
|
||||
struct UIEditorVector4FieldHitTarget {
|
||||
UIEditorVector4FieldHitTargetKind kind = UIEditorVector4FieldHitTargetKind::None;
|
||||
std::size_t componentIndex = UIEditorVector4FieldInvalidComponentIndex;
|
||||
};
|
||||
|
||||
bool IsUIEditorVector4FieldPointInside(
|
||||
const ::XCEngine::UI::UIRect& rect,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
double NormalizeUIEditorVector4FieldComponentValue(
|
||||
const UIEditorVector4FieldSpec& spec,
|
||||
double value);
|
||||
|
||||
bool TryParseUIEditorVector4FieldComponentValue(
|
||||
const UIEditorVector4FieldSpec& spec,
|
||||
std::string_view text,
|
||||
double& outValue);
|
||||
|
||||
std::string FormatUIEditorVector4FieldComponentValue(
|
||||
const UIEditorVector4FieldSpec& spec,
|
||||
std::size_t componentIndex);
|
||||
|
||||
UIEditorVector4FieldLayout BuildUIEditorVector4FieldLayout(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorVector4FieldSpec& spec,
|
||||
const UIEditorVector4FieldMetrics& metrics = {});
|
||||
|
||||
UIEditorVector4FieldHitTarget HitTestUIEditorVector4Field(
|
||||
const UIEditorVector4FieldLayout& layout,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
void AppendUIEditorVector4FieldBackground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorVector4FieldLayout& layout,
|
||||
const UIEditorVector4FieldSpec& spec,
|
||||
const UIEditorVector4FieldState& state,
|
||||
const UIEditorVector4FieldPalette& palette = {},
|
||||
const UIEditorVector4FieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorVector4FieldForeground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorVector4FieldLayout& layout,
|
||||
const UIEditorVector4FieldSpec& spec,
|
||||
const UIEditorVector4FieldState& state,
|
||||
const UIEditorVector4FieldPalette& palette = {},
|
||||
const UIEditorVector4FieldMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorVector4Field(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const UIEditorVector4FieldSpec& spec,
|
||||
const UIEditorVector4FieldState& state,
|
||||
const UIEditorVector4FieldPalette& palette = {},
|
||||
const UIEditorVector4FieldMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEditor/Fields/UIEditorVector4Field.h>
|
||||
|
||||
#include <XCEngine/UI/Text/UITextInputController.h>
|
||||
#include <XCEngine/UI/Types.h>
|
||||
#include <XCEngine/UI/Widgets/UIPropertyEditModel.h>
|
||||
|
||||
#include <array>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor {
|
||||
|
||||
struct UIEditorVector4FieldInteractionState {
|
||||
Widgets::UIEditorVector4FieldState vector4FieldState = {};
|
||||
::XCEngine::UI::Text::UITextInputState textInputState = {};
|
||||
::XCEngine::UI::Widgets::UIPropertyEditModel editModel = {};
|
||||
::XCEngine::UI::UIPoint pointerPosition = {};
|
||||
bool hasPointerPosition = false;
|
||||
};
|
||||
|
||||
struct UIEditorVector4FieldInteractionResult {
|
||||
bool consumed = false;
|
||||
bool focusChanged = false;
|
||||
bool valueChanged = false;
|
||||
bool stepApplied = false;
|
||||
bool selectionChanged = false;
|
||||
bool editStarted = false;
|
||||
bool editCommitted = false;
|
||||
bool editCommitRejected = false;
|
||||
bool editCanceled = false;
|
||||
Widgets::UIEditorVector4FieldHitTarget hitTarget = {};
|
||||
std::size_t selectedComponentIndex = Widgets::UIEditorVector4FieldInvalidComponentIndex;
|
||||
std::size_t changedComponentIndex = Widgets::UIEditorVector4FieldInvalidComponentIndex;
|
||||
std::array<double, 4u> valuesBefore = { 0.0, 0.0, 0.0, 0.0 };
|
||||
std::array<double, 4u> valuesAfter = { 0.0, 0.0, 0.0, 0.0 };
|
||||
double stepDelta = 0.0;
|
||||
std::string committedText = {};
|
||||
};
|
||||
|
||||
struct UIEditorVector4FieldInteractionFrame {
|
||||
Widgets::UIEditorVector4FieldLayout layout = {};
|
||||
UIEditorVector4FieldInteractionResult result = {};
|
||||
};
|
||||
|
||||
UIEditorVector4FieldInteractionFrame UpdateUIEditorVector4FieldInteraction(
|
||||
UIEditorVector4FieldInteractionState& state,
|
||||
Widgets::UIEditorVector4FieldSpec& spec,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const std::vector<::XCEngine::UI::UIInputEvent>& inputEvents,
|
||||
const Widgets::UIEditorVector4FieldMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor
|
||||
Reference in New Issue
Block a user