Disable Auto-Stretch Frame (#1707)

Added option to enable / disable Auto-Stretch Frame
This commit is contained in:
manongjohn 2018-03-27 06:26:37 -04:00 committed by shun-iwasawa
parent 4734f86618
commit 29ce0b3da6
5 changed files with 62 additions and 24 deletions

View file

@ -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;

View file

@ -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

View file

@ -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 -----------------------

View file

@ -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);
};
//**********************************************************************************

View file

@ -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);
}
//-----------------------------------------------------------------
@ -1678,3 +1681,8 @@ QString Preferences::getColorCalibrationLutPath(QString &monitorName) const {
}
//-----------------------------------------------------------------
void Preferences::enableAutoStretch(bool on) {
m_enableAutoStretch = on;
m_settings->setValue("EnableAutoStretch", on ? "1" : "0");
}