diff --git a/src/lib/component/controller/GraphController.cpp b/src/lib/component/controller/GraphController.cpp index eb661f94..f5321a57 100644 --- a/src/lib/component/controller/GraphController.cpp +++ b/src/lib/component/controller/GraphController.cpp @@ -673,8 +673,30 @@ void GraphController::bundleNodes() // } // bundle + bool fileOrMacroActive = false; + for (std::shared_ptr node : m_dummyNodes) + { + if (node->bundleInfo.isActive && node->data->isType(Node::NODE_FILE | Node::NODE_MACRO)) + { + fileOrMacroActive = true; + break; + } + } + + if (!fileOrMacroActive) + { + bundleNodesAndEdgesMatching( + [](const DummyNode::BundleInfo& info, const Node* data) + { + return data->isType(Node::NODE_FILE); + }, + 1, + "Importing Files" + ); + } + bundleNodesAndEdgesMatching( - [](const DummyNode::BundleInfo& info) + [](const DummyNode::BundleInfo& info, const Node* data) { return !info.isDefined && info.isReferencing && !info.layoutVertical; }, @@ -683,7 +705,7 @@ void GraphController::bundleNodes() ); bundleNodesAndEdgesMatching( - [](const DummyNode::BundleInfo& info) + [](const DummyNode::BundleInfo& info, const Node* data) { return !info.isDefined && info.isReferenced && !info.layoutVertical; }, @@ -691,26 +713,29 @@ void GraphController::bundleNodes() "Undefined Symbols" ); - bundleNodesAndEdgesMatching( - [](const DummyNode::BundleInfo& info) - { - return info.isDefined && info.isReferencing && !info.layoutVertical; - }, - 10, - "Referencing Symbols" - ); + if (!fileOrMacroActive) + { + bundleNodesAndEdgesMatching( + [](const DummyNode::BundleInfo& info, const Node* data) + { + return info.isDefined && info.isReferencing && !info.layoutVertical; + }, + 10, + "Referencing Symbols" + ); + + bundleNodesAndEdgesMatching( + [](const DummyNode::BundleInfo& info, const Node* data) + { + return info.isDefined && info.isReferenced && !info.layoutVertical; + }, + 10, + "Referenced Symbols" + ); + } bundleNodesAndEdgesMatching( - [](const DummyNode::BundleInfo& info) - { - return info.isDefined && info.isReferenced && !info.layoutVertical; - }, - 10, - "Referenced Symbols" - ); - - bundleNodesAndEdgesMatching( - [](const DummyNode::BundleInfo& info) + [](const DummyNode::BundleInfo& info, const Node* data) { return info.isReferencing && info.layoutVertical; }, @@ -719,7 +744,7 @@ void GraphController::bundleNodes() ); bundleNodesAndEdgesMatching( - [](const DummyNode::BundleInfo& info) + [](const DummyNode::BundleInfo& info, const Node* data) { return info.isReferenced && info.layoutVertical; }, @@ -729,7 +754,7 @@ void GraphController::bundleNodes() } void GraphController::bundleNodesAndEdgesMatching( - std::function matcher, size_t count, const std::string& name + std::function matcher, size_t count, const std::string& name ){ std::vector matchedNodeIndices; for (size_t i = 0; i < m_dummyNodes.size(); i++) @@ -740,7 +765,7 @@ void GraphController::bundleNodesAndEdgesMatching( continue; } - if (matcher(node->bundleInfo)) + if (matcher(node->bundleInfo, node->data)) { matchedNodeIndices.push_back(i); } diff --git a/src/lib/component/controller/GraphController.h b/src/lib/component/controller/GraphController.h index 3a9021c0..95dfae29 100644 --- a/src/lib/component/controller/GraphController.h +++ b/src/lib/component/controller/GraphController.h @@ -83,7 +83,7 @@ private: void setNodeVisibilityRecursiveTopDown(DummyNode* node, bool parentExpanded) const; void bundleNodes(); - void bundleNodesAndEdgesMatching(std::function matcher, size_t count, const std::string& name); + void bundleNodesAndEdgesMatching(std::function matcher, size_t count, const std::string& name); std::shared_ptr bundleNodesMatching(std::list>& nodes, std::function matcher, const std::string& name); void bundleByType(std::list>& nodes, Node::NodeType type, const std::string& name); void bundleNodesByType();