Skip to content

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

C

#assistants: handle end of dragging in TTool::onPropertyChanged

Ivan Mahonind07d8b2325ea
diff --git a/toonz/sources/include/tools/tool.h b/toonz/sources/include/tools/tool.h
index 4e79da4a6..7346bf9e8 100644
--- a/toonz/sources/include/tools/tool.h
+++ b/toonz/sources/include/tools/tool.h
@@ -426,6 +426,9 @@ return true if the method execution can have changed the current tool
virtual TPropertyGroup *getProperties(int) { return 0; }
+ virtual bool onPropertyChanged(std::string propertyName, bool addToUndo) {
+ return onPropertyChanged(propertyName);
+ }
/*!
Does the tasks associated to changes in \p propertyName and returns \p
true;
diff --git a/toonz/sources/tnztools/editassistantstool.cpp b/toonz/sources/tnztools/editassistantstool.cpp
index c0443f49a..ddb78b683 100644
--- a/toonz/sources/tnztools/editassistantstool.cpp
+++ b/toonz/sources/tnztools/editassistantstool.cpp
@@ -203,14 +203,14 @@ public:
m_readAssistant->updateTranslation();
}
- bool onPropertyChanged(std::string name/*, bool addToUndo*/) override {
+ bool onPropertyChanged(std::string name, bool addToUndo) override {
if (TProperty *property = m_toolProperties.getProperty(name)) {
if (name == m_assistantType.getName())
m_newAssisnantType = TStringId::find( to_string(m_assistantType.getValue()) );
} else {
if (Closer closer = write(ModeAssistant, true))
m_writeAssistant->propertyChanged(TStringId::find(name));
- //if (addToUndo) apply();
+ if (addToUndo) apply();
getViewer()->GLInvalidateAll();
}
return true;
diff --git a/toonz/sources/tnztools/filltool.cpp b/toonz/sources/tnztools/filltool.cpp
index 649dddffe..84ea12311 100644
--- a/toonz/sources/tnztools/filltool.cpp
+++ b/toonz/sources/tnztools/filltool.cpp
@@ -2036,7 +2036,7 @@ void FillTool::resetMulti() {
//-----------------------------------------------------------------------------
-bool FillTool::onPropertyChanged(std::string propertyName) {
+bool FillTool::onPropertyChanged(std::string propertyName, bool addToUndo) {
/*--- m_rectFill->onPropertyChangedを呼ぶかどうかのフラグ
fillType, frameRange, selective,
colorTypeが変わったときに呼ぶ---*/
@@ -2093,8 +2093,7 @@ bool FillTool::onPropertyChanged(std::string propertyName) {
}
else if (!m_frameSwitched &&
- (propertyName == m_maxGapDistance.getName() ||
- propertyName == m_maxGapDistance.getName() + "withUndo")) {
+ (propertyName == m_maxGapDistance.getName())) {
TXshLevel *xl = TTool::getApplication()->getCurrentLevel()->getLevel();
m_level = xl ? xl->getSimpleLevel() : 0;
if (TVectorImageP vi = getImage(true)) {
@@ -2114,8 +2113,7 @@ bool FillTool::onPropertyChanged(std::string propertyName) {
if (m_level) {
m_level->setDirtyFlag(true);
TTool::getApplication()->getCurrentLevel()->notifyLevelChange();
- if (propertyName == m_maxGapDistance.getName() + "withUndo" &&
- m_changedGapOriginalValue != -1.0) {
+ if (addToUndo && m_changedGapOriginalValue != -1.0) {
TUndoManager::manager()->add(new VectorGapSizeChangeUndo(
m_changedGapOriginalValue, m_maxGapDistance.getValue(),
m_level.getPointer(), fid, vi, m_oldFillInformation));
diff --git a/toonz/sources/tnztools/filltool.h b/toonz/sources/tnztools/filltool.h
index 80bdd67e7..29ca18671 100644
--- a/toonz/sources/tnztools/filltool.h
+++ b/toonz/sources/tnztools/filltool.h
@@ -124,7 +124,7 @@ public:
void leftButtonDoubleClick(const TPointD &pos, const TMouseEvent &e) override;
void resetMulti();
- bool onPropertyChanged(std::string propertyName) override;
+ bool onPropertyChanged(std::string propertyName, bool addToUndo) override;
void onImageChanged() override;
void draw() override;
diff --git a/toonz/sources/tnztools/fullcolorbrushtool.cpp b/toonz/sources/tnztools/fullcolorbrushtool.cpp
index fdadf1dd5..d349d39e4 100644
--- a/toonz/sources/tnztools/fullcolorbrushtool.cpp
+++ b/toonz/sources/tnztools/fullcolorbrushtool.cpp
@@ -285,6 +285,8 @@ bool FullColorBrushTool::askWrite(const TRect &rect) {
//--------------------------------------------------------------------------------------------------
bool FullColorBrushTool::preLeftButtonDown() {
+ m_modifierAssistants->drawOnly = !FullcolorAssistants;
+
m_inputmanager.clearModifiers();
m_inputmanager.addModifier( TInputModifierP(m_modifierTangents.getPointer()) );
m_inputmanager.addModifier( TInputModifierP(m_modifierSegmentation.getPointer()) );
diff --git a/toonz/sources/tnztools/tooloptionscontrols.cpp b/toonz/sources/tnztools/tooloptionscontrols.cpp
index 1af2ee973..f26ee4fac 100644
--- a/toonz/sources/tnztools/tooloptionscontrols.cpp
+++ b/toonz/sources/tnztools/tooloptionscontrols.cpp
@@ -53,12 +53,8 @@ ToolOptionControl::ToolOptionControl(TTool *tool, std::string propertyName,
//-----------------------------------------------------------------------------
-void ToolOptionControl::notifyTool(bool addToUndo) {
- std::string tempPropertyName = m_propertyName;
- if (addToUndo && m_propertyName == "Maximum Gap")
- tempPropertyName = tempPropertyName + "withUndo";
- m_tool->onPropertyChanged(tempPropertyName);
-}
+void ToolOptionControl::notifyTool(bool addToUndo)
+ { m_tool->onPropertyChanged(m_propertyName, addToUndo); }
//-----------------------------------------------------------------------------
/*! return true if the control is belonging to the visible combo viewer. very
@@ -221,7 +217,7 @@ void ToolOptionPairSlider::updateStatus() {
void ToolOptionPairSlider::onValuesChanged(bool isDragging) {
m_property->setValue(getValues());
- notifyTool();
+ notifyTool(!isDragging);
// synchronize the state with the same widgets in other tool option bars
if (m_toolHandle) m_toolHandle->notifyToolChanged();
}
@@ -260,7 +256,7 @@ void ToolOptionIntPairSlider::updateStatus() {
void ToolOptionIntPairSlider::onValuesChanged(bool isDragging) {
m_property->setValue(getValues());
- notifyTool();
+ notifyTool(!isDragging);
// synchronize the state with the same widgets in other tool option bars
if (m_toolHandle) m_toolHandle->notifyToolChanged();
}
@@ -299,7 +295,7 @@ void ToolOptionIntSlider::updateStatus() {
void ToolOptionIntSlider::onValueChanged(bool isDragging) {
m_property->setValue(getValue());
- notifyTool();
+ notifyTool(!isDragging);
}
//=============================================================================
diff --git a/toonz/sources/tnztools/tooloptionscontrols.h b/toonz/sources/tnztools/tooloptionscontrols.h
index 78fad5bae..263919a47 100644
--- a/toonz/sources/tnztools/tooloptionscontrols.h
+++ b/toonz/sources/tnztools/tooloptionscontrols.h
@@ -73,7 +73,7 @@ public:
const std::string &propertyName() const { return m_propertyName; }
void onPropertyChanged() override { updateStatus(); }
- void notifyTool(bool addToUndo = false);
+ void notifyTool(bool addToUndo = true);
// return true if the control is belonging to the visible viewer
bool isInVisibleViewer(QWidget *widget);