#pragma once #include #include #include #include #include #include #include namespace XCEngine::UI::Editor::Widgets { inline constexpr std::size_t UIEditorMenuPopupInvalidIndex = static_cast(-1); struct UIEditorMenuPopupItem { std::string itemId = {}; ::XCEngine::UI::Editor::UIEditorMenuItemKind kind = ::XCEngine::UI::Editor::UIEditorMenuItemKind::Command; std::string label = {}; std::string shortcutText = {}; bool enabled = true; bool checked = false; bool hasSubmenu = false; float desiredLabelWidth = 0.0f; float desiredShortcutWidth = 0.0f; }; struct UIEditorMenuPopupState { std::size_t hoveredIndex = UIEditorMenuPopupInvalidIndex; std::size_t submenuOpenIndex = UIEditorMenuPopupInvalidIndex; bool focused = false; }; struct UIEditorMenuPopupMetrics { float contentPaddingX = 2.0f; float contentPaddingY = 3.0f; float itemHeight = 24.0f; float separatorHeight = 7.0f; float checkColumnWidth = 12.0f; float shortcutGap = 14.0f; float submenuIndicatorWidth = 12.0f; float rowCornerRounding = 2.5f; float popupCornerRounding = 4.0f; float labelInsetX = 4.0f; float labelInsetY = -1.0f; float labelFontSize = 13.0f; float shortcutInsetRight = 8.0f; float estimatedGlyphWidth = 7.0f; float glyphFontSize = 12.0f; float separatorThickness = 1.0f; float borderThickness = 1.0f; }; struct UIEditorMenuPopupPalette { ::XCEngine::UI::UIColor popupColor = ::XCEngine::UI::UIColor(0.97f, 0.97f, 0.97f, 1.0f); ::XCEngine::UI::UIColor borderColor = ::XCEngine::UI::UIColor(0.62f, 0.62f, 0.62f, 1.0f); ::XCEngine::UI::UIColor itemHoverColor = ::XCEngine::UI::UIColor(0.86f, 0.86f, 0.86f, 1.0f); ::XCEngine::UI::UIColor itemOpenColor = ::XCEngine::UI::UIColor(0.82f, 0.82f, 0.82f, 1.0f); ::XCEngine::UI::UIColor separatorColor = ::XCEngine::UI::UIColor(0.78f, 0.78f, 0.78f, 1.0f); ::XCEngine::UI::UIColor textPrimary = ::XCEngine::UI::UIColor(0.10f, 0.10f, 0.10f, 1.0f); ::XCEngine::UI::UIColor textMuted = ::XCEngine::UI::UIColor(0.34f, 0.34f, 0.34f, 1.0f); ::XCEngine::UI::UIColor textDisabled = ::XCEngine::UI::UIColor(0.58f, 0.58f, 0.58f, 1.0f); ::XCEngine::UI::UIColor glyphColor = ::XCEngine::UI::UIColor(0.12f, 0.12f, 0.12f, 1.0f); }; struct UIEditorMenuPopupLayout { ::XCEngine::UI::UIRect popupRect = {}; ::XCEngine::UI::UIRect contentRect = {}; std::vector<::XCEngine::UI::UIRect> itemRects = {}; }; enum class UIEditorMenuPopupHitTargetKind : std::uint8_t { None = 0, PopupSurface, Item }; struct UIEditorMenuPopupHitTarget { UIEditorMenuPopupHitTargetKind kind = UIEditorMenuPopupHitTargetKind::None; std::size_t index = UIEditorMenuPopupInvalidIndex; }; float ResolveUIEditorMenuPopupDesiredWidth( const std::vector& items, const UIEditorMenuPopupMetrics& metrics = {}); float MeasureUIEditorMenuPopupHeight( const std::vector& items, const UIEditorMenuPopupMetrics& metrics = {}); UIEditorMenuPopupLayout BuildUIEditorMenuPopupLayout( const ::XCEngine::UI::UIRect& popupRect, const std::vector& items, const UIEditorMenuPopupMetrics& metrics = {}); UIEditorMenuPopupHitTarget HitTestUIEditorMenuPopup( const UIEditorMenuPopupLayout& layout, const std::vector& items, const ::XCEngine::UI::UIPoint& point); void AppendUIEditorMenuPopupBackground( ::XCEngine::UI::UIDrawList& drawList, const UIEditorMenuPopupLayout& layout, const std::vector& items, const UIEditorMenuPopupState& state, const UIEditorMenuPopupPalette& palette = {}, const UIEditorMenuPopupMetrics& metrics = {}); void AppendUIEditorMenuPopupForeground( ::XCEngine::UI::UIDrawList& drawList, const UIEditorMenuPopupLayout& layout, const std::vector& items, const UIEditorMenuPopupState& state, const UIEditorMenuPopupPalette& palette = {}, const UIEditorMenuPopupMetrics& metrics = {}); void AppendUIEditorMenuPopup( ::XCEngine::UI::UIDrawList& drawList, const ::XCEngine::UI::UIRect& popupRect, const std::vector& items, const UIEditorMenuPopupState& state, const UIEditorMenuPopupPalette& palette = {}, const UIEditorMenuPopupMetrics& metrics = {}); } // namespace XCEngine::UI::Editor::Widgets