Skip to content

Commit

Permalink
Better backdrop move
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKepzie committed Dec 22, 2014
1 parent 93c0acd commit e89b923
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Gui/NodeGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ struct NodeGraphPrivate
bool _knobLinksVisible;
double _accumDelta;
bool _detailsVisible;
bool _mergeMoveCommands;

NodeGraphPrivate(Gui* gui,
NodeGraph* p)
Expand Down Expand Up @@ -336,6 +337,7 @@ struct NodeGraphPrivate
, _knobLinksVisible(true)
, _accumDelta(0)
, _detailsVisible(false)
, _mergeMoveCommands(false)
{
}

Expand Down Expand Up @@ -794,7 +796,7 @@ void
NodeGraph::mousePressEvent(QMouseEvent* e)
{
assert(e);

_imp->_mergeMoveCommands = false;
if ( buttonDownIsMiddle(e) ) {
_imp->_evtState = MOVING_AREA;

Expand Down Expand Up @@ -1087,6 +1089,8 @@ NodeGraph::mouseReleaseEvent(QMouseEvent* e)
{
EVENT_STATE state = _imp->_evtState;

_imp->_nodesWithinBDAtPenDown.clear();
_imp->_mergeMoveCommands = false;
_imp->_firstMove = true;
_imp->_evtState = DEFAULT;
_imp->_nodesWithinBDAtPenDown.clear();
Expand Down Expand Up @@ -1403,11 +1407,16 @@ NodeGraph::mouseMoveEvent(QMouseEvent* e)
}
mustUpdateNavigator = true;
pushUndoCommand( new MoveMultipleNodesCommand(nodesToMove,
_imp->_selection.bds,
newPos.x() - _imp->_lastScenePosClick.x(),
newPos.y() - _imp->_lastScenePosClick.y(),newPos) );
_imp->_selection.bds,
newPos.x() - _imp->_lastScenePosClick.x(),
newPos.y() - _imp->_lastScenePosClick.y(),
_imp->_mergeMoveCommands,
newPos) );
if (!_imp->_mergeMoveCommands) {
_imp->_mergeMoveCommands = true;
}
}

if (_imp->_selection.nodes.size() == 1) {
///try to find a nearby edge
boost::shared_ptr<NodeGui> selectedNode = _imp->_selection.nodes.front();
Expand Down
5 changes: 5 additions & 0 deletions Gui/NodeGraphUndoRedo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ MoveMultipleNodesCommand::MoveMultipleNodesCommand(const std::list<NodeToMove> &
const std::list<NodeBackDrop*> & bds,
double dx,
double dy,
bool doMerge,
const QPointF & mouseScenePos,
QUndoCommand *parent)
: QUndoCommand(parent)
Expand All @@ -46,6 +47,7 @@ MoveMultipleNodesCommand::MoveMultipleNodesCommand(const std::list<NodeToMove> &
, _mouseScenePos(mouseScenePos)
, _dx(dx)
, _dy(dy)
, _doMerge(doMerge)
{
assert( !nodes.empty() || !bds.empty() );
}
Expand Down Expand Up @@ -89,6 +91,9 @@ MoveMultipleNodesCommand::mergeWith(const QUndoCommand *command)
if (!mvCmd) {
return false;
}
if (!mvCmd->_doMerge || !_doMerge) {
return false;
}
if ( ( mvCmd->_bds.size() != _bds.size() ) || ( mvCmd->_nodes.size() != _nodes.size() ) ) {
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions Gui/NodeGraphUndoRedo.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class MoveMultipleNodesCommand
const std::list<NodeBackDrop*> & bds,
double dx,
double dy,
bool doMerge,
const QPointF & mouseScenePos,
QUndoCommand *parent = 0);
virtual void undo();
Expand All @@ -70,6 +71,7 @@ class MoveMultipleNodesCommand
std::list<NodeBackDrop*> _bds;
QPointF _mouseScenePos;
double _dx,_dy;
bool _doMerge;
};


Expand Down

0 comments on commit e89b923

Please sign in to comment.