Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Retiming feature #1454

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app/app.pro
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ HEADERS += \
src/doubleprogressdialog.h \
src/colorslider.h \
src/checkupdatesdialog.h \
src/presetdialog.h
src/presetdialog.h \
src/retimedialog.h

SOURCES += \
src/importlayersdialog.cpp \
Expand Down Expand Up @@ -109,7 +110,8 @@ SOURCES += \
src/colorslider.cpp \
src/checkupdatesdialog.cpp \
src/presetdialog.cpp \
src/app_util.cpp
src/app_util.cpp \
src/retimedialog.cpp

FORMS += \
ui/importimageseqpreview.ui \
Expand Down Expand Up @@ -137,7 +139,8 @@ FORMS += \
ui/filespage.ui \
ui/toolspage.ui \
ui/toolboxwidget.ui \
ui/presetdialog.ui
ui/presetdialog.ui \
ui/retimedialog.ui



Expand Down
13 changes: 13 additions & 0 deletions app/src/actioncommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ GNU General Public License for more details.
#include "doubleprogressdialog.h"
#include "checkupdatesdialog.h"
#include "errordialog.h"
#include "retimedialog.h"


ActionCommands::ActionCommands(QWidget* parent) : QObject(parent)
Expand Down Expand Up @@ -760,6 +761,18 @@ void ActionCommands::moveFrameBackward()
}
}

void ActionCommands::retime()
{
auto dialog = new RetimeDialog(mParent);
dialog->setOrigFps(mEditor->fps());
dialog->exec();

if (dialog->result() == QDialog::Accepted)
{
mEditor->retime(dialog->getNewFps(), dialog->getNewSpeed());
}
}

Status ActionCommands::addNewBitmapLayer()
{
bool ok;
Expand Down
1 change: 1 addition & 0 deletions app/src/actioncommands.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class ActionCommands : public QObject
void duplicateKey();
void moveFrameForward();
void moveFrameBackward();
void retime();

// Layer
Status addNewBitmapLayer();
Expand Down
5 changes: 5 additions & 0 deletions app/src/mainwindow2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ void MainWindow2::createMenus()
connect(ui->actionDuplicate_Frame, &QAction::triggered, mCommands, &ActionCommands::duplicateKey);
connect(ui->actionMove_Frame_Forward, &QAction::triggered, mCommands, &ActionCommands::moveFrameForward);
connect(ui->actionMove_Frame_Backward, &QAction::triggered, mCommands, &ActionCommands::moveFrameBackward);
connect(ui->actionRetime, &QAction::triggered, mCommands, &ActionCommands::retime);

//--- Tool Menu ---
connect(ui->actionMove, &QAction::triggered, mToolBox, &ToolBoxWidget::moveOn);
Expand Down Expand Up @@ -1243,6 +1244,7 @@ void MainWindow2::setupKeyboardShortcuts()
ui->actionRemove_Frame->setShortcut(cmdKeySeq(CMD_REMOVE_FRAME));
ui->actionMove_Frame_Backward->setShortcut(cmdKeySeq(CMD_MOVE_FRAME_BACKWARD));
ui->actionMove_Frame_Forward->setShortcut(cmdKeySeq(CMD_MOVE_FRAME_FORWARD));
ui->actionRetime->setShortcut(cmdKeySeq(CMD_RETIME));
ui->actionFlip_inbetween->setShortcut(cmdKeySeq(CMD_FLIP_INBETWEEN));
ui->actionFlip_rolling->setShortcut(cmdKeySeq(CMD_FLIP_ROLLING));

Expand Down Expand Up @@ -1452,6 +1454,7 @@ void MainWindow2::makeConnections(Editor* pEditor, TimeLine* pTimeline)
connect(pTimeline, &TimeLine::newCameraLayer, mCommands, &ActionCommands::addNewCameraLayer);

connect(mTimeLine, &TimeLine::playButtonTriggered, mCommands, &ActionCommands::PlayStop);
connect(mTimeLine, &TimeLine::retimeTriggered, mCommands, &ActionCommands::retime);

connect(pEditor->layers(), &LayerManager::currentLayerChanged, pTimeline, &TimeLine::updateUI);
connect(pEditor->layers(), &LayerManager::layerCountChanged, pTimeline, &TimeLine::updateUI);
Expand All @@ -1461,6 +1464,8 @@ void MainWindow2::makeConnections(Editor* pEditor, TimeLine* pTimeline)
connect(pEditor, &Editor::objectLoaded, pTimeline, &TimeLine::onObjectLoaded);
connect(pEditor, &Editor::updateTimeLine, pTimeline, &TimeLine::updateUI);

connect(pEditor, &Editor::retimed, pTimeline, &TimeLine::updateFps);

connect(pEditor->layers(), &LayerManager::currentLayerChanged, mToolOptions, &ToolOptionWidget::updateUI);
}

Expand Down
30 changes: 30 additions & 0 deletions app/src/retimedialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include "retimedialog.h"
#include "ui_retimedialog.h"

RetimeDialog::RetimeDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::RetimeDialog)
{
ui->setupUi(this);
}

RetimeDialog::~RetimeDialog()
{
delete ui;
}

void RetimeDialog::setOrigFps(int origFps)
{
ui->origFps->setText(QString("<span style=' font-weight:600;'>%1 %2</span>").arg(origFps).arg(tr("fps")));
ui->newFpsBox->setValue(origFps);
}

int RetimeDialog::getNewFps()
{
return ui->newFpsBox->value();
}

qreal RetimeDialog::getNewSpeed()
{
return ui->newSpeedBox->value();
}
27 changes: 27 additions & 0 deletions app/src/retimedialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef RETIMEDIALOG_H
#define RETIMEDIALOG_H

#include <QDialog>

namespace Ui {
class RetimeDialog;
}

class RetimeDialog : public QDialog
{
Q_OBJECT

public:
explicit RetimeDialog(QWidget *parent = nullptr);
~RetimeDialog();

void setOrigFps(int origFps);
int getNewFps();

qreal getNewSpeed();

private:
Ui::RetimeDialog *ui;
};

#endif // RETIMEDIALOG_H
1 change: 1 addition & 0 deletions app/src/shortcutspage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ static QString getHumanReadableShortcutName(const QString& cmdName)
{CMD_LOOP, QObject::tr("Toggle Loop", "Shortcut")},
{CMD_MOVE_FRAME_BACKWARD, QObject::tr("Move Frame Backward", "Shortcut")},
{CMD_MOVE_FRAME_FORWARD, QObject::tr("Move Frame Forward", "Shortcut")},
{CMD_RETIME, QObject::tr("Retime Animation", "Shortcut")},
{CMD_NEW_BITMAP_LAYER, QObject::tr("New Bitmap Layer", "Shortcut")},
{CMD_NEW_CAMERA_LAYER, QObject::tr("New Camera Layer", "Shortcut")},
{CMD_NEW_FILE, QObject::tr("New File", "Shortcut")},
Expand Down
8 changes: 7 additions & 1 deletion app/ui/mainwindow2.ui
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<x>0</x>
<y>0</y>
<width>831</width>
<height>30</height>
<height>24</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
Expand Down Expand Up @@ -197,6 +197,7 @@
<addaction name="separator"/>
<addaction name="actionMove_Frame_Forward"/>
<addaction name="actionMove_Frame_Backward"/>
<addaction name="actionRetime"/>
<addaction name="separator"/>
<addaction name="actionFlip_inbetween"/>
<addaction name="actionFlip_rolling"/>
Expand Down Expand Up @@ -1089,6 +1090,11 @@
<string>Open Temporary Directory</string>
</property>
</action>
<action name="actionRetime">
<property name="text">
<string>Retime Animation</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
190 changes: 190 additions & 0 deletions app/ui/retimedialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RetimeDialog</class>
<widget class="QDialog" name="RetimeDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>456</width>
<height>335</height>
</rect>
</property>
<property name="windowTitle">
<string>Retime Animation</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="titleLabel">
<property name="text">
<string>&lt;h1&gt;Retime Animation&lt;/h1&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="descLabel">
<property name="text">
<string>Retiming allows you to adjust the FPS and playback speed of your project independently. It accomplishes this by moving the frames closer together or further apart to reach the desired speed and frame rate.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="frameRateLabel">
<property name="text">
<string>&lt;span style=&quot; text-decoration: underline;&quot;&gt;Frame Rate&lt;/span&gt;</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="fpsGroup">
<item>
<widget class="QLabel" name="origFpsLabel">
<property name="text">
<string>Original:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="origFps">
<property name="text">
<string>&lt;span style=&quot; font-weight:600;&quot;&gt;12 fps&lt;/span&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="newFpsLabel">
<property name="text">
<string>New:</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="newFpsBox">
<property name="suffix">
<string> fps</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>90</number>
</property>
<property name="value">
<number>12</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="speedTitle">
<property name="text">
<string>&lt;span style=&quot; text-decoration: underline;&quot;&gt;Speed&lt;/span&gt;</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="speedGroup">
<item>
<widget class="QLabel" name="origSpeedLabel">
<property name="text">
<string>Original:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="origSpeed">
<property name="text">
<string>&lt;span style=&quot; font-weight:600;&quot;&gt;1.00x&lt;/span&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="newSpeedLabel">
<property name="text">
<string>New:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="newSpeedBox">
<property name="suffix">
<string>x</string>
</property>
<property name="minimum">
<double>0.010000000000000</double>
</property>
<property name="maximum">
<double>90.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="warningLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; color:red;&quot;&gt;Warning: Retiming to a lower fps or higher speed may result in the loss of frames. This action cannot be undone.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>RetimeDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>RetimeDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
1 change: 1 addition & 0 deletions core_lib/data/resources/kb.ini
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ CmdGotoNextKeyFrame=Alt+.
CmdGotoPreviousKeyFrame=Alt+","
CmdMoveFrameForward=Ctrl+.
CmdMoveFrameBackward=ctrl+","
CmdRetime=
CmdAddFrame=F7
CmdDuplicateFrame=F6
CmdRemoveFrame=Shift+F5
Expand Down
Loading