Save and restore Pump Tool's Size and Accuracy settings

This commit is contained in:
manongjohn 2023-09-23 12:31:44 -04:00
parent af62c0f063
commit 4712c37d55

View file

@ -13,6 +13,7 @@
#include "tvectorrenderdata.h"
#include "tstrokedeformations.h"
#include "tmathutil.h"
#include "tenv.h"
// Toonz includes
#include "toonz/tobjecthandle.h"
@ -26,6 +27,9 @@
// Qt includes
#include <QCoreApplication> // For Qt translation support
TEnv::DoubleVar PumpSize("PumpToolSize", 20.0);
TEnv::IntVar PumpAccuracy("PumpToolAccuracy", 40);
using namespace ToolUtils;
//*****************************************************************************
@ -35,6 +39,7 @@ using namespace ToolUtils;
class PumpTool final : public TTool {
Q_DECLARE_TR_FUNCTIONS(PumpTool)
bool m_firstTime;
int m_strokeStyleId, m_strokeIndex; //!< Edited stroke indices
TStroke *m_inStroke, *m_outStroke; //!< Input/Output strokes
std::vector<TStroke *>
@ -88,7 +93,8 @@ public:
, m_undo(0)
, m_toolSize("Size:", 1, 100, 20)
, m_accuracy("Accuracy:", 0, 100, 40)
, m_enabled(false) {
, m_enabled(false)
, m_firstTime(false) {
bind(TTool::VectorImage);
m_splitPars.resize(2);
@ -125,6 +131,8 @@ public:
}
void invalidateCursorArea();
bool onPropertyChanged(std::string propertyName) override;
void onActivate() override;
void onDeactivate() override;
private:
@ -529,6 +537,28 @@ bool PumpTool::moveCursor(const TPointD &pos) {
return false;
}
//-----------------------------------------------------------------------------
bool PumpTool::onPropertyChanged(std::string propertyName) {
if (propertyName == m_toolSize.getName())
PumpSize = m_toolSize.getValue();
else if (propertyName == m_accuracy.getName())
PumpAccuracy = m_accuracy.getValue();
else
return false;
return true;
}
//-----------------------------------------------------------------------------
void PumpTool::onActivate() {
if (!m_firstTime) {
m_firstTime = true;
m_toolSize.setValue(PumpSize);
m_accuracy.setValue(PumpAccuracy);
}
}
//----------------------------------------------------------------------
void PumpTool::onDeactivate() {