2026-03-24 20:02:38 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
2026-03-26 21:18:33 +08:00
|
|
|
#include "Core.h"
|
2026-03-24 20:02:38 +08:00
|
|
|
#include <imgui.h>
|
|
|
|
|
|
|
|
|
|
namespace XCEngine {
|
|
|
|
|
namespace Editor {
|
|
|
|
|
namespace UI {
|
|
|
|
|
|
|
|
|
|
inline bool DrawFloat(
|
|
|
|
|
const char* label,
|
|
|
|
|
float& value,
|
2026-03-26 21:18:33 +08:00
|
|
|
float columnWidth = DefaultControlLabelWidth(),
|
2026-03-24 20:02:38 +08:00
|
|
|
float dragSpeed = 0.1f,
|
|
|
|
|
float min = 0.0f,
|
|
|
|
|
float max = 0.0f,
|
|
|
|
|
const char* format = "%.2f"
|
|
|
|
|
) {
|
2026-03-26 21:18:33 +08:00
|
|
|
return DrawControlRow(label, columnWidth, [&]() {
|
|
|
|
|
return ImGui::DragFloat("##value", &value, dragSpeed, min, max, format);
|
|
|
|
|
});
|
2026-03-24 20:02:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool DrawInt(
|
|
|
|
|
const char* label,
|
|
|
|
|
int& value,
|
2026-03-26 21:18:33 +08:00
|
|
|
float columnWidth = DefaultControlLabelWidth(),
|
2026-03-24 20:02:38 +08:00
|
|
|
int step = 1,
|
|
|
|
|
int min = 0,
|
|
|
|
|
int max = 0
|
|
|
|
|
) {
|
2026-03-26 21:18:33 +08:00
|
|
|
return DrawControlRow(label, columnWidth, [&]() {
|
|
|
|
|
return ImGui::DragInt("##value", &value, static_cast<float>(step), min, max);
|
|
|
|
|
});
|
2026-03-24 20:02:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool DrawBool(
|
|
|
|
|
const char* label,
|
|
|
|
|
bool& value,
|
2026-03-26 21:18:33 +08:00
|
|
|
float columnWidth = DefaultControlLabelWidth()
|
2026-03-24 20:02:38 +08:00
|
|
|
) {
|
2026-03-26 21:18:33 +08:00
|
|
|
return DrawControlRow(label, columnWidth, [&]() {
|
|
|
|
|
return ImGui::Checkbox("##value", &value);
|
|
|
|
|
});
|
2026-03-24 20:02:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool DrawColor3(
|
|
|
|
|
const char* label,
|
|
|
|
|
float color[3],
|
2026-03-26 21:18:33 +08:00
|
|
|
float columnWidth = DefaultControlLabelWidth()
|
2026-03-24 20:02:38 +08:00
|
|
|
) {
|
2026-03-26 21:18:33 +08:00
|
|
|
return DrawControlRow(label, columnWidth, [&]() {
|
|
|
|
|
return ImGui::ColorEdit3("##value", color, ImGuiColorEditFlags_NoInputs);
|
|
|
|
|
});
|
2026-03-24 20:02:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool DrawColor4(
|
|
|
|
|
const char* label,
|
|
|
|
|
float color[4],
|
2026-03-26 21:18:33 +08:00
|
|
|
float columnWidth = DefaultControlLabelWidth()
|
2026-03-24 20:02:38 +08:00
|
|
|
) {
|
2026-03-26 21:18:33 +08:00
|
|
|
return DrawControlRow(label, columnWidth, [&]() {
|
|
|
|
|
return ImGui::ColorEdit4("##value", color, ImGuiColorEditFlags_NoInputs);
|
|
|
|
|
});
|
2026-03-24 20:02:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool DrawSliderFloat(
|
|
|
|
|
const char* label,
|
|
|
|
|
float& value,
|
|
|
|
|
float min,
|
|
|
|
|
float max,
|
2026-03-26 21:18:33 +08:00
|
|
|
float columnWidth = DefaultControlLabelWidth(),
|
2026-03-24 20:02:38 +08:00
|
|
|
const char* format = "%.2f"
|
|
|
|
|
) {
|
2026-03-26 21:18:33 +08:00
|
|
|
return DrawControlRow(label, columnWidth, [&]() {
|
|
|
|
|
return ImGui::SliderFloat("##value", &value, min, max, format);
|
|
|
|
|
});
|
2026-03-24 20:02:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool DrawSliderInt(
|
|
|
|
|
const char* label,
|
|
|
|
|
int& value,
|
|
|
|
|
int min,
|
|
|
|
|
int max,
|
2026-03-26 21:18:33 +08:00
|
|
|
float columnWidth = DefaultControlLabelWidth()
|
2026-03-24 20:02:38 +08:00
|
|
|
) {
|
2026-03-26 21:18:33 +08:00
|
|
|
return DrawControlRow(label, columnWidth, [&]() {
|
|
|
|
|
return ImGui::SliderInt("##value", &value, min, max);
|
|
|
|
|
});
|
2026-03-24 20:02:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline int DrawCombo(
|
|
|
|
|
const char* label,
|
|
|
|
|
int currentItem,
|
|
|
|
|
const char* const items[],
|
|
|
|
|
int itemCount,
|
2026-03-26 21:18:33 +08:00
|
|
|
float columnWidth = DefaultControlLabelWidth(),
|
2026-03-24 20:02:38 +08:00
|
|
|
int heightInItems = -1
|
|
|
|
|
) {
|
|
|
|
|
int changedItem = currentItem;
|
2026-03-26 21:18:33 +08:00
|
|
|
DrawControlRow(label, columnWidth, [&]() {
|
2026-03-24 20:02:38 +08:00
|
|
|
ImGui::SetNextItemWidth(-1);
|
|
|
|
|
if (ImGui::Combo("##value", ¤tItem, items, itemCount, heightInItems)) {
|
|
|
|
|
changedItem = currentItem;
|
|
|
|
|
}
|
2026-03-26 21:18:33 +08:00
|
|
|
return false;
|
|
|
|
|
});
|
2026-03-24 20:02:38 +08:00
|
|
|
return changedItem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|