Skip to content

Commit

Permalink
fix imgui id confliction
Browse files Browse the repository at this point in the history
  • Loading branch information
T-rvw committed Feb 6, 2024
1 parent 35643c6 commit b2162f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions Engine/Source/Runtime/ImGui/ImGuiUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,13 @@ static bool ImGuiVectorProperty(const char* pName, T& value, cd::Unit unit = cd:

constexpr float labelIndetation = 10.0f;

ImGui::PushID(pName);
ImGui::Indent(labelIndetation);
ImGuiUtils::Text(pName, 0.8f);
ImGui::Unindent(labelIndetation);
ImGui::PushItemWidth(350);
ImGui::SameLine(100.0f);

//std::string metricName = std::format("%.2f{}", cd::GetUnitName(unit));
std::string metricName = "%.2f";
metricName += cd::GetUnitName(unit);
Expand Down Expand Up @@ -179,11 +180,15 @@ static bool ImGuiVectorProperty(const char* pName, T& value, cd::Unit unit = cd:
}

ImGui::PopItemWidth();
ImGui::PopID();

return dirty;
}

static bool ImGuiTransformProperty(const char* pName, cd::Transform& value)
{
ImGui::PushID(pName);

bool dirty = false;
if (ImGuiVectorProperty("Translation", value.GetTranslation()))
{
Expand Down Expand Up @@ -272,6 +277,7 @@ static bool ImGuiTransformProperty(const char* pName, cd::Transform& value)
ImGui::Checkbox("Uniform", &UniformScaleEnabled);
engine::TransformComponent::SetUseUniformScale(UniformScaleEnabled);
ImGui::Columns(1);
ImGui::PopID();

return dirty;
}
Expand All @@ -284,15 +290,15 @@ static void ColorPickerProperty(const char* pName, T& color)
{
showMap[pName] = false;
}

ImGui::PushID(pName);
ImGui::TextUnformatted(pName);
ImGui::SameLine();
ImGui::NextColumn();
ImGui::PushID(pName);
if (ImGui::Button("..."))
{
showMap[pName] = true;
}
ImGui::PopID();
ImGui::PushItemWidth(-1);
ImGui::SameLine();
ImGui::NextColumn();
Expand Down Expand Up @@ -331,6 +337,7 @@ static void ColorPickerProperty(const char* pName, T& color)
ImGui::End();
}
ImGui::Separator();
ImGui::PopID();
}

}

0 comments on commit b2162f3

Please sign in to comment.