mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-24 15:50:25 +01:00
parent
9733f4fa24
commit
bb674ccee6
10
imgui.cpp
10
imgui.cpp
@ -5600,6 +5600,9 @@ void ImGui::LogButtons()
|
||||
|
||||
bool ImGui::TreeNodeBehaviorIsOpened(ImGuiID id, ImGuiTreeNodeFlags flags)
|
||||
{
|
||||
if (flags & ImGuiTreeNodeFlags_AlwaysOpen)
|
||||
return true;
|
||||
|
||||
// We only write to the tree storage if the user clicks (or explicitely use SetNextTreeNode*** functions)
|
||||
ImGuiState& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
@ -5692,7 +5695,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick)
|
||||
button_flags |= ImGuiButtonFlags_PressedOnDoubleClick | ((flags & ImGuiTreeNodeFlags_OpenOnArrow) ? ImGuiButtonFlags_PressedOnClickRelease : 0);
|
||||
bool hovered, held, pressed = ButtonBehavior(interact_bb, id, &hovered, &held, button_flags);
|
||||
if (pressed)
|
||||
if (pressed && !(flags & ImGuiTreeNodeFlags_AlwaysOpen))
|
||||
{
|
||||
bool toggled = !(flags & (ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick));
|
||||
if (flags & ImGuiTreeNodeFlags_OpenOnArrow)
|
||||
@ -5736,7 +5739,10 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
if (hovered || (flags & ImGuiTreeNodeFlags_Selected))
|
||||
RenderFrame(bb.Min, bb.Max, col, false);
|
||||
|
||||
RenderCollapseTriangle(bb.Min + ImVec2(padding.x, g.FontSize*0.15f + text_base_offset_y), opened, 0.70f, false);
|
||||
if (flags & ImGuiTreeNodeFlags_AlwaysOpen)
|
||||
RenderBullet(bb.Min + ImVec2((padding.x + collapser_width) * 0.5f, g.FontSize*0.50f + text_base_offset_y));
|
||||
else
|
||||
RenderCollapseTriangle(bb.Min + ImVec2(padding.x, g.FontSize*0.15f + text_base_offset_y), opened, 0.70f, false);
|
||||
if (g.LogEnabled)
|
||||
LogRenderedText(text_pos, ">");
|
||||
RenderText(text_pos, label, label_end, false);
|
||||
|
4
imgui.h
4
imgui.h
@ -532,7 +532,7 @@ enum ImGuiTreeNodeFlags_
|
||||
ImGuiTreeNodeFlags_DefaultOpen = 1 << 5, // Default node to be opened
|
||||
ImGuiTreeNodeFlags_OpenOnDoubleClick = 1 << 6, // Need double-click to open node
|
||||
ImGuiTreeNodeFlags_OpenOnArrow = 1 << 7, // Only open when clicking on the arrow part. If ImGuiTreeNodeFlags_OpenOnDoubleClick is also set, single-click arrow or double-click all box to open.
|
||||
//ImGuiTreeNodeFlags_AlwaysOpen = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes).
|
||||
ImGuiTreeNodeFlags_AlwaysOpen = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes).
|
||||
//ImGuiTreeNodeFlags_UnindentArrow = 1 << 9, // FIXME: TODO: Unindent tree so that Label is aligned to current X position
|
||||
//ImGuITreeNodeFlags_SpanAllAvailWidth = 1 << 10, // FIXME: TODO: Extend hit box horizontally even if not framed
|
||||
//ImGuiTreeNodeFlags_NoScrollOnOpen = 1 << 11, // FIXME: TODO: Automatically scroll on TreePop() if node got just opened and contents is not visible
|
||||
@ -695,7 +695,7 @@ struct ImGuiStyle
|
||||
ImVec2 ItemSpacing; // Horizontal and vertical spacing between widgets/lines
|
||||
ImVec2 ItemInnerSpacing; // Horizontal and vertical spacing between within elements of a composed widget (e.g. a slider and its label)
|
||||
ImVec2 TouchExtraPadding; // Expand reactive bounding box for touch-based system where touch position is not accurate enough. Unfortunately we don't sort widgets so priority on overlap will always be given to the first widget. So don't grow this too much!
|
||||
float IndentSpacing; // Horizontal indentation when e.g. entering a tree node
|
||||
float IndentSpacing; // Horizontal indentation when e.g. entering a tree node. Generally == (FontSize + FramePadding.x*2)
|
||||
float ColumnsMinSpacing; // Minimum horizontal spacing between two columns
|
||||
float ScrollbarSize; // Width of the vertical scrollbar, Height of the horizontal scrollbar
|
||||
float ScrollbarRounding; // Radius of grab corners for scrollbar
|
||||
|
@ -291,11 +291,14 @@ void ImGui::ShowTestWindow(bool* p_opened)
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
ImGuiTreeNodeFlags node_flags = ((selection_mask & (1 << i)) ? ImGuiTreeNodeFlags_Selected : 0) | ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick;
|
||||
bool opened = ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Child %d", i);
|
||||
if (i >= 3)
|
||||
node_flags |= ImGuiTreeNodeFlags_AlwaysOpen;
|
||||
bool opened = ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable %s %d", (i >= 3) ? "Leaf" : "Node", i);
|
||||
if (ImGui::IsItemClicked())
|
||||
node_clicked = i;
|
||||
if (opened)
|
||||
{
|
||||
ImGui::Text("Blah blah");
|
||||
ImGui::Text("Blah blah");
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user