Files
XCEngine/editor/src/UI/PropertyGrid.h

136 lines
2.9 KiB
C++

#pragma once
#include "Core/IUndoManager.h"
#include "ScalarControls.h"
#include "StyleTokens.h"
#include "VectorControls.h"
namespace XCEngine {
namespace Editor {
namespace UI {
inline PropertyLayoutSpec InspectorPropertyLayout() {
return MakePropertyLayout();
}
template <typename ApplyFn>
inline bool ApplyPropertyChange(
bool changedByWidget,
::XCEngine::Editor::IUndoManager* undoManager,
const char* undoLabel,
ApplyFn&& apply) {
if (!changedByWidget) {
return false;
}
if (undoManager) {
undoManager->BeginInteractiveChange(undoLabel);
}
apply();
return true;
}
inline bool DrawPropertyFloat(
const char* label,
float& value,
float dragSpeed = 0.1f,
float min = 0.0f,
float max = 0.0f,
const char* format = "%.2f"
) {
return DrawFloat(label, value, InspectorPropertyLayout(), dragSpeed, min, max, format);
}
inline bool DrawPropertyInt(
const char* label,
int& value,
int step = 1,
int min = 0,
int max = 0
) {
return DrawInt(label, value, InspectorPropertyLayout(), step, min, max);
}
inline bool DrawPropertyBool(
const char* label,
bool& value
) {
return DrawBool(label, value, InspectorPropertyLayout());
}
inline bool DrawPropertyColor3(
const char* label,
float color[3]
) {
return DrawColor3(label, color, InspectorPropertyLayout());
}
inline bool DrawPropertyColor4(
const char* label,
float color[4]
) {
return DrawColor4(label, color, InspectorPropertyLayout());
}
inline bool DrawPropertySliderFloat(
const char* label,
float& value,
float min,
float max,
const char* format = "%.2f"
) {
return DrawSliderFloat(label, value, min, max, InspectorPropertyLayout(), format);
}
inline bool DrawPropertySliderInt(
const char* label,
int& value,
int min,
int max
) {
return DrawSliderInt(label, value, min, max, InspectorPropertyLayout());
}
inline int DrawPropertyCombo(
const char* label,
int currentItem,
const char* const items[],
int itemCount,
int heightInItems = -1
) {
return DrawCombo(label, currentItem, items, itemCount, InspectorPropertyLayout(), heightInItems);
}
inline bool DrawPropertyVec2(
const char* label,
::XCEngine::Math::Vector2& values,
float resetValue = 0.0f,
float dragSpeed = 0.1f
) {
return DrawVec2(label, values, resetValue, InspectorPropertyLayout(), dragSpeed);
}
inline bool DrawPropertyVec3(
const char* label,
::XCEngine::Math::Vector3& values,
float resetValue = 0.0f,
float dragSpeed = 0.1f,
bool* isActive = nullptr
) {
return DrawVec3(label, values, resetValue, InspectorPropertyLayout(), dragSpeed, isActive);
}
inline bool DrawPropertyVec3Input(
const char* label,
::XCEngine::Math::Vector3& values,
float dragSpeed = 0.1f,
bool* isActive = nullptr
) {
return DrawVec3Input(label, values, InspectorPropertyLayout(), dragSpeed, isActive);
}
}
}
}