diff --git a/src/lib/component/controller/GraphController.cpp b/src/lib/component/controller/GraphController.cpp index 85d8fe93..82d023f2 100644 --- a/src/lib/component/controller/GraphController.cpp +++ b/src/lib/component/controller/GraphController.cpp @@ -1308,26 +1308,22 @@ void GraphController::addExpandToggleNode(DummyNode* node) const void GraphController::layoutToGrid(DummyNode* node) const { - if (!node->visible) + if (!node->visible || !node->isGraphNode() || !node->hasVisibleSubNode()) { return; } + // Increase size of nodes with visible chilren to cover full grid cells + size_t width = GraphViewStyle::toGridSize(node->size.x); size_t height = GraphViewStyle::toGridSize(node->size.y); size_t incX = width - node->size.x; size_t incY = height - node->size.y; - node->size.x = width; - node->size.y = height; - - if (!node->isGraphNode()) - { - return; - } - DummyNode* lastAccessNode = nullptr; + DummyNode* expandToggleNode = nullptr; + for (std::shared_ptr subNode : node->subNodes) { if (!subNode->visible) @@ -1342,13 +1338,18 @@ void GraphController::layoutToGrid(DummyNode* node) const } else if (subNode->isExpandToggleNode()) { - subNode->position.x = subNode->position.x + incX; + expandToggleNode = subNode.get(); + } } if (lastAccessNode) { lastAccessNode->size.y = lastAccessNode->size.y + incY; + expandToggleNode->position.x = expandToggleNode->position.x + incX; + + node->size.x = width; + node->size.y = height; } } diff --git a/src/lib/component/controller/helper/BucketLayouter.cpp b/src/lib/component/controller/helper/BucketLayouter.cpp index 18a8bc48..e40e9e47 100644 --- a/src/lib/component/controller/helper/BucketLayouter.cpp +++ b/src/lib/component/controller/helper/BucketLayouter.cpp @@ -47,7 +47,7 @@ void Bucket::addNode(std::shared_ptr node) m_nodes.insert(node); m_width = (node->size.x > m_width ? node->size.x : m_width); - m_height += node->size.y + GraphViewStyle::toGridGap(10); + m_height += GraphViewStyle::toGridSize(node->size.y) + GraphViewStyle::s_gridCellPadding; } const DummyNode::BundledNodesSet& Bucket::getNodes() const @@ -71,7 +71,7 @@ void Bucket::preLayout(Vec2i viewSize) node->position.x = x; node->position.y = y; - y += node->size.y + GraphViewStyle::toGridGap(10); + y += GraphViewStyle::toGridSize(node->size.y) + GraphViewStyle::s_gridCellPadding; width = (node->size.x > width ? node->size.x : width); m_height = (y > m_height ? y : m_height); @@ -80,7 +80,7 @@ void Bucket::preLayout(Vec2i viewSize) { y = 0; - x += width + GraphViewStyle::toGridGap(30); + x += GraphViewStyle::toGridOffset(width + 30); width = 0; } } diff --git a/src/lib/component/view/GraphViewStyle.cpp b/src/lib/component/view/GraphViewStyle.cpp index 43db8cc2..064d511e 100644 --- a/src/lib/component/view/GraphViewStyle.cpp +++ b/src/lib/component/view/GraphViewStyle.cpp @@ -142,6 +142,9 @@ void GraphViewStyle::loadStyleSettings() s_nodeColors.clear(); s_edgeColors.clear(); + + s_gridCellPadding = getImpl()->getCharHeightForNodeType(Node::NODE_TYPE) - 8; + s_gridCellSize = s_gridCellPadding / 2; } float GraphViewStyle::getCharWidthForNodeType(Node::NodeType type)