Demo: Improved trees in columns demo. (#2136)

This commit is contained in:
omar 2019-05-02 20:19:53 +02:00
parent ce19cb465f
commit 86f92fe756
3 changed files with 33 additions and 9 deletions

View File

@ -89,6 +89,7 @@ Other Changes:
- Misc: Added IM_MALLOC/IM_FREE macros mimicking IM_NEW/IM_DELETE so user doesn't need to revert
to using the ImGui::MemAlloc()/MemFree() calls directly.
- Metrics: Added "Show windows rectangles" tool to visualize the different rectangles.
- Demo: Improved trees in columns demo.
- Examples: OpenGL: Added a dummy GL call + comments in ImGui_ImplOpenGL3_Init() to detect uninitialized
GL function loaders early, and help users understand what they are missing. (#2421)
- Examples: Emscripten: Added Emscripten+SDL+GLES2 example. (#2494, #2492, #2351, #336) [@nicolasnoble, @redblobgames]

View File

@ -2545,16 +2545,39 @@ static void ShowDemoWindowColumns()
ImGui::TreePop();
}
bool node_open = ImGui::TreeNode("Tree within single cell");
ImGui::SameLine(); HelpMarker("NB: Tree node must be poped before ending the cell. There's no storage of state per-cell.");
if (node_open)
if (ImGui::TreeNode("Tree"))
{
ImGui::Columns(2, "tree items");
ImGui::Separator();
if (ImGui::TreeNode("Hello")) { ImGui::BulletText("Sailor"); ImGui::TreePop(); } ImGui::NextColumn();
if (ImGui::TreeNode("Bonjour")) { ImGui::BulletText("Marin"); ImGui::TreePop(); } ImGui::NextColumn();
ImGui::Columns(2, "tree", true);
for (int x = 0; x < 3; x++)
{
bool open1 = ImGui::TreeNode((void*)(intptr_t)x, "Node%d", x);
ImGui::NextColumn();
ImGui::Text("Node contents");
ImGui::NextColumn();
if (open1)
{
for (int y = 0; y < 5; y++)
{
bool open2 = ImGui::TreeNode((void*)(intptr_t)y, "Node%d.%d", x, y);
ImGui::NextColumn();
ImGui::Text("Node contents");
if (open2)
{
ImGui::Text("Even more contents");
if (ImGui::TreeNode("Tree in column"))
{
ImGui::Text("The quick brown fox jumps over the lazy dog");
ImGui::TreePop();
}
}
ImGui::NextColumn();
if (open2)
ImGui::TreePop();
}
ImGui::TreePop();
}
}
ImGui::Columns(1);
ImGui::Separator();
ImGui::TreePop();
}

View File

@ -346,7 +346,7 @@ enum ImGuiSelectableFlagsPrivate_
ImGuiSelectableFlags_NoHoldingActiveID = 1 << 10,
ImGuiSelectableFlags_PressedOnClick = 1 << 11,
ImGuiSelectableFlags_PressedOnRelease = 1 << 12,
ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 13,
ImGuiSelectableFlags_DrawFillAvailWidth = 1 << 13, // FIXME: We may be able to remove this (added in 6251d379 for menus)
ImGuiSelectableFlags_AllowItemOverlap = 1 << 14
};