#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 = {}; bool closable = true; float desiredHeaderLabelWidth = 0.0f; }; struct UIEditorTabStripState { std::size_t selectedIndex = UIEditorTabStripInvalidIndex; std::size_t hoveredIndex = UIEditorTabStripInvalidIndex; std::size_t closeHoveredIndex = UIEditorTabStripInvalidIndex; bool focused = false; }; struct UIEditorTabStripMetrics { ::XCEngine::UI::Layout::UITabStripMetrics layoutMetrics = ::XCEngine::UI::Layout::UITabStripMetrics{ 32.0f, 88.0f, 12.0f, 1.0f }; float estimatedGlyphWidth = 7.0f; float closeButtonExtent = 14.0f; float closeButtonGap = 8.0f; float closeInsetRight = 12.0f; float closeInsetY = 0.0f; float labelInsetX = 12.0f; float labelInsetY = -1.0f; float baseBorderThickness = 1.0f; float selectedBorderThickness = 1.5f; float focusedBorderThickness = 2.0f; }; struct UIEditorTabStripPalette { ::XCEngine::UI::UIColor stripBackgroundColor = ::XCEngine::UI::UIColor(0.15f, 0.15f, 0.16f, 1.0f); ::XCEngine::UI::UIColor headerBackgroundColor = ::XCEngine::UI::UIColor(0.18f, 0.18f, 0.19f, 1.0f); ::XCEngine::UI::UIColor contentBackgroundColor = ::XCEngine::UI::UIColor(0.15f, 0.15f, 0.16f, 1.0f); ::XCEngine::UI::UIColor stripBorderColor = ::XCEngine::UI::UIColor(0.30f, 0.32f, 0.34f, 1.0f); ::XCEngine::UI::UIColor focusedBorderColor = ::XCEngine::UI::UIColor(0.78f, 0.80f, 0.84f, 1.0f); ::XCEngine::UI::UIColor tabColor = ::XCEngine::UI::UIColor(0.21f, 0.22f, 0.24f, 1.0f); ::XCEngine::UI::UIColor tabHoveredColor = ::XCEngine::UI::UIColor(0.27f, 0.28f, 0.30f, 1.0f); ::XCEngine::UI::UIColor tabSelectedColor = ::XCEngine::UI::UIColor(0.33f, 0.35f, 0.38f, 1.0f); ::XCEngine::UI::UIColor tabBorderColor = ::XCEngine::UI::UIColor(0.32f, 0.34f, 0.36f, 1.0f); ::XCEngine::UI::UIColor tabHoveredBorderColor = ::XCEngine::UI::UIColor(0.42f, 0.44f, 0.47f, 1.0f); ::XCEngine::UI::UIColor tabSelectedBorderColor = ::XCEngine::UI::UIColor(0.50f, 0.52f, 0.56f, 1.0f); ::XCEngine::UI::UIColor textPrimary = ::XCEngine::UI::UIColor(0.93f, 0.94f, 0.96f, 1.0f); ::XCEngine::UI::UIColor textSecondary = ::XCEngine::UI::UIColor(0.70f, 0.72f, 0.74f, 1.0f); ::XCEngine::UI::UIColor textMuted = ::XCEngine::UI::UIColor(0.58f, 0.59f, 0.62f, 1.0f); ::XCEngine::UI::UIColor closeButtonColor = ::XCEngine::UI::UIColor(0.21f, 0.22f, 0.24f, 1.0f); ::XCEngine::UI::UIColor closeButtonHoveredColor = ::XCEngine::UI::UIColor(0.27f, 0.28f, 0.30f, 1.0f); ::XCEngine::UI::UIColor closeButtonBorderColor = ::XCEngine::UI::UIColor(0.42f, 0.44f, 0.47f, 1.0f); ::XCEngine::UI::UIColor closeGlyphColor = ::XCEngine::UI::UIColor(0.93f, 0.94f, 0.96f, 1.0f); }; struct UIEditorTabStripLayout { ::XCEngine::UI::UIRect bounds = {}; ::XCEngine::UI::UIRect headerRect = {}; ::XCEngine::UI::UIRect contentRect = {}; std::vector<::XCEngine::UI::UIRect> tabHeaderRects = {}; std::vector<::XCEngine::UI::UIRect> closeButtonRects = {}; std::vector showCloseButtons = {}; std::size_t selectedIndex = UIEditorTabStripInvalidIndex; }; enum class UIEditorTabStripHitTargetKind : std::uint8_t { None = 0, HeaderBackground, Tab, CloseButton, 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); std::size_t ResolveUIEditorTabStripSelectedIndexAfterClose( std::size_t selectedIndex, std::size_t closedIndex, std::size_t itemCountBeforeClose); 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