132 lines
2.9 KiB
C
132 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 {
|
||
|
|
|
||
|
|
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, InspectorPropertyLabelWidth(), 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, InspectorPropertyLabelWidth(), step, min, max);
|
||
|
|
}
|
||
|
|
|
||
|
|
inline bool DrawPropertyBool(
|
||
|
|
const char* label,
|
||
|
|
bool& value
|
||
|
|
) {
|
||
|
|
return DrawBool(label, value, InspectorPropertyLabelWidth());
|
||
|
|
}
|
||
|
|
|
||
|
|
inline bool DrawPropertyColor3(
|
||
|
|
const char* label,
|
||
|
|
float color[3]
|
||
|
|
) {
|
||
|
|
return DrawColor3(label, color, InspectorPropertyLabelWidth());
|
||
|
|
}
|
||
|
|
|
||
|
|
inline bool DrawPropertyColor4(
|
||
|
|
const char* label,
|
||
|
|
float color[4]
|
||
|
|
) {
|
||
|
|
return DrawColor4(label, color, InspectorPropertyLabelWidth());
|
||
|
|
}
|
||
|
|
|
||
|
|
inline bool DrawPropertySliderFloat(
|
||
|
|
const char* label,
|
||
|
|
float& value,
|
||
|
|
float min,
|
||
|
|
float max,
|
||
|
|
const char* format = "%.2f"
|
||
|
|
) {
|
||
|
|
return DrawSliderFloat(label, value, min, max, InspectorPropertyLabelWidth(), format);
|
||
|
|
}
|
||
|
|
|
||
|
|
inline bool DrawPropertySliderInt(
|
||
|
|
const char* label,
|
||
|
|
int& value,
|
||
|
|
int min,
|
||
|
|
int max
|
||
|
|
) {
|
||
|
|
return DrawSliderInt(label, value, min, max, InspectorPropertyLabelWidth());
|
||
|
|
}
|
||
|
|
|
||
|
|
inline int DrawPropertyCombo(
|
||
|
|
const char* label,
|
||
|
|
int currentItem,
|
||
|
|
const char* const items[],
|
||
|
|
int itemCount,
|
||
|
|
int heightInItems = -1
|
||
|
|
) {
|
||
|
|
return DrawCombo(label, currentItem, items, itemCount, InspectorPropertyLabelWidth(), heightInItems);
|
||
|
|
}
|
||
|
|
|
||
|
|
inline bool DrawPropertyVec2(
|
||
|
|
const char* label,
|
||
|
|
::XCEngine::Math::Vector2& values,
|
||
|
|
float resetValue = 0.0f,
|
||
|
|
float dragSpeed = 0.1f
|
||
|
|
) {
|
||
|
|
return DrawVec2(label, values, resetValue, InspectorPropertyLabelWidth(), 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, InspectorPropertyLabelWidth(), dragSpeed, isActive);
|
||
|
|
}
|
||
|
|
|
||
|
|
inline bool DrawPropertyVec3Input(
|
||
|
|
const char* label,
|
||
|
|
::XCEngine::Math::Vector3& values,
|
||
|
|
float dragSpeed = 0.1f,
|
||
|
|
bool* isActive = nullptr
|
||
|
|
) {
|
||
|
|
return DrawVec3Input(label, values, InspectorPropertyLabelWidth(), dragSpeed, isActive);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|