2026-04-07 03:51:26 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <XCEngine/UI/DrawData.h>
|
|
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <string_view>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
namespace XCEngine::UI::Editor::Widgets {
|
|
|
|
|
|
|
|
|
|
inline constexpr std::size_t UIEditorStatusBarInvalidIndex =
|
|
|
|
|
static_cast<std::size_t>(-1);
|
|
|
|
|
|
|
|
|
|
enum class UIEditorStatusBarSlot : std::uint8_t {
|
|
|
|
|
Leading = 0,
|
|
|
|
|
Trailing
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class UIEditorStatusBarTextTone : std::uint8_t {
|
|
|
|
|
Primary = 0,
|
|
|
|
|
Muted,
|
|
|
|
|
Accent
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class UIEditorStatusBarHitTargetKind : std::uint8_t {
|
|
|
|
|
None = 0,
|
|
|
|
|
Background,
|
|
|
|
|
Segment,
|
|
|
|
|
Separator
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct UIEditorStatusBarSegment {
|
|
|
|
|
std::string segmentId = {};
|
|
|
|
|
std::string label = {};
|
|
|
|
|
UIEditorStatusBarSlot slot = UIEditorStatusBarSlot::Leading;
|
|
|
|
|
UIEditorStatusBarTextTone tone = UIEditorStatusBarTextTone::Primary;
|
|
|
|
|
bool interactive = true;
|
|
|
|
|
bool showSeparator = false;
|
|
|
|
|
float desiredWidth = 0.0f;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct UIEditorStatusBarState {
|
|
|
|
|
std::size_t hoveredIndex = UIEditorStatusBarInvalidIndex;
|
|
|
|
|
std::size_t activeIndex = UIEditorStatusBarInvalidIndex;
|
|
|
|
|
bool focused = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct UIEditorStatusBarMetrics {
|
2026-04-10 21:05:07 +08:00
|
|
|
float barHeight = 22.0f;
|
|
|
|
|
float outerPaddingX = 8.0f;
|
|
|
|
|
float segmentPaddingX = 8.0f;
|
|
|
|
|
float segmentPaddingY = 4.0f;
|
|
|
|
|
float segmentGap = 2.0f;
|
2026-04-07 03:51:26 +08:00
|
|
|
float separatorWidth = 1.0f;
|
2026-04-10 21:05:07 +08:00
|
|
|
float separatorInsetY = 5.0f;
|
2026-04-07 03:51:26 +08:00
|
|
|
float slotGapMin = 18.0f;
|
2026-04-10 21:05:07 +08:00
|
|
|
float cornerRounding = 0.0f;
|
|
|
|
|
float estimatedGlyphWidth = 6.5f;
|
2026-04-07 03:51:26 +08:00
|
|
|
float borderThickness = 1.0f;
|
2026-04-10 21:05:07 +08:00
|
|
|
float focusedBorderThickness = 1.0f;
|
2026-04-07 03:51:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct UIEditorStatusBarPalette {
|
|
|
|
|
::XCEngine::UI::UIColor surfaceColor =
|
2026-04-10 21:05:07 +08:00
|
|
|
::XCEngine::UI::UIColor(0.16f, 0.16f, 0.16f, 1.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor borderColor =
|
2026-04-10 21:05:07 +08:00
|
|
|
::XCEngine::UI::UIColor(0.23f, 0.23f, 0.23f, 1.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor focusedBorderColor =
|
2026-04-10 21:05:07 +08:00
|
|
|
::XCEngine::UI::UIColor(0.35f, 0.35f, 0.35f, 1.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor segmentColor =
|
2026-04-10 21:05:07 +08:00
|
|
|
::XCEngine::UI::UIColor(0.18f, 0.18f, 0.18f, 1.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor segmentHoveredColor =
|
2026-04-10 21:05:07 +08:00
|
|
|
::XCEngine::UI::UIColor(0.22f, 0.22f, 0.22f, 1.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor segmentActiveColor =
|
2026-04-10 21:05:07 +08:00
|
|
|
::XCEngine::UI::UIColor(0.25f, 0.25f, 0.25f, 1.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor segmentBorderColor =
|
2026-04-10 21:05:07 +08:00
|
|
|
::XCEngine::UI::UIColor(0.29f, 0.29f, 0.29f, 1.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor separatorColor =
|
2026-04-10 21:05:07 +08:00
|
|
|
::XCEngine::UI::UIColor(0.27f, 0.27f, 0.27f, 1.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor textPrimary =
|
2026-04-10 21:05:07 +08:00
|
|
|
::XCEngine::UI::UIColor(0.84f, 0.84f, 0.84f, 1.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor textMuted =
|
2026-04-10 21:05:07 +08:00
|
|
|
::XCEngine::UI::UIColor(0.62f, 0.62f, 0.62f, 1.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
::XCEngine::UI::UIColor textAccent =
|
2026-04-10 21:05:07 +08:00
|
|
|
::XCEngine::UI::UIColor(0.84f, 0.84f, 0.84f, 1.0f);
|
2026-04-07 03:51:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct UIEditorStatusBarLayout {
|
|
|
|
|
::XCEngine::UI::UIRect bounds = {};
|
|
|
|
|
::XCEngine::UI::UIRect leadingSlotRect = {};
|
|
|
|
|
::XCEngine::UI::UIRect trailingSlotRect = {};
|
|
|
|
|
std::vector<::XCEngine::UI::UIRect> segmentRects = {};
|
|
|
|
|
std::vector<::XCEngine::UI::UIRect> separatorRects = {};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct UIEditorStatusBarHitTarget {
|
|
|
|
|
UIEditorStatusBarHitTargetKind kind = UIEditorStatusBarHitTargetKind::None;
|
|
|
|
|
std::size_t index = UIEditorStatusBarInvalidIndex;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
float ResolveUIEditorStatusBarDesiredSegmentWidth(
|
|
|
|
|
const UIEditorStatusBarSegment& segment,
|
|
|
|
|
const UIEditorStatusBarMetrics& metrics = {});
|
|
|
|
|
|
|
|
|
|
UIEditorStatusBarLayout BuildUIEditorStatusBarLayout(
|
|
|
|
|
const ::XCEngine::UI::UIRect& bounds,
|
|
|
|
|
const std::vector<UIEditorStatusBarSegment>& segments,
|
|
|
|
|
const UIEditorStatusBarMetrics& metrics = {});
|
|
|
|
|
|
|
|
|
|
UIEditorStatusBarHitTarget HitTestUIEditorStatusBar(
|
|
|
|
|
const UIEditorStatusBarLayout& layout,
|
|
|
|
|
const ::XCEngine::UI::UIPoint& point);
|
|
|
|
|
|
|
|
|
|
::XCEngine::UI::UIColor ResolveUIEditorStatusBarTextColor(
|
|
|
|
|
UIEditorStatusBarTextTone tone,
|
|
|
|
|
const UIEditorStatusBarPalette& palette = {});
|
|
|
|
|
|
|
|
|
|
void AppendUIEditorStatusBarBackground(
|
|
|
|
|
::XCEngine::UI::UIDrawList& drawList,
|
|
|
|
|
const UIEditorStatusBarLayout& layout,
|
|
|
|
|
const std::vector<UIEditorStatusBarSegment>& segments,
|
|
|
|
|
const UIEditorStatusBarState& state,
|
|
|
|
|
const UIEditorStatusBarPalette& palette = {},
|
|
|
|
|
const UIEditorStatusBarMetrics& metrics = {});
|
|
|
|
|
|
|
|
|
|
void AppendUIEditorStatusBarForeground(
|
|
|
|
|
::XCEngine::UI::UIDrawList& drawList,
|
|
|
|
|
const UIEditorStatusBarLayout& layout,
|
|
|
|
|
const std::vector<UIEditorStatusBarSegment>& segments,
|
|
|
|
|
const UIEditorStatusBarState& state,
|
|
|
|
|
const UIEditorStatusBarPalette& palette = {},
|
|
|
|
|
const UIEditorStatusBarMetrics& metrics = {});
|
|
|
|
|
|
|
|
|
|
void AppendUIEditorStatusBar(
|
|
|
|
|
::XCEngine::UI::UIDrawList& drawList,
|
|
|
|
|
const ::XCEngine::UI::UIRect& bounds,
|
|
|
|
|
const std::vector<UIEditorStatusBarSegment>& segments,
|
|
|
|
|
const UIEditorStatusBarState& state,
|
|
|
|
|
const UIEditorStatusBarPalette& palette = {},
|
|
|
|
|
const UIEditorStatusBarMetrics& metrics = {});
|
|
|
|
|
|
|
|
|
|
} // namespace XCEngine::UI::Editor::Widgets
|