mirror of
https://github.com/ocornut/imgui.git
synced 2025-09-06 03:18:21 +00:00
TreeNode: DrawLines: latch X1 offset during TreePush(). (#2920)
This commit is contained in:
@@ -6562,7 +6562,7 @@ static void TreeNodeStoreStackData(ImGuiTreeNodeFlags flags, float x1)
|
|||||||
tree_node_data->NavRect = g.LastItemData.NavRect;
|
tree_node_data->NavRect = g.LastItemData.NavRect;
|
||||||
|
|
||||||
// Initially I tried to latch value for GetColorU32(ImGuiCol_TreeLines) but it's not a good trade-off for very large trees.
|
// Initially I tried to latch value for GetColorU32(ImGuiCol_TreeLines) but it's not a good trade-off for very large trees.
|
||||||
tree_node_data->DrawLinesX1 = (flags & (ImGuiTreeNodeFlags_DrawLinesFull | ImGuiTreeNodeFlags_DrawLinesToNodes)) ? x1 : +FLT_MAX;
|
tree_node_data->DrawLinesX1 = (flags & (ImGuiTreeNodeFlags_DrawLinesFull | ImGuiTreeNodeFlags_DrawLinesToNodes)) ? (x1 + g.FontSize * 0.5f + g.Style.FramePadding.x) : +FLT_MAX;
|
||||||
tree_node_data->DrawLinesY2 = -FLT_MAX;
|
tree_node_data->DrawLinesY2 = -FLT_MAX;
|
||||||
window->DC.TreeHasStackDataDepthMask |= (1 << window->DC.TreeDepth);
|
window->DC.TreeHasStackDataDepthMask |= (1 << window->DC.TreeDepth);
|
||||||
}
|
}
|
||||||
@@ -6857,11 +6857,12 @@ void ImGui::TreeNodeDrawLineToChildNode(const ImVec2& target_pos)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ImGuiTreeNodeStackData* parent_data = &g.TreeNodeStack.Data[g.TreeNodeStack.Size - 1];
|
ImGuiTreeNodeStackData* parent_data = &g.TreeNodeStack.Data[g.TreeNodeStack.Size - 1];
|
||||||
float x1 = parent_data->DrawLinesX1 + ImTrunc(g.FontSize * 0.5f + g.Style.FramePadding.x); // GetTreeNodeToLabelSpacing() * 0.5f
|
float x1 = ImTrunc(parent_data->DrawLinesX1);
|
||||||
|
float x2 = ImTrunc(target_pos.x);
|
||||||
float y = ImTrunc(target_pos.y);
|
float y = ImTrunc(target_pos.y);
|
||||||
parent_data->DrawLinesY2 = ImMax(parent_data->DrawLinesY2, y);
|
parent_data->DrawLinesY2 = ImMax(parent_data->DrawLinesY2, y);
|
||||||
if (x1 < target_pos.x)
|
if (x1 < x2)
|
||||||
window->DrawList->AddLine(ImVec2(x1, y), ImVec2(target_pos.x, y), GetColorU32(ImGuiCol_TreeLines), g.Style.TreeLinesSize);
|
window->DrawList->AddLine(ImVec2(x1, y), ImVec2(x2, y), GetColorU32(ImGuiCol_TreeLines), g.Style.TreeLinesSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::TreePush(const char* str_id)
|
void ImGui::TreePush(const char* str_id)
|
||||||
@@ -6916,7 +6917,7 @@ void ImGui::TreePop()
|
|||||||
y2 = ImMin(y2, window->ClipRect.Max.y);
|
y2 = ImMin(y2, window->ClipRect.Max.y);
|
||||||
if (y1 < y2)
|
if (y1 < y2)
|
||||||
{
|
{
|
||||||
float x = data->DrawLinesX1 + ImTrunc(g.FontSize * 0.5f + g.Style.FramePadding.x); // GetTreeNodeToLabelSpacing() * 0.5f
|
float x = ImTrunc(data->DrawLinesX1);
|
||||||
window->DrawList->AddLine(ImVec2(x, y1), ImVec2(x, y2), GetColorU32(ImGuiCol_TreeLines), g.Style.TreeLinesSize);
|
window->DrawList->AddLine(ImVec2(x, y1), ImVec2(x, y2), GetColorU32(ImGuiCol_TreeLines), g.Style.TreeLinesSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user