ui: Pan graph view to name of active symbol after activation

bug id = 80
This commit is contained in:
Eberhard Graether
2016-07-22 13:57:58 +02:00
parent b2cb95de1b
commit f4677a902d
7 changed files with 103 additions and 29 deletions
+35 -11
View File
@@ -84,9 +84,9 @@ void QtGraphView::rebuildGraph(
std::shared_ptr<Graph> graph,
const std::vector<std::shared_ptr<DummyNode>>& nodes,
const std::vector<std::shared_ptr<DummyEdge>>& edges,
bool animated
const GraphParams params
){
m_rebuildGraphFunctor(graph, nodes, edges, animated);
m_rebuildGraphFunctor(graph, nodes, edges, params);
}
void QtGraphView::clear()
@@ -166,7 +166,7 @@ void QtGraphView::switchToNewGraphData()
doResize();
// Manually hover the item below the mouse cursor.
QGraphicsView* view = getView();
QtGraphicsView* view = getView();
QPointF point = view->mapToScene(view->mapFromGlobal(QCursor::pos()));
QGraphicsItem* item = view->scene()->itemAt(point, QTransform());
if (item)
@@ -178,6 +178,22 @@ void QtGraphView::switchToNewGraphData()
}
}
if (m_activeNode)
{
Vec2i pos = m_activeNode->getPosition();
Vec2i size = m_activeNode->getSize();
QRectF rect(pos.x, pos.y, size.x, size.y);
if (rect.height() > view->height() - 200)
{
rect.setHeight(view->height() - 200);
}
view->ensureVisibleAnimated(rect, 100, 100);
m_activeNode.reset();
}
// Repaint to make sure all artifacts are removed
view->update();
}
@@ -200,7 +216,7 @@ void QtGraphView::doRebuildGraph(
std::shared_ptr<Graph> graph,
const std::vector<std::shared_ptr<DummyNode>>& nodes,
const std::vector<std::shared_ptr<DummyEdge>>& edges,
bool animated
const GraphParams params
){
if (m_transition && m_transition->currentTime() < m_transition->totalDuration())
{
@@ -217,6 +233,7 @@ void QtGraphView::doRebuildGraph(
}
m_nodes.clear();
m_activeNode.reset();
for (unsigned int i = 0; i < nodes.size(); i++)
{
std::shared_ptr<QtGraphNode> node = createNodeRecursive(view, NULL, nodes[i].get(), activeNodeCount > 1);
@@ -251,7 +268,7 @@ void QtGraphView::doRebuildGraph(
m_graph = graph;
}
if (animated)
if (params.animatedTransition)
{
createTransition();
}
@@ -259,6 +276,11 @@ void QtGraphView::doRebuildGraph(
{
switchToNewGraphData();
}
if (!params.centerActiveNode)
{
m_activeNode.reset();
}
}
void QtGraphView::doClear()
@@ -352,6 +374,11 @@ std::shared_ptr<QtGraphNode> QtGraphView::createNodeRecursive(
newNode->addComponent(std::make_shared<QtGraphNodeComponentMoveable>(newNode));
}
if (node->active && !m_activeNode)
{
m_activeNode = newNode;
}
for (unsigned int i = 0; i < node->subNodes.size(); i++)
{
std::shared_ptr<QtGraphNode> subNode = createNodeRecursive(view, newNode, node->subNodes[i].get(), multipleActive);
@@ -544,13 +571,10 @@ void QtGraphView::createTransition()
anim->setStartValue(view->sceneRect());
anim->setEndValue(getSceneRect(m_nodes));
if (remainingNodes.size())
anim->setDuration(300);
if (!remainingNodes.size())
{
anim->setDuration(300);
}
else
{
anim->setDuration(300);
connect(anim, SIGNAL(finished()), this, SLOT(centerScrollBars()));
}