Skip to content

Commit 1ca7c3a

Browse files
committed
add ability to create string parameters in UI
1 parent dbe6c6f commit 1ca7c3a

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

tsd/src/anari_tsd/Object.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ void TSDObject::commitParameters()
127127
tsd::core::Token(p.first), *obj->tsdObject());
128128
}
129129
}
130+
} else if (p.first == "name" && p.second.type() == ANARI_STRING) {
131+
object->setName(p.second.getString().c_str());
130132
} else if (p.second.type() != ANARI_UNKNOWN) {
131133
object->setParameter(
132134
tsd::core::Token(p.first), p.second.type(), p.second.data());

tsd/src/tsd/ui/imgui/tsd_ui_imgui.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,16 @@ static void buildUI_parameter_contextMenu(
109109
p->setUsage(tsd::core::ParameterUsageHint::NONE);
110110
p->setValue(tsd::math::int4(1));
111111
}
112-
ImGui::EndMenu(); // "float"
112+
ImGui::EndMenu(); // "int"
113+
}
114+
115+
ImGui::Separator();
116+
117+
if (ImGui::MenuItem("string")) {
118+
p->setUsage(tsd::core::ParameterUsageHint::NONE);
119+
p->setValue("");
120+
p->setStringSelection(0);
121+
p->setStringValues({});
113122
}
114123

115124
ImGui::EndMenu(); // "uniform"
@@ -537,8 +546,8 @@ bool buildUI_parameter(tsd::core::Object &o,
537546
: std::numeric_limits<float>::lowest();
538547
float maxLower = pMax ? pMax.get<tsd::math::box2>().lower.x
539548
: std::numeric_limits<float>::max();
540-
update |=
541-
ImGui::DragFloat2("lower", (float *)value, 1.f, minLower, maxLower);
549+
update |= ImGui::DragFloat2(
550+
"lower", (float *)value, 1.f, minLower, maxLower);
542551
float minUpper = pMin ? pMin.get<tsd::math::box2>().upper.x
543552
: std::numeric_limits<float>::lowest();
544553
float maxUpper = pMax ? pMax.get<tsd::math::box2>().upper.x
@@ -572,8 +581,8 @@ bool buildUI_parameter(tsd::core::Object &o,
572581
: std::numeric_limits<float>::lowest();
573582
float maxLower = pMax ? pMax.get<tsd::math::box3>().lower.x
574583
: std::numeric_limits<float>::max();
575-
update |=
576-
ImGui::DragFloat3("lower", (float *)value, 1.f, minLower, maxLower);
584+
update |= ImGui::DragFloat3(
585+
"lower", (float *)value, 1.f, minLower, maxLower);
577586
float minUpper = pMin ? pMin.get<tsd::math::box3>().upper.x
578587
: std::numeric_limits<float>::lowest();
579588
float maxUpper = pMax ? pMax.get<tsd::math::box3>().upper.x

0 commit comments

Comments
 (0)