ui: Fixed group related issues in graph

* fixed aggregation layout within group
* fixed moving of group did not resize view
* fixed edges behind group could not be hovered
* fixed overlapping lines in sublayout
* fixed use of correct column width in sublayout
This commit is contained in:
Eberhard Graether
2018-04-11 14:11:53 +02:00
parent cbd782d0c1
commit 5f56a167d1
12 changed files with 57 additions and 43 deletions
@@ -1846,11 +1846,11 @@ void GraphController::layoutNestingRecursive(DummyNode* node) const
break;
case GroupLayout::BUCKET:
if (node->hasActiveSubNode())
if (node->hasActiveSubNode() || !m_activeNodeIds.size() /* aggregations */)
{
BucketLayouter grid(viewSize);
grid.createBuckets(node->subNodes, m_dummyEdges);
grid.layoutBuckets(true);
grid.layoutBuckets(m_activeNodeIds.size());
node->subNodes = grid.getSortedNodes();
}
else
@@ -55,7 +55,7 @@ const DummyNode::BundledNodesSet& Bucket::getNodes() const
return m_nodes;
}
void Bucket::preLayout(Vec2i viewSize, bool addVerticalOffset)
void Bucket::preLayout(Vec2i viewSize, bool addVerticalSplit, bool forceVerticalSplit)
{
int cols = (viewSize.y > 0 ? (m_height / viewSize.y) : 0) + 1;
@@ -111,7 +111,8 @@ void Bucket::preLayout(Vec2i viewSize, bool addVerticalOffset)
}
}
if (!addVerticalOffset || nodesInCol.size() < 2)
addVerticalSplit &= nodesInCol.size() > 1 || forceVerticalSplit;
if (!addVerticalSplit)
{
return;
}
@@ -296,7 +297,7 @@ void BucketLayouter::createBuckets(
}
}
void BucketLayouter::layoutBuckets(bool addVerticalOffset)
void BucketLayouter::layoutBuckets(bool addVerticalSplit)
{
std::map<int, int> widths;
std::map<int, int> heights;
@@ -307,7 +308,7 @@ void BucketLayouter::layoutBuckets(bool addVerticalOffset)
{
Bucket* bucket = &m_buckets[j][i];
bucket->preLayout(m_viewSize, i != 0);
bucket->preLayout(m_viewSize, i != 0, addVerticalSplit);
std::map<int, int>::iterator wt = widths.find(i);
if (wt == widths.end() || wt->second < bucket->getWidth())
@@ -345,11 +346,6 @@ void BucketLayouter::layoutBuckets(bool addVerticalOffset)
Bucket* midBucket = &m_buckets[0][0];
yOff = (heights[0] - midBucket->getHeight()) / 2 * -j;
}
// move every second bucket in a row slighly lower to avoid edges over nodes
else if (addVerticalOffset && std::abs(i) % 2 == 1)
{
yOff = GraphViewStyle::toGridGap(10);
}
// align buckets left and right of center to be vertically centered next to the active node
else if (j == 0 && i != 0 && verticalOffset != 0)
{
@@ -23,7 +23,7 @@ public:
void addNode(std::shared_ptr<DummyNode> node);
const DummyNode::BundledNodesSet& getNodes() const;
void preLayout(Vec2i viewSize, bool addVerticalOffset);
void preLayout(Vec2i viewSize, bool addVerticalSplit, bool forceVerticalSplit);
void layout(int x, int y, int width, int height);
int i;
@@ -44,7 +44,7 @@ public:
void createBuckets(
std::vector<std::shared_ptr<DummyNode>>& nodes,
const std::vector<std::shared_ptr<DummyEdge>>& edges);
void layoutBuckets(bool addVerticalOffset);
void layoutBuckets(bool addVerticalSplit);
std::vector<std::shared_ptr<DummyNode>> getSortedNodes();
+1 -1
View File
@@ -347,7 +347,7 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfGroupNode(GroupType type
margins.spacingA = (hasName ? 14 : 0);
margins.left = margins.right = 20;
margins.left = margins.right = 26;
margins.top = (hasName ? 12 : 20);
margins.bottom = 20;