ui: add typed editor field foundations
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include <XCEngine/UI/Widgets/UIPropertyEditModel.h>
|
||||
#include <XCEngine/UI/Widgets/UISelectionModel.h>
|
||||
|
||||
#include <XCEditor/Widgets/UIEditorMenuPopup.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
@@ -15,6 +17,13 @@ namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
inline constexpr std::size_t UIEditorPropertyGridInvalidIndex = static_cast<std::size_t>(-1);
|
||||
|
||||
enum class UIEditorPropertyGridFieldKind : std::uint8_t {
|
||||
Text = 0,
|
||||
Bool,
|
||||
Number,
|
||||
Enum
|
||||
};
|
||||
|
||||
enum class UIEditorPropertyGridHitTargetKind : std::uint8_t {
|
||||
None = 0,
|
||||
SectionHeader,
|
||||
@@ -32,12 +41,29 @@ struct UIEditorPropertyGridFieldLocation {
|
||||
}
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridNumberFieldValue {
|
||||
double value = 0.0;
|
||||
double step = 1.0;
|
||||
double minValue = 0.0;
|
||||
double maxValue = 100.0;
|
||||
bool integerMode = true;
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridEnumFieldValue {
|
||||
std::vector<std::string> options = {};
|
||||
std::size_t selectedIndex = 0u;
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridField {
|
||||
std::string fieldId = {};
|
||||
std::string label = {};
|
||||
std::string valueText = {};
|
||||
bool readOnly = false;
|
||||
float desiredHeight = 0.0f;
|
||||
UIEditorPropertyGridFieldKind kind = UIEditorPropertyGridFieldKind::Text;
|
||||
bool boolValue = false;
|
||||
UIEditorPropertyGridNumberFieldValue numberValue = {};
|
||||
UIEditorPropertyGridEnumFieldValue enumValue = {};
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridSection {
|
||||
@@ -50,7 +76,11 @@ struct UIEditorPropertyGridSection {
|
||||
struct UIEditorPropertyGridState {
|
||||
std::string hoveredSectionId = {};
|
||||
std::string hoveredFieldId = {};
|
||||
UIEditorPropertyGridHitTargetKind hoveredHitTarget = UIEditorPropertyGridHitTargetKind::None;
|
||||
bool focused = false;
|
||||
std::string pressedFieldId = {};
|
||||
std::string popupFieldId = {};
|
||||
std::size_t popupHighlightedIndex = UIEditorPropertyGridInvalidIndex;
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridMetrics {
|
||||
@@ -65,10 +95,17 @@ struct UIEditorPropertyGridMetrics {
|
||||
float disclosureExtent = 12.0f;
|
||||
float disclosureLabelGap = 8.0f;
|
||||
float sectionTextInsetY = 8.0f;
|
||||
float sectionFontSize = 12.0f;
|
||||
float disclosureGlyphInsetX = 2.0f;
|
||||
float disclosureGlyphInsetY = -1.0f;
|
||||
float disclosureGlyphFontSize = 12.0f;
|
||||
float labelTextInsetY = 8.0f;
|
||||
float labelFontSize = 12.0f;
|
||||
float valueTextInsetY = 8.0f;
|
||||
float valueFontSize = 12.0f;
|
||||
float valueBoxInsetY = 4.0f;
|
||||
float valueBoxInsetX = 8.0f;
|
||||
float tagFontSize = 11.0f;
|
||||
float cornerRounding = 6.0f;
|
||||
float valueBoxRounding = 5.0f;
|
||||
float borderThickness = 1.0f;
|
||||
@@ -153,6 +190,9 @@ UIEditorPropertyGridFieldLocation FindUIEditorPropertyGridFieldLocation(
|
||||
const std::vector<UIEditorPropertyGridSection>& sections,
|
||||
std::string_view fieldId);
|
||||
|
||||
std::string ResolveUIEditorPropertyGridFieldValueText(
|
||||
const UIEditorPropertyGridField& field);
|
||||
|
||||
std::size_t FindUIEditorPropertyGridVisibleFieldIndex(
|
||||
const UIEditorPropertyGridLayout& layout,
|
||||
std::string_view fieldId,
|
||||
@@ -182,9 +222,12 @@ void AppendUIEditorPropertyGridForeground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorPropertyGridLayout& layout,
|
||||
const std::vector<UIEditorPropertyGridSection>& sections,
|
||||
const UIEditorPropertyGridState& state,
|
||||
const ::XCEngine::UI::Widgets::UIPropertyEditModel& propertyEditModel,
|
||||
const UIEditorPropertyGridPalette& palette = {},
|
||||
const UIEditorPropertyGridMetrics& metrics = {});
|
||||
const UIEditorPropertyGridMetrics& metrics = {},
|
||||
const UIEditorMenuPopupPalette& popupPalette = {},
|
||||
const UIEditorMenuPopupMetrics& popupMetrics = {});
|
||||
|
||||
void AppendUIEditorPropertyGrid(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
@@ -195,6 +238,8 @@ void AppendUIEditorPropertyGrid(
|
||||
const ::XCEngine::UI::Widgets::UIPropertyEditModel& propertyEditModel,
|
||||
const UIEditorPropertyGridState& state,
|
||||
const UIEditorPropertyGridPalette& palette = {},
|
||||
const UIEditorPropertyGridMetrics& metrics = {});
|
||||
const UIEditorPropertyGridMetrics& metrics = {},
|
||||
const UIEditorMenuPopupPalette& popupPalette = {},
|
||||
const UIEditorMenuPopupMetrics& popupMetrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
|
||||
Reference in New Issue
Block a user