Commit 00619382 authored by Scott Petrovic's avatar Scott Petrovic

Add option to animation menu for setting start time, end time, and playback range

parent 6304ab9a
......@@ -2504,6 +2504,50 @@
<statusTip></statusTip>
</Action>
<Action name="set_start_time">
<icon></icon>
<text>Set Start Time</text>
<whatsThis></whatsThis>
<toolTip></toolTip>
<iconText></iconText>
<activationFlags>100000</activationFlags>
<activationConditions>0</activationConditions>
<shortcut></shortcut>
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="set_end_time">
<icon></icon>
<text>Set End Time</text>
<whatsThis></whatsThis>
<toolTip></toolTip>
<iconText></iconText>
<activationFlags>100000</activationFlags>
<activationConditions>0</activationConditions>
<shortcut></shortcut>
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="update_playback_range">
<icon></icon>
<text>Update Playback Range</text>
<whatsThis></whatsThis>
<toolTip></toolTip>
<iconText></iconText>
<activationFlags>100000</activationFlags>
<activationConditions>0</activationConditions>
<shortcut></shortcut>
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
</Actions>
<Actions category="Layers">
......
......@@ -146,11 +146,24 @@ const KisTimeRange& KisImageAnimationInterface::fullClipRange() const
return m_d->fullClipRange;
}
void KisImageAnimationInterface::setFullClipRange(const KisTimeRange range) {
void KisImageAnimationInterface::setFullClipRange(const KisTimeRange range)
{
m_d->fullClipRange = range;
emit sigFullClipRangeChanged();
}
void KisImageAnimationInterface::setFullClipRangeStartTime(int column)
{
KisTimeRange newRange(column, m_d->fullClipRange.end(), false);
setFullClipRange(newRange);
}
void KisImageAnimationInterface::setFullClipRangeEndTime(int column)
{
KisTimeRange newRange(m_d->fullClipRange.start(), column, false);
setFullClipRange(newRange);
}
const KisTimeRange& KisImageAnimationInterface::playbackRange() const
{
return m_d->playbackRange.isValid() ? m_d->playbackRange : m_d->fullClipRange;
......
......@@ -119,6 +119,10 @@ public:
const KisTimeRange& fullClipRange() const;
void setFullClipRange(const KisTimeRange range);
void setFullClipRangeStartTime(int column);
void setFullClipRangeEndTime(int column);
const KisTimeRange &playbackRange() const;
void setPlaybackRange(const KisTimeRange range);
......
......@@ -162,6 +162,7 @@ KisAnimationPlayer::KisAnimationPlayer(KisCanvas2 *canvas)
connect(m_d->canvas->image()->animationInterface(), SIGNAL(sigAudioChannelChanged()), SLOT(slotAudioChannelChanged()));
connect(m_d->canvas->image()->animationInterface(), SIGNAL(sigAudioVolumeChanged()), SLOT(slotAudioVolumeChanged()));
slotAudioChannelChanged();
}
......@@ -291,16 +292,17 @@ void KisAnimationPlayer::slotUpdatePlaybackTimer()
m_d->timer->stop();
const KisImageAnimationInterface *animation = m_d->canvas->image()->animationInterface();
const KisTimeRange &range = animation->playbackRange();
if (!range.isValid()) return;
const KisTimeRange &playBackRange = animation->playbackRange();
if (!playBackRange.isValid()) return;
const int fps = animation->framerate();
m_d->initialFrame = animation->currentUITime();
m_d->firstFrame = range.start();
m_d->lastFrame = range.end();
m_d->firstFrame = playBackRange.start();
m_d->lastFrame = playBackRange.end();
m_d->expectedFrame = qBound(m_d->firstFrame, m_d->expectedFrame, m_d->lastFrame);
m_d->expectedInterval = qreal(1000) / fps / m_d->playbackSpeed;
m_d->lastTimerInterval = m_d->expectedInterval;
......
......@@ -66,10 +66,12 @@ private Q_SLOTS:
void slotAudioVolumeChanged();
void slotOnAudioError(const QString &fileName, const QString &message);
Q_SIGNALS:
void sigFrameChanged();
void sigPlaybackStopped();
void sigPlaybackStatisticsUpdated();
void sigFullClipRangeChanged();
private:
void connectCancelSignals();
......
......@@ -118,6 +118,10 @@ void AnimationDocker::setCanvas(KoCanvasBase * canvas)
connect(m_canvas->viewManager()->nodeManager(), SIGNAL(sigNodeActivated(KisNodeSP)),
this, SLOT(slotCurrentNodeChanged(KisNodeSP)));
connect (animation, SIGNAL(sigFullClipRangeChanged()), this, SLOT(updateClipRange()));
slotGlobalTimeChanged();
slotCurrentNodeChanged(m_canvas->viewManager()->nodeManager()->activeNode());
}
......@@ -495,6 +499,12 @@ void AnimationDocker::slotCurrentNodeChanged(KisNodeSP node)
m_animationWidget->btnDeleteKeyframe->setEnabled(isNodeAnimatable);
}
void AnimationDocker::updateClipRange()
{
m_animationWidget->spinFromFrame->setValue(m_canvas->image()->animationInterface()->fullClipRange().start());
m_animationWidget->spinToFrame->setValue(m_canvas->image()->animationInterface()->fullClipRange().end());
}
void AnimationDocker::addKeyframe(const QString &channel, bool copy)
{
if (!m_canvas) return;
......
......@@ -78,6 +78,8 @@ private Q_SLOTS:
void slotCurrentNodeChanged(KisNodeSP node);
void updateClipRange();
private:
QPointer<KisCanvas2> m_canvas;
......
......@@ -939,3 +939,13 @@ void TimelineFramesModel::setAudioVolume(qreal value)
KIS_SAFE_ASSERT_RECOVER_RETURN(m_d->image);
m_d->image->animationInterface()->setAudioVolume(value);
}
void TimelineFramesModel::setFullClipRangeStart(int column)
{
m_d->image->animationInterface()->setFullClipRangeStartTime(column);
}
void TimelineFramesModel::setFullClipRangeEnd(int column)
{
m_d->image->animationInterface()->setFullClipRangeEndTime(column);
}
......@@ -72,6 +72,9 @@ public:
qreal audioVolume() const;
void setAudioVolume(qreal value);
void setFullClipRangeStart(int column);
void setFullClipRangeEnd(int column);
void setLastClickedIndex(const QModelIndex &index);
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
......
......@@ -363,6 +363,17 @@ void TimelineFramesView::setActionManager( KisActionManager * actionManager)
action = m_d->actionMan->createAction("paste_frames_from_clipboard");
connect(action, SIGNAL(triggered()), SLOT(slotPasteFrames()));
action = m_d->actionMan->createAction("set_start_time");
connect(action, SIGNAL(triggered()), SLOT(slotSetStartTimeToCurrentPosition()));
action = m_d->actionMan->createAction("set_end_time");
connect(action, SIGNAL(triggered()), SLOT(slotSetEndTimeToCurrentPosition()));
action = m_d->actionMan->createAction("update_playback_range");
connect(action, SIGNAL(triggered()), SLOT(slotUpdatePlackbackRange()));
}
}
......@@ -552,6 +563,9 @@ void TimelineFramesView::slotAudioVolumeChanged(int value)
m_d->model->setAudioVolume(qreal(value) / 100.0);
}
void TimelineFramesView::slotUpdateInfiniteFramesCount()
{
if (horizontalScrollBar()->isSliderDown()) return;
......@@ -924,20 +938,33 @@ void TimelineFramesView::createFrameEditingMenuActions(QMenu *menu, bool addFram
{
slotUpdateFrameActions();
// calculate if selection range is set. This will determine if the update playback range is available
QSet<int> rows;
int minColumn = 0;
int maxColumn = 0;
calculateSelectionMetrics(minColumn, maxColumn, rows);
bool selectionExists = minColumn != maxColumn;
if (selectionExists) {
KisActionManager::safePopulateMenu(menu, "update_playback_range", m_d->actionMan);
} else {
KisActionManager::safePopulateMenu(menu, "set_start_time", m_d->actionMan);
KisActionManager::safePopulateMenu(menu, "set_end_time", m_d->actionMan);
}
menu->addSeparator();
KisActionManager::safePopulateMenu(menu, "cut_frames_to_clipboard", m_d->actionMan);
KisActionManager::safePopulateMenu(menu, "copy_frames_to_clipboard", m_d->actionMan);
KisActionManager::safePopulateMenu(menu, "paste_frames_from_clipboard", m_d->actionMan);
menu->addSeparator();
if (addFrameCreationActions) {
KisActionManager::safePopulateMenu(menu, "add_blank_frame", m_d->actionMan);
KisActionManager::safePopulateMenu(menu, "add_duplicate_frame", m_d->actionMan);
menu->addSeparator();
}
menu->addSeparator();
QMenu *frames = menu->addMenu(i18nc("@item:inmenu", "Keyframes"));
KisActionManager::safePopulateMenu(frames, "insert_keyframes_right", m_d->actionMan);
KisActionManager::safePopulateMenu(frames, "insert_keyframes_left", m_d->actionMan);
frames->addSeparator();
KisActionManager::safePopulateMenu(frames, "insert_n_keyframes_right", m_d->actionMan);
KisActionManager::safePopulateMenu(frames, "insert_n_keyframes_left", m_d->actionMan);
......@@ -945,6 +972,7 @@ void TimelineFramesView::createFrameEditingMenuActions(QMenu *menu, bool addFram
QMenu *hold = menu->addMenu(i18nc("@item:inmenu", "Hold Frames"));
KisActionManager::safePopulateMenu(hold, "insert_hold_frame", m_d->actionMan);
KisActionManager::safePopulateMenu(hold, "remove_hold_frame", m_d->actionMan);
hold->addSeparator();
KisActionManager::safePopulateMenu(hold, "insert_n_hold_frames", m_d->actionMan);
KisActionManager::safePopulateMenu(hold, "remove_n_hold_frames", m_d->actionMan);
......@@ -952,6 +980,14 @@ void TimelineFramesView::createFrameEditingMenuActions(QMenu *menu, bool addFram
menu->addSeparator();
KisActionManager::safePopulateMenu(menu, "remove_frames", m_d->actionMan);
KisActionManager::safePopulateMenu(menu, "remove_frames_and_pull", m_d->actionMan);
menu->addSeparator();
if (addFrameCreationActions) {
KisActionManager::safePopulateMenu(menu, "add_blank_frame", m_d->actionMan);
KisActionManager::safePopulateMenu(menu, "add_duplicate_frame", m_d->actionMan);
menu->addSeparator();
}
}
void TimelineFramesView::mousePressEvent(QMouseEvent *event)
......@@ -1195,6 +1231,28 @@ void TimelineFramesView::slotUpdateFrameActions()
//TODO: update column actions!
}
void TimelineFramesView::slotSetStartTimeToCurrentPosition()
{
m_d->model->setFullClipRangeStart(this->currentIndex().column());
}
void TimelineFramesView::slotSetEndTimeToCurrentPosition()
{
m_d->model->setFullClipRangeEnd(this->currentIndex().column());
}
void TimelineFramesView::slotUpdatePlackbackRange()
{
QSet<int> rows;
int minColumn = 0;
int maxColumn = 0;
calculateSelectionMetrics(minColumn, maxColumn, rows);
m_d->model->setFullClipRangeStart(minColumn);
m_d->model->setFullClipRangeEnd(maxColumn);
}
void TimelineFramesView::slotLayerContextMenuRequested(const QPoint &globalPos)
{
m_d->layerEditingMenu->exec(globalPos);
......
......@@ -51,6 +51,10 @@ private Q_SLOTS:
void slotUpdateLayersMenu();
void slotUpdateFrameActions();
void slotSetStartTimeToCurrentPosition();
void slotSetEndTimeToCurrentPosition();
void slotUpdatePlackbackRange();
void slotAddNewLayer();
void slotAddExistingLayer(QAction *action);
void slotDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment