TreeNode: Fixed nodes with ImGuiTreeNodeFlags_Leaf flag always returning true which was meaningless. Tweak demo.

This commit is contained in:
omar 2018-05-14 23:36:37 +02:00
parent 99ff6fc7e4
commit 640c056602
3 changed files with 6 additions and 9 deletions

View File

@ -44,6 +44,7 @@ Breaking Changes:
Other Changes:
- Nav: To keep the navigated item in view we also attempt to scroll the parent window as well as the current window. (#787)
- TreeNode: Fixed nodes with ImGuiTreeNodeFlags_Leaf flag always returning true which was meaningless.
-----------------------------------------------------------------------

View File

@ -8109,7 +8109,7 @@ void ImGui::LogButtons()
bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags)
{
if (flags & ImGuiTreeNodeFlags_Leaf)
return true;
return false;
// We only write to the tree storage if the user clicks (or explicitly use SetNextTreeNode*** functions)
ImGuiContext& g = *GImGui;

View File

@ -457,7 +457,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
else
{
// Leaf: The only reason we have a TreeNode at all is to allow selection of the leaf. Otherwise we can use BulletText() or TreeAdvanceToLabelPos()+Text().
node_flags |= ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen; // ImGuiTreeNodeFlags_Bullet
node_flags |= ImGuiTreeNodeFlags_Leaf; // | ImGuiTreeNodeFlags_Bullet;
ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Leaf %d", i);
if (ImGui::IsItemClicked())
node_clicked = i;
@ -3188,13 +3188,9 @@ static void ShowExampleAppPropertyEditor(bool* p_open)
}
else
{
// Here we use a TreeNode to highlight on hover (we could use e.g. Selectable as well)
ImGui::AlignTextToFramePadding();
// Here we use a Selectable (instead of Text) to highlight on hover
//ImGui::Text("Field_%d", i);
char label[32];
sprintf(label, "Field_%d", i);
ImGui::Bullet();
ImGui::Selectable(label);
ImGui::TreeNodeEx("Field", ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_Bullet, "Field_%d", i);
ImGui::NextColumn();
ImGui::PushItemWidth(-1);
if (i >= 5)