@@ -6868,6 +6868,33 @@ void ImGui::TreeNodeDrawLineToChildNode(const ImVec2& target_pos)
6868
6868
window->DrawList->AddLine(ImVec2(x1, y), ImVec2(x2, y), GetColorU32(ImGuiCol_TreeLines), g.Style.TreeLinesSize);
6869
6869
}
6870
6870
6871
+ // Draw vertical line of the hierarchy
6872
+ void ImGui::TreeNodeDrawLineToTreePop(const ImGuiTreeNodeStackData* data)
6873
+ {
6874
+ ImGuiContext& g = *GImGui;
6875
+ ImGuiWindow* window = g.CurrentWindow;
6876
+ float y1 = ImMax(data->NavRect.Max.y, window->ClipRect.Min.y);
6877
+ float y2 = data->DrawLinesToNodesY2;
6878
+ if (data->TreeFlags & ImGuiTreeNodeFlags_DrawLinesFull)
6879
+ {
6880
+ float y2_full = window->DC.CursorPos.y;
6881
+ if (g.CurrentTable)
6882
+ y2_full = ImMax(g.CurrentTable->RowPosY2, y2_full);
6883
+ y2_full = ImTrunc(y2_full - g.Style.ItemSpacing.y - g.FontSize * 0.5f);
6884
+ if (y2 + g.Style.ItemSpacing.y < y2_full) // FIXME: threshold to use ToNodes Y2 instead of Full Y2 when close by ItemSpacing.y
6885
+ y2 = y2_full;
6886
+ }
6887
+ y2 = ImMin(y2, window->ClipRect.Max.y);
6888
+ if (y2 <= y1)
6889
+ return;
6890
+ float x = ImTrunc(data->DrawLinesX1);
6891
+ if (data->DrawLinesTableColumn != -1)
6892
+ TablePushColumnChannel(data->DrawLinesTableColumn);
6893
+ window->DrawList->AddLine(ImVec2(x, y1), ImVec2(x, y2), GetColorU32(ImGuiCol_TreeLines), g.Style.TreeLinesSize);
6894
+ if (data->DrawLinesTableColumn != -1)
6895
+ TablePopColumnChannel();
6896
+ }
6897
+
6871
6898
void ImGui::TreePush(const char* str_id)
6872
6899
{
6873
6900
ImGuiWindow* window = GetCurrentWindow();
@@ -6906,37 +6933,16 @@ void ImGui::TreePop()
6906
6933
{
6907
6934
const ImGuiTreeNodeStackData* data = &g.TreeNodeStack.Data[g.TreeNodeStack.Size - 1];
6908
6935
IM_ASSERT(data->ID == window->IDStack.back());
6936
+
6937
+ // Handle Left arrow to move to parent tree node (when ImGuiTreeNodeFlags_NavLeftJumpsBackHere is enabled)
6909
6938
if (data->TreeFlags & ImGuiTreeNodeFlags_NavLeftJumpsBackHere)
6910
- {
6911
- // Handle Left arrow to move to parent tree node (when ImGuiTreeNodeFlags_NavLeftJumpsBackHere is enabled)
6912
6939
if (g.NavIdIsAlive && g.NavMoveDir == ImGuiDir_Left && g.NavWindow == window && NavMoveRequestButNoResultYet())
6913
6940
NavMoveRequestResolveWithPastTreeNode(&g.NavMoveResultLocal, data);
6914
- }
6941
+
6942
+ // Draw hierarchy lines
6915
6943
if (data->DrawLinesX1 != +FLT_MAX && window->DC.CursorPos.y >= window->ClipRect.Min.y)
6916
- {
6917
- // Draw vertical line of the hierarchy
6918
- float y1 = ImMax(data->NavRect.Max.y, window->ClipRect.Min.y);
6919
- float y2 = data->DrawLinesToNodesY2;
6920
- if (data->TreeFlags & ImGuiTreeNodeFlags_DrawLinesFull)
6921
- {
6922
- float y2_full = window->DC.CursorPos.y;
6923
- if (g.CurrentTable)
6924
- y2_full = ImMax(g.CurrentTable->RowPosY2, y2_full);
6925
- y2_full = ImTrunc(y2_full - g.Style.ItemSpacing.y - g.FontSize * 0.5f);
6926
- if (y2 + g.Style.ItemSpacing.y < y2_full) // FIXME: threshold to use ToNodes Y2 instead of Full Y2 when close by ItemSpacing.y
6927
- y2 = y2_full;
6928
- }
6929
- y2 = ImMin(y2, window->ClipRect.Max.y);
6930
- if (y1 < y2)
6931
- {
6932
- float x = ImTrunc(data->DrawLinesX1);
6933
- if (data->DrawLinesTableColumn != -1)
6934
- TablePushColumnChannel(data->DrawLinesTableColumn);
6935
- window->DrawList->AddLine(ImVec2(x, y1), ImVec2(x, y2), GetColorU32(ImGuiCol_TreeLines), g.Style.TreeLinesSize);
6936
- if (data->DrawLinesTableColumn != -1)
6937
- TablePopColumnChannel();
6938
- }
6939
- }
6944
+ TreeNodeDrawLineToTreePop(data);
6945
+
6940
6946
g.TreeNodeStack.pop_back();
6941
6947
window->DC.TreeHasStackDataDepthMask &= ~tree_depth_mask;
6942
6948
}
0 commit comments