#pragma once #include #include #include #include #include #include #include #include #include namespace XCEngine::UI::Editor::Widgets { inline constexpr std::size_t UIEditorPropertyGridInvalidIndex = static_cast(-1); 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 UIEditorPropertyGridField { std::string fieldId = {}; std::string label = {}; std::string valueText = {}; bool readOnly = false; float desiredHeight = 0.0f; }; struct UIEditorPropertyGridSection { std::string sectionId = {}; std::string title = {}; std::vector fields = {}; float desiredHeaderHeight = 0.0f; }; struct UIEditorPropertyGridState { std::string hoveredSectionId = {}; std::string hoveredFieldId = {}; bool focused = false; }; 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 labelTextInsetY = 8.0f; float valueTextInsetY = 8.0f; float valueBoxInsetY = 4.0f; float valueBoxInsetX = 8.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 sectionIndices = {}; std::vector<::XCEngine::UI::UIRect> sectionHeaderRects = {}; std::vector<::XCEngine::UI::UIRect> sectionDisclosureRects = {}; std::vector<::XCEngine::UI::UIRect> sectionTitleRects = {}; std::vector sectionExpanded = {}; std::vector visibleFieldSectionIndices = {}; std::vector visibleFieldIndices = {}; std::vector<::XCEngine::UI::UIRect> fieldRowRects = {}; std::vector<::XCEngine::UI::UIRect> fieldLabelRects = {}; std::vector<::XCEngine::UI::UIRect> fieldValueRects = {}; std::vector 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& sections, std::string_view sectionId); UIEditorPropertyGridFieldLocation FindUIEditorPropertyGridFieldLocation( const std::vector& sections, std::string_view fieldId); std::size_t FindUIEditorPropertyGridVisibleFieldIndex( const UIEditorPropertyGridLayout& layout, std::string_view fieldId, const std::vector& sections); UIEditorPropertyGridLayout BuildUIEditorPropertyGridLayout( const ::XCEngine::UI::UIRect& bounds, const std::vector& 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& 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& sections, const ::XCEngine::UI::Widgets::UIPropertyEditModel& propertyEditModel, const UIEditorPropertyGridPalette& palette = {}, const UIEditorPropertyGridMetrics& metrics = {}); void AppendUIEditorPropertyGrid( ::XCEngine::UI::UIDrawList& drawList, const ::XCEngine::UI::UIRect& bounds, const std::vector& 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 = {}); } // namespace XCEngine::UI::Editor::Widgets