diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp index b68138e..c20cc77 100644 --- a/toonz/sources/toonz/mainwindow.cpp +++ b/toonz/sources/toonz/mainwindow.cpp @@ -2013,6 +2013,23 @@ void MainWindow::defineActions() { createRightClickMenuAction(MI_ResetInterpolation, tr("Reset Interpolation"), ""); + createRightClickMenuAction(MI_UseLinearInterpolation, + tr("Linear Interpolation"), ""); + createRightClickMenuAction(MI_UseSpeedInOutInterpolation, + tr("Speed In / Speed Out Interpolation"), ""); + createRightClickMenuAction(MI_UseEaseInOutInterpolation, + tr("Ease In / Ease Out Interpolation"), ""); + createRightClickMenuAction(MI_UseEaseInOutPctInterpolation, + tr("Ease In / Ease Out (%) Interpolation"), ""); + createRightClickMenuAction(MI_UseExponentialInterpolation, + tr("Exponential Interpolation"), ""); + createRightClickMenuAction(MI_UseExpressionInterpolation, + tr("Expression Interpolation"), ""); + createRightClickMenuAction(MI_UseFileInterpolation, tr("File Interpolation"), + ""); + createRightClickMenuAction(MI_UseConstantInterpolation, + tr("Constant Interpolation"), ""); + createRightClickMenuAction(MI_FoldColumns, tr("Fold Column"), ""); createRightClickMenuAction(MI_ActivateThisColumnOnly, tr("Show This Only"), @@ -2315,9 +2332,9 @@ RecentFiles::~RecentFiles() {} void RecentFiles::addFilePath(QString path, FileType fileType) { QList files = - (fileType == Scene) - ? m_recentScenes - : (fileType == Level) ? m_recentLevels : m_recentFlipbookImages; + (fileType == Scene) ? m_recentScenes : (fileType == Level) + ? m_recentLevels + : m_recentFlipbookImages; int i; for (i = 0; i < files.size(); i++) if (files.at(i) == path) files.removeAt(i); @@ -2442,9 +2459,9 @@ void RecentFiles::saveRecentFiles() { QList RecentFiles::getFilesNameList(FileType fileType) { QList files = - (fileType == Scene) - ? m_recentScenes - : (fileType == Level) ? m_recentLevels : m_recentFlipbookImages; + (fileType == Scene) ? m_recentScenes : (fileType == Level) + ? m_recentLevels + : m_recentFlipbookImages; QList names; int i; for (i = 0; i < files.size(); i++) { @@ -2471,9 +2488,9 @@ void RecentFiles::refreshRecentFilesMenu(FileType fileType) { menu->setEnabled(false); else { CommandId clearActionId = - (fileType == Scene) - ? MI_ClearRecentScene - : (fileType == Level) ? MI_ClearRecentLevel : MI_ClearRecentImage; + (fileType == Scene) ? MI_ClearRecentScene : (fileType == Level) + ? MI_ClearRecentLevel + : MI_ClearRecentImage; menu->setActions(names); menu->addSeparator(); QAction *clearAction = CommandManager::instance()->getAction(clearActionId); diff --git a/toonz/sources/toonz/menubarcommandids.h b/toonz/sources/toonz/menubarcommandids.h index e27b12e..996825b 100644 --- a/toonz/sources/toonz/menubarcommandids.h +++ b/toonz/sources/toonz/menubarcommandids.h @@ -277,6 +277,15 @@ #define MI_SetConstantSpeed "MI_SetConstantSpeed" #define MI_ResetInterpolation "MI_ResetInterpolation" +#define MI_UseLinearInterpolation "MI_UseLinearInterpolation" +#define MI_UseSpeedInOutInterpolation "MI_UseSpeedInOutInterpolation" +#define MI_UseEaseInOutInterpolation "MI_UseEaseInOutInterpolation" +#define MI_UseEaseInOutPctInterpolation "MI_UseEaseInOutPctInterpolation" +#define MI_UseExponentialInterpolation "MI_UseExponentialInterpolation" +#define MI_UseExpressionInterpolation "MI_UseExpressionInterpolation" +#define MI_UseFileInterpolation "MI_UseFileInterpolation" +#define MI_UseConstantInterpolation "MI_UseConstantInterpolation" + #define MI_ActivateThisColumnOnly "MI_ActivateThisColumnOnly" #define MI_ActivateSelectedColumns "MI_ActivateSelectedColumns" #define MI_ActivateAllColumns "MI_ActivateAllColumns" diff --git a/toonz/sources/toonz/preferencespopup.cpp b/toonz/sources/toonz/preferencespopup.cpp index e3e3ce9..53c9dda 100644 --- a/toonz/sources/toonz/preferencespopup.cpp +++ b/toonz/sources/toonz/preferencespopup.cpp @@ -711,7 +711,7 @@ void PreferencesPopup::onStartupPopupChanged(int index) { //----------------------------------------------------------------------------- void PreferencesPopup::onKeyframeTypeChanged(int index) { - m_pref->setKeyframeType(index + 2); + m_pref->setKeyframeType(index + 1); } //----------------------------------------------------------------------------- @@ -1888,11 +1888,12 @@ PreferencesPopup::PreferencesPopup() //--- Animation ------------------------------ QStringList list; - list << tr("Linear") << tr("Speed In / Speed Out") << tr("Ease In / Ease Out") - << tr("Ease In / Ease Out %"); + list << tr("Constant") << tr("Linear") << tr("Speed In / Speed Out") + << tr("Ease In / Ease Out") << tr("Ease In / Ease Out %") + << tr("Exponential") << tr("Expression ") << tr("File"); m_keyframeType->addItems(list); int keyframeType = m_pref->getKeyframeType(); - m_keyframeType->setCurrentIndex(keyframeType - 2); + m_keyframeType->setCurrentIndex(keyframeType - 1); m_animationStepField->setValue(m_pref->getAnimationStep()); //--- Preview ------------------------------ diff --git a/toonz/sources/toonz/xshcellviewer.cpp b/toonz/sources/toonz/xshcellviewer.cpp index 4f42836..107f177 100644 --- a/toonz/sources/toonz/xshcellviewer.cpp +++ b/toonz/sources/toonz/xshcellviewer.cpp @@ -3389,6 +3389,7 @@ void CellArea::createKeyLineMenu(QMenu &menu, int row, int col) { menu.addAction(cmdManager->getAction(MI_SetAcceleration)); menu.addAction(cmdManager->getAction(MI_SetDeceleration)); menu.addAction(cmdManager->getAction(MI_SetConstantSpeed)); + menu.addSeparator(); } else { // Se le due chiavi non sono linear aggiungo il comando ResetInterpolation bool isR0FullK = pegbar->isFullKeyframe(r0); @@ -3398,9 +3399,32 @@ void CellArea::createKeyLineMenu(QMenu &menu, int row, int col) { TDoubleKeyframe::Type r1Type = pegbar->getParam(TStageObject::T_X)->getKeyframeAt(r1).m_prevType; if (isGlobalKeyFrameWithSameTypeDiffFromLinear(pegbar, r0) && - isGlobalKeyFrameWithSamePrevTypeDiffFromLinear(pegbar, r1)) + isGlobalKeyFrameWithSamePrevTypeDiffFromLinear(pegbar, r1)) { menu.addAction(cmdManager->getAction(MI_ResetInterpolation)); + menu.addSeparator(); + } } + + TDoubleKeyframe::Type rType = + pegbar->getParam(TStageObject::T_X)->getKeyframeAt(r0).m_type; + + if (rType != TDoubleKeyframe::Linear) + menu.addAction(cmdManager->getAction(MI_UseLinearInterpolation)); + if (rType != TDoubleKeyframe::SpeedInOut) + menu.addAction(cmdManager->getAction(MI_UseSpeedInOutInterpolation)); + if (rType != TDoubleKeyframe::EaseInOut) + menu.addAction(cmdManager->getAction(MI_UseEaseInOutInterpolation)); + if (rType != TDoubleKeyframe::EaseInOutPercentage) + menu.addAction(cmdManager->getAction(MI_UseEaseInOutPctInterpolation)); + if (rType != TDoubleKeyframe::Exponential) + menu.addAction(cmdManager->getAction(MI_UseExponentialInterpolation)); + if (rType != TDoubleKeyframe::Expression) + menu.addAction(cmdManager->getAction(MI_UseExpressionInterpolation)); + if (rType != TDoubleKeyframe::File) + menu.addAction(cmdManager->getAction(MI_UseFileInterpolation)); + if (rType != TDoubleKeyframe::Constant) + menu.addAction(cmdManager->getAction(MI_UseConstantInterpolation)); + #ifdef LINETEST menu.addSeparator(); int paramStep = getParamStep(pegbar, r0); diff --git a/toonz/sources/toonz/xsheetcmd.cpp b/toonz/sources/toonz/xsheetcmd.cpp index 553832f..1544141 100644 --- a/toonz/sources/toonz/xsheetcmd.cpp +++ b/toonz/sources/toonz/xsheetcmd.cpp @@ -1686,6 +1686,63 @@ public: } ResetArrowCommand; +//----------------------------------------------------------------------------- +// Unify commands for all types of interpolation +class SetInterpolation final : public MenuItemHandler { + TDoubleKeyframe::Type m_type; + +public: + SetInterpolation(CommandId cmdId, TDoubleKeyframe::Type type) + : MenuItemHandler(cmdId), m_type(type) {} + + void execute() override { + TApp *app = TApp::instance(); + TXsheet *xsh = app->getCurrentXsheet()->getXsheet(); + int row = app->getCurrentFrame()->getFrame(); + + TStageObjectId objectId = app->getCurrentObject()->getObjectId(); + TStageObject *pegbar = xsh->getStageObject(objectId); + if (!pegbar) return; + + int r0, r1; + double ease0, ease1; + + pegbar->getKeyframeSpan(row, r0, ease0, r1, ease1); + + KeyFrameHandleCommandUndo *undo = + new KeyFrameHandleCommandUndo(objectId, r0, r1); + + TStageObject::Keyframe k0 = pegbar->getKeyframe(r0); + TStageObject::Keyframe k1 = pegbar->getKeyframe(r1); + + for (int i = 0; i < TStageObject::T_ChannelCount; i++) { + k0.m_channels[i].m_type = m_type; + k1.m_channels[i].m_prevType = m_type; + } + pegbar->setKeyframeWithoutUndo(r0, k0); + pegbar->setKeyframeWithoutUndo(r1, k1); + + TUndoManager::manager()->add(undo); + + TApp::instance()->getCurrentScene()->setDirtyFlag(true); + TApp::instance()->getCurrentObject()->notifyObjectIdChanged(false); + } + +} UseLinearInterpolation(MI_UseLinearInterpolation, TDoubleKeyframe::Linear), + UseSpeedInOutInterpolation(MI_UseSpeedInOutInterpolation, + TDoubleKeyframe::SpeedInOut), + UseEaseInOutInterpolation(MI_UseEaseInOutInterpolation, + TDoubleKeyframe::EaseInOut), + UseEaseInOutPctInterpolation(MI_UseEaseInOutPctInterpolation, + TDoubleKeyframe::EaseInOutPercentage), + UseExponentialInterpolation(MI_UseExponentialInterpolation, + TDoubleKeyframe::Exponential), + UseExpressionInterpolation(MI_UseExpressionInterpolation, + TDoubleKeyframe::Expression), + UseFileInterpolation(MI_UseFileInterpolation, TDoubleKeyframe::File), + UseConstantInterpolation(MI_UseConstantInterpolation, + TDoubleKeyframe::Constant); + //=========================================================== // To Be Reworked //===========================================================