ImGUI labels need to be unique


#1

Hi,

In ImGUI, if you have two UI elements with the same label, editing UI element 1 will also change the value of UI element 2 if both are visible.

In NAP’s ParameterGui, this problem will occur if two parameters have the same display name.

A simple way to solve this would be to set the label to (parameter->getDisplayName() + "##" + parameter->mID) instead of parameter->getDisplayName().

See also ‘Solving ID conflict’ in ImGUI’s FAQ: https://github.com/ocornut/imgui/blob/master/docs/FAQ.md

Casi


#2

Better is to use ImGui::PushID(&parameter) and a matching PopID, to avoid all of these temporary strings from being created and concatenated, which has a serious performance impact.


#3

yup, pushID seems like the right way to do this. i’ll submit an issue.


#4

This has been fixed in the Vulkan branch, together with rendering a GUI to multiple viewports. Will be part of the 0.4 NAP release