diff --git a/toonz/sources/tnztools/mypainttoonzbrush.cpp b/toonz/sources/tnztools/mypainttoonzbrush.cpp index c3670dc..deb9b04 100644 --- a/toonz/sources/tnztools/mypainttoonzbrush.cpp +++ b/toonz/sources/tnztools/mypainttoonzbrush.cpp @@ -9,7 +9,8 @@ #include namespace { -void putOnRasterCM(const TRasterCM32P &out, const TRaster32P &in, int styleId) { +void putOnRasterCM(const TRasterCM32P &out, const TRaster32P &in, int styleId, + bool lockAlpha) { if (!out.getPointer() || !in.getPointer()) return; assert(out->getSize() == in->getSize()); int x, y; @@ -24,7 +25,13 @@ void putOnRasterCM(const TRasterCM32P &out, const TRaster32P &in, int styleId) { TPixel32 *inPix = &in->pixels(y)[x]; if (inPix->m == 0) continue; TPixelCM32 *outPix = &out->pixels(y)[x]; - bool sameStyleId = styleId == outPix->getInk(); + if (lockAlpha && !outPix->isPureInk() && outPix->getPaint() == 0 && + outPix->getTone() == 255) { + *outPix = + TPixelCM32(outPix->getInk(), outPix->getPaint(), outPix->getTone()); + continue; + } + bool sameStyleId = styleId == outPix->getInk(); // line with the same style : multiply tones // line with different style : pick darker tone int tone = sameStyleId ? outPix->getTone() * (255 - inPix->m) / 255 @@ -196,7 +203,8 @@ void MyPaintToonzBrush::strokeTo(const TPointD &point, double pressure, void MyPaintToonzBrush::updateDrawing(const TRasterCM32P rasCM, const TRasterCM32P rasBackupCM, - const TRect &bbox, int styleId) const { + const TRect &bbox, int styleId, + bool lockAlpha) const { if (!rasCM) return; TRect rasRect = rasCM->getBounds(); @@ -204,6 +212,6 @@ void MyPaintToonzBrush::updateDrawing(const TRasterCM32P rasCM, if (targetRect.isEmpty()) return; rasCM->copy(rasBackupCM->extract(targetRect), targetRect.getP00()); - putOnRasterCM(rasCM->extract(targetRect), m_ras->extract(targetRect), - styleId); + putOnRasterCM(rasCM->extract(targetRect), m_ras->extract(targetRect), styleId, + lockAlpha); } \ No newline at end of file diff --git a/toonz/sources/tnztools/mypainttoonzbrush.h b/toonz/sources/tnztools/mypainttoonzbrush.h index 352afa5..f26aa60 100644 --- a/toonz/sources/tnztools/mypainttoonzbrush.h +++ b/toonz/sources/tnztools/mypainttoonzbrush.h @@ -130,7 +130,7 @@ public: // colormapped void updateDrawing(const TRasterCM32P rasCM, const TRasterCM32P rasBackupCM, - const TRect &bbox, int styleId) const; + const TRect &bbox, int styleId, bool lockAlpha) const; }; #endif // T_BLUREDBRUSH diff --git a/toonz/sources/tnztools/tooloptions.cpp b/toonz/sources/tnztools/tooloptions.cpp index 0f64f64..d4b05d2 100644 --- a/toonz/sources/tnztools/tooloptions.cpp +++ b/toonz/sources/tnztools/tooloptions.cpp @@ -1784,16 +1784,18 @@ void BrushToolOptionsBox::filterControls() { for (QMap::iterator it = m_labels.begin(); it != m_labels.end(); it++) { bool isModifier = (it.key().substr(0, 8) == "Modifier"); - bool isCommon = (it.key() == "Pressure" || it.key() == "Preset:"); - bool visible = isCommon || (isModifier == showModifiers); + bool isCommon = (it.key() == "Lock Alpha" || it.key() == "Pressure" || + it.key() == "Preset:"); + bool visible = isCommon || (isModifier == showModifiers); it.value()->setVisible(visible); } for (QMap::iterator it = m_controls.begin(); it != m_controls.end(); it++) { bool isModifier = (it.key().substr(0, 8) == "Modifier"); - bool isCommon = (it.key() == "Pressure" || it.key() == "Preset:"); - bool visible = isCommon || (isModifier == showModifiers); + bool isCommon = (it.key() == "Lock Alpha" || it.key() == "Pressure" || + it.key() == "Preset:"); + bool visible = isCommon || (isModifier == showModifiers); if (QWidget *widget = dynamic_cast(it.value())) widget->setVisible(visible); } diff --git a/toonz/sources/tnztools/toonzrasterbrushtool.cpp b/toonz/sources/tnztools/toonzrasterbrushtool.cpp index 08d0621..db1db72 100644 --- a/toonz/sources/tnztools/toonzrasterbrushtool.cpp +++ b/toonz/sources/tnztools/toonzrasterbrushtool.cpp @@ -1335,7 +1335,7 @@ void ToonzRasterBrushTool::leftButtonDown(const TPointD &pos, if (!updateRect.isEmpty()) { // ras->extract(updateRect)->copy(m_workRas->extract(updateRect)); m_toonz_brush->updateDrawing(ri->getRaster(), m_backupRas, m_strokeRect, - m_styleId); + m_styleId, m_modifierLockAlpha.getValue()); } m_lastRect = m_strokeRect; @@ -1439,7 +1439,7 @@ void ToonzRasterBrushTool::leftButtonDrag(const TPointD &pos, if (!updateRect.isEmpty()) { // ras->extract(updateRect)->copy(m_workRaster->extract(updateRect)); m_toonz_brush->updateDrawing(ras, m_backupRas, m_strokeSegmentRect, - m_styleId); + m_styleId, m_modifierLockAlpha.getValue()); } m_lastRect = m_strokeRect; @@ -1594,7 +1594,7 @@ void ToonzRasterBrushTool::finishRasterBrush(const TPointD &pos, if (!updateRect.isEmpty()) { // ras->extract(updateRect)->copy(m_workRaster->extract(updateRect)); m_toonz_brush->updateDrawing(ras, m_backupRas, m_strokeSegmentRect, - m_styleId); + m_styleId, m_modifierLockAlpha.getValue()); } TPointD thickOffset(m_maxCursorThick * 0.5, m_maxCursorThick * 0.5); // TODO