#pragma once #include #include #include #include #include #include #include #include namespace XCEngine::UI::Editor::Widgets { inline constexpr std::size_t UIEditorTreeViewInvalidIndex = static_cast(-1); enum class UIEditorTreeViewHitTargetKind : std::uint8_t { None = 0, Row, Disclosure }; struct UIEditorTreeViewItem { std::string itemId = {}; std::string label = {}; std::uint32_t depth = 0u; bool forceLeaf = false; float desiredHeight = 0.0f; }; struct UIEditorTreeViewState { std::string hoveredItemId = {}; bool focused = false; }; struct UIEditorTreeViewMetrics { float rowHeight = 28.0f; float rowGap = 2.0f; float horizontalPadding = 8.0f; float indentWidth = 18.0f; float disclosureExtent = 12.0f; float disclosureLabelGap = 6.0f; float labelInsetY = 6.0f; float cornerRounding = 6.0f; float borderThickness = 1.0f; float focusedBorderThickness = 2.0f; }; struct UIEditorTreeViewPalette { ::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 rowHoverColor = ::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f); ::XCEngine::UI::UIColor rowSelectedColor = ::XCEngine::UI::UIColor(0.32f, 0.32f, 0.32f, 1.0f); ::XCEngine::UI::UIColor rowSelectedFocusedColor = ::XCEngine::UI::UIColor(0.40f, 0.40f, 0.40f, 1.0f); ::XCEngine::UI::UIColor disclosureColor = ::XCEngine::UI::UIColor(0.74f, 0.74f, 0.74f, 1.0f); ::XCEngine::UI::UIColor textColor = ::XCEngine::UI::UIColor(0.94f, 0.94f, 0.94f, 1.0f); }; struct UIEditorTreeViewLayout { ::XCEngine::UI::UIRect bounds = {}; std::vector visibleItemIndices = {}; std::vector<::XCEngine::UI::UIRect> rowRects = {}; std::vector<::XCEngine::UI::UIRect> disclosureRects = {}; std::vector<::XCEngine::UI::UIRect> labelRects = {}; std::vector itemHasChildren = {}; std::vector itemExpanded = {}; }; struct UIEditorTreeViewHitTarget { UIEditorTreeViewHitTargetKind kind = UIEditorTreeViewHitTargetKind::None; std::size_t visibleIndex = UIEditorTreeViewInvalidIndex; std::size_t itemIndex = UIEditorTreeViewInvalidIndex; }; bool IsUIEditorTreeViewPointInside( const ::XCEngine::UI::UIRect& rect, const ::XCEngine::UI::UIPoint& point); bool DoesUIEditorTreeViewItemHaveChildren( const std::vector& items, std::size_t itemIndex); std::size_t FindUIEditorTreeViewItemIndex( const std::vector& items, std::string_view itemId); std::size_t FindUIEditorTreeViewParentItemIndex( const std::vector& items, std::size_t itemIndex); std::vector CollectUIEditorTreeViewVisibleItemIndices( const std::vector& items, const ::XCEngine::UI::Widgets::UIExpansionModel& expansionModel); std::size_t FindUIEditorTreeViewFirstVisibleChildItemIndex( const std::vector& items, const ::XCEngine::UI::Widgets::UIExpansionModel& expansionModel, std::size_t itemIndex); UIEditorTreeViewLayout BuildUIEditorTreeViewLayout( const ::XCEngine::UI::UIRect& bounds, const std::vector& items, const ::XCEngine::UI::Widgets::UIExpansionModel& expansionModel, const UIEditorTreeViewMetrics& metrics = {}); UIEditorTreeViewHitTarget HitTestUIEditorTreeView( const UIEditorTreeViewLayout& layout, const ::XCEngine::UI::UIPoint& point); void AppendUIEditorTreeViewBackground( ::XCEngine::UI::UIDrawList& drawList, const UIEditorTreeViewLayout& layout, const std::vector& items, const ::XCEngine::UI::Widgets::UISelectionModel& selectionModel, const UIEditorTreeViewState& state, const UIEditorTreeViewPalette& palette = {}, const UIEditorTreeViewMetrics& metrics = {}); void AppendUIEditorTreeViewForeground( ::XCEngine::UI::UIDrawList& drawList, const UIEditorTreeViewLayout& layout, const std::vector& items, const UIEditorTreeViewPalette& palette = {}, const UIEditorTreeViewMetrics& metrics = {}); void AppendUIEditorTreeView( ::XCEngine::UI::UIDrawList& drawList, const ::XCEngine::UI::UIRect& bounds, const std::vector& items, const ::XCEngine::UI::Widgets::UISelectionModel& selectionModel, const ::XCEngine::UI::Widgets::UIExpansionModel& expansionModel, const UIEditorTreeViewState& state, const UIEditorTreeViewPalette& palette = {}, const UIEditorTreeViewMetrics& metrics = {}); } // namespace XCEngine::UI::Editor::Widgets