Skip to content

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

C

Remember last brush preset used

manongjohndf5842849357
diff --git a/toonz/sources/tnztools/fullcolorbrushtool.cpp b/toonz/sources/tnztools/fullcolorbrushtool.cpp
index 1f421a5fc..1d013008c 100644
--- a/toonz/sources/tnztools/fullcolorbrushtool.cpp
+++ b/toonz/sources/tnztools/fullcolorbrushtool.cpp
@@ -54,6 +54,7 @@ TEnv::DoubleVar FullcolorModifierSize("FullcolorModifierSize", 0);
TEnv::DoubleVar FullcolorModifierOpacity("FullcolorModifierOpacity", 100);
TEnv::IntVar FullcolorModifierEraser("FullcolorModifierEraser", 0);
TEnv::IntVar FullcolorModifierLockAlpha("FullcolorModifierLockAlpha", 0);
+TEnv::StringVar FullcolorBrushPreset("FullcolorBrushPreset", "<custom>");
//----------------------------------------------------------------------------------
@@ -195,16 +196,15 @@ void FullColorBrushTool::onActivate() {
if (m_firstTime) {
m_firstTime = false;
- m_thickness.setValue(
- TIntPairProperty::Value(FullcolorBrushMinSize, FullcolorBrushMaxSize));
- m_pressure.setValue(FullcolorPressureSensitivity ? 1 : 0);
- m_opacity.setValue(
- TDoublePairProperty::Value(FullcolorMinOpacity, FullcolorMaxOpacity));
- m_hardness.setValue(FullcolorBrushHardness);
- m_modifierSize.setValue(FullcolorModifierSize);
- m_modifierOpacity.setValue(FullcolorModifierOpacity);
- m_modifierEraser.setValue(FullcolorModifierEraser ? true : false);
- m_modifierLockAlpha.setValue(FullcolorModifierLockAlpha ? true : false);
+
+ std::wstring wpreset =
+ QString::fromStdString(FullcolorBrushPreset.getValue()).toStdWString();
+ if (wpreset != CUSTOM_WSTR) {
+ initPresets();
+ m_preset.setValue(wpreset);
+ loadPreset();
+ } else
+ loadLastBrush();
}
setWorkAndBackupImages();
@@ -578,6 +578,19 @@ void FullColorBrushTool::setWorkAndBackupImages() {
//------------------------------------------------------------------
bool FullColorBrushTool::onPropertyChanged(std::string propertyName) {
+ updateCurrentStyle();
+
+ if (propertyName == "Preset:") {
+ if (m_preset.getValue() != CUSTOM_WSTR)
+ loadPreset();
+ else // Chose <custom>, go back to last saved brush settings
+ loadLastBrush();
+
+ FullcolorBrushPreset = m_preset.getValueAsString();
+ getApplication()->getCurrentTool()->notifyToolChanged();
+ return true;
+ }
+
FullcolorBrushMinSize = m_thickness.getValue().first;
FullcolorBrushMaxSize = m_thickness.getValue().second;
FullcolorPressureSensitivity = m_pressure.getValue();
@@ -589,16 +602,9 @@ bool FullColorBrushTool::onPropertyChanged(std::string propertyName) {
FullcolorModifierEraser = m_modifierEraser.getValue() ? 1 : 0;
FullcolorModifierLockAlpha = m_modifierLockAlpha.getValue() ? 1 : 0;
- updateCurrentStyle();
-
- if (propertyName == "Preset:") {
- loadPreset();
- getApplication()->getCurrentTool()->notifyToolChanged();
- return true;
- }
-
if (m_preset.getValue() != CUSTOM_WSTR) {
m_preset.setValue(CUSTOM_WSTR);
+ FullcolorBrushPreset = m_preset.getValueAsString();
getApplication()->getCurrentTool()->notifyToolChanged();
}
@@ -694,6 +700,21 @@ void FullColorBrushTool::removePreset() {
//------------------------------------------------------------------
+void FullColorBrushTool::loadLastBrush() {
+ m_thickness.setValue(
+ TIntPairProperty::Value(FullcolorBrushMinSize, FullcolorBrushMaxSize));
+ m_pressure.setValue(FullcolorPressureSensitivity ? 1 : 0);
+ m_opacity.setValue(
+ TDoublePairProperty::Value(FullcolorMinOpacity, FullcolorMaxOpacity));
+ m_hardness.setValue(FullcolorBrushHardness);
+ m_modifierSize.setValue(FullcolorModifierSize);
+ m_modifierOpacity.setValue(FullcolorModifierOpacity);
+ m_modifierEraser.setValue(FullcolorModifierEraser ? true : false);
+ m_modifierLockAlpha.setValue(FullcolorModifierLockAlpha ? true : false);
+}
+
+//------------------------------------------------------------------
+
void FullColorBrushTool::updateCurrentStyle() {
m_currentColor = TPixel32::Black;
if (TTool::Application *app = getApplication()) {
diff --git a/toonz/sources/tnztools/fullcolorbrushtool.h b/toonz/sources/tnztools/fullcolorbrushtool.h
index 9ac932004..b4df3c93a 100644
--- a/toonz/sources/tnztools/fullcolorbrushtool.h
+++ b/toonz/sources/tnztools/fullcolorbrushtool.h
@@ -76,6 +76,8 @@ public:
void addPreset(QString name);
void removePreset();
+ void loadLastBrush();
+
void onCanvasSizeChanged();
void onColorStyleChanged();
diff --git a/toonz/sources/tnztools/toonzrasterbrushtool.cpp b/toonz/sources/tnztools/toonzrasterbrushtool.cpp
index c432f367d..ffb70f37d 100644
--- a/toonz/sources/tnztools/toonzrasterbrushtool.cpp
+++ b/toonz/sources/tnztools/toonzrasterbrushtool.cpp
@@ -55,6 +55,7 @@ TEnv::IntVar RasterBrushPencilMode("InknpaintRasterBrushPencilMode", 0);
TEnv::IntVar BrushPressureSensitivity("InknpaintBrushPressureSensitivity", 1);
TEnv::DoubleVar RasterBrushHardness("RasterBrushHardness", 100);
TEnv::DoubleVar RasterBrushModifierSize("RasterBrushModifierSize", 0);
+TEnv::StringVar RasterBrushPreset("RasterBrushPreset", "<custom>");
//-------------------------------------------------------------------
#define CUSTOM_WSTR L"<custom>"
@@ -1125,17 +1126,16 @@ void ToonzRasterBrushTool::onActivate() {
if (!m_notifier) m_notifier = new ToonzRasterBrushToolNotifier(this);
if (m_firstTime) {
- m_rasThickness.setValue(
- TDoublePairProperty::Value(RasterBrushMinSize, RasterBrushMaxSize));
-
- m_drawOrder.setIndex(BrushDrawOrder);
- m_pencil.setValue(RasterBrushPencilMode ? 1 : 0);
- m_hardness.setValue(RasterBrushHardness);
-
- m_pressure.setValue(BrushPressureSensitivity ? 1 : 0);
m_firstTime = false;
- m_smooth.setValue(BrushSmooth);
- m_modifierSize.setValue(RasterBrushModifierSize);
+
+ std::wstring wpreset =
+ QString::fromStdString(RasterBrushPreset.getValue()).toStdWString();
+ if (wpreset != CUSTOM_WSTR) {
+ initPresets();
+ m_preset.setValue(wpreset);
+ loadPreset();
+ } else
+ loadLastBrush();
}
m_brushPad = ToolUtils::getBrushPad(m_rasThickness.getValue().second,
m_hardness.getValue() * 0.01);
@@ -1936,11 +1936,18 @@ void ToonzRasterBrushTool::setWorkAndBackupImages() {
//------------------------------------------------------------------
bool ToonzRasterBrushTool::onPropertyChanged(std::string propertyName) {
- // Set the following to true whenever a different piece of interface must
- // be refreshed - done once at the end.
- bool notifyTool = false;
+ if (propertyName == m_preset.getName()) {
+ if (m_preset.getValue() != CUSTOM_WSTR)
+ loadPreset();
+ else // Chose <custom>, go back to last saved brush settings
+ loadLastBrush();
+
+ RasterBrushPreset = m_preset.getValueAsString();
+ getApplication()->getCurrentTool()->notifyToolChanged();
+ return true;
+ }
- /*--- 変更されたPropertyに合わせて処理を分ける ---*/
+ /*--- Divide the process according to the changed Property ---*/
/*--- determine which type of brush to be modified ---*/
if (propertyName == m_rasThickness.getName()) {
@@ -1951,9 +1958,6 @@ bool ToonzRasterBrushTool::onPropertyChanged(std::string propertyName) {
m_maxThick = m_rasThickness.getValue().second;
} else if (propertyName == m_smooth.getName()) {
BrushSmooth = m_smooth.getValue();
- } else if (propertyName == m_preset.getName()) {
- loadPreset();
- notifyTool = true;
} else if (propertyName == m_drawOrder.getName()) {
BrushDrawOrder = m_drawOrder.getIndex();
} else if (propertyName == m_pencil.getName()) {
@@ -1974,14 +1978,12 @@ bool ToonzRasterBrushTool::onPropertyChanged(std::string propertyName) {
invalidate(rect);
}
- if (propertyName != m_preset.getName() &&
- m_preset.getValue() != CUSTOM_WSTR) {
+ if (m_preset.getValue() != CUSTOM_WSTR) {
m_preset.setValue(CUSTOM_WSTR);
- notifyTool = true;
+ RasterBrushPreset = m_preset.getValueAsString();
+ getApplication()->getCurrentTool()->notifyToolChanged();
}
- if (notifyTool) getApplication()->getCurrentTool()->notifyToolChanged();
-
return true;
}
@@ -2071,6 +2073,21 @@ void ToonzRasterBrushTool::removePreset() {
m_preset.setValue(CUSTOM_WSTR);
}
+//------------------------------------------------------------------
+
+void ToonzRasterBrushTool::loadLastBrush() {
+ m_rasThickness.setValue(
+ TDoublePairProperty::Value(RasterBrushMinSize, RasterBrushMaxSize));
+
+ m_drawOrder.setIndex(BrushDrawOrder);
+ m_pencil.setValue(RasterBrushPencilMode ? 1 : 0);
+ m_hardness.setValue(RasterBrushHardness);
+
+ m_pressure.setValue(BrushPressureSensitivity ? 1 : 0);
+ m_smooth.setValue(BrushSmooth);
+ m_modifierSize.setValue(RasterBrushModifierSize);
+}
+
//------------------------------------------------------------------
/*! Brush、PaintBrush、EraserToolがPencilModeのときにTrueを返す
*/
diff --git a/toonz/sources/tnztools/toonzrasterbrushtool.h b/toonz/sources/tnztools/toonzrasterbrushtool.h
index c524ad653..ece7ca3d6 100644
--- a/toonz/sources/tnztools/toonzrasterbrushtool.h
+++ b/toonz/sources/tnztools/toonzrasterbrushtool.h
@@ -156,6 +156,8 @@ public:
void addPreset(QString name);
void removePreset();
+ void loadLastBrush();
+
void finishRasterBrush(const TPointD &pos, double pressureVal);
// return true if the pencil mode is active in the Brush / PaintBrush / Eraser
// Tools.
diff --git a/toonz/sources/tnztools/toonzvectorbrushtool.cpp b/toonz/sources/tnztools/toonzvectorbrushtool.cpp
index 0a54da8f1..bfaee3674 100644
--- a/toonz/sources/tnztools/toonzvectorbrushtool.cpp
+++ b/toonz/sources/tnztools/toonzvectorbrushtool.cpp
@@ -57,6 +57,7 @@ TEnv::IntVar V_BrushPressureSensitivity("InknpaintBrushPressureSensitivity", 1);
TEnv::IntVar V_VectorBrushFrameRange("VectorBrushFrameRange", 0);
TEnv::IntVar V_VectorBrushSnap("VectorBrushSnap", 0);
TEnv::IntVar V_VectorBrushSnapSensitivity("VectorBrushSnapSensitivity", 0);
+TEnv::StringVar V_VectorBrushPreset("VectorBrushPreset", "<custom>");
//-------------------------------------------------------------------
@@ -587,33 +588,16 @@ void ToonzVectorBrushTool::updateTranslation() {
void ToonzVectorBrushTool::onActivate() {
if (m_firstTime) {
- m_thickness.setValue(
- TDoublePairProperty::Value(V_VectorBrushMinSize, V_VectorBrushMaxSize));
-
- m_capStyle.setIndex(V_VectorCapStyle);
- m_joinStyle.setIndex(V_VectorJoinStyle);
- m_miterJoinLimit.setValue(V_VectorMiterValue);
- m_breakAngles.setValue(V_BrushBreakSharpAngles ? 1 : 0);
- m_accuracy.setValue(V_BrushAccuracy);
-
- m_pressure.setValue(V_BrushPressureSensitivity ? 1 : 0);
m_firstTime = false;
- m_smooth.setValue(V_BrushSmooth);
- m_frameRange.setIndex(V_VectorBrushFrameRange);
- m_snap.setValue(V_VectorBrushSnap);
- m_snapSensitivity.setIndex(V_VectorBrushSnapSensitivity);
- switch (V_VectorBrushSnapSensitivity) {
- case 0:
- m_minDistance2 = SNAPPING_LOW;
- break;
- case 1:
- m_minDistance2 = SNAPPING_MEDIUM;
- break;
- case 2:
- m_minDistance2 = SNAPPING_HIGH;
- break;
- }
+ std::wstring wpreset =
+ QString::fromStdString(V_VectorBrushPreset.getValue()).toStdWString();
+ if (wpreset != CUSTOM_WSTR) {
+ initPresets();
+ m_preset.setValue(wpreset);
+ loadPreset();
+ } else
+ loadLastBrush();
}
resetFrameRange();
// TODO:app->editImageOrSpline();
@@ -628,7 +612,7 @@ void ToonzVectorBrushTool::onDeactivate() {
// End current stroke.
if (m_active && m_enabled) {
- leftButtonUp(m_lastDragPos, m_lastDragEvent);
+ leftButtonUp(m_lastDragPos, m_lastDragEvent);
}
if (m_tileSaver && !m_isPath) {
@@ -725,7 +709,7 @@ void ToonzVectorBrushTool::leftButtonDrag(const TPointD &pos,
return;
}
- m_lastDragPos = pos;
+ m_lastDragPos = pos;
m_lastDragEvent = e;
double thickness = (m_pressure.getValue() || m_isPath)
@@ -1330,8 +1314,8 @@ void ToonzVectorBrushTool::checkGuideSnapping(bool beforeMousePress,
snapPoint.x = hGuide;
}
beforeMousePress ? m_foundFirstSnap = true : m_foundLastSnap = true;
- beforeMousePress ? m_firstSnapPoint = snapPoint
- : m_lastSnapPoint = snapPoint;
+ beforeMousePress ? m_firstSnapPoint = snapPoint : m_lastSnapPoint =
+ snapPoint;
}
}
}
@@ -1458,7 +1442,18 @@ bool ToonzVectorBrushTool::onPropertyChanged(std::string propertyName) {
// be refreshed - done once at the end.
bool notifyTool = false;
- /*--- �ύX���ꂽProperty�ɍ��킹�ď����𕪂��� ---*/
+ if (propertyName == m_preset.getName()) {
+ if (m_preset.getValue() != CUSTOM_WSTR)
+ loadPreset();
+ else // Chose <custom>, go back to last saved brush settings
+ loadLastBrush();
+
+ V_VectorBrushPreset = m_preset.getValueAsString();
+ getApplication()->getCurrentTool()->notifyToolChanged();
+ return true;
+ }
+
+ /*--- Divide the process according to the changed Property ---*/
/*--- determine which type of brush to be modified ---*/
if (propertyName == m_thickness.getName()) {
@@ -1470,9 +1465,6 @@ bool ToonzVectorBrushTool::onPropertyChanged(std::string propertyName) {
V_BrushAccuracy = m_accuracy.getValue();
} else if (propertyName == m_smooth.getName()) {
V_BrushSmooth = m_smooth.getValue();
- } else if (propertyName == m_preset.getName()) {
- loadPreset();
- notifyTool = true;
} else if (propertyName == m_breakAngles.getName()) {
V_BrushBreakSharpAngles = m_breakAngles.getValue();
} else if (propertyName == m_pressure.getName()) {
@@ -1507,10 +1499,10 @@ bool ToonzVectorBrushTool::onPropertyChanged(std::string propertyName) {
if (propertyName == m_joinStyle.getName()) notifyTool = true;
- if (propertyName != m_preset.getName() &&
- m_preset.getValue() != CUSTOM_WSTR) {
+ if (m_preset.getValue() != CUSTOM_WSTR) {
m_preset.setValue(CUSTOM_WSTR);
- notifyTool = true;
+ V_VectorBrushPreset = m_preset.getValueAsString();
+ notifyTool = true;
}
if (notifyTool) getApplication()->getCurrentTool()->notifyToolChanged();
@@ -1605,6 +1597,37 @@ void ToonzVectorBrushTool::removePreset() {
m_preset.setValue(CUSTOM_WSTR);
}
+//------------------------------------------------------------------
+
+void ToonzVectorBrushTool::loadLastBrush() {
+ m_thickness.setValue(
+ TDoublePairProperty::Value(V_VectorBrushMinSize, V_VectorBrushMaxSize));
+
+ m_capStyle.setIndex(V_VectorCapStyle);
+ m_joinStyle.setIndex(V_VectorJoinStyle);
+ m_miterJoinLimit.setValue(V_VectorMiterValue);
+ m_breakAngles.setValue(V_BrushBreakSharpAngles ? 1 : 0);
+ m_accuracy.setValue(V_BrushAccuracy);
+
+ m_pressure.setValue(V_BrushPressureSensitivity ? 1 : 0);
+ m_smooth.setValue(V_BrushSmooth);
+
+ m_frameRange.setIndex(V_VectorBrushFrameRange);
+ m_snap.setValue(V_VectorBrushSnap);
+ m_snapSensitivity.setIndex(V_VectorBrushSnapSensitivity);
+ switch (V_VectorBrushSnapSensitivity) {
+ case 0:
+ m_minDistance2 = SNAPPING_LOW;
+ break;
+ case 1:
+ m_minDistance2 = SNAPPING_MEDIUM;
+ break;
+ case 2:
+ m_minDistance2 = SNAPPING_HIGH;
+ break;
+ }
+}
+
//------------------------------------------------------------------
/*! Brush�APaintBrush�AEraserTool��PencilMode�̂Ƃ���True��Ԃ�
*/
diff --git a/toonz/sources/tnztools/toonzvectorbrushtool.h b/toonz/sources/tnztools/toonzvectorbrushtool.h
index 21fad2313..8978d8c9f 100644
--- a/toonz/sources/tnztools/toonzvectorbrushtool.h
+++ b/toonz/sources/tnztools/toonzvectorbrushtool.h
@@ -118,6 +118,8 @@ public:
void addPreset(QString name);
void removePreset();
+ void loadLastBrush();
+
// return true if the pencil mode is active in the Brush / PaintBrush / Eraser
// Tools.
bool isPencilModeActive() override;
@@ -193,8 +195,8 @@ protected:
�ړ����Ă����Ƃ��̕s����C������B---*/
TFrameId m_workingFrameId;
- TPointD m_lastDragPos; //!< Position where mouse was last dragged.
- TMouseEvent m_lastDragEvent; //!< Previous mouse-drag event.
+ TPointD m_lastDragPos; //!< Position where mouse was last dragged.
+ TMouseEvent m_lastDragEvent; //!< Previous mouse-drag event.
};
#endif // TOONZVECTORBRUSHTOOL_H