131 lines
4.4 KiB
C
131 lines
4.4 KiB
C
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <XCEngine/UI/DrawData.h>
|
||
|
|
|
||
|
|
#include <cstdint>
|
||
|
|
#include <string>
|
||
|
|
#include <string_view>
|
||
|
|
|
||
|
|
namespace XCEngine::UI::Editor::Widgets {
|
||
|
|
|
||
|
|
enum class UIEditorTextFieldHitTargetKind : std::uint8_t {
|
||
|
|
None = 0,
|
||
|
|
Row,
|
||
|
|
ValueBox
|
||
|
|
};
|
||
|
|
|
||
|
|
struct UIEditorTextFieldSpec {
|
||
|
|
std::string fieldId = {};
|
||
|
|
std::string label = {};
|
||
|
|
std::string value = {};
|
||
|
|
bool readOnly = false;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct UIEditorTextFieldState {
|
||
|
|
UIEditorTextFieldHitTargetKind hoveredTarget = UIEditorTextFieldHitTargetKind::None;
|
||
|
|
UIEditorTextFieldHitTargetKind activeTarget = UIEditorTextFieldHitTargetKind::None;
|
||
|
|
bool focused = false;
|
||
|
|
bool editing = false;
|
||
|
|
std::string displayText = {};
|
||
|
|
};
|
||
|
|
|
||
|
|
struct UIEditorTextFieldMetrics {
|
||
|
|
float rowHeight = 22.0f;
|
||
|
|
float horizontalPadding = 12.0f;
|
||
|
|
float labelControlGap = 20.0f;
|
||
|
|
float controlColumnStart = 236.0f;
|
||
|
|
float controlTrailingInset = 8.0f;
|
||
|
|
float valueBoxMinWidth = 96.0f;
|
||
|
|
float controlInsetY = 1.0f;
|
||
|
|
float labelTextInsetY = 0.0f;
|
||
|
|
float labelFontSize = 11.0f;
|
||
|
|
float valueTextInsetX = 5.0f;
|
||
|
|
float valueTextInsetY = 0.0f;
|
||
|
|
float valueFontSize = 12.0f;
|
||
|
|
float cornerRounding = 0.0f;
|
||
|
|
float valueBoxRounding = 2.0f;
|
||
|
|
float borderThickness = 1.0f;
|
||
|
|
float focusedBorderThickness = 1.0f;
|
||
|
|
};
|
||
|
|
|
||
|
|
struct UIEditorTextFieldPalette {
|
||
|
|
::XCEngine::UI::UIColor surfaceColor =
|
||
|
|
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||
|
|
::XCEngine::UI::UIColor borderColor =
|
||
|
|
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||
|
|
::XCEngine::UI::UIColor focusedBorderColor =
|
||
|
|
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||
|
|
::XCEngine::UI::UIColor rowHoverColor =
|
||
|
|
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||
|
|
::XCEngine::UI::UIColor rowActiveColor =
|
||
|
|
::XCEngine::UI::UIColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||
|
|
::XCEngine::UI::UIColor valueBoxColor =
|
||
|
|
::XCEngine::UI::UIColor(0.18f, 0.18f, 0.18f, 1.0f);
|
||
|
|
::XCEngine::UI::UIColor valueBoxHoverColor =
|
||
|
|
::XCEngine::UI::UIColor(0.21f, 0.21f, 0.21f, 1.0f);
|
||
|
|
::XCEngine::UI::UIColor valueBoxEditingColor =
|
||
|
|
::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f);
|
||
|
|
::XCEngine::UI::UIColor readOnlyColor =
|
||
|
|
::XCEngine::UI::UIColor(0.17f, 0.17f, 0.17f, 1.0f);
|
||
|
|
::XCEngine::UI::UIColor controlBorderColor =
|
||
|
|
::XCEngine::UI::UIColor(0.14f, 0.14f, 0.14f, 1.0f);
|
||
|
|
::XCEngine::UI::UIColor controlFocusedBorderColor =
|
||
|
|
::XCEngine::UI::UIColor(0.46f, 0.46f, 0.46f, 1.0f);
|
||
|
|
::XCEngine::UI::UIColor labelColor =
|
||
|
|
::XCEngine::UI::UIColor(0.80f, 0.80f, 0.80f, 1.0f);
|
||
|
|
::XCEngine::UI::UIColor valueColor =
|
||
|
|
::XCEngine::UI::UIColor(0.92f, 0.92f, 0.92f, 1.0f);
|
||
|
|
::XCEngine::UI::UIColor readOnlyValueColor =
|
||
|
|
::XCEngine::UI::UIColor(0.62f, 0.62f, 0.62f, 1.0f);
|
||
|
|
};
|
||
|
|
|
||
|
|
struct UIEditorTextFieldLayout {
|
||
|
|
::XCEngine::UI::UIRect bounds = {};
|
||
|
|
::XCEngine::UI::UIRect labelRect = {};
|
||
|
|
::XCEngine::UI::UIRect controlRect = {};
|
||
|
|
::XCEngine::UI::UIRect valueRect = {};
|
||
|
|
};
|
||
|
|
|
||
|
|
struct UIEditorTextFieldHitTarget {
|
||
|
|
UIEditorTextFieldHitTargetKind kind = UIEditorTextFieldHitTargetKind::None;
|
||
|
|
};
|
||
|
|
|
||
|
|
bool IsUIEditorTextFieldPointInside(
|
||
|
|
const ::XCEngine::UI::UIRect& rect,
|
||
|
|
const ::XCEngine::UI::UIPoint& point);
|
||
|
|
|
||
|
|
UIEditorTextFieldLayout BuildUIEditorTextFieldLayout(
|
||
|
|
const ::XCEngine::UI::UIRect& bounds,
|
||
|
|
const UIEditorTextFieldSpec& spec,
|
||
|
|
const UIEditorTextFieldMetrics& metrics = {});
|
||
|
|
|
||
|
|
UIEditorTextFieldHitTarget HitTestUIEditorTextField(
|
||
|
|
const UIEditorTextFieldLayout& layout,
|
||
|
|
const ::XCEngine::UI::UIPoint& point);
|
||
|
|
|
||
|
|
void AppendUIEditorTextFieldBackground(
|
||
|
|
::XCEngine::UI::UIDrawList& drawList,
|
||
|
|
const UIEditorTextFieldLayout& layout,
|
||
|
|
const UIEditorTextFieldSpec& spec,
|
||
|
|
const UIEditorTextFieldState& state,
|
||
|
|
const UIEditorTextFieldPalette& palette = {},
|
||
|
|
const UIEditorTextFieldMetrics& metrics = {});
|
||
|
|
|
||
|
|
void AppendUIEditorTextFieldForeground(
|
||
|
|
::XCEngine::UI::UIDrawList& drawList,
|
||
|
|
const UIEditorTextFieldLayout& layout,
|
||
|
|
const UIEditorTextFieldSpec& spec,
|
||
|
|
const UIEditorTextFieldState& state,
|
||
|
|
const UIEditorTextFieldPalette& palette = {},
|
||
|
|
const UIEditorTextFieldMetrics& metrics = {});
|
||
|
|
|
||
|
|
void AppendUIEditorTextField(
|
||
|
|
::XCEngine::UI::UIDrawList& drawList,
|
||
|
|
const ::XCEngine::UI::UIRect& bounds,
|
||
|
|
const UIEditorTextFieldSpec& spec,
|
||
|
|
const UIEditorTextFieldState& state,
|
||
|
|
const UIEditorTextFieldPalette& palette = {},
|
||
|
|
const UIEditorTextFieldMetrics& metrics = {});
|
||
|
|
|
||
|
|
} // namespace XCEngine::UI::Editor::Widgets
|