|
@@ -5177,29 +5177,36 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|
const ImVec2 label_size = CalcTextSize(label, label_end, false);
|
|
const ImVec2 label_size = CalcTextSize(label, label_end, false);
|
|
|
|
|
|
// We vertically grow up to current line height up the typical widget height.
|
|
// We vertically grow up to current line height up the typical widget height.
|
|
- const float text_base_offset_y = ImMax(padding.y, window->DC.CurrLineTextBaseOffset); // Latch before ItemSize changes it
|
|
|
|
const float frame_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + style.FramePadding.y*2), label_size.y + padding.y*2);
|
|
const float frame_height = ImMax(ImMin(window->DC.CurrLineSize.y, g.FontSize + style.FramePadding.y*2), label_size.y + padding.y*2);
|
|
- ImRect frame_bb = ImRect(window->DC.CursorPos, ImVec2(window->WorkRect.Max.x, window->DC.CursorPos.y + frame_height));
|
|
|
|
|
|
+ ImRect frame_bb;
|
|
|
|
+ frame_bb.Min.x = (flags & ImGuiTreeNodeFlags_SpanFullWidth) ? window->WorkRect.Min.x : window->DC.CursorPos.x;
|
|
|
|
+ frame_bb.Min.y = window->DC.CursorPos.y;
|
|
|
|
+ frame_bb.Max.x = window->WorkRect.Max.x;
|
|
|
|
+ frame_bb.Max.y = window->DC.CursorPos.y + frame_height;
|
|
if (display_frame)
|
|
if (display_frame)
|
|
{
|
|
{
|
|
- // Framed header expand a little outside the default padding
|
|
|
|
|
|
+ // Framed header expand a little outside the default padding, to the edge of InnerClipRect
|
|
|
|
+ // (FIXME: May remove this at some point and make InnerClipRect align with WindowPadding.x instead of WindowPadding.x*0.5f)
|
|
frame_bb.Min.x -= (float)(int)(window->WindowPadding.x * 0.5f - 1.0f);
|
|
frame_bb.Min.x -= (float)(int)(window->WindowPadding.x * 0.5f - 1.0f);
|
|
frame_bb.Max.x += (float)(int)(window->WindowPadding.x * 0.5f);
|
|
frame_bb.Max.x += (float)(int)(window->WindowPadding.x * 0.5f);
|
|
}
|
|
}
|
|
|
|
|
|
- const float text_offset_x = (g.FontSize + (display_frame ? padding.x*3 : padding.x*2)); // Collapser arrow width + Spacing
|
|
|
|
- const float text_width = g.FontSize + (label_size.x > 0.0f ? label_size.x + padding.x*2 : 0.0f); // Include collapser
|
|
|
|
- ItemSize(ImVec2(text_width, frame_height), text_base_offset_y);
|
|
|
|
|
|
+ const float text_offset_x = g.FontSize + (display_frame ? padding.x*3 : padding.x*2); // Collapser arrow width + Spacing
|
|
|
|
+ const float text_offset_y = ImMax(padding.y, window->DC.CurrLineTextBaseOffset); // Latch before ItemSize changes it
|
|
|
|
+ const float text_width = g.FontSize + (label_size.x > 0.0f ? label_size.x + padding.x*2 : 0.0f); // Include collapser
|
|
|
|
+ const ImVec2 text_pos(window->DC.CursorPos.x + text_offset_x, window->DC.CursorPos.y + text_offset_y);
|
|
|
|
+ ItemSize(ImVec2(text_width, frame_height), text_offset_y);
|
|
|
|
|
|
// For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing
|
|
// For regular tree nodes, we arbitrary allow to click past 2 worth of ItemSpacing
|
|
- // (Ideally we'd want to add a flag for the user to specify if we want the hit test to be done up to the right side of the content or not)
|
|
|
|
- const ImRect interact_bb = display_frame ? frame_bb : ImRect(frame_bb.Min.x, frame_bb.Min.y, frame_bb.Min.x + text_width + style.ItemSpacing.x*2, frame_bb.Max.y);
|
|
|
|
- bool is_open = TreeNodeBehaviorIsOpen(id, flags);
|
|
|
|
- bool is_leaf = (flags & ImGuiTreeNodeFlags_Leaf) != 0;
|
|
|
|
-
|
|
|
|
|
|
+ ImRect interact_bb = frame_bb;
|
|
|
|
+ if (!display_frame && (flags & (ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_SpanFullWidth)) == 0)
|
|
|
|
+ interact_bb.Max.x = frame_bb.Min.x + text_width + style.ItemSpacing.x * 2.0f;
|
|
|
|
+
|
|
// Store a flag for the current depth to tell if we will allow closing this node when navigating one of its child.
|
|
// Store a flag for the current depth to tell if we will allow closing this node when navigating one of its child.
|
|
// For this purpose we essentially compare if g.NavIdIsAlive went from 0 to 1 between TreeNode() and TreePop().
|
|
// For this purpose we essentially compare if g.NavIdIsAlive went from 0 to 1 between TreeNode() and TreePop().
|
|
// This is currently only support 32 level deep and we are fine with (1 << Depth) overflowing into a zero.
|
|
// This is currently only support 32 level deep and we are fine with (1 << Depth) overflowing into a zero.
|
|
|
|
+ const bool is_leaf = (flags & ImGuiTreeNodeFlags_Leaf) != 0;
|
|
|
|
+ bool is_open = TreeNodeBehaviorIsOpen(id, flags);
|
|
if (is_open && !g.NavIdIsAlive && (flags & ImGuiTreeNodeFlags_NavLeftJumpsBackHere) && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
|
|
if (is_open && !g.NavIdIsAlive && (flags & ImGuiTreeNodeFlags_NavLeftJumpsBackHere) && !(flags & ImGuiTreeNodeFlags_NoTreePushOnOpen))
|
|
window->DC.TreeStoreMayJumpToParentOnPop |= (1 << window->DC.TreeDepth);
|
|
window->DC.TreeStoreMayJumpToParentOnPop |= (1 << window->DC.TreeDepth);
|
|
|
|
|
|
@@ -5273,7 +5280,6 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|
|
|
|
|
// Render
|
|
// Render
|
|
const ImU32 text_col = GetColorU32(ImGuiCol_Text);
|
|
const ImU32 text_col = GetColorU32(ImGuiCol_Text);
|
|
- const ImVec2 text_pos = frame_bb.Min + ImVec2(text_offset_x, text_base_offset_y);
|
|
|
|
ImGuiNavHighlightFlags nav_highlight_flags = ImGuiNavHighlightFlags_TypeThin;
|
|
ImGuiNavHighlightFlags nav_highlight_flags = ImGuiNavHighlightFlags_TypeThin;
|
|
if (display_frame)
|
|
if (display_frame)
|
|
{
|
|
{
|
|
@@ -5281,7 +5287,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|
const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header);
|
|
const ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_HeaderActive : hovered ? ImGuiCol_HeaderHovered : ImGuiCol_Header);
|
|
RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, true, style.FrameRounding);
|
|
RenderFrame(frame_bb.Min, frame_bb.Max, bg_col, true, style.FrameRounding);
|
|
RenderNavHighlight(frame_bb, id, nav_highlight_flags);
|
|
RenderNavHighlight(frame_bb, id, nav_highlight_flags);
|
|
- RenderArrow(window->DrawList, frame_bb.Min + ImVec2(padding.x, text_base_offset_y), text_col, is_open ? ImGuiDir_Down : ImGuiDir_Right, 1.0f);
|
|
|
|
|
|
+ RenderArrow(window->DrawList, ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y), text_col, is_open ? ImGuiDir_Down : ImGuiDir_Right, 1.0f);
|
|
if (flags & ImGuiTreeNodeFlags_ClipLabelForTrailingButton)
|
|
if (flags & ImGuiTreeNodeFlags_ClipLabelForTrailingButton)
|
|
frame_bb.Max.x -= g.FontSize + style.FramePadding.x;
|
|
frame_bb.Max.x -= g.FontSize + style.FramePadding.x;
|
|
if (g.LogEnabled)
|
|
if (g.LogEnabled)
|
|
@@ -5309,9 +5315,9 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|
}
|
|
}
|
|
|
|
|
|
if (flags & ImGuiTreeNodeFlags_Bullet)
|
|
if (flags & ImGuiTreeNodeFlags_Bullet)
|
|
- RenderBullet(window->DrawList, frame_bb.Min + ImVec2(text_offset_x * 0.5f, g.FontSize*0.50f + text_base_offset_y), text_col);
|
|
|
|
|
|
+ RenderBullet(window->DrawList, ImVec2(text_pos.x - text_offset_x * 0.5f, text_pos.y + g.FontSize*0.50f), text_col);
|
|
else if (!is_leaf)
|
|
else if (!is_leaf)
|
|
- RenderArrow(window->DrawList, frame_bb.Min + ImVec2(padding.x, g.FontSize*0.15f + text_base_offset_y), text_col, is_open ? ImGuiDir_Down : ImGuiDir_Right, 0.70f);
|
|
|
|
|
|
+ RenderArrow(window->DrawList, ImVec2(text_pos.x - text_offset_x + padding.x, text_pos.y + g.FontSize*0.15f), text_col, is_open ? ImGuiDir_Down : ImGuiDir_Right, 0.70f);
|
|
if (g.LogEnabled)
|
|
if (g.LogEnabled)
|
|
LogRenderedText(&text_pos, ">");
|
|
LogRenderedText(&text_pos, ">");
|
|
RenderText(text_pos, label, label_end, false);
|
|
RenderText(text_pos, label, label_end, false);
|