diff --git a/src/lib/component/controller/GraphController.cpp b/src/lib/component/controller/GraphController.cpp index afe5e4b1..c9b8e640 100644 --- a/src/lib/component/controller/GraphController.cpp +++ b/src/lib/component/controller/GraphController.cpp @@ -1860,7 +1860,7 @@ void GraphController::layoutNesting() for (const std::shared_ptr& node : m_dummyNodes) { - layoutNestingRecursive(node.get(), -1); + layoutNestingRecursive(node.get()); } for (const std::shared_ptr& node : m_dummyNodes) @@ -1903,7 +1903,7 @@ void GraphController::extendEqualFunctionNames(const std::vectorvisible) { @@ -1975,43 +1975,46 @@ Vec4i GraphController::layoutNestingRecursive(DummyNode* node, int maxWidth) con width += margins.iconWidth; width = std::max(width, margins.minWidth); - int maxAccessWidth = 0; - - for (const std::shared_ptr& subNode : node->subNodes) + if (relayoutAccessMaxWidth == -1) { - if (!subNode->visible) - { - continue; - } - else if (subNode->isQualifierNode()) - { - subNode->position.y = margins.top + margins.charHeight / 2; - width += 5; - continue; - } + int maxAccessWidth = 0; + std::shared_ptr maxWidthAccessNode; - Vec4i rect = layoutNestingRecursive(subNode.get(), maxWidth); - - if (subNode->isExpandToggleNode()) - { - width += margins.spacingX + subNode->size.x; - } - else if (subNode->isAccessNode()) - { - maxAccessWidth = std::max(maxAccessWidth, rect.z()); - } - } - - if (maxAccessWidth > 0) - { for (const std::shared_ptr& subNode : node->subNodes) { - if (!subNode->visible || !subNode->isAccessNode()) + if (!subNode->visible) { continue; } + else if (subNode->isQualifierNode()) + { + subNode->position.y = margins.top + margins.charHeight / 2; + width += 5; + continue; + } - layoutNestingRecursive(subNode.get(), maxAccessWidth); + Vec4i rect = layoutNestingRecursive(subNode.get()); + + if (subNode->isExpandToggleNode()) + { + width += margins.spacingX + subNode->size.x; + } + else if (subNode->isAccessNode() && rect.z() > maxAccessWidth) + { + maxAccessWidth = rect.z(); + maxWidthAccessNode = subNode; + } + } + + if (maxAccessWidth > 0) + { + for (const std::shared_ptr& subNode : node->subNodes) + { + if (subNode->visible && subNode->isAccessNode() && subNode != maxWidthAccessNode) + { + layoutNestingRecursive(subNode.get(), maxAccessWidth); + } + } } } @@ -2053,7 +2056,7 @@ Vec4i GraphController::layoutNestingRecursive(DummyNode* node, int maxWidth) con } else if (node->isAccessNode() && !node->hasConnectedSubNode()) { - ListLayouter::layoutSquare(&node->subNodes, maxWidth); + ListLayouter::layoutSquare(&node->subNodes, relayoutAccessMaxWidth); } else { diff --git a/src/lib/component/controller/GraphController.h b/src/lib/component/controller/GraphController.h index 5d6870d0..2cefeaba 100644 --- a/src/lib/component/controller/GraphController.h +++ b/src/lib/component/controller/GraphController.h @@ -120,7 +120,7 @@ private: void layoutNesting(); void extendEqualFunctionNames(const std::vector>& nodes) const; - Vec4i layoutNestingRecursive(DummyNode* node, int maxWidth) const; + Vec4i layoutNestingRecursive(DummyNode* node, int relayoutAccessMaxWidth = -1) const; void addExpandToggleNode(DummyNode* node) const; void layoutToGrid(DummyNode* node) const;