Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

fix(tools): keep raster undo on the level where the stroke started

Ahl76e4f049495a1b
diff --git a/toonz/sources/tnztools/fullcolorbrushtool.cpp b/toonz/sources/tnztools/fullcolorbrushtool.cpp
index ab5473250..8c7f6c30d 100644
--- a/toonz/sources/tnztools/fullcolorbrushtool.cpp
+++ b/toonz/sources/tnztools/fullcolorbrushtool.cpp
@@ -144,7 +144,8 @@ FullColorBrushTool::FullColorBrushTool(std::string name)
, m_presetsLoaded(false)
, m_firstTime(true)
, m_started(false)
- , m_strokeFrameId() {
+ , m_strokeFrameId()
+ , m_strokeLevel() {
bind(TTool::RasterImage | TTool::EmptyTarget);
m_thickness.setNonLinearSlider();
@@ -525,6 +526,13 @@ void FullColorBrushTool::inputSetBusy(bool busy) {
m_tileSet = new TTileSetFullColor(ras->getSize());
m_tileSaver = new TTileSaverFullColor(ras, m_tileSet);
m_strokeFrameId = getCurrentFid();
+ m_strokeLevel = TXshSimpleLevelP();
+ if (TTool::Application *app = TTool::getApplication()) {
+ if (TXshLevelHandle *lh = app->getCurrentLevel()) {
+ if (TXshLevel *xl = lh->getLevel())
+ m_strokeLevel = xl->getSimpleLevel();
+ }
+ }
// update color here since the current style might be switched
// with numpad shortcut keys
@@ -665,15 +673,10 @@ void FullColorBrushTool::commitStroke() {
TFrameId frameId =
m_strokeFrameId.isEmptyFrame() ? getCurrentFid() : m_strokeFrameId;
+ TXshSimpleLevel *sl = m_strokeLevel.getPointer();
- TRasterImageP ri;
- TXshSimpleLevel *sl = 0;
- TTool::Application *app = TTool::getApplication();
- if (app && app->getCurrentLevel()) {
- TXshLevel *level = app->getCurrentLevel()->getLevel();
- sl = level ? level->getSimpleLevel() : 0;
- if (sl) ri = TRasterImageP(sl->getFrame(frameId, true));
- }
+ TRasterImageP ri =
+ sl ? TRasterImageP(sl->getFrame(frameId, true)) : TRasterImageP();
TRasterP ras = ri ? ri->getRaster() : TRasterP();
m_lastRect.empty();
@@ -696,8 +699,9 @@ void FullColorBrushTool::commitStroke() {
m_started = false;
m_strokeFrameId = TFrameId();
+ m_strokeLevel = TXshSimpleLevelP();
m_strokeRect.empty();
- if (ras) notifyImageChanged(frameId);
+ if (ras && sl) notifyImageChanged(frameId, sl);
}
//----------------------------------------------------------------------------------------------------------
diff --git a/toonz/sources/tnztools/fullcolorbrushtool.h b/toonz/sources/tnztools/fullcolorbrushtool.h
index 4f52acca9..ff1fbcb73 100644
--- a/toonz/sources/tnztools/fullcolorbrushtool.h
+++ b/toonz/sources/tnztools/fullcolorbrushtool.h
@@ -169,6 +169,7 @@ protected:
bool m_started;
TFrameId m_strokeFrameId;
+ TXshSimpleLevelP m_strokeLevel;
bool m_propertyUpdating = false;
bool m_skipStrokeUntilDown = false;
diff --git a/toonz/sources/tnztools/toonzrasterbrushtool.cpp b/toonz/sources/tnztools/toonzrasterbrushtool.cpp
index 87852e8bd..395a8676d 100644
--- a/toonz/sources/tnztools/toonzrasterbrushtool.cpp
+++ b/toonz/sources/tnztools/toonzrasterbrushtool.cpp
@@ -1220,6 +1220,11 @@ void ToonzRasterBrushTool::inputSetBusy(bool busy) {
}
m_painting.frameId = getFrameId();
+ m_painting.level = TXshSimpleLevelP();
+ if (TXshLevelHandle *lh = app->getCurrentLevel()) {
+ if (TXshLevel *xl = lh->getLevel())
+ m_painting.level = xl->getSimpleLevel();
+ }
TToonzImageP ri(getImage(true));
TRasterCM32P ras = ri ? ri->getRaster() : TRasterCM32P();
@@ -1578,15 +1583,10 @@ void ToonzRasterBrushTool::commitPainting() {
TFrameId frameId =
m_painting.frameId.isEmptyFrame() ? getCurrentFid() : m_painting.frameId;
- TXshSimpleLevel *sl = 0;
- TTool::Application *app = TTool::getApplication();
- if (app && app->getCurrentLevel()) {
- TXshLevel *level = app->getCurrentLevel()->getLevel();
- sl = level ? level->getSimpleLevel() : 0;
- }
+ TXshSimpleLevel *sl = m_painting.level.getPointer();
- TToonzImageP ti = sl ? TToonzImageP(sl->getFrame(frameId, true))
- : TToonzImageP(getImage(true));
+ TToonzImageP ti =
+ sl ? TToonzImageP(sl->getFrame(frameId, true)) : TToonzImageP();
TRasterCM32P ras = ti ? ti->getRaster() : TRasterCM32P();
if (m_painting.tileSet && m_painting.tileSet->getTileCount() > 0 && ras &&
@@ -1604,12 +1604,13 @@ void ToonzRasterBrushTool::commitPainting() {
if (tc & ToonzCheck::eGap || tc & ToonzCheck::eAutoclose) invalidate();
m_painting.frameId = TFrameId();
+ m_painting.level = TXshSimpleLevelP();
m_painting.myPaint.isActive = false;
m_painting.pencil.isActive = false;
m_painting.blured.isActive = false;
m_painting.active = false;
- notifyImageChanged(frameId);
+ if (sl) notifyImageChanged(frameId, sl);
ToolUtils::updateSaveBox();
}
diff --git a/toonz/sources/tnztools/toonzrasterbrushtool.h b/toonz/sources/tnztools/toonzrasterbrushtool.h
index a2df069de..5754b7b40 100644
--- a/toonz/sources/tnztools/toonzrasterbrushtool.h
+++ b/toonz/sources/tnztools/toonzrasterbrushtool.h
@@ -11,6 +11,7 @@
#include <toonz/strokegenerator.h>
#include <toonz/rasterstrokegenerator.h>
#include "toonz/preferences.h"
+#include "toonz/txshsimplelevel.h"
#include <tools/tool.h>
#include <tools/cursors.h>
@@ -254,6 +255,7 @@ protected:
// 作業中のFrameIdをクリック時に保存し、マウスリリース時(Undoの登録時)に別のフレームに
// 移動していたときの不具合を修正する。
TFrameId frameId;
+ TXshSimpleLevelP level;
// common variables
TTileSetCM32 *tileSet = nullptr;