mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-01 17:20:09 -06:00
Enable rendering of IVecX properties in the GuiPropertyComponent
This commit is contained in:
@@ -39,6 +39,9 @@ void renderOptionProperty(properties::Property* prop, const std::string& ownerNa
|
||||
void renderSelectionProperty(properties::Property* prop, const std::string& ownerName);
|
||||
void renderStringProperty(properties::Property* prop, const std::string& ownerName);
|
||||
void renderIntProperty(properties::Property* prop, const std::string& ownerName);
|
||||
void renderIVec2Property(properties::Property* prop, const std::string& ownerName);
|
||||
void renderIVec3Property(properties::Property* prop, const std::string& ownerName);
|
||||
void renderIVec4Property(properties::Property* prop, const std::string& ownerName);
|
||||
void renderFloatProperty(properties::Property* prop, const std::string& ownerName);
|
||||
void renderVec2Property(properties::Property* prop, const std::string& ownerName);
|
||||
void renderVec3Property(properties::Property* prop, const std::string& ownerName);
|
||||
|
||||
@@ -135,6 +135,9 @@ void GuiPropertyComponent::renderProperty(properties::Property* prop, properties
|
||||
static std::map<std::string, Func> FunctionMapping = {
|
||||
{ "BoolProperty", &renderBoolProperty },
|
||||
{ "IntProperty", &renderIntProperty },
|
||||
{ "IVec2Property", &renderIVec2Property },
|
||||
{ "IVec3Property", &renderIVec3Property },
|
||||
{ "IVec4Property", &renderIVec4Property },
|
||||
{ "FloatProperty", &renderFloatProperty },
|
||||
{ "Vec2Property", &renderVec2Property },
|
||||
{ "Vec3Property", &renderVec3Property },
|
||||
|
||||
@@ -172,6 +172,87 @@ void renderIntProperty(Property* prop, const std::string& ownerName) {
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
void renderIVec2Property(Property* prop, const std::string& ownerName) {
|
||||
IVec2Property* p = static_cast<IVec2Property*>(prop);
|
||||
std::string name = p->guiName();
|
||||
ImGui::PushID((ownerName + "." + name).c_str());
|
||||
|
||||
IVec2Property::ValueType value = *p;
|
||||
float min = std::min(p->minValue().x, p->minValue().y);
|
||||
float max = std::max(p->maxValue().x, p->maxValue().y);
|
||||
ImGui::SliderInt2(
|
||||
name.c_str(),
|
||||
&value.x,
|
||||
min,
|
||||
max
|
||||
);
|
||||
renderTooltip(prop);
|
||||
|
||||
if (value != p->value()) {
|
||||
executeScript(p->fullyQualifiedIdentifier(),
|
||||
"{" + std::to_string(value.x) + "," + std::to_string(value.y) + "}"
|
||||
);
|
||||
}
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
void renderIVec3Property(Property* prop, const std::string& ownerName) {
|
||||
IVec3Property* p = static_cast<IVec3Property*>(prop);
|
||||
std::string name = p->guiName();
|
||||
ImGui::PushID((ownerName + "." + name).c_str());
|
||||
|
||||
IVec3Property::ValueType value = *p;
|
||||
float min = std::min(std::min(p->minValue().x, p->minValue().y), p->minValue().z);
|
||||
float max = std::max(std::max(p->maxValue().x, p->maxValue().y), p->maxValue().z);
|
||||
|
||||
ImGui::SliderInt3(
|
||||
name.c_str(),
|
||||
&value.x,
|
||||
min,
|
||||
max
|
||||
);
|
||||
renderTooltip(prop);
|
||||
|
||||
if (value != p->value())
|
||||
executeScript(p->fullyQualifiedIdentifier(),
|
||||
"{" + std::to_string(value.x) + "," +
|
||||
std::to_string(value.y) + "," +
|
||||
std::to_string(value.z) + "}");
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
void renderIVec4Property(Property* prop, const std::string& ownerName) {
|
||||
IVec4Property* p = static_cast<IVec4Property*>(prop);
|
||||
std::string name = p->guiName();
|
||||
ImGui::PushID((ownerName + "." + name).c_str());
|
||||
|
||||
IVec4Property::ValueType value = *p;
|
||||
float min = std::min(std::min(std::min(
|
||||
p->minValue().x, p->minValue().y), p->minValue().z), p->minValue().w);
|
||||
float max = std::max(std::max(std::max(
|
||||
p->maxValue().x, p->maxValue().y), p->maxValue().z), p->maxValue().w);
|
||||
|
||||
ImGui::SliderInt4(
|
||||
name.c_str(),
|
||||
&value.x,
|
||||
min,
|
||||
max
|
||||
);
|
||||
renderTooltip(prop);
|
||||
|
||||
if (value != p->value())
|
||||
executeScript(p->fullyQualifiedIdentifier(),
|
||||
"{" + std::to_string(value.x) + "," +
|
||||
std::to_string(value.y) + "," +
|
||||
std::to_string(value.z) + "," +
|
||||
std::to_string(value.w) + "}");
|
||||
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
|
||||
void renderFloatProperty(Property* prop, const std::string& ownerName) {
|
||||
FloatProperty* p = static_cast<FloatProperty*>(prop);
|
||||
std::string name = p->guiName();
|
||||
|
||||
Reference in New Issue
Block a user