114 lines
3.7 KiB
C++
114 lines
3.7 KiB
C++
#pragma once
|
|
|
|
#include <XCEngine/UI/DrawData.h>
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
namespace XCEngine::UI::Editor::Widgets {
|
|
|
|
enum class UIEditorBoolFieldHitTargetKind : std::uint8_t {
|
|
None = 0,
|
|
Row,
|
|
Toggle
|
|
};
|
|
|
|
struct UIEditorBoolFieldSpec {
|
|
std::string fieldId = {};
|
|
std::string label = {};
|
|
bool value = false;
|
|
bool readOnly = false;
|
|
};
|
|
|
|
struct UIEditorBoolFieldState {
|
|
UIEditorBoolFieldHitTargetKind hoveredTarget = UIEditorBoolFieldHitTargetKind::None;
|
|
bool focused = false;
|
|
bool active = false;
|
|
};
|
|
|
|
struct UIEditorBoolFieldMetrics {
|
|
float rowHeight = 32.0f;
|
|
float horizontalPadding = 12.0f;
|
|
float labelControlGap = 20.0f;
|
|
float controlColumnStart = 236.0f;
|
|
float toggleWidth = 42.0f;
|
|
float toggleHeight = 20.0f;
|
|
float toggleKnobInset = 3.0f;
|
|
float textInsetY = 8.0f;
|
|
float cornerRounding = 6.0f;
|
|
float borderThickness = 1.0f;
|
|
float focusedBorderThickness = 2.0f;
|
|
};
|
|
|
|
struct UIEditorBoolFieldPalette {
|
|
::XCEngine::UI::UIColor surfaceColor =
|
|
::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f);
|
|
::XCEngine::UI::UIColor borderColor =
|
|
::XCEngine::UI::UIColor(0.29f, 0.29f, 0.29f, 1.0f);
|
|
::XCEngine::UI::UIColor focusedBorderColor =
|
|
::XCEngine::UI::UIColor(0.84f, 0.84f, 0.84f, 1.0f);
|
|
::XCEngine::UI::UIColor rowHoverColor =
|
|
::XCEngine::UI::UIColor(0.22f, 0.22f, 0.22f, 1.0f);
|
|
::XCEngine::UI::UIColor rowActiveColor =
|
|
::XCEngine::UI::UIColor(0.28f, 0.28f, 0.28f, 1.0f);
|
|
::XCEngine::UI::UIColor toggleOffColor =
|
|
::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f);
|
|
::XCEngine::UI::UIColor toggleOnColor =
|
|
::XCEngine::UI::UIColor(0.78f, 0.78f, 0.78f, 1.0f);
|
|
::XCEngine::UI::UIColor toggleReadOnlyColor =
|
|
::XCEngine::UI::UIColor(0.18f, 0.18f, 0.18f, 1.0f);
|
|
::XCEngine::UI::UIColor toggleBorderColor =
|
|
::XCEngine::UI::UIColor(0.36f, 0.36f, 0.36f, 1.0f);
|
|
::XCEngine::UI::UIColor knobColor =
|
|
::XCEngine::UI::UIColor(0.92f, 0.92f, 0.92f, 1.0f);
|
|
::XCEngine::UI::UIColor labelColor =
|
|
::XCEngine::UI::UIColor(0.92f, 0.92f, 0.92f, 1.0f);
|
|
::XCEngine::UI::UIColor valueColor =
|
|
::XCEngine::UI::UIColor(0.70f, 0.70f, 0.70f, 1.0f);
|
|
};
|
|
|
|
struct UIEditorBoolFieldLayout {
|
|
::XCEngine::UI::UIRect bounds = {};
|
|
::XCEngine::UI::UIRect labelRect = {};
|
|
::XCEngine::UI::UIRect toggleRect = {};
|
|
::XCEngine::UI::UIRect knobRect = {};
|
|
};
|
|
|
|
struct UIEditorBoolFieldHitTarget {
|
|
UIEditorBoolFieldHitTargetKind kind = UIEditorBoolFieldHitTargetKind::None;
|
|
};
|
|
|
|
UIEditorBoolFieldLayout BuildUIEditorBoolFieldLayout(
|
|
const ::XCEngine::UI::UIRect& bounds,
|
|
const UIEditorBoolFieldSpec& spec,
|
|
const UIEditorBoolFieldMetrics& metrics = {});
|
|
|
|
UIEditorBoolFieldHitTarget HitTestUIEditorBoolField(
|
|
const UIEditorBoolFieldLayout& layout,
|
|
const ::XCEngine::UI::UIPoint& point);
|
|
|
|
void AppendUIEditorBoolFieldBackground(
|
|
::XCEngine::UI::UIDrawList& drawList,
|
|
const UIEditorBoolFieldLayout& layout,
|
|
const UIEditorBoolFieldSpec& spec,
|
|
const UIEditorBoolFieldState& state,
|
|
const UIEditorBoolFieldPalette& palette = {},
|
|
const UIEditorBoolFieldMetrics& metrics = {});
|
|
|
|
void AppendUIEditorBoolFieldForeground(
|
|
::XCEngine::UI::UIDrawList& drawList,
|
|
const UIEditorBoolFieldLayout& layout,
|
|
const UIEditorBoolFieldSpec& spec,
|
|
const UIEditorBoolFieldPalette& palette = {},
|
|
const UIEditorBoolFieldMetrics& metrics = {});
|
|
|
|
void AppendUIEditorBoolField(
|
|
::XCEngine::UI::UIDrawList& drawList,
|
|
const ::XCEngine::UI::UIRect& bounds,
|
|
const UIEditorBoolFieldSpec& spec,
|
|
const UIEditorBoolFieldState& state,
|
|
const UIEditorBoolFieldPalette& palette = {},
|
|
const UIEditorBoolFieldMetrics& metrics = {});
|
|
|
|
} // namespace XCEngine::UI::Editor::Widgets
|