2026-04-07 03:51:26 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <XCEngine/UI/DrawData.h>
|
|
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
namespace XCEngine::UI::Editor::Widgets {
|
|
|
|
|
|
|
|
|
|
inline constexpr std::size_t UIEditorMenuBarInvalidIndex =
|
|
|
|
|
static_cast<std::size_t>(-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 {
|
2026-04-10 21:05:07 +08:00
|
|
|
float barHeight = 24.0f;
|
|
|
|
|
float horizontalInset = 0.0f;
|
|
|
|
|
float verticalInset = 2.0f;
|
2026-04-11 17:07:37 +08:00
|
|
|
float buttonGap = 1.0f;
|
|
|
|
|
float buttonPaddingX = 4.0f;
|
|
|
|
|
float labelFontSize = 13.0f;
|
2026-04-10 21:05:07 +08:00
|
|
|
float estimatedGlyphWidth = 6.5f;
|
|
|
|
|
float labelInsetY = -1.5f;
|
|
|
|
|
float barCornerRounding = 0.0f;
|
2026-04-11 17:07:37 +08:00
|
|
|
float buttonCornerRounding = 0.75f;
|
2026-04-07 03:51:26 +08:00
|
|
|
float baseBorderThickness = 1.0f;
|
2026-04-10 21:05:07 +08:00
|
|
|
float focusedBorderThickness = 1.0f;
|
|
|
|
|
float openBorderThickness = 1.0f;
|
2026-04-07 03:51:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct UIEditorMenuBarPalette {
|
|
|
|
|
::XCEngine::UI::UIColor barColor =
|
2026-04-11 17:07:37 +08:00
|
|
|
::XCEngine::UI::UIColor(1.0f, 1.0f, 1.0f, 1.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor buttonColor =
|
2026-04-11 17:07:37 +08:00
|
|
|
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor buttonHoveredColor =
|
2026-04-11 17:07:37 +08:00
|
|
|
::XCEngine::UI::UIColor(0.88f, 0.88f, 0.88f, 1.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor buttonOpenColor =
|
2026-04-11 17:07:37 +08:00
|
|
|
::XCEngine::UI::UIColor(0.84f, 0.84f, 0.84f, 1.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor borderColor =
|
2026-04-11 17:07:37 +08:00
|
|
|
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor focusedBorderColor =
|
2026-04-11 17:07:37 +08:00
|
|
|
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor openBorderColor =
|
2026-04-11 17:07:37 +08:00
|
|
|
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor textPrimary =
|
2026-04-11 17:07:37 +08:00
|
|
|
::XCEngine::UI::UIColor(0.08f, 0.08f, 0.08f, 1.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor textMuted =
|
2026-04-11 17:07:37 +08:00
|
|
|
::XCEngine::UI::UIColor(0.28f, 0.28f, 0.28f, 1.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor textDisabled =
|
2026-04-10 21:05:07 +08:00
|
|
|
::XCEngine::UI::UIColor(0.50f, 0.50f, 0.50f, 1.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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<UIEditorMenuBarItem>& 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<UIEditorMenuBarItem>& items,
|
|
|
|
|
const UIEditorMenuBarState& state,
|
|
|
|
|
const UIEditorMenuBarPalette& palette = {},
|
|
|
|
|
const UIEditorMenuBarMetrics& metrics = {});
|
|
|
|
|
|
|
|
|
|
void AppendUIEditorMenuBarForeground(
|
|
|
|
|
::XCEngine::UI::UIDrawList& drawList,
|
|
|
|
|
const UIEditorMenuBarLayout& layout,
|
|
|
|
|
const std::vector<UIEditorMenuBarItem>& items,
|
|
|
|
|
const UIEditorMenuBarState& state,
|
|
|
|
|
const UIEditorMenuBarPalette& palette = {},
|
|
|
|
|
const UIEditorMenuBarMetrics& metrics = {});
|
|
|
|
|
|
|
|
|
|
void AppendUIEditorMenuBar(
|
|
|
|
|
::XCEngine::UI::UIDrawList& drawList,
|
|
|
|
|
const ::XCEngine::UI::UIRect& bounds,
|
|
|
|
|
const std::vector<UIEditorMenuBarItem>& items,
|
|
|
|
|
const UIEditorMenuBarState& state,
|
|
|
|
|
const UIEditorMenuBarPalette& palette = {},
|
|
|
|
|
const UIEditorMenuBarMetrics& metrics = {});
|
|
|
|
|
|
|
|
|
|
} // namespace XCEngine::UI::Editor::Widgets
|