Skip to content

Commit

Permalink
ui: improve paste position in nodal
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Jan 10, 2025
1 parent 8da4d21 commit 84b09e3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ void NodalIntervalView::recenterRelativeToView()
auto viewRect = QRectF{viewTopLeft, viewBottomRight};
auto visibleRect = viewRect.intersected(parentRect);

// qDebug() << "\n- parent:" << parentRect << "\n- child:" << childRect
// << "\n- view:" << viewRect << "\n- visible:" << visibleRect;

auto childCenter
= m_container->mapRectToParent(childRect).center() - m_container->pos();
auto ourCenter = visibleRect.center();
Expand Down Expand Up @@ -135,6 +132,7 @@ void NodalIntervalView::recenter()

void NodalIntervalView::rescale()
{
recenterRelativeToView();
auto parentRect = boundingRect();
auto childRect = enclosingRect();

Expand Down Expand Up @@ -273,6 +271,9 @@ void NodalIntervalView::mousePressEvent(QGraphicsSceneMouseEvent* e)

m_pressedPos = e->scenePos();
e->accept();

score::SelectionDispatcher disp{m_context.selectionStack};
disp.select(m_model);
}

void NodalIntervalView::mouseMoveEvent(QGraphicsSceneMouseEvent* e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void CentralNodalDisplay::init()
this->recenter();
});

QTimer::singleShot(0, presenter, &NodalIntervalView::recenter);
QTimer::singleShot(0, presenter, &NodalIntervalView::recenterRelativeToView);
}

void CentralNodalDisplay::recenter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ bool ScenarioEditor::paste(
}
else
{
// FIXME proper nodal position
return pasteInInterval(*obj, QPointF{0., 0.}, mime, ctx);
return pasteInInterval(*obj, newProcessPosition(*obj), mime, ctx);
}
}
else if(auto obj = qobject_cast<StateModel*>(sel.at(0)))
Expand All @@ -283,13 +282,15 @@ bool ScenarioEditor::paste(
else if(auto obj = qobject_cast<Scenario::ProcessModel*>(sel.at(0)))
{
// Do nothing, handled below as we really need the position in the view
// FIXME if we're in nodal view and pasting just a process and
// not clicking in the scenario then it would be better to paste
// next to the scenario
}
else if(auto obj = qobject_cast<Process::ProcessModel*>(sel.at(0)))
{
if(auto itv = Scenario::closestParentInterval(obj))
{
// FIXME proper nodal position
return pasteInInterval(*itv, QPointF{0., 0.}, mime, ctx);
return pasteInInterval(*itv, newProcessPosition(*itv), mime, ctx);
}
}
}
Expand Down

0 comments on commit 84b09e3

Please sign in to comment.