Preserve focus when duplicating pieces. Fixes #130.

This commit is contained in:
leozide 2017-11-03 11:38:47 -07:00
parent 657fdc0f2b
commit fd19af8e73

View file

@ -1155,6 +1155,7 @@ void lcModel::Paste()
void lcModel::DuplicateSelectedPieces() void lcModel::DuplicateSelectedPieces()
{ {
lcArray<lcObject*> NewPieces; lcArray<lcObject*> NewPieces;
lcPiece* Focus = nullptr;
for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++) for (int PieceIdx = 0; PieceIdx < mPieces.GetSize(); PieceIdx++)
{ {
@ -1167,6 +1168,9 @@ void lcModel::DuplicateSelectedPieces()
NewPiece->UpdatePosition(mCurrentStep); NewPiece->UpdatePosition(mCurrentStep);
NewPieces.Add(NewPiece); NewPieces.Add(NewPiece);
if (Piece->IsFocused())
Focus = NewPiece;
PieceIdx++; PieceIdx++;
InsertPiece(NewPiece, PieceIdx); InsertPiece(NewPiece, PieceIdx);
} }
@ -1175,7 +1179,7 @@ void lcModel::DuplicateSelectedPieces()
return; return;
gMainWindow->UpdateTimeline(false, false); gMainWindow->UpdateTimeline(false, false);
SetSelectionAndFocus(NewPieces, nullptr, 0); SetSelectionAndFocus(NewPieces, Focus, LC_PIECE_SECTION_POSITION);
SaveCheckpoint(tr("Duplicating Pieces")); SaveCheckpoint(tr("Duplicating Pieces"));
} }