Refactor XCUI editor module layout
This commit is contained in:
144
new_editor/include/XCEditor/Shell/UIEditorStatusBar.h
Normal file
144
new_editor/include/XCEditor/Shell/UIEditorStatusBar.h
Normal file
@@ -0,0 +1,144 @@
|
||||
#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 {
|
||||
float barHeight = 28.0f;
|
||||
float outerPaddingX = 10.0f;
|
||||
float segmentPaddingX = 10.0f;
|
||||
float segmentPaddingY = 6.0f;
|
||||
float segmentGap = 4.0f;
|
||||
float separatorWidth = 1.0f;
|
||||
float separatorInsetY = 6.0f;
|
||||
float slotGapMin = 18.0f;
|
||||
float cornerRounding = 8.0f;
|
||||
float estimatedGlyphWidth = 7.0f;
|
||||
float borderThickness = 1.0f;
|
||||
float focusedBorderThickness = 2.0f;
|
||||
};
|
||||
|
||||
struct UIEditorStatusBarPalette {
|
||||
::XCEngine::UI::UIColor surfaceColor =
|
||||
::XCEngine::UI::UIColor(0.15f, 0.15f, 0.16f, 1.0f);
|
||||
::XCEngine::UI::UIColor borderColor =
|
||||
::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 segmentColor =
|
||||
::XCEngine::UI::UIColor(0.19f, 0.19f, 0.21f, 1.0f);
|
||||
::XCEngine::UI::UIColor segmentHoveredColor =
|
||||
::XCEngine::UI::UIColor(0.24f, 0.26f, 0.28f, 1.0f);
|
||||
::XCEngine::UI::UIColor segmentActiveColor =
|
||||
::XCEngine::UI::UIColor(0.30f, 0.32f, 0.35f, 1.0f);
|
||||
::XCEngine::UI::UIColor segmentBorderColor =
|
||||
::XCEngine::UI::UIColor(0.42f, 0.44f, 0.47f, 1.0f);
|
||||
::XCEngine::UI::UIColor separatorColor =
|
||||
::XCEngine::UI::UIColor(0.32f, 0.34f, 0.36f, 1.0f);
|
||||
::XCEngine::UI::UIColor textPrimary =
|
||||
::XCEngine::UI::UIColor(0.93f, 0.94f, 0.96f, 1.0f);
|
||||
::XCEngine::UI::UIColor textMuted =
|
||||
::XCEngine::UI::UIColor(0.58f, 0.59f, 0.62f, 1.0f);
|
||||
::XCEngine::UI::UIColor textAccent =
|
||||
::XCEngine::UI::UIColor(0.82f, 0.86f, 0.93f, 1.0f);
|
||||
};
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user