Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing undo Raster Create Frame #1459

Merged
merged 1 commit into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 24 additions & 20 deletions toonz/sources/tnztools/fullcolorbrushtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,9 @@ void FullColorBrushTool::leftButtonUp(const TPointD &pos,
else
point = TPointD(pos + rasCenter);

// Clicked with no movement. Make it look like it moved
if (m_strokeRect.isEmpty()) point += TPointD(1, 1);

double pressure;
if (getApplication()->getCurrentLevelStyle()->getTagId() ==
4001) // mypaint brush case
Expand Down Expand Up @@ -665,35 +668,36 @@ void FullColorBrushTool::leftButtonUp(const TPointD &pos,
m_lastRect.empty();
m_workRaster->unlock();

bool isEditingLevel = m_application->getCurrentFrame()->isEditingLevel();
bool renameColumn = m_isFrameCreated;
if (!isEditingLevel && renameColumn) TUndoManager::manager()->beginBlock();
TTool::Application *app = TTool::getApplication();
TXshLevel *level = app->getCurrentLevel()->getLevel();
TXshSimpleLevelP simLevel = level->getSimpleLevel();

if (m_tileSet->getTileCount() > 0) {
delete m_tileSaver;
bool isEditingLevel = m_application->getCurrentFrame()->isEditingLevel();
bool renameColumn = m_isFrameCreated;
if (!isEditingLevel && renameColumn) TUndoManager::manager()->beginBlock();
TTool::Application *app = TTool::getApplication();
TXshLevel *level = app->getCurrentLevel()->getLevel();
TXshSimpleLevelP simLevel = level->getSimpleLevel();
TFrameId frameId = getCurrentFid();
TRasterP subras = ras->extract(m_strokeRect)->clone();
TUndoManager::manager()->add(new FullColorBrushUndo(
m_tileSet, simLevel.getPointer(), frameId, m_isFrameCreated, subras,
m_strokeRect.getP00()));
}

// Column name renamed to level name only if was originally empty
if (!isEditingLevel && renameColumn) {
int col = app->getCurrentColumn()->getColumnIndex();
TXshColumn *column = app->getCurrentXsheet()->getXsheet()->getColumn(col);
int r0, r1;
column->getRange(r0, r1);
if (r0 == r1) {
TStageObjectId columnId = TStageObjectId::ColumnId(col);
std::string columnName =
QString::fromStdWString(simLevel->getName()).toStdString();
TStageObjectCmd::rename(columnId, columnName, app->getCurrentXsheet());
}

TUndoManager::manager()->endBlock();
// Column name renamed to level name only if was originally empty
if (!isEditingLevel && renameColumn) {
int col = app->getCurrentColumn()->getColumnIndex();
TXshColumn *column = app->getCurrentXsheet()->getXsheet()->getColumn(col);
int r0, r1;
column->getRange(r0, r1);
if (r0 == r1) {
TStageObjectId columnId = TStageObjectId::ColumnId(col);
std::string columnName =
QString::fromStdWString(simLevel->getName()).toStdString();
TStageObjectCmd::rename(columnId, columnName, app->getCurrentXsheet());
}

TUndoManager::manager()->endBlock();
}

notifyImageChanged();
Expand Down