Skip to content

Commit

Permalink
Tidy up Imgui stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelOtter committed Aug 11, 2024
1 parent e7943e1 commit d1d1ea6
Showing 1 changed file with 30 additions and 22 deletions.
52 changes: 30 additions & 22 deletions src/scene/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,32 @@ Node* Node::addChild(std::unique_ptr<Node> node) {

void Node::populateDebugUI(Batch& batch) {
#ifdef GROWL_IMGUI
if (ImGui::TreeNodeEx(
getLabel().c_str(),
parent ? ImGuiTreeNodeFlags_None : ImGuiTreeNodeFlags_Framed)) {
ImGui::SliderFloat(
"X", &x, 0.0f, parent ? parent->getWidth() : batch.getTargetWidth(),
"%.2f");
ImGui::SliderFloat(
"Y", &y, 0.0f,
parent ? parent->getHeight() : batch.getTargetHeight(), "%.2f");
ImGui::SliderFloat(
"Width", &w, 0.0f,
parent ? parent->getWidth() : batch.getTargetWidth(), "%.2f");
ImGui::SliderFloat(
"Height", &h, 0.0f,
parent ? parent->getHeight() : batch.getTargetHeight(), "%.2f");
ImGui::SliderFloat(
"Rotation", &rotation, 0.0f, 2 * glm::pi<float>(), "%.2f");
if (ImGui::TreeNodeEx(getLabel().c_str(), ImGuiTreeNodeFlags_Framed)) {
if (ImGui::TreeNodeEx("Node", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SliderFloat(
"X", &x, 0.0f,
parent ? parent->getWidth() : batch.getTargetWidth(), "%.2f");
ImGui::SliderFloat(
"Y", &y, 0.0f,
parent ? parent->getHeight() : batch.getTargetHeight(), "%.2f");
ImGui::SliderFloat(
"Width", &w, 0.0f,
parent ? parent->getWidth() : batch.getTargetWidth(), "%.2f");
ImGui::SliderFloat(
"Height", &h, 0.0f,
parent ? parent->getHeight() : batch.getTargetHeight(), "%.2f");
ImGui::SliderFloat(
"Rotation", &rotation, 0.0f, 2 * glm::pi<float>(), "%.2f");

onPopulateDebugUI(batch);
ImGui::TreePop();
}

if (script && ImGui::TreeNode("Script")) {
ImGui::InputTextMultiline("##source", &(script->getSource()));
ImGui::InputTextMultiline(
"##source", &(script->getSource()),
ImVec2(-1, ImGui::GetTextLineHeight() * 16),
ImGuiInputTextFlags_AllowTabInput);
if (ImGui::Button("Save")) {
if (auto err = bindScript(*api, *script)) {
api->system().log(
Expand All @@ -60,10 +67,11 @@ void Node::populateDebugUI(Batch& batch) {
ImGui::TreePop();
}

onPopulateDebugUI(batch);

for (auto& child : children) {
child->populateDebugUI(batch);
if (!children.empty() && ImGui::TreeNode("Children")) {
for (auto& child : children) {
child->populateDebugUI(batch);
}
ImGui::TreePop();
}

ImGui::TreePop();
Expand Down

0 comments on commit d1d1ea6

Please sign in to comment.