Add editor list, scroll, and property grid widgets
This commit is contained in:
200
new_editor/include/XCEditor/Widgets/UIEditorPropertyGrid.h
Normal file
200
new_editor/include/XCEditor/Widgets/UIEditorPropertyGrid.h
Normal file
@@ -0,0 +1,200 @@
|
||||
#pragma once
|
||||
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
#include <XCEngine/UI/Widgets/UIExpansionModel.h>
|
||||
#include <XCEngine/UI/Widgets/UIPropertyEditModel.h>
|
||||
#include <XCEngine/UI/Widgets/UISelectionModel.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine::UI::Editor::Widgets {
|
||||
|
||||
inline constexpr std::size_t UIEditorPropertyGridInvalidIndex = static_cast<std::size_t>(-1);
|
||||
|
||||
enum class UIEditorPropertyGridHitTargetKind : std::uint8_t {
|
||||
None = 0,
|
||||
SectionHeader,
|
||||
FieldRow,
|
||||
ValueBox
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridFieldLocation {
|
||||
std::size_t sectionIndex = UIEditorPropertyGridInvalidIndex;
|
||||
std::size_t fieldIndex = UIEditorPropertyGridInvalidIndex;
|
||||
|
||||
constexpr bool IsValid() const {
|
||||
return sectionIndex != UIEditorPropertyGridInvalidIndex &&
|
||||
fieldIndex != UIEditorPropertyGridInvalidIndex;
|
||||
}
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridField {
|
||||
std::string fieldId = {};
|
||||
std::string label = {};
|
||||
std::string valueText = {};
|
||||
bool readOnly = false;
|
||||
float desiredHeight = 0.0f;
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridSection {
|
||||
std::string sectionId = {};
|
||||
std::string title = {};
|
||||
std::vector<UIEditorPropertyGridField> fields = {};
|
||||
float desiredHeaderHeight = 0.0f;
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridState {
|
||||
std::string hoveredSectionId = {};
|
||||
std::string hoveredFieldId = {};
|
||||
bool focused = false;
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridMetrics {
|
||||
float contentInset = 8.0f;
|
||||
float sectionGap = 8.0f;
|
||||
float sectionHeaderHeight = 32.0f;
|
||||
float fieldRowHeight = 32.0f;
|
||||
float rowGap = 2.0f;
|
||||
float horizontalPadding = 12.0f;
|
||||
float controlColumnStart = 236.0f;
|
||||
float labelControlGap = 20.0f;
|
||||
float disclosureExtent = 12.0f;
|
||||
float disclosureLabelGap = 8.0f;
|
||||
float sectionTextInsetY = 8.0f;
|
||||
float labelTextInsetY = 8.0f;
|
||||
float valueTextInsetY = 8.0f;
|
||||
float valueBoxInsetY = 4.0f;
|
||||
float valueBoxInsetX = 8.0f;
|
||||
float cornerRounding = 6.0f;
|
||||
float valueBoxRounding = 5.0f;
|
||||
float borderThickness = 1.0f;
|
||||
float focusedBorderThickness = 2.0f;
|
||||
float editOutlineThickness = 1.0f;
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridPalette {
|
||||
::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 sectionHeaderColor =
|
||||
::XCEngine::UI::UIColor(0.19f, 0.19f, 0.19f, 1.0f);
|
||||
::XCEngine::UI::UIColor sectionHeaderHoverColor =
|
||||
::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f);
|
||||
::XCEngine::UI::UIColor fieldHoverColor =
|
||||
::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f);
|
||||
::XCEngine::UI::UIColor fieldSelectedColor =
|
||||
::XCEngine::UI::UIColor(0.31f, 0.31f, 0.31f, 1.0f);
|
||||
::XCEngine::UI::UIColor fieldSelectedFocusedColor =
|
||||
::XCEngine::UI::UIColor(0.40f, 0.40f, 0.40f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxColor =
|
||||
::XCEngine::UI::UIColor(0.17f, 0.17f, 0.17f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxHoverColor =
|
||||
::XCEngine::UI::UIColor(0.22f, 0.22f, 0.22f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxEditingColor =
|
||||
::XCEngine::UI::UIColor(0.24f, 0.24f, 0.24f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxReadOnlyColor =
|
||||
::XCEngine::UI::UIColor(0.15f, 0.15f, 0.15f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxBorderColor =
|
||||
::XCEngine::UI::UIColor(0.32f, 0.32f, 0.32f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueBoxEditingBorderColor =
|
||||
::XCEngine::UI::UIColor(0.75f, 0.75f, 0.75f, 1.0f);
|
||||
::XCEngine::UI::UIColor disclosureColor =
|
||||
::XCEngine::UI::UIColor(0.74f, 0.74f, 0.74f, 1.0f);
|
||||
::XCEngine::UI::UIColor sectionTextColor =
|
||||
::XCEngine::UI::UIColor(0.94f, 0.94f, 0.94f, 1.0f);
|
||||
::XCEngine::UI::UIColor labelTextColor =
|
||||
::XCEngine::UI::UIColor(0.84f, 0.84f, 0.84f, 1.0f);
|
||||
::XCEngine::UI::UIColor valueTextColor =
|
||||
::XCEngine::UI::UIColor(0.94f, 0.94f, 0.94f, 1.0f);
|
||||
::XCEngine::UI::UIColor readOnlyValueTextColor =
|
||||
::XCEngine::UI::UIColor(0.60f, 0.60f, 0.60f, 1.0f);
|
||||
::XCEngine::UI::UIColor editTagColor =
|
||||
::XCEngine::UI::UIColor(0.62f, 0.78f, 0.96f, 1.0f);
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridLayout {
|
||||
::XCEngine::UI::UIRect bounds = {};
|
||||
std::vector<std::size_t> sectionIndices = {};
|
||||
std::vector<::XCEngine::UI::UIRect> sectionHeaderRects = {};
|
||||
std::vector<::XCEngine::UI::UIRect> sectionDisclosureRects = {};
|
||||
std::vector<::XCEngine::UI::UIRect> sectionTitleRects = {};
|
||||
std::vector<bool> sectionExpanded = {};
|
||||
std::vector<std::size_t> visibleFieldSectionIndices = {};
|
||||
std::vector<std::size_t> visibleFieldIndices = {};
|
||||
std::vector<::XCEngine::UI::UIRect> fieldRowRects = {};
|
||||
std::vector<::XCEngine::UI::UIRect> fieldLabelRects = {};
|
||||
std::vector<::XCEngine::UI::UIRect> fieldValueRects = {};
|
||||
std::vector<bool> fieldReadOnly = {};
|
||||
};
|
||||
|
||||
struct UIEditorPropertyGridHitTarget {
|
||||
UIEditorPropertyGridHitTargetKind kind = UIEditorPropertyGridHitTargetKind::None;
|
||||
std::size_t sectionIndex = UIEditorPropertyGridInvalidIndex;
|
||||
std::size_t fieldIndex = UIEditorPropertyGridInvalidIndex;
|
||||
std::size_t visibleFieldIndex = UIEditorPropertyGridInvalidIndex;
|
||||
};
|
||||
|
||||
bool IsUIEditorPropertyGridPointInside(
|
||||
const ::XCEngine::UI::UIRect& rect,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
std::size_t FindUIEditorPropertyGridSectionIndex(
|
||||
const std::vector<UIEditorPropertyGridSection>& sections,
|
||||
std::string_view sectionId);
|
||||
|
||||
UIEditorPropertyGridFieldLocation FindUIEditorPropertyGridFieldLocation(
|
||||
const std::vector<UIEditorPropertyGridSection>& sections,
|
||||
std::string_view fieldId);
|
||||
|
||||
std::size_t FindUIEditorPropertyGridVisibleFieldIndex(
|
||||
const UIEditorPropertyGridLayout& layout,
|
||||
std::string_view fieldId,
|
||||
const std::vector<UIEditorPropertyGridSection>& sections);
|
||||
|
||||
UIEditorPropertyGridLayout BuildUIEditorPropertyGridLayout(
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const std::vector<UIEditorPropertyGridSection>& sections,
|
||||
const ::XCEngine::UI::Widgets::UIExpansionModel& expansionModel,
|
||||
const UIEditorPropertyGridMetrics& metrics = {});
|
||||
|
||||
UIEditorPropertyGridHitTarget HitTestUIEditorPropertyGrid(
|
||||
const UIEditorPropertyGridLayout& layout,
|
||||
const ::XCEngine::UI::UIPoint& point);
|
||||
|
||||
void AppendUIEditorPropertyGridBackground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorPropertyGridLayout& layout,
|
||||
const std::vector<UIEditorPropertyGridSection>& sections,
|
||||
const ::XCEngine::UI::Widgets::UISelectionModel& selectionModel,
|
||||
const ::XCEngine::UI::Widgets::UIPropertyEditModel& propertyEditModel,
|
||||
const UIEditorPropertyGridState& state,
|
||||
const UIEditorPropertyGridPalette& palette = {},
|
||||
const UIEditorPropertyGridMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorPropertyGridForeground(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const UIEditorPropertyGridLayout& layout,
|
||||
const std::vector<UIEditorPropertyGridSection>& sections,
|
||||
const ::XCEngine::UI::Widgets::UIPropertyEditModel& propertyEditModel,
|
||||
const UIEditorPropertyGridPalette& palette = {},
|
||||
const UIEditorPropertyGridMetrics& metrics = {});
|
||||
|
||||
void AppendUIEditorPropertyGrid(
|
||||
::XCEngine::UI::UIDrawList& drawList,
|
||||
const ::XCEngine::UI::UIRect& bounds,
|
||||
const std::vector<UIEditorPropertyGridSection>& sections,
|
||||
const ::XCEngine::UI::Widgets::UISelectionModel& selectionModel,
|
||||
const ::XCEngine::UI::Widgets::UIExpansionModel& expansionModel,
|
||||
const ::XCEngine::UI::Widgets::UIPropertyEditModel& propertyEditModel,
|
||||
const UIEditorPropertyGridState& state,
|
||||
const UIEditorPropertyGridPalette& palette = {},
|
||||
const UIEditorPropertyGridMetrics& metrics = {});
|
||||
|
||||
} // namespace XCEngine::UI::Editor::Widgets
|
||||
Reference in New Issue
Block a user