#pragma once #include #include #include #include #include namespace XCEngine::UI::Editor::Widgets { inline constexpr std::size_t UIEditorMenuBarInvalidIndex = static_cast(-1); struct UIEditorMenuBarItem { std::string menuId = {}; std::string label = {}; bool enabled = true; float desiredLabelWidth = 0.0f; }; struct UIEditorMenuBarState { std::size_t openIndex = UIEditorMenuBarInvalidIndex; std::size_t hoveredIndex = UIEditorMenuBarInvalidIndex; bool focused = false; }; struct UIEditorMenuBarMetrics { float barHeight = 24.0f; float horizontalInset = 0.0f; float verticalInset = 2.0f; float buttonGap = 1.0f; float buttonPaddingX = 4.0f; float labelFontSize = 13.0f; float estimatedGlyphWidth = 6.5f; float labelInsetY = -1.5f; float barCornerRounding = 0.0f; float buttonCornerRounding = 0.75f; float baseBorderThickness = 1.0f; float focusedBorderThickness = 1.0f; float openBorderThickness = 1.0f; }; struct UIEditorMenuBarPalette { ::XCEngine::UI::UIColor barColor = ::XCEngine::UI::UIColor(1.0f, 1.0f, 1.0f, 1.0f); ::XCEngine::UI::UIColor buttonColor = ::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f); ::XCEngine::UI::UIColor buttonHoveredColor = ::XCEngine::UI::UIColor(0.88f, 0.88f, 0.88f, 1.0f); ::XCEngine::UI::UIColor buttonOpenColor = ::XCEngine::UI::UIColor(0.84f, 0.84f, 0.84f, 1.0f); ::XCEngine::UI::UIColor borderColor = ::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f); ::XCEngine::UI::UIColor focusedBorderColor = ::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f); ::XCEngine::UI::UIColor openBorderColor = ::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f); ::XCEngine::UI::UIColor textPrimary = ::XCEngine::UI::UIColor(0.08f, 0.08f, 0.08f, 1.0f); ::XCEngine::UI::UIColor textMuted = ::XCEngine::UI::UIColor(0.28f, 0.28f, 0.28f, 1.0f); ::XCEngine::UI::UIColor textDisabled = ::XCEngine::UI::UIColor(0.50f, 0.50f, 0.50f, 1.0f); }; struct UIEditorMenuBarLayout { ::XCEngine::UI::UIRect bounds = {}; ::XCEngine::UI::UIRect contentRect = {}; std::vector<::XCEngine::UI::UIRect> buttonRects = {}; }; enum class UIEditorMenuBarHitTargetKind : std::uint8_t { None = 0, BarBackground, Button }; struct UIEditorMenuBarHitTarget { UIEditorMenuBarHitTargetKind kind = UIEditorMenuBarHitTargetKind::None; std::size_t index = UIEditorMenuBarInvalidIndex; }; float ResolveUIEditorMenuBarDesiredButtonWidth( const UIEditorMenuBarItem& item, const UIEditorMenuBarMetrics& metrics = {}); UIEditorMenuBarLayout BuildUIEditorMenuBarLayout( const ::XCEngine::UI::UIRect& bounds, const std::vector& items, const UIEditorMenuBarMetrics& metrics = {}); UIEditorMenuBarHitTarget HitTestUIEditorMenuBar( const UIEditorMenuBarLayout& layout, const ::XCEngine::UI::UIPoint& point); void AppendUIEditorMenuBarBackground( ::XCEngine::UI::UIDrawList& drawList, const UIEditorMenuBarLayout& layout, const std::vector& items, const UIEditorMenuBarState& state, const UIEditorMenuBarPalette& palette = {}, const UIEditorMenuBarMetrics& metrics = {}); void AppendUIEditorMenuBarForeground( ::XCEngine::UI::UIDrawList& drawList, const UIEditorMenuBarLayout& layout, const std::vector& items, const UIEditorMenuBarState& state, const UIEditorMenuBarPalette& palette = {}, const UIEditorMenuBarMetrics& metrics = {}); void AppendUIEditorMenuBar( ::XCEngine::UI::UIDrawList& drawList, const ::XCEngine::UI::UIRect& bounds, const std::vector& items, const UIEditorMenuBarState& state, const UIEditorMenuBarPalette& palette = {}, const UIEditorMenuBarMetrics& metrics = {}); } // namespace XCEngine::UI::Editor::Widgets