OpenToonz - An open-source full-featured 2D animation creation software
C
undo for autoapply
shun_iwasawae553fc7d2741
diff --git a/toonz/sources/include/toonz/tpalettehandle.h b/toonz/sources/include/toonz/tpalettehandle.hindex d953b212b..c2bdd1dc2 100644--- a/toonz/sources/include/toonz/tpalettehandle.h+++ b/toonz/sources/include/toonz/tpalettehandle.h@@ -63,6 +63,7 @@ public:void notifyPaletteLockChanged() { emit paletteLockChanged(); }void toggleAutopaint();+public:signals:@@ -70,7 +71,7 @@ signals:void paletteChanged();void paletteTitleChanged();void colorStyleSwitched();- void colorStyleChanged();+ void colorStyleChanged(bool);void colorStyleChangedOnMouseRelease();void paletteDirtyFlagChanged();void paletteLockChanged();@@ -90,7 +91,7 @@ signals:void broadcastPaletteChanged();void broadcastPaletteTitleChanged();void broadcastColorStyleSwitched();- void broadcastColorStyleChanged();+ void broadcastColorStyleChanged(bool);void broadcastColorStyleChangedOnMouseRelease();};diff --git a/toonz/sources/include/toonzqt/styleeditor.h b/toonz/sources/include/toonzqt/styleeditor.hindex cb2254372..3e41d7b44 100644--- a/toonz/sources/include/toonzqt/styleeditor.h+++ b/toonz/sources/include/toonzqt/styleeditor.h@@ -686,8 +686,8 @@ protected:protected slots:void onStyleSwitched();- void onStyleChanged();- void onCleanupStyleChanged();+ void onStyleChanged(bool isDragging);+ void onCleanupStyleChanged(bool isDragging);void onOldStyleClicked(const TColorStyle &);// called (e.g.) by PaletteController when an other StyleEditor change thediff --git a/toonz/sources/tnztools/fullcolorbrushtool.cpp b/toonz/sources/tnztools/fullcolorbrushtool.cppindex 127019d0e..fd4e7ac27 100644--- a/toonz/sources/tnztools/fullcolorbrushtool.cpp+++ b/toonz/sources/tnztools/fullcolorbrushtool.cpp@@ -216,9 +216,9 @@ void FullColorBrushTool::updateWorkAndBackupRasters(const TRect &rect) {TRasterP ras = ri->getRaster();const int denominator = 8;- TRect enlargedRect = rect + m_lastRect;- int dx = (enlargedRect.getLx()-1)/denominator+1;- int dy = (enlargedRect.getLy()-1)/denominator+1;+ TRect enlargedRect = rect + m_lastRect;+ int dx = (enlargedRect.getLx() - 1) / denominator + 1;+ int dy = (enlargedRect.getLy() - 1) / denominator + 1;if (m_lastRect.isEmpty()) {enlargedRect.x0 -= dx;@@ -226,7 +226,7 @@ void FullColorBrushTool::updateWorkAndBackupRasters(const TRect &rect) {enlargedRect.x1 += dx;enlargedRect.y1 += dy;- TRect _rect = enlargedRect*ras->getBounds();+ TRect _rect = enlargedRect * ras->getBounds();if (_rect.isEmpty()) return;m_workRaster->extract(_rect)->copy(ras->extract(_rect));@@ -237,10 +237,10 @@ void FullColorBrushTool::updateWorkAndBackupRasters(const TRect &rect) {if (enlargedRect.x1 > m_lastRect.x1) enlargedRect.x1 += dx;if (enlargedRect.y1 > m_lastRect.y1) enlargedRect.y1 += dy;- TRect _rect = enlargedRect*ras->getBounds();+ TRect _rect = enlargedRect * ras->getBounds();if (_rect.isEmpty()) return;- TRect _lastRect = m_lastRect * ras->getBounds();+ TRect _lastRect = m_lastRect * ras->getBounds();QList<TRect> rects = ToolUtils::splitRect(_rect, _lastRect);for (int i = 0; i < rects.size(); i++) {m_workRaster->extract(rects[i])->copy(ras->extract(rects[i]));@@ -253,9 +253,7 @@ void FullColorBrushTool::updateWorkAndBackupRasters(const TRect &rect) {//---------------------------------------------------------------------------------------------------bool FullColorBrushTool::askRead(const TRect &rect) {- return askWrite(rect);-}+bool FullColorBrushTool::askRead(const TRect &rect) { return askWrite(rect); }//--------------------------------------------------------------------------------------------------@@ -306,10 +304,11 @@ void FullColorBrushTool::leftButtonDown(const TPointD &pos,TPointD rasCenter = ras->getCenterD();TPointD point(pos + rasCenter);- double pressure = m_enabledPressure && e.isTablet() ? e.m_pressure/255.0 : 0.5;+ double pressure =+ m_enabledPressure && e.isTablet() ? e.m_pressure / 255.0 : 0.5;- m_tileSet = new TTileSetFullColor(ras->getSize());- m_tileSaver = new TTileSaverFullColor(ras, m_tileSet);+ m_tileSet = new TTileSetFullColor(ras->getSize());+ m_tileSaver = new TTileSaverFullColor(ras, m_tileSet);mypaint::Brush mypaintBrush;applyToonzBrushSettings(mypaintBrush);@@ -319,14 +318,15 @@ void FullColorBrushTool::leftButtonDown(const TPointD &pos,m_strokeSegmentRect.empty();m_toonz_brush->beginStroke();m_toonz_brush->strokeTo(point, pressure, restartBrushTimer());- TRect updateRect = m_strokeSegmentRect*ras->getBounds();+ TRect updateRect = m_strokeSegmentRect * ras->getBounds();if (!updateRect.isEmpty())ras->extract(updateRect)->copy(m_workRaster->extract(updateRect));- TPointD thickOffset(m_maxCursorThick*0.5, m_maxCursorThick*0.5);+ TPointD thickOffset(m_maxCursorThick * 0.5, m_maxCursorThick * 0.5);TRectD invalidateRect = convert(m_strokeSegmentRect) - rasCenter;invalidateRect += TRectD(m_brushPos - thickOffset, m_brushPos + thickOffset);- invalidateRect += TRectD(previousBrushPos - thickOffset, previousBrushPos + thickOffset);+ invalidateRect +=+ TRectD(previousBrushPos - thickOffset, previousBrushPos + thickOffset);invalidate(invalidateRect.enlarge(2.0));}@@ -340,21 +340,23 @@ void FullColorBrushTool::leftButtonDrag(const TPointD &pos,TRasterImageP ri = (TRasterImageP)getImage(true);if (!ri) return;- TRasterP ras = ri->getRaster();+ TRasterP ras = ri->getRaster();TPointD rasCenter = ras->getCenterD();TPointD point(pos + rasCenter);- double pressure = m_enabledPressure && e.isTablet() ? e.m_pressure/255.0 : 0.5;+ double pressure =+ m_enabledPressure && e.isTablet() ? e.m_pressure / 255.0 : 0.5;m_strokeSegmentRect.empty();m_toonz_brush->strokeTo(point, pressure, restartBrushTimer());- TRect updateRect = m_strokeSegmentRect*ras->getBounds();+ TRect updateRect = m_strokeSegmentRect * ras->getBounds();if (!updateRect.isEmpty())ras->extract(updateRect)->copy(m_workRaster->extract(updateRect));- TPointD thickOffset(m_maxCursorThick*0.5, m_maxCursorThick*0.5);+ TPointD thickOffset(m_maxCursorThick * 0.5, m_maxCursorThick * 0.5);TRectD invalidateRect = convert(m_strokeSegmentRect) - rasCenter;invalidateRect += TRectD(m_brushPos - thickOffset, m_brushPos + thickOffset);- invalidateRect += TRectD(previousBrushPos - thickOffset, previousBrushPos + thickOffset);+ invalidateRect +=+ TRectD(previousBrushPos - thickOffset, previousBrushPos + thickOffset);invalidate(invalidateRect.enlarge(2.0));}@@ -368,22 +370,24 @@ void FullColorBrushTool::leftButtonUp(const TPointD &pos,TRasterImageP ri = (TRasterImageP)getImage(true);if (!ri) return;- TRasterP ras = ri->getRaster();+ TRasterP ras = ri->getRaster();TPointD rasCenter = ras->getCenterD();TPointD point(pos + rasCenter);- double pressure = m_enabledPressure && e.isTablet() ? e.m_pressure/255.0 : 0.5;+ double pressure =+ m_enabledPressure && e.isTablet() ? e.m_pressure / 255.0 : 0.5;m_strokeSegmentRect.empty();m_toonz_brush->strokeTo(point, pressure, restartBrushTimer());m_toonz_brush->endStroke();- TRect updateRect = m_strokeSegmentRect*ras->getBounds();+ TRect updateRect = m_strokeSegmentRect * ras->getBounds();if (!updateRect.isEmpty())ras->extract(updateRect)->copy(m_workRaster->extract(updateRect));- TPointD thickOffset(m_maxCursorThick*0.5, m_maxCursorThick*0.5);+ TPointD thickOffset(m_maxCursorThick * 0.5, m_maxCursorThick * 0.5);TRectD invalidateRect = convert(m_strokeSegmentRect) - rasCenter;invalidateRect += TRectD(m_brushPos - thickOffset, m_brushPos + thickOffset);- invalidateRect += TRectD(previousBrushPos - thickOffset, previousBrushPos + thickOffset);+ invalidateRect +=+ TRectD(previousBrushPos - thickOffset, previousBrushPos + thickOffset);invalidate(invalidateRect.enlarge(2.0));if (m_toonz_brush) {@@ -401,9 +405,9 @@ void FullColorBrushTool::leftButtonUp(const TPointD &pos,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()));+ TUndoManager::manager()->add(new FullColorBrushUndo(+ m_tileSet, simLevel.getPointer(), frameId, m_isFrameCreated, subras,+ m_strokeRect.getP00()));}notifyImageChanged();@@ -478,16 +482,16 @@ void FullColorBrushTool::draw() {if (TRasterImageP ri = TRasterImageP(getImage(false))) {TRasterP ras = ri->getRaster();- double alpha = 1.0;+ double alpha = 1.0;double alphaRadius = 3.0;- double pixelSize = sqrt(tglGetPixelSize2());+ double pixelSize = sqrt(tglGetPixelSize2());// circles with lesser radius looks more bold// to avoid these effect we'll reduce alpha for small radiuses- double minX = m_minCursorThick/(alphaRadius*pixelSize);- double maxX = m_maxCursorThick/(alphaRadius*pixelSize);- double minAlpha = alpha*(1.0 - 1.0/(1.0 + minX));- double maxAlpha = alpha*(1.0 - 1.0/(1.0 + maxX));+ double minX = m_minCursorThick / (alphaRadius * pixelSize);+ double maxX = m_maxCursorThick / (alphaRadius * pixelSize);+ double minAlpha = alpha * (1.0 - 1.0 / (1.0 + minX));+ double maxAlpha = alpha * (1.0 - 1.0 / (1.0 + maxX));glPushAttrib(GL_ALL_ATTRIB_BITS);tglEnableBlending();@@ -495,15 +499,15 @@ void FullColorBrushTool::draw() {if (m_minCursorThick < m_maxCursorThick - pixelSize) {glColor4d(1.0, 1.0, 1.0, minAlpha);- tglDrawCircle(m_brushPos, (m_minCursorThick + 1)*0.5 - pixelSize);+ tglDrawCircle(m_brushPos, (m_minCursorThick + 1) * 0.5 - pixelSize);glColor4d(0.0, 0.0, 0.0, minAlpha);- tglDrawCircle(m_brushPos, (m_minCursorThick + 1)*0.5);+ tglDrawCircle(m_brushPos, (m_minCursorThick + 1) * 0.5);}glColor4d(1.0, 1.0, 1.0, maxAlpha);- tglDrawCircle(m_brushPos, (m_maxCursorThick + 1)*0.5 - pixelSize);+ tglDrawCircle(m_brushPos, (m_maxCursorThick + 1) * 0.5 - pixelSize);glColor4d(0.0, 0.0, 0.0, maxAlpha);- tglDrawCircle(m_brushPos, (m_maxCursorThick + 1)*0.5);+ tglDrawCircle(m_brushPos, (m_maxCursorThick + 1) * 0.5);glPopAttrib();}@@ -511,9 +515,7 @@ void FullColorBrushTool::draw() {//---------------------------------------------------------------------------------------------------------------void FullColorBrushTool::onEnter() {- updateCurrentStyle();-}+void FullColorBrushTool::onEnter() { updateCurrentStyle(); }//----------------------------------------------------------------------------------------------------------@@ -672,8 +674,7 @@ void FullColorBrushTool::updateCurrentStyle() {if (TTool::Application *app = getApplication()) {if (app->getCurrentObject()->isSpline()) {m_currentColor = TPixel32::Red;- } else- if (TPalette *plt = app->getCurrentPalette()->getPalette()) {+ } else if (TPalette *plt = app->getCurrentPalette()->getPalette()) {int style = app->getCurrentLevelStyleIndex();TColorStyle *colorStyle = plt->getStyle(style);m_currentColor = colorStyle->getMainColor();@@ -685,25 +686,29 @@ void FullColorBrushTool::updateCurrentStyle() {m_enabledPressure = m_pressure.getValue();if (TMyPaintBrushStyle *brushStyle = getBrushStyle()) {- double radiusLog = brushStyle->getBrush().getBaseValue(MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC)- + m_modifierSize.getValue()*log(2.0);- double radius = exp(radiusLog);- m_minCursorThick = m_maxCursorThick = (int)round(2.0*radius);+ double radiusLog = brushStyle->getBrush().getBaseValue(+ MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC) ++ m_modifierSize.getValue() * log(2.0);+ double radius = exp(radiusLog);+ m_minCursorThick = m_maxCursorThick = (int)round(2.0 * radius);} else {m_minCursorThick = std::max(m_thickness.getValue().first, 1);- m_maxCursorThick = std::max(m_thickness.getValue().second, m_minCursorThick);+ m_maxCursorThick =+ std::max(m_thickness.getValue().second, m_minCursorThick);if (!m_enabledPressure) {- double minRadiusLog = log(0.5*m_minCursorThick);- double maxRadiusLog = log(0.5*m_maxCursorThick);- double avgRadiusLog = 0.5*(minRadiusLog + maxRadiusLog);- double avgRadius = exp(avgRadiusLog);- m_minCursorThick = m_maxCursorThick = (int)round(2.0*avgRadius);+ double minRadiusLog = log(0.5 * m_minCursorThick);+ double maxRadiusLog = log(0.5 * m_maxCursorThick);+ double avgRadiusLog = 0.5 * (minRadiusLog + maxRadiusLog);+ double avgRadius = exp(avgRadiusLog);+ m_minCursorThick = m_maxCursorThick = (int)round(2.0 * avgRadius);}}- if (m_minCursorThick != prevMinCursorThick || m_maxCursorThick != prevMaxCursorThick) {- TRectD rect(m_brushPos - TPointD(m_maxCursorThick + 2, m_maxCursorThick + 2),- m_brushPos + TPointD(m_maxCursorThick + 2, m_maxCursorThick + 2));+ if (m_minCursorThick != prevMinCursorThick ||+ m_maxCursorThick != prevMaxCursorThick) {+ TRectD rect(+ m_brushPos - TPointD(m_maxCursorThick + 2, m_maxCursorThick + 2),+ m_brushPos + TPointD(m_maxCursorThick + 2, m_maxCursorThick + 2));invalidate(rect);}}@@ -711,112 +716,100 @@ void FullColorBrushTool::updateCurrentStyle() {//------------------------------------------------------------------double FullColorBrushTool::restartBrushTimer() {- double dtime = m_brushTimer.nsecsElapsed()*1e-9;+ double dtime = m_brushTimer.nsecsElapsed() * 1e-9;m_brushTimer.restart();return dtime;}//-------------------------------------------------------------------TMyPaintBrushStyle* FullColorBrushTool::getBrushStyle() {+TMyPaintBrushStyle *FullColorBrushTool::getBrushStyle() {if (TTool::Application *app = getApplication())- return dynamic_cast<TMyPaintBrushStyle*>( app->getCurrentLevelStyle() );+ return dynamic_cast<TMyPaintBrushStyle *>(app->getCurrentLevelStyle());return 0;}//-------------------------------------------------------------------void FullColorBrushTool::applyClassicToonzBrushSettings(mypaint::Brush &mypaintBrush) {- const double precision = 1e-5;+void FullColorBrushTool::applyClassicToonzBrushSettings(+ mypaint::Brush &mypaintBrush) {+ const double precision = 1e-5;const double hardnessOpacity = 0.1;- double minThickness = 0.5*m_thickness.getValue().first;- double maxThickness = 0.5*m_thickness.getValue().second;- double minOpacity = 0.01*m_opacity.getValue().first;- double maxOpacity = 0.01*m_opacity.getValue().second;- double hardness = 0.01*m_hardness.getValue();+ double minThickness = 0.5 * m_thickness.getValue().first;+ double maxThickness = 0.5 * m_thickness.getValue().second;+ double minOpacity = 0.01 * m_opacity.getValue().first;+ double maxOpacity = 0.01 * m_opacity.getValue().second;+ double hardness = 0.01 * m_hardness.getValue();- TPixelD color = PixelConverter<TPixelD>::from(m_currentColor);- double colorH = 0.0;- double colorS = 0.0;- double colorV = 0.0;+ TPixelD color = PixelConverter<TPixelD>::from(m_currentColor);+ double colorH = 0.0;+ double colorS = 0.0;+ double colorV = 0.0;RGB2HSV(color.r, color.g, color.b, &colorH, &colorS, &colorV);// avoid log(0)- if (minThickness < precision)- minThickness = precision;- if (maxThickness < precision)- maxThickness = precision;+ if (minThickness < precision) minThickness = precision;+ if (maxThickness < precision) maxThickness = precision;// tune hardness opacity for better visual softnesshardness *= hardness;- double opacityAmplifier = 1.0 - hardnessOpacity + hardness*hardnessOpacity;+ double opacityAmplifier = 1.0 - hardnessOpacity + hardness * hardnessOpacity;minOpacity *= opacityAmplifier;maxOpacity *= opacityAmplifier;// resetmypaintBrush.fromDefaults();mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_OPAQUE_MULTIPLY, 1.0);- mypaintBrush.setMappingN(- MYPAINT_BRUSH_SETTING_OPAQUE_MULTIPLY,- MYPAINT_BRUSH_INPUT_PRESSURE,- 0 );-- mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_HARDNESS, 0.5*hardness + 0.5);- mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_COLOR_H, colorH/360.0);- mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_COLOR_S, colorS);- mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_COLOR_V, colorV);- mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_DABS_PER_ACTUAL_RADIUS, 5.0 + hardness*10.0);+ mypaintBrush.setMappingN(MYPAINT_BRUSH_SETTING_OPAQUE_MULTIPLY,+ MYPAINT_BRUSH_INPUT_PRESSURE, 0);++ mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_HARDNESS,+ 0.5 * hardness + 0.5);+ mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_COLOR_H, colorH / 360.0);+ mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_COLOR_S, colorS);+ mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_COLOR_V, colorV);+ mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_DABS_PER_ACTUAL_RADIUS,+ 5.0 + hardness * 10.0);mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_DABS_PER_BASIC_RADIUS, 0.0);mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_DABS_PER_SECOND, 0.0);// thickness may be dynamicif (minThickness + precision >= maxThickness) {- mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC, log(maxThickness));- mypaintBrush.setMappingN(- MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC,- MYPAINT_BRUSH_INPUT_PRESSURE,- 0 );+ mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC,+ log(maxThickness));+ mypaintBrush.setMappingN(MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC,+ MYPAINT_BRUSH_INPUT_PRESSURE, 0);} else {- double minThicknessLog = log(minThickness);- double maxThicknessLog = log(maxThickness);- double baseThicknessLog = 0.5*(minThicknessLog + maxThicknessLog);- mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC, baseThicknessLog);- mypaintBrush.setMappingN(- MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC,- MYPAINT_BRUSH_INPUT_PRESSURE,- 2 );- mypaintBrush.setMappingPoint(- MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC,- MYPAINT_BRUSH_INPUT_PRESSURE,- 0, 0.0, minThicknessLog - baseThicknessLog);- mypaintBrush.setMappingPoint(- MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC,- MYPAINT_BRUSH_INPUT_PRESSURE,- 1, 1.0, maxThicknessLog - baseThicknessLog);+ double minThicknessLog = log(minThickness);+ double maxThicknessLog = log(maxThickness);+ double baseThicknessLog = 0.5 * (minThicknessLog + maxThicknessLog);+ mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC,+ baseThicknessLog);+ mypaintBrush.setMappingN(MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC,+ MYPAINT_BRUSH_INPUT_PRESSURE, 2);+ mypaintBrush.setMappingPoint(MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC,+ MYPAINT_BRUSH_INPUT_PRESSURE, 0, 0.0,+ minThicknessLog - baseThicknessLog);+ mypaintBrush.setMappingPoint(MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC,+ MYPAINT_BRUSH_INPUT_PRESSURE, 1, 1.0,+ maxThicknessLog - baseThicknessLog);}// opacity may be dynamicif (minOpacity + precision >= maxOpacity) {mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_OPAQUE, maxOpacity);- mypaintBrush.setMappingN(- MYPAINT_BRUSH_SETTING_OPAQUE,- MYPAINT_BRUSH_INPUT_PRESSURE,- 0 );+ mypaintBrush.setMappingN(MYPAINT_BRUSH_SETTING_OPAQUE,+ MYPAINT_BRUSH_INPUT_PRESSURE, 0);} else {mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_OPAQUE, minOpacity);- mypaintBrush.setMappingN(- MYPAINT_BRUSH_SETTING_OPAQUE,- MYPAINT_BRUSH_INPUT_PRESSURE,- 2 );- mypaintBrush.setMappingPoint(- MYPAINT_BRUSH_SETTING_OPAQUE,- MYPAINT_BRUSH_INPUT_PRESSURE,- 0, 0.0, 0.0);- mypaintBrush.setMappingPoint(- MYPAINT_BRUSH_SETTING_OPAQUE,- MYPAINT_BRUSH_INPUT_PRESSURE,- 1, 1.0, maxOpacity - minOpacity);+ mypaintBrush.setMappingN(MYPAINT_BRUSH_SETTING_OPAQUE,+ MYPAINT_BRUSH_INPUT_PRESSURE, 2);+ mypaintBrush.setMappingPoint(MYPAINT_BRUSH_SETTING_OPAQUE,+ MYPAINT_BRUSH_INPUT_PRESSURE, 0, 0.0, 0.0);+ mypaintBrush.setMappingPoint(MYPAINT_BRUSH_SETTING_OPAQUE,+ MYPAINT_BRUSH_INPUT_PRESSURE, 1, 1.0,+ maxOpacity - minOpacity);}}@@ -826,31 +819,33 @@ void FullColorBrushTool::applyToonzBrushSettings(mypaint::Brush &mypaintBrush) {if (mypaintStyle) {const double precision = 1e-5;- double modifierSize = m_modifierSize.getValue()*log(2.0);- double modifierOpacity = 0.01*m_modifierOpacity.getValue();+ double modifierSize = m_modifierSize.getValue() * log(2.0);+ double modifierOpacity = 0.01 * m_modifierOpacity.getValue();- TPixelD color = PixelConverter<TPixelD>::from(m_currentColor);- double colorH = 0.0;- double colorS = 0.0;- double colorV = 0.0;+ TPixelD color = PixelConverter<TPixelD>::from(m_currentColor);+ double colorH = 0.0;+ double colorS = 0.0;+ double colorV = 0.0;RGB2HSV(color.r, color.g, color.b, &colorH, &colorS, &colorV);mypaintBrush.fromBrush(mypaintStyle->getBrush());- float baseSize = mypaintBrush.getBaseValue(MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC);+ float baseSize =+ mypaintBrush.getBaseValue(MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC);float baseOpacity = mypaintBrush.getBaseValue(MYPAINT_BRUSH_SETTING_OPAQUE);- mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC, baseSize + modifierSize);- mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_OPAQUE, baseOpacity*modifierOpacity);- mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_COLOR_H, colorH/360.0);- mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_COLOR_S, colorS);- mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_COLOR_V, colorV);+ mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_RADIUS_LOGARITHMIC,+ baseSize + modifierSize);+ mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_OPAQUE,+ baseOpacity * modifierOpacity);+ mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_COLOR_H, colorH / 360.0);+ mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_COLOR_S, colorS);+ mypaintBrush.setBaseValue(MYPAINT_BRUSH_SETTING_COLOR_V, colorV);} else {applyClassicToonzBrushSettings(mypaintBrush);}}-//==========================================================================================================FullColorBrushToolNotifier::FullColorBrushToolNotifier(FullColorBrushTool *tool)@@ -863,7 +858,7 @@ FullColorBrushToolNotifier::FullColorBrushToolNotifier(FullColorBrushTool *tool)}if (TPaletteHandle *paletteHandle = app->getCurrentPalette()) {bool ret;- ret = connect(paletteHandle, SIGNAL(colorStyleChanged()), this,+ ret = connect(paletteHandle, SIGNAL(colorStyleChanged(bool)), this,SLOT(onColorStyleChanged()));assert(ret);ret = connect(paletteHandle, SIGNAL(colorStyleSwitched()), this,diff --git a/toonz/sources/tnztools/tooloptionscontrols.cpp b/toonz/sources/tnztools/tooloptionscontrols.cppindex 72bdf8ff6..1a93c2814 100644--- a/toonz/sources/tnztools/tooloptionscontrols.cpp+++ b/toonz/sources/tnztools/tooloptionscontrols.cpp@@ -748,7 +748,7 @@ StyleIndexFieldAndChip::StyleIndexFieldAndChip(TTool *tool,setPaletteHandle(pltHandle);connect(pltHandle, SIGNAL(colorStyleSwitched()), SLOT(updateColor()));- connect(pltHandle, SIGNAL(colorStyleChanged()), SLOT(updateColor()));+ connect(pltHandle, SIGNAL(colorStyleChanged(bool)), SLOT(updateColor()));}//-----------------------------------------------------------------------------diff --git a/toonz/sources/toonz/cleanuppaletteviewer.cpp b/toonz/sources/toonz/cleanuppaletteviewer.cppindex 03b1dbef7..7f095c09a 100644--- a/toonz/sources/toonz/cleanuppaletteviewer.cpp+++ b/toonz/sources/toonz/cleanuppaletteviewer.cpp@@ -87,8 +87,8 @@ CleanupPaletteViewer::CleanupPaletteViewer(QWidget *parent)bool ret = true;ret = ret && connect(m_ph, SIGNAL(paletteSwitched()), SLOT(buildGUI()));ret = ret && connect(m_ph, SIGNAL(paletteChanged()), SLOT(buildGUI()));- ret = ret &&- connect(m_ph, SIGNAL(colorStyleChanged()), SLOT(onColorStyleChanged()));+ ret = ret && connect(m_ph, SIGNAL(colorStyleChanged(bool)),+ SLOT(onColorStyleChanged()));ret = ret && connect(m_add, SIGNAL(clicked(bool)), SLOT(onAddClicked(bool)));ret = ret &&diff --git a/toonz/sources/toonz/cleanuppreview.cpp b/toonz/sources/toonz/cleanuppreview.cppindex e312d7c20..0263690cb 100644--- a/toonz/sources/toonz/cleanuppreview.cpp+++ b/toonz/sources/toonz/cleanuppreview.cpp@@ -98,8 +98,8 @@ void PreviewToggleCommand::enable() {TPaletteHandle *ph =TApp::instance()->getPaletteController()->getCurrentCleanupPalette();- ret =- ret && connect(ph, SIGNAL(colorStyleChanged()), &m_timer, SLOT(start()));+ ret = ret &&+ connect(ph, SIGNAL(colorStyleChanged(bool)), &m_timer, SLOT(start()));ret = ret && connect(ph, SIGNAL(paletteChanged()), &m_timer, SLOT(start()));assert(ret);@@ -129,8 +129,8 @@ void PreviewToggleCommand::disable() {// involve the model.TPaletteHandle *ph =TApp::instance()->getPaletteController()->getCurrentCleanupPalette();- ret = ret &&- disconnect(ph, SIGNAL(colorStyleChanged()), &m_timer, SLOT(start()));+ ret = ret && disconnect(ph, SIGNAL(colorStyleChanged(bool)), &m_timer,+ SLOT(start()));ret =ret && disconnect(ph, SIGNAL(paletteChanged()), &m_timer, SLOT(start()));assert(ret);diff --git a/toonz/sources/toonz/cleanupsettingsmodel.cpp b/toonz/sources/toonz/cleanupsettingsmodel.cppindex 499570a3b..0d6faa18e 100644--- a/toonz/sources/toonz/cleanupsettingsmodel.cpp+++ b/toonz/sources/toonz/cleanupsettingsmodel.cpp@@ -250,7 +250,7 @@ void CleanupSettingsModel::connectSignals() {SLOT(onCellChanged()), Qt::QueuedConnection);ret = ret && connect(columnHandle, SIGNAL(columnIndexSwitched()),SLOT(onCellChanged()), Qt::QueuedConnection);- ret = ret && connect(paletteHandle, SIGNAL(colorStyleChanged()),+ ret = ret && connect(paletteHandle, SIGNAL(colorStyleChanged(bool)),SLOT(onPaletteChanged()), Qt::QueuedConnection);ret = ret && connect(paletteHandle, SIGNAL(paletteChanged()),SLOT(onPaletteChanged()), Qt::QueuedConnection);diff --git a/toonz/sources/toonz/colormodelviewer.cpp b/toonz/sources/toonz/colormodelviewer.cppindex e4b0085c1..d8e0f53eb 100644--- a/toonz/sources/toonz/colormodelviewer.cpp+++ b/toonz/sources/toonz/colormodelviewer.cpp@@ -350,7 +350,7 @@ void ColorModelViewer::hideEvent(QHideEvent *e) {SLOT(showCurrentImage()));disconnect(paletteHandle, SIGNAL(paletteChanged()), this,SLOT(showCurrentImage()));- disconnect(paletteHandle, SIGNAL(colorStyleChanged()), this,+ disconnect(paletteHandle, SIGNAL(colorStyleChanged(bool)), this,SLOT(showCurrentImage()));disconnect(toolHandle, SIGNAL(toolSwitched()), this, SLOT(changePickType()));@@ -370,7 +370,7 @@ void ColorModelViewer::showEvent(QShowEvent *e) {SLOT(showCurrentImage()));ret = ret && connect(paletteHandle, SIGNAL(paletteChanged()), this,SLOT(showCurrentImage()));- ret = ret && connect(paletteHandle, SIGNAL(colorStyleChanged()), this,+ ret = ret && connect(paletteHandle, SIGNAL(colorStyleChanged(bool)), this,SLOT(showCurrentImage()));/*- ツールのTypeに合わせてPickのタイプも変え、カーソルも切り替える -*/ret = ret && connect(toolHandle, SIGNAL(toolSwitched()), this,diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cppindex 84c7b1800..1bde81eaa 100644--- a/toonz/sources/toonz/sceneviewer.cpp+++ b/toonz/sources/toonz/sceneviewer.cpp@@ -755,7 +755,7 @@ void SceneViewer::showEvent(QShowEvent *) {TPaletteHandle *paletteHandle =app->getPaletteController()->getCurrentLevelPalette();- connect(paletteHandle, SIGNAL(colorStyleChanged()), this, SLOT(update()));+ connect(paletteHandle, SIGNAL(colorStyleChanged(bool)), this, SLOT(update()));connect(app->getCurrentObject(), SIGNAL(objectSwitched()), this,SLOT(onObjectSwitched()));diff --git a/toonz/sources/toonz/tpanels.cpp b/toonz/sources/toonz/tpanels.cppindex 0ebe8c906..77d546416 100644--- a/toonz/sources/toonz/tpanels.cpp+++ b/toonz/sources/toonz/tpanels.cpp@@ -670,14 +670,14 @@ void ColorFieldEditorController::edit(DVGui::ColorField *colorField) {connect(m_currentColorField, SIGNAL(colorChanged(const TPixel32 &, bool)),SLOT(onColorChanged(const TPixel32 &, bool)));- connect(m_colorFieldHandle, SIGNAL(colorStyleChanged()),+ connect(m_colorFieldHandle, SIGNAL(colorStyleChanged(bool)),SLOT(onColorStyleChanged()));}//-----------------------------------------------------------------------------void ColorFieldEditorController::hide() {- disconnect(m_colorFieldHandle, SIGNAL(colorStyleChanged()), this,+ disconnect(m_colorFieldHandle, SIGNAL(colorStyleChanged(bool)), this,SLOT(onColorStyleChanged()));}@@ -749,14 +749,14 @@ void CleanupColorFieldEditorController::edit(TApp::instance()->getPaletteController()->setCurrentPalette(m_colorFieldHandle);- connect(m_colorFieldHandle, SIGNAL(colorStyleChanged()),+ connect(m_colorFieldHandle, SIGNAL(colorStyleChanged(bool)),SLOT(onColorStyleChanged()));}//-----------------------------------------------------------------------------void CleanupColorFieldEditorController::hide() {- disconnect(m_colorFieldHandle, SIGNAL(colorStyleChanged()), this,+ disconnect(m_colorFieldHandle, SIGNAL(colorStyleChanged(bool)), this,SLOT(onColorStyleChanged()));}@@ -958,9 +958,9 @@ void FlipbookPanel::initializeTitleBar(TPanelTitleBar *titleBar) {int iconWidth = 20;// safe area buttonTPanelTitleBarButtonForSafeArea *safeAreaButton =- new TPanelTitleBarButtonForSafeArea(titleBar, ":Resources/pane_safe_off.svg",- ":Resources/pane_safe_over.svg",- ":Resources/pane_safe_on.svg");+ new TPanelTitleBarButtonForSafeArea(+ titleBar, ":Resources/pane_safe_off.svg",+ ":Resources/pane_safe_over.svg", ":Resources/pane_safe_on.svg");safeAreaButton->setToolTip("Safe Area (Right Click to Select)");titleBar->add(QPoint(x, 0), safeAreaButton);ret = ret && connect(safeAreaButton, SIGNAL(toggled(bool)),diff --git a/toonz/sources/toonzlib/tpalettehandle.cpp b/toonz/sources/toonzlib/tpalettehandle.cppindex f300da404..f1d5770b6 100644--- a/toonz/sources/toonzlib/tpalettehandle.cpp+++ b/toonz/sources/toonzlib/tpalettehandle.cpp@@ -10,48 +10,40 @@//-----------------------------------------------------------------------------namespace {- class AutopaintToggleUndo final : public TUndo {- TPaletteHandle *m_paletteHandle;- TPaletteP m_palette;- int m_styleId;- bool m_flag;-- public:- AutopaintToggleUndo(TPaletteHandle *paletteHandle, int styleId)+class AutopaintToggleUndo final : public TUndo {+ TPaletteHandle *m_paletteHandle;+ TPaletteP m_palette;+ int m_styleId;+ bool m_flag;++public:+ AutopaintToggleUndo(TPaletteHandle *paletteHandle, int styleId): m_paletteHandle(paletteHandle), m_palette(paletteHandle->getPalette())- , m_styleId(styleId)- {}+ , m_styleId(styleId) {}- void toggleAutopaint() const {- TColorStyle *s = m_palette->getStyle(m_styleId);- s->setFlags(s->getFlags() == 0 ? 1 : 0);- m_paletteHandle->notifyColorStyleChanged();- }+ void toggleAutopaint() const {+ TColorStyle *s = m_palette->getStyle(m_styleId);+ s->setFlags(s->getFlags() == 0 ? 1 : 0);+ m_paletteHandle->notifyColorStyleChanged();+ }- void undo() const override {- toggleAutopaint();- }+ void undo() const override { toggleAutopaint(); }- void redo() const override {- toggleAutopaint();- }+ void redo() const override { toggleAutopaint(); }- void onAdd() { redo(); }+ void onAdd() { redo(); }- int getSize() const override {- return sizeof(*this);- }+ int getSize() const override { return sizeof(*this); }- QString getHistoryString() override {- return QObject::tr(- "Toggle Autopaint Option Palette : %1 Style#%2")+ QString getHistoryString() override {+ return QObject::tr("Toggle Autopaint Option Palette : %1 Style#%2").arg(QString::fromStdWString(m_palette->getPaletteName())).arg(QString::number(m_styleId));- }+ }- int getHistoryType() override { return HistoryType::Palette; }- };+ int getHistoryType() override { return HistoryType::Palette; }+};} // namespace@@ -101,8 +93,8 @@ bool TPaletteHandle::connectBroadcasts(const QObject *receiver) {ret = connect(this, SIGNAL(broadcastColorStyleSwitched()), receiver,SIGNAL(colorStyleSwitched())) &&ret;- ret = connect(this, SIGNAL(broadcastColorStyleChanged()), receiver,- SIGNAL(colorStyleChanged())) &&+ ret = connect(this, SIGNAL(broadcastColorStyleChanged(bool)), receiver,+ SIGNAL(colorStyleChanged(bool))) &&ret;ret = connect(this, SIGNAL(broadcastColorStyleChangedOnMouseRelease()),receiver, SIGNAL(colorStyleChangedOnMouseRelease())) &&@@ -125,8 +117,8 @@ bool TPaletteHandle::disconnectBroadcasts(const QObject *receiver) {ret = disconnect(this, SIGNAL(broadcastColorStyleSwitched()), receiver,SIGNAL(colorStyleSwitched())) &&ret;- ret = disconnect(this, SIGNAL(broadcastColorStyleChanged()), receiver,- SIGNAL(colorStyleChanged())) &&+ ret = disconnect(this, SIGNAL(broadcastColorStyleChanged(bool)), receiver,+ SIGNAL(colorStyleChanged(bool))) &&ret;ret = disconnect(this, SIGNAL(broadcastColorStyleChangedOnMouseRelease()),receiver, SIGNAL(colorStyleChangedOnMouseRelease())) &&@@ -192,7 +184,7 @@ void TPaletteHandle::notifyColorStyleChanged(bool onDragging,if (setDirtyFlag && getPalette() && !getPalette()->getDirtyFlag())getPalette()->setDirtyFlag(true);- emit broadcastColorStyleChanged();+ emit broadcastColorStyleChanged(onDragging);if (!onDragging) emit broadcastColorStyleChangedOnMouseRelease();}diff --git a/toonz/sources/toonzqt/paletteviewer.cpp b/toonz/sources/toonzqt/paletteviewer.cppindex 17eaa334f..ddb8ace26 100644--- a/toonz/sources/toonzqt/paletteviewer.cpp+++ b/toonz/sources/toonzqt/paletteviewer.cpp@@ -200,7 +200,7 @@ void PaletteViewer::setPaletteHandle(TPaletteHandle *paletteHandle) {SLOT(changeWindowTitle()));ret = ret && connect(m_paletteHandle, SIGNAL(colorStyleSwitched()), this,SLOT(onColorStyleSwitched()));- ret = ret && connect(m_paletteHandle, SIGNAL(colorStyleChanged()), this,+ ret = ret && connect(m_paletteHandle, SIGNAL(colorStyleChanged(bool)), this,SLOT(changeWindowTitle()));ret = ret && connect(m_paletteHandle, SIGNAL(paletteDirtyFlagChanged()),this, SLOT(changeWindowTitle()));@@ -635,7 +635,7 @@ void PaletteViewer::showEvent(QShowEvent *) {SLOT(changeWindowTitle()));connect(m_paletteHandle, SIGNAL(colorStyleSwitched()), this,SLOT(onColorStyleSwitched()));- connect(m_paletteHandle, SIGNAL(colorStyleChanged()), this,+ connect(m_paletteHandle, SIGNAL(colorStyleChanged(bool)), this,SLOT(changeWindowTitle()));connect(m_paletteHandle, SIGNAL(paletteDirtyFlagChanged()), this,SLOT(changeWindowTitle()));@@ -657,7 +657,7 @@ void PaletteViewer::hideEvent(QHideEvent *) {SLOT(changeWindowTitle()));disconnect(m_paletteHandle, SIGNAL(colorStyleSwitched()), this,SLOT(onColorStyleSwitched()));- disconnect(m_paletteHandle, SIGNAL(colorStyleChanged()), this,+ disconnect(m_paletteHandle, SIGNAL(colorStyleChanged(bool)), this,SLOT(changeWindowTitle()));disconnect(m_paletteHandle, SIGNAL(paletteDirtyFlagChanged()), this,SLOT(changeWindowTitle()));diff --git a/toonz/sources/toonzqt/paletteviewergui.cpp b/toonz/sources/toonzqt/paletteviewergui.cppindex b3f01c4a0..7b20ad900 100644--- a/toonz/sources/toonzqt/paletteviewergui.cpp+++ b/toonz/sources/toonzqt/paletteviewergui.cpp@@ -163,11 +163,11 @@ void PageViewer::setPaletteHandle(TPaletteHandle *paletteHandle) {if (previousPalette == paletteHandle) return;if (previousPalette)- disconnect(previousPalette, SIGNAL(colorStyleChanged()), this,+ disconnect(previousPalette, SIGNAL(colorStyleChanged(bool)), this,SLOT(update()));m_styleSelection->setPaletteHandle(paletteHandle);- connect(paletteHandle, SIGNAL(colorStyleChanged()), SLOT(update()));+ connect(paletteHandle, SIGNAL(colorStyleChanged(bool)), SLOT(update()));if (m_styleNameEditor) m_styleNameEditor->setPaletteHandle(paletteHandle);}@@ -1281,7 +1281,7 @@ void PageViewer::keyPressEvent(QKeyEvent *e) {void PageViewer::showEvent(QShowEvent *) {TPaletteHandle *paletteHandle = getPaletteHandle();if (!paletteHandle) return;- connect(paletteHandle, SIGNAL(colorStyleChanged()), SLOT(update()),+ connect(paletteHandle, SIGNAL(colorStyleChanged(bool)), SLOT(update()),Qt::UniqueConnection);}@@ -1290,7 +1290,8 @@ void PageViewer::showEvent(QShowEvent *) {void PageViewer::hideEvent(QHideEvent *) {TPaletteHandle *paletteHandle = getPaletteHandle();if (!paletteHandle) return;- disconnect(paletteHandle, SIGNAL(colorStyleChanged()), this, SLOT(update()));+ disconnect(paletteHandle, SIGNAL(colorStyleChanged(bool)), this,+ SLOT(update()));}//-----------------------------------------------------------------------------diff --git a/toonz/sources/toonzqt/styleeditor.cpp b/toonz/sources/toonzqt/styleeditor.cppindex 86aadf6d8..d830d58ce 100644--- a/toonz/sources/toonzqt/styleeditor.cpp+++ b/toonz/sources/toonzqt/styleeditor.cpp@@ -3138,13 +3138,14 @@ void StyleEditor::showEvent(QShowEvent *) {bool ret = true;ret = ret && connect(m_paletteHandle, SIGNAL(colorStyleSwitched()),SLOT(onStyleSwitched()));- ret = ret && connect(m_paletteHandle, SIGNAL(colorStyleChanged()),- SLOT(onStyleChanged()));+ ret = ret && connect(m_paletteHandle, SIGNAL(colorStyleChanged(bool)),+ SLOT(onStyleChanged(bool)));ret = ret && connect(m_paletteHandle, SIGNAL(paletteSwitched()), this,SLOT(onStyleSwitched()));if (m_cleanupPaletteHandle)- ret = ret && connect(m_cleanupPaletteHandle, SIGNAL(colorStyleChanged()),- SLOT(onCleanupStyleChanged()));+ ret =+ ret && connect(m_cleanupPaletteHandle, SIGNAL(colorStyleChanged(bool)),+ SLOT(onCleanupStyleChanged(bool)));ret = ret && connect(m_paletteController, SIGNAL(colorAutoApplyEnabled(bool)),this, SLOT(enableColorAutoApply(bool)));@@ -3220,7 +3221,7 @@ void StyleEditor::onStyleSwitched() {//------------------------------------------------------------------------------void StyleEditor::onStyleChanged() {+void StyleEditor::onStyleChanged(bool isDragging) {TPalette *palette = getPalette();if (!palette) return;@@ -3228,10 +3229,11 @@ void StyleEditor::onStyleChanged() {assert(0 <= styleIndex && styleIndex < palette->getStyleCount());setEditedStyleToStyle(palette->getStyle(styleIndex));- setOldStyleToStyle(- m_editedStyle- .getPointer()); // This line is needed for proper undo behavior-+ if (!isDragging) {+ setOldStyleToStyle(+ m_editedStyle+ .getPointer()); // This line is needed for proper undo behavior+ }m_plainColorPage->setColor(*m_editedStyle, getColorParam());m_colorParameterSelector->setStyle(*m_editedStyle);m_settingsPage->setStyle(m_editedStyle);@@ -3242,10 +3244,10 @@ void StyleEditor::onStyleChanged() {//------------------------------------------------------------------------void StyleEditor::onCleanupStyleChanged() {+void StyleEditor::onCleanupStyleChanged(bool isDragging) {if (!m_cleanupPaletteHandle) return;- onStyleChanged();+ onStyleChanged(isDragging);}//-----------------------------------------------------------------------------