diff --git a/toonz/sources/include/toonz/preferences.h b/toonz/sources/include/toonz/preferences.h index be2fa17b..e6c0eb53 100644 --- a/toonz/sources/include/toonz/preferences.h +++ b/toonz/sources/include/toonz/preferences.h @@ -245,7 +245,7 @@ public: FunctionEditorToggle getFunctionEditorToggle() { return m_functionEditorToggle; } - + // color calibration using 3DLUT void enableColorCalibration(bool on); bool isColorCalibrationEnabled() const { return m_colorCalibrationEnabled; } @@ -332,6 +332,9 @@ public: bool isAutoCreateEnabled() const { return m_autocreationType > 0; } bool isAnimationSheetEnabled() const { return m_autocreationType == 2; } + void enableAutoStretch(bool on); + bool isAutoStretchEnabled() const { return m_enableAutoStretch; } + void enableSaveUnpaintedInCleanup(bool on); bool isSaveUnpaintedInCleanupEnable() const { return m_saveUnpaintedInCleanup; @@ -680,6 +683,7 @@ private: FunctionEditorToggle m_functionEditorToggle; bool m_currentTimelineEnabled; + bool m_enableAutoStretch; // color calibration using 3DLUT bool m_colorCalibrationEnabled = false; diff --git a/toonz/sources/tnztools/tool.cpp b/toonz/sources/tnztools/tool.cpp index c0532074..fa2ecde8 100644 --- a/toonz/sources/tnztools/tool.cpp +++ b/toonz/sources/tnztools/tool.cpp @@ -266,6 +266,7 @@ TImage *TTool::touchImage() { bool isAutoCreateEnabled = pref->isAutoCreateEnabled(); bool animationSheetEnabled = pref->isAnimationSheetEnabled(); + bool isAutoStretchEnabled = pref->isAutoStretchEnabled(); TFrameHandle *currentFrame = m_application->getCurrentFrame(); TXshLevelHandle *currentLevel = m_application->getCurrentLevel(); @@ -318,7 +319,8 @@ TImage *TTool::touchImage() { // create a new drawing. // measure the hold length (starting from the current row) : r0-r1 int r0 = row, r1 = row; - while (xsh->getCell(r1 + 1, col) == cell) r1++; + if (isAutoStretchEnabled) + while (xsh->getCell(r1 + 1, col) == cell) r1++; // find the proper frameid (possibly addisng suffix, in order to avoid a // fid already used) TFrameId fid = getNewFrameId(sl, row); @@ -387,31 +389,37 @@ TImage *TTool::touchImage() { xsh->setCell(row, col, cell); // create holds - if (a >= r0) { - // create a hold before : [a+1, row-1] - TXshCell aCell = xsh->getCell(a, col); - for (int i = a + 1; i < row; i++) xsh->setCell(i, col, aCell); - m_cellsData.push_back(a + 1); - m_cellsData.push_back(row - 1); - m_cellsData.push_back(1); // vuoto => vecchio + if (!isAutoStretchEnabled) { + m_cellsData.push_back(row); + m_cellsData.push_back(row); + m_cellsData.push_back(2); // vuoto => nuovo + } else { + if (a >= r0) { + // create a hold before : [a+1, row-1] + TXshCell aCell = xsh->getCell(a, col); + for (int i = a + 1; i < row; i++) xsh->setCell(i, col, aCell); + m_cellsData.push_back(a + 1); + m_cellsData.push_back(row - 1); + m_cellsData.push_back(1); // vuoto => vecchio - if (b <= r1 && xsh->getCell(b, col).getSimpleLevel() == sl) { - // create also a hold after + if (b <= r1 && xsh->getCell(b, col).getSimpleLevel() == sl) { + // create also a hold after + for (int i = row + 1; i < b; i++) xsh->setCell(i, col, cell); + m_cellsData.push_back(row); + m_cellsData.push_back(b - 1); + m_cellsData.push_back(2); // vuoto => nuovo + } else { + m_cellsData.push_back(row); + m_cellsData.push_back(row); + m_cellsData.push_back(2); // vuoto => nuovo + } + } else if (b <= r1) { + // create a hold after for (int i = row + 1; i < b; i++) xsh->setCell(i, col, cell); m_cellsData.push_back(row); m_cellsData.push_back(b - 1); m_cellsData.push_back(2); // vuoto => nuovo - } else { - m_cellsData.push_back(row); - m_cellsData.push_back(row); - m_cellsData.push_back(2); // vuoto => nuovo } - } else if (b <= r1) { - // create a hold after - for (int i = row + 1; i < b; i++) xsh->setCell(i, col, cell); - m_cellsData.push_back(row); - m_cellsData.push_back(b - 1); - m_cellsData.push_back(2); // vuoto => nuovo } } // notify & return diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index 11a116e2..4da7636b 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -686,6 +686,10 @@ void PreferencesPopup::onKeyframeTypeChanged(int index) { void PreferencesPopup::onAutocreationTypeChanged(int index) { m_pref->setAutocreationType(index); + if (index == 2) + m_enableAutoStretch->setDisabled(false); + else + m_enableAutoStretch->setDisabled(true); } //----------------------------------------------------------------------------- @@ -1172,6 +1176,12 @@ void PreferencesPopup::onLutPathChanged() { m_lutPathFileField->getPath()); } +//----------------------------------------------------------------------------- + +void PreferencesPopup::onEnableAutoStretch(int index) { + m_pref->enableAutoStretch(index == Qt::Checked); +} + //********************************************************************************** // PrefencesPopup's constructor //********************************************************************************** @@ -1360,6 +1370,7 @@ PreferencesPopup::PreferencesPopup() tr("Use higher DPI for calculations - Slower but more accurate"), this); m_downArrowInLevelStripCreatesNewFrame = new CheckBox( tr("Down Arrow at End of Level Strip Creates a New Frame"), this); + m_enableAutoStretch = new CheckBox(tr("Enable auto-stretch frame"), this); //--- Tools ------------------------------- categoryList->addItem(tr("Tools")); @@ -1742,6 +1753,8 @@ PreferencesPopup::PreferencesPopup() m_autocreationType->addItems(autocreationTypes); int autocreationType = m_pref->getAutocreationType(); m_autocreationType->setCurrentIndex(autocreationType); + m_enableAutoStretch->setChecked(m_pref->isAutoStretchEnabled()); + if (autocreationType != 2) m_enableAutoStretch->setDisabled(true); QStringList vectorSnappingTargets; vectorSnappingTargets << tr("Strokes") << tr("Guides") << tr("All"); @@ -2224,6 +2237,7 @@ PreferencesPopup::PreferencesPopup() Qt::AlignRight); drawingTopLay->addWidget(m_autocreationType, 5, 1, 1, 3, Qt::AlignLeft | Qt::AlignVCenter); + drawingTopLay->addWidget(m_enableAutoStretch, 5, 3); drawingTopLay->addWidget(new QLabel(tr("Vector Snapping:")), 6, 0, Qt::AlignRight); drawingTopLay->addWidget(m_vectorSnappingTargetCB, 6, 1, 1, 3, @@ -2720,6 +2734,8 @@ PreferencesPopup::PreferencesPopup() SLOT(onDownArrowInLevelStripCreatesNewFrame(int))); ret = ret && connect(m_newLevelToCameraSizeCB, SIGNAL(clicked(bool)), SLOT(onNewLevelToCameraSizeChanged(bool))); + ret = ret && connect(m_enableAutoStretch, SIGNAL(stateChanged(int)), this, + SLOT(onEnableAutoStretch(int))); //--- Tools ----------------------- diff --git a/toonz/sources/toonz/preferencespopup.h b/toonz/sources/toonz/preferencespopup.h index f7bd4db1..db411281 100644 --- a/toonz/sources/toonz/preferencespopup.h +++ b/toonz/sources/toonz/preferencespopup.h @@ -78,7 +78,8 @@ private: *m_useNumpadForSwitchingStyles, *m_expandFunctionHeader, *m_useHigherDpiOnVectorSimplifyCB, *m_keepFillOnVectorSimplifyCB, *m_newLevelToCameraSizeCB, *m_ignoreImageDpiCB, - *m_syncLevelRenumberWithXsheet, *m_downArrowInLevelStripCreatesNewFrame; + *m_syncLevelRenumberWithXsheet, *m_downArrowInLevelStripCreatesNewFrame, + *m_enableAutoStretch; DVGui::FileField *m_customProjectRootFileField; @@ -206,6 +207,7 @@ private slots: void onColorCalibrationChanged(bool); void onLutPathChanged(); void onCheckLatestVersionChanged(bool); + void onEnableAutoStretch(int index); }; //********************************************************************************** diff --git a/toonz/sources/toonzlib/preferences.cpp b/toonz/sources/toonzlib/preferences.cpp index 6238ed41..bf983951 100644 --- a/toonz/sources/toonzlib/preferences.cpp +++ b/toonz/sources/toonzlib/preferences.cpp @@ -336,7 +336,8 @@ Preferences::Preferences() , m_loadedXsheetLayout("Classic-revised") , m_pathAliasPriority(ProjectFolderOnly) , m_functionEditorToggle(ShowGraphEditorInPopup) - , m_currentTimelineEnabled(true) { + , m_currentTimelineEnabled(true) + , m_enableAutoStretch(true) { TCamera camera; m_defLevelType = PLI_XSHLEVEL; m_defLevelWidth = camera.getSize().lx; @@ -686,6 +687,8 @@ Preferences::Preferences() } getValue(*m_settings, "latestVersionCheckEnabled", m_latestVersionCheckEnabled); + + getValue(*m_settings, "EnableAutoStretch", m_enableAutoStretch); } //----------------------------------------------------------------- @@ -1677,4 +1680,9 @@ QString Preferences::getColorCalibrationLutPath(QString &monitorName) const { return m_colorCalibrationLutPaths.value(monitorName); } -//----------------------------------------------------------------- \ No newline at end of file +//----------------------------------------------------------------- + +void Preferences::enableAutoStretch(bool on) { + m_enableAutoStretch = on; + m_settings->setValue("EnableAutoStretch", on ? "1" : "0"); +} \ No newline at end of file