Skip to content

Commit

Permalink
Merge pull request #1491 from manongjohn/fix_timeline_duplicate_level…
Browse files Browse the repository at this point in the history
…_strip

Timeline duplicate created after original in Level Strip
  • Loading branch information
manongjohn committed May 30, 2024
2 parents 49d25ae + 54cc354 commit 1623098
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
6 changes: 4 additions & 2 deletions toonz/sources/include/tools/tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,10 @@ class DVAPI TTool {
bool toBeModified,
int subsampling = 0); //!< Returns the image to be edited by the tool.

static TImage *touchImage(); //!< Returns a pointer to the actual image - the
//! one of the frame that has been selected.
static TImage *touchImage(
bool forDuplicate =
false); //!< Returns a pointer to the actual image - the
//! one of the frame that has been selected.

/*! \details This function is necessary since tools are created before
the main
Expand Down
15 changes: 9 additions & 6 deletions toonz/sources/tnztools/tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ TFrameId getNewFrameId(TXshSimpleLevel *sl, int row) {
}

TFrameId getDesiredFId(TXshCellColumn *column, int r0, TXshSimpleLevel *sl,
int row, TFrameId &maxFId) {
int row, TFrameId &maxFId, bool forDuplicate) {
// search upper cells in the current column and return the next fids to be
// inserted if the maximum fid has no suffix it returns next number, otherwise
// returns next suffix.
Expand All @@ -122,7 +122,10 @@ TFrameId getDesiredFId(TXshCellColumn *column, int r0, TXshSimpleLevel *sl,
if (sl != column->getCell(r).getSimpleLevel()) continue;
TFrameId tmpFId = column->getCell(r).getFrameId();
if (neighborFId.isEmptyFrame()) neighborFId = tmpFId;
if (maxFId < tmpFId) maxFId = tmpFId;
if (maxFId < tmpFId) {
maxFId = tmpFId;
if (forDuplicate) break;
}
}

QByteArray suffix = maxFId.getLetter().toUtf8();
Expand Down Expand Up @@ -292,7 +295,7 @@ TImage *TTool::getImage(bool toBeModified, int subsampling) {

//-----------------------------------------------------------------------------

TImage *TTool::touchImage() {
TImage *TTool::touchImage(bool forDuplicate) {
if (!m_application) return 0;

m_cellsData.clear();
Expand Down Expand Up @@ -401,15 +404,15 @@ TImage *TTool::touchImage() {
// find the proper frameid
TFrameId fid;
TXshCellColumn *column = xsh->getColumn(col)->getCellColumn();
if (isAutoRenumberEnabled && column) {
if ((isAutoRenumberEnabled && column) || forDuplicate) {
TFrameId maxFid;
if (animationSheetEnabled) {
fid = TFrameId(row + 1);
maxFid = TFrameId(row);
} else {
int r_begin, r_end;
column->getRange(r_begin, r_end);
fid = getDesiredFId(column, r_begin, sl, row, maxFid);
fid = getDesiredFId(column, r_begin, sl, row, maxFid, forDuplicate);
}
// renumber fids
sl->getFids(m_oldFids);
Expand Down Expand Up @@ -506,7 +509,7 @@ TImage *TTool::touchImage() {
TFrameId maxFid(row);
fid = (animationSheetEnabled)
? TFrameId(row + 1)
: getDesiredFId(column, r0, sl, row, maxFid);
: getDesiredFId(column, r0, sl, row, maxFid, forDuplicate);
sl->getFids(m_oldFids);
m_isLevelRenumbererd = ToolUtils::renumberForInsertFId(
sl, fid, maxFid, scene->getTopXsheet());
Expand Down
2 changes: 1 addition & 1 deletion toonz/sources/toonz/cellselection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3316,7 +3316,7 @@ void TCellSelection::duplicateFrame(int row, int col, bool multiple) {
Preferences::instance()->setValue(EnableCreationInHoldCells, true, false);
//------------------

TImage *img = toolHandle->getTool()->touchImage();
TImage *img = toolHandle->getTool()->touchImage(true);
if (!img) {
//----- Restore previous states of autocreation
if (!isAutoCreateEnabled)
Expand Down

0 comments on commit 1623098

Please sign in to comment.