Skip to content

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

C

Feat: Add selective mode for Finger Tool, Area Mode

Abel You6e875d07bd42
diff --git a/toonz/sources/include/tools/tooloptions.h b/toonz/sources/include/tools/tooloptions.h
index bdf4b4030..710353df0 100644
--- a/toonz/sources/include/tools/tooloptions.h
+++ b/toonz/sources/include/tools/tooloptions.h
@@ -609,6 +609,7 @@ class FingerToolOptionsBox final : public ToolOptionsBox {
ToolOptionCombo *m_colorMode;
ToolOptionCheckbox *m_invertMode;
+ ToolOptionCheckbox *m_selectiveMode;
public:
FingerToolOptionsBox(QWidget *parent, TTool *tool, TPaletteHandle *pltHandle,
diff --git a/toonz/sources/tnztools/fingertool.cpp b/toonz/sources/tnztools/fingertool.cpp
index c6cee4f3e..3dacd6ef9 100644
--- a/toonz/sources/tnztools/fingertool.cpp
+++ b/toonz/sources/tnztools/fingertool.cpp
@@ -50,6 +50,7 @@ TEnv::IntVar FingerInvert("InknpaintFingerInvert", 0);
TEnv::DoubleVar FingerSize("InknpaintFingerSize", 10);
TEnv::IntVar FingerMode("InknpaintFingerMode", 0);
TEnv::IntVar FingerPick("InknpaintFingerPick", 1);
+TEnv::IntVar FingerSelective("InknpaintFingerSelective", 1);
//-----------------------------------------------------------------------------
@@ -263,6 +264,7 @@ class FingerTool final : public TTool {
TEnumProperty m_mode;
TBoolProperty m_pick;
TBoolProperty m_invert;
+ TBoolProperty m_selective;
TPropertyGroup m_prop;
int m_cursor;
@@ -325,6 +327,7 @@ FingerTool::FingerTool()
, m_mode("Mode:")
, m_pick("Pick", true)
, m_invert("Invert", false)
+ , m_selective("Selective", true)
, m_firstTime(true)
, m_workingFrameId(TFrameId()) {
bind(TTool::ToonzImage);
@@ -337,6 +340,7 @@ FingerTool::FingerTool()
m_prop.bind(m_mode);
m_prop.bind(m_pick);
m_prop.bind(m_invert);
+ m_prop.bind(m_selective);
m_invert.setId("Invert");
}
@@ -348,6 +352,7 @@ void FingerTool::updateTranslation() {
m_mode.setQStringName(tr("Mode:"));
m_pick.setQStringName(tr("Pick"));
m_invert.setQStringName(tr("Invert", NULL));
+ m_selective.setQStringName(tr("Selective", NULL));
}
//-----------------------------------------------------------------------------
@@ -414,6 +419,10 @@ bool FingerTool::onPropertyChanged(std::string propertyName) {
FingerInvert = (int)(m_invert.getValue());
}
+ else if (propertyName == m_selective.getName()) {
+ FingerSelective = (int)(m_selective.getValue());
+ }
+
return true;
}
@@ -436,7 +445,9 @@ void FingerTool::leftButtonDown(const TPointD &pos, const TMouseEvent &e) {
m_rasterTrack = new RasterStrokeGenerator(
ras, FINGER, (ColorType)m_mode.getIndex(), styleId,
TThickPoint(pos + convert(ras->getCenter()), thickness),
- m_mode.getIndex() == 0 ? m_invert.getValue() : false, 0, false, false);
+ m_mode.getIndex() == 1 ? m_selective.getValue() : false,
+ m_mode.getIndex() == 0 ? m_invert.getValue() : false,
+ false, false);
/*-- 作業中Fidを現在のFIDにする --*/
m_workingFrameId = getFrameId();
@@ -497,6 +508,7 @@ void FingerTool::onEnter() {
m_toolSize.setValue(FingerSize);
m_mode.setIndex(FingerMode);
m_pick.setValue(FingerPick ? 1 : 0);
+ m_selective.setValue(FingerSelective ? 1 : 0);
m_firstTime = false;
}
double x = m_toolSize.getValue();
diff --git a/toonz/sources/tnztools/tooloptions.cpp b/toonz/sources/tnztools/tooloptions.cpp
index 59ff42ad5..f98704c30 100644
--- a/toonz/sources/tnztools/tooloptions.cpp
+++ b/toonz/sources/tnztools/tooloptions.cpp
@@ -2190,18 +2190,22 @@ FingerToolOptionsBox::FingerToolOptionsBox(QWidget* parent, TTool* tool, TPalett
m_colorMode = dynamic_cast<ToolOptionCombo*>(m_controls.value("Mode:"));
m_invertMode = dynamic_cast<ToolOptionCheckbox*>(m_controls.value("Invert"));
+ m_selectiveMode = dynamic_cast<ToolOptionCheckbox*>(m_controls.value("Selective"));
bool ret = true;
if (m_colorMode) {
ret = ret && connect(m_colorMode, SIGNAL(currentIndexChanged(int)), this,
SLOT(onColorModeChanged(int)));
- if (m_invertMode && m_colorMode->currentIndex() == 1)//Paint
- m_invertMode->setEnabled(false);
+ if (m_invertMode)
+ m_invertMode->setEnabled(m_colorMode->currentIndex() == 0);//INK
+ if (m_selectiveMode)
+ m_selectiveMode->setEnabled(m_colorMode->currentIndex() == 1);//PAINT
}
}
void FingerToolOptionsBox::onColorModeChanged(int i) {
if (m_invertMode) m_invertMode->setEnabled(i == 0);
+ if (m_selectiveMode) m_selectiveMode->setEnabled(i == 1);
}
//=============================================================================
//
diff --git a/toonz/sources/toonzlib/rasterstrokegenerator.cpp b/toonz/sources/toonzlib/rasterstrokegenerator.cpp
index a6370d4e8..0aade6269 100644
--- a/toonz/sources/toonzlib/rasterstrokegenerator.cpp
+++ b/toonz/sources/toonzlib/rasterstrokegenerator.cpp
@@ -283,7 +283,9 @@ void RasterStrokeGenerator::placeOver(const TRasterCM32P &out,
else if (m_task == FINGER) {
/*-- Boundary Conditions --*/
if (outPix == rOut->pixels(y) || outPix == outEnd - 1) continue;
-
+ if (m_selective) {
+ if (outPix->getPaint() != 0) continue;
+ }
int inStyle = inPix->getInk();
if (inStyle == 0) continue;
@@ -296,7 +298,7 @@ void RasterStrokeGenerator::placeOver(const TRasterCM32P &out,
int tone = outPix->getTone();
/*--- When Invert is off: Fill hole operation ---*/
- if (!m_selective) {
+ if (!m_selectedStyle) {
/*-- For 4 neighborhood pixels --*/
int minTone = tone;
for (int p = 0; p < 4; p++) {