From 9380d5ae30586a2ce701cfbf71ac6255ea27d58b Mon Sep 17 00:00:00 2001 From: Ivan Mahonin Date: May 01 2023 08:50:46 +0000 Subject: #assistants: enable/disable assistants in FullColorBrushTool --- diff --git a/toonz/sources/include/tools/tooloptions.h b/toonz/sources/include/tools/tooloptions.h index a4f712b..e2a51ee 100644 --- a/toonz/sources/include/tools/tooloptions.h +++ b/toonz/sources/include/tools/tooloptions.h @@ -557,7 +557,6 @@ class BrushToolOptionsBox final : public ToolOptionsBox { private: class PresetNamePopup; PresetNamePopup *m_presetNamePopup; - void filterControls(); public: BrushToolOptionsBox(QWidget *parent, TTool *tool, TPaletteHandle *pltHandle, diff --git a/toonz/sources/tnztools/fullcolorbrushtool.cpp b/toonz/sources/tnztools/fullcolorbrushtool.cpp index 78c5016..fdadf1d 100644 --- a/toonz/sources/tnztools/fullcolorbrushtool.cpp +++ b/toonz/sources/tnztools/fullcolorbrushtool.cpp @@ -55,6 +55,7 @@ TEnv::DoubleVar FullcolorModifierSize("FullcolorModifierSize", 0); TEnv::DoubleVar FullcolorModifierOpacity("FullcolorModifierOpacity", 100); TEnv::IntVar FullcolorModifierEraser("FullcolorModifierEraser", 0); TEnv::IntVar FullcolorModifierLockAlpha("FullcolorModifierLockAlpha", 0); +TEnv::IntVar FullcolorAssistants("FullcolorAssistants", 0); TEnv::StringVar FullcolorBrushPreset("FullcolorBrushPreset", ""); //---------------------------------------------------------------------------------- @@ -122,6 +123,7 @@ FullColorBrushTool::FullColorBrushTool(std::string name) , m_modifierOpacity("ModifierOpacity", 0, 100, 100, true) , m_modifierEraser("ModifierEraser", false) , m_modifierLockAlpha("Lock Alpha", false) + , m_assistants("Assistants", true) , m_preset("Preset:") , m_enabledPressure(false) , m_minCursorThick(0) @@ -142,17 +144,6 @@ FullColorBrushTool::FullColorBrushTool(std::string name) m_modifierSegmentation = new TModifierSegmentation(); m_thickness.setNonLinearSlider(); - - m_prop.bind(m_thickness); - m_prop.bind(m_hardness); - m_prop.bind(m_opacity); - m_prop.bind(m_modifierSize); - m_prop.bind(m_modifierOpacity); - m_prop.bind(m_modifierEraser); - m_prop.bind(m_modifierLockAlpha); - m_prop.bind(m_pressure); - m_prop.bind(m_preset); - m_preset.setId("BrushPreset"); m_modifierEraser.setId("RasterEraser"); m_modifierLockAlpha.setId("LockAlpha"); @@ -193,6 +184,7 @@ void FullColorBrushTool::updateTranslation() { m_modifierOpacity.setQStringName(tr("Opacity")); m_modifierEraser.setQStringName(tr("Eraser")); m_modifierLockAlpha.setQStringName(tr("Lock Alpha")); + m_assistants.setQStringName(tr("Assistants")); } //--------------------------------------------------------------------------------------------------- @@ -576,6 +568,24 @@ void FullColorBrushTool::onLeave() { TPropertyGroup *FullColorBrushTool::getProperties(int targetType) { if (!m_presetsLoaded) initPresets(); + + bool noBrush = !getBrushStyle(); + + m_prop.clear(); + if (noBrush) { + m_prop.bind(m_thickness); + m_prop.bind(m_hardness); + m_prop.bind(m_opacity); + } else { + m_prop.bind(m_modifierSize); + m_prop.bind(m_modifierOpacity); + m_prop.bind(m_modifierEraser); + m_prop.bind(m_modifierLockAlpha); + } + m_prop.bind(m_pressure); + m_prop.bind(m_assistants); + m_prop.bind(m_preset); + return &m_prop; } @@ -635,6 +645,7 @@ bool FullColorBrushTool::onPropertyChanged(std::string propertyName) { FullcolorModifierOpacity = m_modifierOpacity.getValue(); FullcolorModifierEraser = m_modifierEraser.getValue() ? 1 : 0; FullcolorModifierLockAlpha = m_modifierLockAlpha.getValue() ? 1 : 0; + FullcolorAssistants = m_assistants.getValue() ? 1 : 0; if (m_preset.getValue() != CUSTOM_WSTR) { m_preset.setValue(CUSTOM_WSTR); @@ -690,6 +701,7 @@ void FullColorBrushTool::loadPreset() { m_modifierOpacity.setValue(preset.m_modifierOpacity); m_modifierEraser.setValue(preset.m_modifierEraser); m_modifierLockAlpha.setValue(preset.m_modifierLockAlpha); + m_assistants.setValue(preset.m_assistants); } catch (...) { } } @@ -710,6 +722,7 @@ void FullColorBrushTool::addPreset(QString name) { preset.m_modifierOpacity = m_modifierOpacity.getValue(); preset.m_modifierEraser = m_modifierEraser.getValue(); preset.m_modifierLockAlpha = m_modifierLockAlpha.getValue(); + preset.m_assistants = m_assistants.getValue(); // Pass the preset to the manager m_presetsManager.addPreset(preset); @@ -749,6 +762,7 @@ void FullColorBrushTool::loadLastBrush() { m_modifierOpacity.setValue(FullcolorModifierOpacity); m_modifierEraser.setValue(FullcolorModifierEraser ? true : false); m_modifierLockAlpha.setValue(FullcolorModifierLockAlpha ? true : false); + m_assistants.setValue(FullcolorAssistants ? true : false); } //------------------------------------------------------------------ diff --git a/toonz/sources/tnztools/fullcolorbrushtool.h b/toonz/sources/tnztools/fullcolorbrushtool.h index 50fdfb1..13ca08f 100644 --- a/toonz/sources/tnztools/fullcolorbrushtool.h +++ b/toonz/sources/tnztools/fullcolorbrushtool.h @@ -130,6 +130,7 @@ protected: TDoubleProperty m_modifierOpacity; TBoolProperty m_modifierEraser; TBoolProperty m_modifierLockAlpha; + TBoolProperty m_assistants; TEnumProperty m_preset; TPixel32 m_currentColor; diff --git a/toonz/sources/tnztools/tooloptions.cpp b/toonz/sources/tnztools/tooloptions.cpp index 2ca4b7c..10ab2db 100644 --- a/toonz/sources/tnztools/tooloptions.cpp +++ b/toonz/sources/tnztools/tooloptions.cpp @@ -1953,53 +1953,11 @@ BrushToolOptionsBox::BrushToolOptionsBox(QWidget *parent, TTool *tool, TStroke::OutlineOptions::MITER_JOIN); } hLayout()->addStretch(1); - filterControls(); -} - -//----------------------------------------------------------------------------- - -void BrushToolOptionsBox::filterControls() { - // show or hide widgets which modify imported brush (mypaint) - - bool showModifiers = false; - if (m_tool->getTargetType() & TTool::RasterImage) { - FullColorBrushTool *fullColorBrushTool = - dynamic_cast(m_tool); - showModifiers = fullColorBrushTool->getBrushStyle(); - } else if (m_tool->getTargetType() & TTool::ToonzImage) { - ToonzRasterBrushTool *toonzRasterBrushTool = - dynamic_cast(m_tool); - showModifiers = toonzRasterBrushTool->isMyPaintStyleSelected(); - } else { // (m_tool->getTargetType() & TTool::Vectors) - m_snapSensitivityCombo->setHidden(!m_snapCheckbox->isChecked()); - return; - } - - for (QMap::iterator it = m_labels.begin(); - it != m_labels.end(); it++) { - bool isModifier = (it.key().substr(0, 8) == "Modifier"); - 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() == "Lock Alpha" || it.key() == "Pressure" || - it.key() == "Preset:"); - bool visible = isCommon || (isModifier == showModifiers); - if (QWidget *widget = dynamic_cast(it.value())) - widget->setVisible(visible); - } } //----------------------------------------------------------------------------- void BrushToolOptionsBox::updateStatus() { - filterControls(); - QMap::iterator it; for (it = m_controls.begin(); it != m_controls.end(); it++) it.value()->updateStatus(); diff --git a/toonz/sources/tnztools/toonzrasterbrushtool.cpp b/toonz/sources/tnztools/toonzrasterbrushtool.cpp index 0b256e9..180f9ea 100644 --- a/toonz/sources/tnztools/toonzrasterbrushtool.cpp +++ b/toonz/sources/tnztools/toonzrasterbrushtool.cpp @@ -2372,13 +2372,14 @@ BrushData::BrushData() , m_hardness(0.0) , m_opacityMin(0.0) , m_opacityMax(0.0) - , m_drawOrder(0) , m_pencil(false) , m_pressure(false) , m_modifierSize(0.0) + , m_drawOrder(0) , m_modifierOpacity(0.0) , m_modifierEraser(0.0) - , m_modifierLockAlpha(0.0) {} + , m_modifierLockAlpha(0.0) + , m_assistants(false) {} //---------------------------------------------------------------------------------------------------------- @@ -2390,13 +2391,14 @@ BrushData::BrushData(const std::wstring &name) , m_hardness(0.0) , m_opacityMin(0.0) , m_opacityMax(0.0) - , m_drawOrder(0) , m_pencil(false) , m_pressure(false) + , m_drawOrder(0) , m_modifierSize(0.0) , m_modifierOpacity(0.0) , m_modifierEraser(0.0) - , m_modifierLockAlpha(0.0) {} + , m_modifierLockAlpha(0.0) + , m_assistants(false) {} //---------------------------------------------------------------------------------------------------------- @@ -2437,6 +2439,9 @@ void BrushData::saveData(TOStream &os) { os.openChild("Modifier_LockAlpha"); os << (int)m_modifierLockAlpha; os.closeChild(); + os.openChild("Assistants"); + os << (int)m_assistants; + os.closeChild(); } //---------------------------------------------------------------------------------------------------------- @@ -2472,6 +2477,8 @@ void BrushData::loadData(TIStream &is) { is >> val, m_modifierEraser = val, is.matchEndTag(); else if (tagName == "Modifier_LockAlpha") is >> val, m_modifierLockAlpha = val, is.matchEndTag(); + else if (tagName == "Assistants") + is >> val, m_assistants = val, is.matchEndTag(); else is.skipCurrentTag(); } diff --git a/toonz/sources/tnztools/toonzrasterbrushtool.h b/toonz/sources/tnztools/toonzrasterbrushtool.h index 3bf070c..3ac8fae 100644 --- a/toonz/sources/tnztools/toonzrasterbrushtool.h +++ b/toonz/sources/tnztools/toonzrasterbrushtool.h @@ -46,6 +46,7 @@ struct BrushData final : public TPersist { int m_drawOrder; double m_modifierSize, m_modifierOpacity; bool m_modifierEraser, m_modifierLockAlpha; + bool m_assistants; BrushData(); BrushData(const std::wstring &name);