#pragma once #include #include #include #include #include #include #include #include namespace XCEngine::UI::Editor::Widgets { inline constexpr std::size_t UIEditorTabStripInvalidIndex = ::XCEngine::UI::Widgets::UITabStripModel::InvalidIndex; struct UIEditorTabStripItem { std::string tabId = {}; std::string title = {}; float desiredHeaderLabelWidth = 0.0f; }; struct UIEditorTabStripState { std::size_t selectedIndex = UIEditorTabStripInvalidIndex; std::size_t hoveredIndex = UIEditorTabStripInvalidIndex; bool focused = false; }; struct UIEditorTabStripMetrics { ::XCEngine::UI::Layout::UITabStripMetrics layoutMetrics = ::XCEngine::UI::Layout::UITabStripMetrics{ 22.0f, 68.0f, 8.0f, 1.0f }; float estimatedGlyphWidth = 6.0f; float labelInsetX = 8.0f; float labelInsetY = -0.5f; float baseBorderThickness = 1.0f; float selectedBorderThickness = 1.0f; float dragThreshold = 6.0f; }; struct UIEditorTabStripPalette { ::XCEngine::UI::UIColor stripBackgroundColor = ::XCEngine::UI::UIColor(0.10f, 0.10f, 0.10f, 1.0f); ::XCEngine::UI::UIColor headerBackgroundColor = ::XCEngine::UI::UIColor(0.11f, 0.11f, 0.11f, 1.0f); ::XCEngine::UI::UIColor contentBackgroundColor = ::XCEngine::UI::UIColor(0.10f, 0.10f, 0.10f, 1.0f); ::XCEngine::UI::UIColor headerContentSeparatorColor = ::XCEngine::UI::UIColor(0.15f, 0.15f, 0.15f, 1.0f); ::XCEngine::UI::UIColor tabColor = ::XCEngine::UI::UIColor(0.11f, 0.11f, 0.11f, 1.0f); ::XCEngine::UI::UIColor tabHoveredColor = ::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f); ::XCEngine::UI::UIColor tabSelectedColor = ::XCEngine::UI::UIColor(0.11f, 0.11f, 0.11f, 1.0f); ::XCEngine::UI::UIColor tabBorderColor = ::XCEngine::UI::UIColor(0.15f, 0.15f, 0.15f, 1.0f); ::XCEngine::UI::UIColor tabHoveredBorderColor = ::XCEngine::UI::UIColor(0.19f, 0.19f, 0.19f, 1.0f); ::XCEngine::UI::UIColor tabSelectedBorderColor = ::XCEngine::UI::UIColor(0.15f, 0.15f, 0.15f, 1.0f); ::XCEngine::UI::UIColor textPrimary = ::XCEngine::UI::UIColor(0.92f, 0.92f, 0.92f, 1.0f); ::XCEngine::UI::UIColor textSecondary = ::XCEngine::UI::UIColor(0.72f, 0.72f, 0.72f, 1.0f); }; struct UIEditorTabStripLayout { ::XCEngine::UI::UIRect bounds = {}; ::XCEngine::UI::UIRect headerRect = {}; ::XCEngine::UI::UIRect contentRect = {}; std::vector<::XCEngine::UI::UIRect> tabHeaderRects = {}; std::size_t selectedIndex = UIEditorTabStripInvalidIndex; }; enum class UIEditorTabStripHitTargetKind : std::uint8_t { None = 0, HeaderBackground, Tab, Content }; struct UIEditorTabStripHitTarget { UIEditorTabStripHitTargetKind kind = UIEditorTabStripHitTargetKind::None; std::size_t index = UIEditorTabStripInvalidIndex; }; float ResolveUIEditorTabStripDesiredHeaderLabelWidth( const UIEditorTabStripItem& item, const UIEditorTabStripMetrics& metrics = {}); std::size_t ResolveUIEditorTabStripSelectedIndex( const std::vector& items, std::string_view selectedTabId, std::size_t fallbackIndex = UIEditorTabStripInvalidIndex); UIEditorTabStripLayout BuildUIEditorTabStripLayout( const ::XCEngine::UI::UIRect& bounds, const std::vector& items, const UIEditorTabStripState& state, const UIEditorTabStripMetrics& metrics = {}); UIEditorTabStripHitTarget HitTestUIEditorTabStrip( const UIEditorTabStripLayout& layout, const UIEditorTabStripState& state, const ::XCEngine::UI::UIPoint& point); void AppendUIEditorTabStripBackground( ::XCEngine::UI::UIDrawList& drawList, const UIEditorTabStripLayout& layout, const UIEditorTabStripState& state, const UIEditorTabStripPalette& palette = {}, const UIEditorTabStripMetrics& metrics = {}); void AppendUIEditorTabStripForeground( ::XCEngine::UI::UIDrawList& drawList, const UIEditorTabStripLayout& layout, const std::vector& items, const UIEditorTabStripState& state, const UIEditorTabStripPalette& palette = {}, const UIEditorTabStripMetrics& metrics = {}); void AppendUIEditorTabStrip( ::XCEngine::UI::UIDrawList& drawList, const ::XCEngine::UI::UIRect& bounds, const std::vector& items, const UIEditorTabStripState& state, const UIEditorTabStripPalette& palette = {}, const UIEditorTabStripMetrics& metrics = {}); } // namespace XCEngine::UI::Editor::Widgets