158 lines
5.7 KiB
C++
158 lines
5.7 KiB
C++
#pragma once
|
|
|
|
#include <XCEngine/UI/DrawData.h>
|
|
#include <XCEngine/UI/Layout/UITabStripLayout.h>
|
|
#include <XCEngine/UI/Widgets/UITabStripModel.h>
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
namespace XCEngine::UI::Editor::Widgets {
|
|
|
|
inline constexpr std::size_t UIEditorTabStripInvalidIndex =
|
|
::XCEngine::UI::Widgets::UITabStripModel::InvalidIndex;
|
|
|
|
struct UIEditorTabStripItem {
|
|
std::string tabId = {};
|
|
std::string title = {};
|
|
bool closable = true;
|
|
float desiredHeaderLabelWidth = 0.0f;
|
|
};
|
|
|
|
struct UIEditorTabStripState {
|
|
std::size_t selectedIndex = UIEditorTabStripInvalidIndex;
|
|
std::size_t hoveredIndex = UIEditorTabStripInvalidIndex;
|
|
std::size_t closeHoveredIndex = UIEditorTabStripInvalidIndex;
|
|
bool focused = false;
|
|
};
|
|
|
|
struct UIEditorTabStripMetrics {
|
|
::XCEngine::UI::Layout::UITabStripMetrics layoutMetrics =
|
|
::XCEngine::UI::Layout::UITabStripMetrics{ 32.0f, 88.0f, 12.0f, 1.0f };
|
|
float estimatedGlyphWidth = 7.0f;
|
|
float closeButtonExtent = 14.0f;
|
|
float closeButtonGap = 8.0f;
|
|
float closeInsetRight = 12.0f;
|
|
float closeInsetY = 0.0f;
|
|
float labelInsetX = 12.0f;
|
|
float labelInsetY = -1.0f;
|
|
float baseBorderThickness = 1.0f;
|
|
float selectedBorderThickness = 1.5f;
|
|
float focusedBorderThickness = 2.0f;
|
|
};
|
|
|
|
struct UIEditorTabStripPalette {
|
|
::XCEngine::UI::UIColor stripBackgroundColor =
|
|
::XCEngine::UI::UIColor(0.17f, 0.17f, 0.17f, 1.0f);
|
|
::XCEngine::UI::UIColor headerBackgroundColor =
|
|
::XCEngine::UI::UIColor(0.20f, 0.20f, 0.20f, 1.0f);
|
|
::XCEngine::UI::UIColor contentBackgroundColor =
|
|
::XCEngine::UI::UIColor(0.21f, 0.21f, 0.21f, 1.0f);
|
|
::XCEngine::UI::UIColor stripBorderColor =
|
|
::XCEngine::UI::UIColor(0.30f, 0.30f, 0.30f, 1.0f);
|
|
::XCEngine::UI::UIColor focusedBorderColor =
|
|
::XCEngine::UI::UIColor(0.86f, 0.86f, 0.86f, 1.0f);
|
|
::XCEngine::UI::UIColor tabColor =
|
|
::XCEngine::UI::UIColor(0.23f, 0.23f, 0.23f, 1.0f);
|
|
::XCEngine::UI::UIColor tabHoveredColor =
|
|
::XCEngine::UI::UIColor(0.27f, 0.27f, 0.27f, 1.0f);
|
|
::XCEngine::UI::UIColor tabSelectedColor =
|
|
::XCEngine::UI::UIColor(0.29f, 0.29f, 0.29f, 1.0f);
|
|
::XCEngine::UI::UIColor tabBorderColor =
|
|
::XCEngine::UI::UIColor(0.32f, 0.32f, 0.32f, 1.0f);
|
|
::XCEngine::UI::UIColor tabHoveredBorderColor =
|
|
::XCEngine::UI::UIColor(0.46f, 0.46f, 0.46f, 1.0f);
|
|
::XCEngine::UI::UIColor tabSelectedBorderColor =
|
|
::XCEngine::UI::UIColor(0.72f, 0.72f, 0.72f, 1.0f);
|
|
::XCEngine::UI::UIColor textPrimary =
|
|
::XCEngine::UI::UIColor(0.94f, 0.94f, 0.94f, 1.0f);
|
|
::XCEngine::UI::UIColor textSecondary =
|
|
::XCEngine::UI::UIColor(0.76f, 0.76f, 0.76f, 1.0f);
|
|
::XCEngine::UI::UIColor textMuted =
|
|
::XCEngine::UI::UIColor(0.60f, 0.60f, 0.60f, 1.0f);
|
|
::XCEngine::UI::UIColor closeButtonColor =
|
|
::XCEngine::UI::UIColor(0.25f, 0.25f, 0.25f, 1.0f);
|
|
::XCEngine::UI::UIColor closeButtonHoveredColor =
|
|
::XCEngine::UI::UIColor(0.36f, 0.36f, 0.36f, 1.0f);
|
|
::XCEngine::UI::UIColor closeButtonBorderColor =
|
|
::XCEngine::UI::UIColor(0.44f, 0.44f, 0.44f, 1.0f);
|
|
::XCEngine::UI::UIColor closeGlyphColor =
|
|
::XCEngine::UI::UIColor(0.92f, 0.92f, 0.92f, 1.0f);
|
|
};
|
|
|
|
struct UIEditorTabStripLayout {
|
|
::XCEngine::UI::UIRect bounds = {};
|
|
::XCEngine::UI::UIRect headerRect = {};
|
|
::XCEngine::UI::UIRect contentRect = {};
|
|
std::vector<::XCEngine::UI::UIRect> tabHeaderRects = {};
|
|
std::vector<::XCEngine::UI::UIRect> closeButtonRects = {};
|
|
std::vector<bool> showCloseButtons = {};
|
|
std::size_t selectedIndex = UIEditorTabStripInvalidIndex;
|
|
};
|
|
|
|
enum class UIEditorTabStripHitTargetKind : std::uint8_t {
|
|
None = 0,
|
|
HeaderBackground,
|
|
Tab,
|
|
CloseButton,
|
|
Content
|
|
};
|
|
|
|
struct UIEditorTabStripHitTarget {
|
|
UIEditorTabStripHitTargetKind kind = UIEditorTabStripHitTargetKind::None;
|
|
std::size_t index = UIEditorTabStripInvalidIndex;
|
|
};
|
|
|
|
float ResolveUIEditorTabStripDesiredHeaderLabelWidth(
|
|
const UIEditorTabStripItem& item,
|
|
const UIEditorTabStripMetrics& metrics = {});
|
|
|
|
std::size_t ResolveUIEditorTabStripSelectedIndex(
|
|
const std::vector<UIEditorTabStripItem>& items,
|
|
std::string_view selectedTabId,
|
|
std::size_t fallbackIndex = UIEditorTabStripInvalidIndex);
|
|
|
|
std::size_t ResolveUIEditorTabStripSelectedIndexAfterClose(
|
|
std::size_t selectedIndex,
|
|
std::size_t closedIndex,
|
|
std::size_t itemCountBeforeClose);
|
|
|
|
UIEditorTabStripLayout BuildUIEditorTabStripLayout(
|
|
const ::XCEngine::UI::UIRect& bounds,
|
|
const std::vector<UIEditorTabStripItem>& items,
|
|
const UIEditorTabStripState& state,
|
|
const UIEditorTabStripMetrics& metrics = {});
|
|
|
|
UIEditorTabStripHitTarget HitTestUIEditorTabStrip(
|
|
const UIEditorTabStripLayout& layout,
|
|
const UIEditorTabStripState& state,
|
|
const ::XCEngine::UI::UIPoint& point);
|
|
|
|
void AppendUIEditorTabStripBackground(
|
|
::XCEngine::UI::UIDrawList& drawList,
|
|
const UIEditorTabStripLayout& layout,
|
|
const UIEditorTabStripState& state,
|
|
const UIEditorTabStripPalette& palette = {},
|
|
const UIEditorTabStripMetrics& metrics = {});
|
|
|
|
void AppendUIEditorTabStripForeground(
|
|
::XCEngine::UI::UIDrawList& drawList,
|
|
const UIEditorTabStripLayout& layout,
|
|
const std::vector<UIEditorTabStripItem>& items,
|
|
const UIEditorTabStripState& state,
|
|
const UIEditorTabStripPalette& palette = {},
|
|
const UIEditorTabStripMetrics& metrics = {});
|
|
|
|
void AppendUIEditorTabStrip(
|
|
::XCEngine::UI::UIDrawList& drawList,
|
|
const ::XCEngine::UI::UIRect& bounds,
|
|
const std::vector<UIEditorTabStripItem>& items,
|
|
const UIEditorTabStripState& state,
|
|
const UIEditorTabStripPalette& palette = {},
|
|
const UIEditorTabStripMetrics& metrics = {});
|
|
|
|
} // namespace XCEngine::UI::Editor::Widgets
|