various code cleanups
This commit is contained in:
@@ -104,7 +104,7 @@ void Block::set_length_and_media_in(const rational &length)
|
||||
}
|
||||
|
||||
// Calculate media_in adjustment
|
||||
set_media_in(SequenceToMediaTime(in() + (this->length() - length)));
|
||||
set_media_in(SequenceToMediaTime(this->length() - length));
|
||||
|
||||
// Set the length without setting media out
|
||||
set_length_internal(length);
|
||||
@@ -164,7 +164,7 @@ rational Block::SequenceToMediaTime(const rational &sequence_time) const
|
||||
return sequence_time;
|
||||
}
|
||||
|
||||
rational local_time = sequence_time - in();
|
||||
rational local_time = sequence_time;
|
||||
|
||||
// FIXME: Doesn't handle reversing
|
||||
if (speed_input_->IsKeyframing() || speed_input_->IsConnected()) {
|
||||
@@ -208,7 +208,7 @@ rational Block::MediaToSequenceTime(const rational &media_time) const
|
||||
}
|
||||
}
|
||||
|
||||
return sequence_time + in();
|
||||
return sequence_time;
|
||||
}
|
||||
|
||||
void Block::LoadInternal(QXmlStreamReader *reader, XMLNodeData &xml_node_data)
|
||||
|
||||
@@ -73,22 +73,26 @@ void ClipBlock::InvalidateCache(const TimeRange& range, const InputConnection& f
|
||||
}
|
||||
}
|
||||
|
||||
TimeRange ClipBlock::InputTimeAdjustment(NodeInput *input, const TimeRange &input_time) const
|
||||
TimeRange ClipBlock::InputTimeAdjustment(NodeInput *input, int element, const TimeRange &input_time) const
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
|
||||
if (input == texture_input_) {
|
||||
return TimeRange(SequenceToMediaTime(input_time.in()), SequenceToMediaTime(input_time.out()));
|
||||
}
|
||||
|
||||
return Block::InputTimeAdjustment(input, input_time);
|
||||
return Block::InputTimeAdjustment(input, element, input_time);
|
||||
}
|
||||
|
||||
TimeRange ClipBlock::OutputTimeAdjustment(NodeInput *input, const TimeRange &input_time) const
|
||||
TimeRange ClipBlock::OutputTimeAdjustment(NodeInput *input, int element, const TimeRange &input_time) const
|
||||
{
|
||||
Q_UNUSED(element)
|
||||
|
||||
if (input == texture_input_) {
|
||||
return TimeRange(MediaToSequenceTime(input_time.in()), MediaToSequenceTime(input_time.out()));
|
||||
}
|
||||
|
||||
return Block::InputTimeAdjustment(input, input_time);
|
||||
return Block::OutputTimeAdjustment(input, element, input_time);
|
||||
}
|
||||
|
||||
NodeValueTable ClipBlock::Value(NodeValueDatabase &value) const
|
||||
@@ -113,7 +117,7 @@ void ClipBlock::Retranslate()
|
||||
void ClipBlock::Hash(QCryptographicHash &hash, const rational &time) const
|
||||
{
|
||||
if (texture_input_->IsConnected()) {
|
||||
rational t = InputTimeAdjustment(texture_input_, TimeRange(time, time)).in();
|
||||
rational t = InputTimeAdjustment(texture_input_, -1, TimeRange(time, time)).in();
|
||||
|
||||
texture_input_->GetConnectedNode()->Hash(hash, t);
|
||||
}
|
||||
|
||||
@@ -46,9 +46,9 @@ public:
|
||||
|
||||
virtual void InvalidateCache(const TimeRange& range, const InputConnection& from) override;
|
||||
|
||||
virtual TimeRange InputTimeAdjustment(NodeInput* input, const TimeRange& input_time) const override;
|
||||
virtual TimeRange InputTimeAdjustment(NodeInput* input, int element, const TimeRange& input_time) const override;
|
||||
|
||||
virtual TimeRange OutputTimeAdjustment(NodeInput* input, const TimeRange& input_time) const override;
|
||||
virtual TimeRange OutputTimeAdjustment(NodeInput* input, int element, const TimeRange& input_time) const override;
|
||||
|
||||
virtual NodeValueTable Value(NodeValueDatabase& value) const override;
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ void TransitionBlock::Hash(QCryptographicHash &hash, const rational &time) const
|
||||
|
||||
double TransitionBlock::GetInternalTransitionTime(const double &time) const
|
||||
{
|
||||
return time - in().toDouble();
|
||||
return time;
|
||||
}
|
||||
|
||||
void TransitionBlock::InsertTransitionTimes(AcceleratedJob *job, const double &time) const
|
||||
|
||||
+6
-6
@@ -203,13 +203,13 @@ void Node::EndOperation()
|
||||
}
|
||||
}
|
||||
|
||||
TimeRange Node::InputTimeAdjustment(NodeInput *, const TimeRange &input_time) const
|
||||
TimeRange Node::InputTimeAdjustment(NodeInput *, int, const TimeRange &input_time) const
|
||||
{
|
||||
// Default behavior is no time adjustment at all
|
||||
return input_time;
|
||||
}
|
||||
|
||||
TimeRange Node::OutputTimeAdjustment(NodeInput *, const TimeRange &input_time) const
|
||||
TimeRange Node::OutputTimeAdjustment(NodeInput *, int, const TimeRange &input_time) const
|
||||
{
|
||||
// Default behavior is no time adjustment at all
|
||||
return input_time;
|
||||
@@ -398,7 +398,7 @@ void Node::HashInputElement(QCryptographicHash &hash, NodeInput *input, int elem
|
||||
{
|
||||
// Get time adjustment
|
||||
// For a single frame, we only care about one of the times
|
||||
rational input_time = InputTimeAdjustment(input, TimeRange(time, time)).in();
|
||||
rational input_time = InputTimeAdjustment(input, element, TimeRange(time, time)).in();
|
||||
|
||||
if (input->IsConnected(element)) {
|
||||
// Traverse down this edge
|
||||
@@ -661,8 +661,8 @@ QVector<TimeRange> Node::TransformTimeTo(const TimeRange &time, Node *target, bo
|
||||
// If this input is connected, traverse it to see if we stumble across the specified `node`
|
||||
foreach (NodeInput* input, inputs_) {
|
||||
for (auto it=input->edges().cbegin(); it!=input->edges().cend(); it++) {
|
||||
TimeRange input_adjustment = InputTimeAdjustment(input, time);
|
||||
Node* connected = input->GetConnectedNode(it.key());
|
||||
TimeRange input_adjustment = InputTimeAdjustment(input, it.key(), time);
|
||||
Node* connected = it.value();
|
||||
|
||||
if (connected == target) {
|
||||
// We found the target, no need to keep traversing
|
||||
@@ -680,7 +680,7 @@ QVector<TimeRange> Node::TransformTimeTo(const TimeRange &time, Node *target, bo
|
||||
foreach (const InputConnection& conn, edges()) {
|
||||
Node* input_node = conn.input->parent();
|
||||
|
||||
TimeRange output_adjustment = input_node->OutputTimeAdjustment(conn.input, time);
|
||||
TimeRange output_adjustment = input_node->OutputTimeAdjustment(conn.input, conn.element, time);
|
||||
|
||||
if (input_node == target) {
|
||||
paths_found.append(output_adjustment);
|
||||
|
||||
+2
-2
@@ -329,12 +329,12 @@ public:
|
||||
* If this node modifies the `time` (i.e. a clip converting sequence time to media time), this function should be
|
||||
* overridden to do so. Also make sure to override OutputTimeAdjustment() to provide the inverse function.
|
||||
*/
|
||||
virtual TimeRange InputTimeAdjustment(NodeInput* input, const TimeRange& input_time) const;
|
||||
virtual TimeRange InputTimeAdjustment(NodeInput* input, int element, const TimeRange& input_time) const;
|
||||
|
||||
/**
|
||||
* @brief The inverse of InputTimeAdjustment()
|
||||
*/
|
||||
virtual TimeRange OutputTimeAdjustment(NodeInput* input, const TimeRange& input_time) const;
|
||||
virtual TimeRange OutputTimeAdjustment(NodeInput* input, int element, const TimeRange& input_time) const;
|
||||
|
||||
/**
|
||||
* @brief Copies inputs from from Node to another including connections
|
||||
|
||||
@@ -96,6 +96,30 @@ QString Track::Description() const
|
||||
"a Sequence.");
|
||||
}
|
||||
|
||||
TimeRange Track::InputTimeAdjustment(NodeInput *input, int element, const TimeRange &input_time) const
|
||||
{
|
||||
if (input == block_input_ && element >= 0) {
|
||||
int cache_index = GetCacheIndexFromArrayIndex(element);
|
||||
const rational& block_in = blocks_.at(cache_index).range.in();
|
||||
|
||||
return input_time - block_in;
|
||||
}
|
||||
|
||||
return Node::InputTimeAdjustment(input, element, input_time);
|
||||
}
|
||||
|
||||
TimeRange Track::OutputTimeAdjustment(NodeInput *input, int element, const TimeRange &input_time) const
|
||||
{
|
||||
if (input == block_input_ && element >= 0) {
|
||||
int cache_index = GetCacheIndexFromArrayIndex(element);
|
||||
const rational& block_in = blocks_.at(cache_index).range.in();
|
||||
|
||||
return input_time + block_in;
|
||||
}
|
||||
|
||||
return Node::OutputTimeAdjustment(input, element, input_time);
|
||||
}
|
||||
|
||||
const double &Track::GetTrackHeight() const
|
||||
{
|
||||
return track_height_;
|
||||
@@ -435,15 +459,15 @@ void Track::UpdateInOutFrom(int index)
|
||||
SetLengthInternal(last_out);
|
||||
}
|
||||
|
||||
int Track::GetInputIndexFromCacheIndex(int cache_index)
|
||||
int Track::GetArrayIndexFromCacheIndex(int index) const
|
||||
{
|
||||
return GetInputIndexFromCacheIndex(block_cache_.at(cache_index));
|
||||
return blocks_.at(index).array_index;
|
||||
}
|
||||
|
||||
int Track::GetInputIndexFromCacheIndex(Block *block)
|
||||
int Track::GetCacheIndexFromArrayIndex(int index) const
|
||||
{
|
||||
for (int i=0; i<block_input_->ArraySize(); i++) {
|
||||
if (block_input_->GetConnectedNode(i) == block) {
|
||||
for (int i=0; i<blocks_.size(); i++) {
|
||||
if (blocks_.at(i).array_index == index) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TRACKOUTPUT_H
|
||||
#define TRACKOUTPUT_H
|
||||
#ifndef TRACK_H
|
||||
#define TRACK_H
|
||||
|
||||
#include "audio/audiovisualwaveform.h"
|
||||
#include "node/block/block.h"
|
||||
@@ -56,6 +56,10 @@ public:
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
virtual TimeRange InputTimeAdjustment(NodeInput* input, int element, const TimeRange& input_time) const override;
|
||||
|
||||
virtual TimeRange OutputTimeAdjustment(NodeInput* input, int element, const TimeRange& input_time) const override;
|
||||
|
||||
const double& GetTrackHeight() const;
|
||||
void SetTrackHeight(const double& height);
|
||||
|
||||
@@ -277,8 +281,9 @@ protected:
|
||||
private:
|
||||
void UpdateInOutFrom(int index);
|
||||
|
||||
int GetInputIndexFromCacheIndex(int cache_index);
|
||||
int GetInputIndexFromCacheIndex(Block* block);
|
||||
int GetArrayIndexFromCacheIndex(int index) const;
|
||||
|
||||
int GetCacheIndexFromArrayIndex(int index) const;
|
||||
|
||||
void SetLengthInternal(const rational& r, bool invalidate = true);
|
||||
|
||||
@@ -313,4 +318,4 @@ private slots:
|
||||
|
||||
}
|
||||
|
||||
#endif // TRACKOUTPUT_H
|
||||
#endif // TRACK_H
|
||||
|
||||
@@ -97,6 +97,11 @@ public:
|
||||
return track_cache_;
|
||||
}
|
||||
|
||||
Track* GetTrackFromReference(const TrackReference& track_ref) const
|
||||
{
|
||||
return track_lists_.at(track_ref.type())->GetTrackAt(track_ref.index());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Same as GetTracks() but omits tracks that are locked.
|
||||
*/
|
||||
|
||||
+15
-12
@@ -34,9 +34,7 @@ NodeValueDatabase NodeTraverser::GenerateDatabase(const Node* node, const TimeRa
|
||||
return NodeValueDatabase();
|
||||
}
|
||||
|
||||
TimeRange input_time = node->InputTimeAdjustment(input, range);
|
||||
|
||||
database.Insert(input, ProcessInput(input, input_time));
|
||||
database.Insert(input, ProcessInput(input, range));
|
||||
}
|
||||
|
||||
AddGlobalsToDatabase(database, range);
|
||||
@@ -47,16 +45,18 @@ NodeValueDatabase NodeTraverser::GenerateDatabase(const Node* node, const TimeRa
|
||||
NodeValueTable NodeTraverser::ProcessInput(NodeInput* input, const TimeRange& range)
|
||||
{
|
||||
// If input is connected, retrieve value directly
|
||||
Node* node = input->parent();
|
||||
|
||||
if (input->IsConnected()) {
|
||||
|
||||
TimeRange adjusted_range = node->InputTimeAdjustment(input, -1, range);
|
||||
|
||||
// Value will equal something from the connected node, follow it
|
||||
return GenerateTable(input->GetConnectedNode(), range);
|
||||
return GenerateTable(input->GetConnectedNode(), adjusted_range);
|
||||
|
||||
} else {
|
||||
|
||||
// Store node
|
||||
Node* node = static_cast<Node*>(input->parent());
|
||||
|
||||
QVariant return_val;
|
||||
|
||||
if (input->IsArray()) {
|
||||
@@ -66,11 +66,12 @@ NodeValueTable NodeTraverser::ProcessInput(NodeInput* input, const TimeRange& ra
|
||||
|
||||
for (int i=0; i<array_tbl.size(); i++) {
|
||||
NodeValueTable& sub_tbl = array_tbl[i];
|
||||
TimeRange adjusted_range = node->InputTimeAdjustment(input, i, range);
|
||||
|
||||
if (input->IsConnected(i)) {
|
||||
sub_tbl = GenerateTable(input->GetConnectedNode(i), range);
|
||||
sub_tbl = GenerateTable(input->GetConnectedNode(i), adjusted_range);
|
||||
} else {
|
||||
QVariant input_value = input->GetValueAtTime(range.in(), i);
|
||||
QVariant input_value = input->GetValueAtTime(adjusted_range.in(), i);
|
||||
sub_tbl.Push(input->GetDataType(), input_value, node);
|
||||
}
|
||||
}
|
||||
@@ -80,7 +81,9 @@ NodeValueTable NodeTraverser::ProcessInput(NodeInput* input, const TimeRange& ra
|
||||
} else {
|
||||
|
||||
// Not connected or an array, just pull the immediate
|
||||
return_val = input->GetValueAtTime(range.in());
|
||||
TimeRange adjusted_range = node->InputTimeAdjustment(input, -1, range);
|
||||
|
||||
return_val = input->GetValueAtTime(adjusted_range.in());
|
||||
|
||||
}
|
||||
|
||||
@@ -120,12 +123,12 @@ NodeValueTable NodeTraverser::GenerateTable(const Node *n, const rational &in, c
|
||||
NodeValueTable NodeTraverser::GenerateBlockTable(const Track *track, const TimeRange &range)
|
||||
{
|
||||
// By default, just follow the in point
|
||||
Block* active_block = track->BlockAtTime(range.in());
|
||||
int active_block = track->BlockAtTime(range.in());
|
||||
|
||||
NodeValueTable table;
|
||||
|
||||
if (active_block) {
|
||||
table = GenerateTable(active_block, range);
|
||||
if (active_block >= 0) {
|
||||
table = GenerateTable(track->Blocks().at(active_block).block, range);
|
||||
}
|
||||
|
||||
return table;
|
||||
|
||||
@@ -24,10 +24,12 @@
|
||||
#include <QUndoCommand>
|
||||
|
||||
#include "common/define.h"
|
||||
#include "project/project.h"
|
||||
#include "node/graph.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class Project;
|
||||
|
||||
class UndoCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "node/graph.h"
|
||||
#include "node/node.h"
|
||||
#include "undo/undocommand.h"
|
||||
#include "widget/timelinewidget/undo/undo.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
|
||||
@@ -33,6 +33,5 @@ set(OLIVE_SOURCES
|
||||
widget/projectexplorer/projectexplorernavigation.h
|
||||
widget/projectexplorer/projectexplorernavigation.cpp
|
||||
widget/projectexplorer/projectexplorerundo.h
|
||||
widget/projectexplorer/projectexplorerundo.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2020 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "projectexplorerundo.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
OfflineFootageCommand::OfflineFootageCommand(const QVector<MediaInput *> &media, QUndoCommand* parent) :
|
||||
UndoCommand(parent)
|
||||
{
|
||||
foreach (MediaInput* i, media) {
|
||||
stream_data_.insert(i, i->stream());
|
||||
}
|
||||
|
||||
project_ = static_cast<Sequence*>(media.first()->parent())->project();
|
||||
}
|
||||
|
||||
Project *OfflineFootageCommand::GetRelevantProject() const
|
||||
{
|
||||
return project_;
|
||||
}
|
||||
|
||||
void OfflineFootageCommand::redo_internal()
|
||||
{
|
||||
for (auto it=stream_data_.cbegin(); it!=stream_data_.cend(); it++) {
|
||||
it.key()->SetStream(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void OfflineFootageCommand::undo_internal()
|
||||
{
|
||||
for (auto it=stream_data_.cbegin(); it!=stream_data_.cend(); it++) {
|
||||
it.key()->SetStream(it.value());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,14 +31,35 @@ namespace olive {
|
||||
*/
|
||||
class OfflineFootageCommand : public UndoCommand {
|
||||
public:
|
||||
OfflineFootageCommand(const QVector<MediaInput*>& media, QUndoCommand* parent = nullptr);
|
||||
OfflineFootageCommand(const QVector<MediaInput*>& media, QUndoCommand* parent = nullptr) :
|
||||
UndoCommand(parent)
|
||||
{
|
||||
foreach (MediaInput* i, media) {
|
||||
stream_data_.insert(i, i->stream());
|
||||
}
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
project_ = media.first()->parent()->project();
|
||||
}
|
||||
|
||||
virtual Project* GetRelevantProject() const override
|
||||
{
|
||||
return project_;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void redo_internal() override
|
||||
{
|
||||
for (auto it=stream_data_.cbegin(); it!=stream_data_.cend(); it++) {
|
||||
it.key()->SetStream(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void undo_internal() override;
|
||||
virtual void undo_internal() override
|
||||
{
|
||||
for (auto it=stream_data_.cbegin(); it!=stream_data_.cend(); it++) {
|
||||
it.key()->SetStream(it.value());
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
QMap<MediaInput*, Stream*> stream_data_;
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "config/config.h"
|
||||
#include "core.h"
|
||||
#include "project/item/sequence/sequence.h"
|
||||
#include "widget/timelinewidget/undo/undo.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
add_subdirectory(trackview)
|
||||
add_subdirectory(tool)
|
||||
add_subdirectory(undo)
|
||||
add_subdirectory(view)
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
widget/timelinewidget/timelineandtrackview.h
|
||||
widget/timelinewidget/timelineandtrackview.cpp
|
||||
widget/timelinewidget/timelineundo.h
|
||||
widget/timelinewidget/timelinewidget.h
|
||||
widget/timelinewidget/timelinewidget.cpp
|
||||
widget/timelinewidget/timelinewidgetselections.h
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2020 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
widget/timelinewidget/undo/undo.h
|
||||
widget/timelinewidget/undo/undo.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,639 +0,0 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2020 Olive Team
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TIMELINEUNDOABLE_H
|
||||
#define TIMELINEUNDOABLE_H
|
||||
|
||||
#include <QUndoCommand>
|
||||
|
||||
#include "node/block/block.h"
|
||||
#include "node/block/gap/gap.h"
|
||||
#include "node/block/transition/transition.h"
|
||||
#include "node/output/track/track.h"
|
||||
#include "node/output/track/tracklist.h"
|
||||
#include "timeline/timelinepoints.h"
|
||||
#include "undo/undocommand.h"
|
||||
#include "widget/timelinewidget/timelinewidgetselections.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class BlockResizeCommand : public UndoCommand {
|
||||
public:
|
||||
BlockResizeCommand(Block* block, rational new_length, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Block* block_;
|
||||
rational old_length_;
|
||||
rational new_length_;
|
||||
};
|
||||
|
||||
class BlockResizeWithMediaInCommand : public UndoCommand {
|
||||
public:
|
||||
BlockResizeWithMediaInCommand(Block* block, rational new_length, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Block* block_;
|
||||
rational old_length_;
|
||||
rational new_length_;
|
||||
};
|
||||
|
||||
class BlockTrimCommand : public UndoCommand {
|
||||
public:
|
||||
BlockTrimCommand(Track *track, Block* block, rational new_length, Timeline::MovementMode mode, QUndoCommand* command = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
void SetTrimIsARollEdit(bool e)
|
||||
{
|
||||
trim_is_a_roll_edit_ = e;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Track* track_;
|
||||
Block* block_;
|
||||
rational old_length_;
|
||||
rational new_length_;
|
||||
Timeline::MovementMode mode_;
|
||||
|
||||
Block* adjacent_;
|
||||
bool we_created_adjacent_;
|
||||
bool we_deleted_adjacent_;
|
||||
|
||||
bool trim_is_a_roll_edit_;
|
||||
|
||||
QObject memory_manager_;
|
||||
|
||||
};
|
||||
|
||||
class BlockSetMediaInCommand : public UndoCommand {
|
||||
public:
|
||||
BlockSetMediaInCommand(Block* block, rational new_media_in, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Block* block_;
|
||||
rational old_media_in_;
|
||||
rational new_media_in_;
|
||||
};
|
||||
|
||||
class TrackRippleRemoveBlockCommand : public UndoCommand {
|
||||
public:
|
||||
TrackRippleRemoveBlockCommand(Track* track, Block* block, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Track* track_;
|
||||
|
||||
Block* block_;
|
||||
|
||||
Block* before_;
|
||||
};
|
||||
|
||||
class TrackPrependBlockCommand : public UndoCommand {
|
||||
public:
|
||||
TrackPrependBlockCommand(Track* track, Block* block, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Track* track_;
|
||||
Block* block_;
|
||||
};
|
||||
|
||||
class TrackInsertBlockAfterCommand : public UndoCommand {
|
||||
public:
|
||||
TrackInsertBlockAfterCommand(Track* track, Block* block, Block* before, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Track* track_;
|
||||
|
||||
Block* block_;
|
||||
|
||||
Block* before_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Clears the area between in and out
|
||||
*
|
||||
* The area between `in` and `out` is guaranteed to be freed. BLocks are trimmed and removed to free this space.
|
||||
* By default, nothing takes this area meaning all subsequent clips are pushed backward, however you can specify
|
||||
* a block to insert at the `in` point. No checking is done to ensure `insert` is the same length as `in` to `out`.
|
||||
*/
|
||||
class TrackRippleRemoveAreaCommand : public UndoCommand {
|
||||
public:
|
||||
TrackRippleRemoveAreaCommand(Track* track, rational in, rational out, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
void SetInsert(Block* insert);
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
protected:
|
||||
Project* project_;
|
||||
|
||||
Track* track_;
|
||||
rational in_;
|
||||
rational out_;
|
||||
|
||||
bool splice_;
|
||||
QUndoCommand* splice_split_command_;
|
||||
|
||||
Block* trim_out_;
|
||||
Block* trim_in_;
|
||||
QVector<Block*> removed_blocks_;
|
||||
|
||||
rational trim_in_old_length_;
|
||||
rational trim_out_old_length_;
|
||||
|
||||
rational trim_in_new_length_;
|
||||
rational trim_out_new_length_;
|
||||
|
||||
Block* insert_;
|
||||
|
||||
QObject memory_manager_;
|
||||
|
||||
QVector<QUndoCommand*> remove_block_commands_;
|
||||
|
||||
};
|
||||
|
||||
class TrackListRippleRemoveAreaCommand : public UndoCommand {
|
||||
public:
|
||||
TrackListRippleRemoveAreaCommand(TrackList* list, rational in, rational out, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual ~TrackListRippleRemoveAreaCommand() override;
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
TrackList* list_;
|
||||
|
||||
QList<Track*> working_tracks_;
|
||||
|
||||
rational in_;
|
||||
|
||||
rational out_;
|
||||
|
||||
bool all_tracks_unlocked_;
|
||||
|
||||
QVector<TrackRippleRemoveAreaCommand*> commands_;
|
||||
|
||||
};
|
||||
|
||||
class TimelineRippleRemoveAreaCommand : public UndoCommand {
|
||||
public:
|
||||
TimelineRippleRemoveAreaCommand(ViewerOutput* timeline, rational in, rational out, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
private:
|
||||
ViewerOutput* timeline_;
|
||||
|
||||
};
|
||||
|
||||
class TrackListRippleToolCommand : public UndoCommand {
|
||||
public:
|
||||
struct RippleInfo {
|
||||
Block* block;
|
||||
Block* ref_block;
|
||||
Track* track;
|
||||
rational new_length;
|
||||
rational old_length;
|
||||
};
|
||||
|
||||
TrackListRippleToolCommand(TrackList* track_list,
|
||||
const QList<RippleInfo>& info,
|
||||
const Timeline::MovementMode& movement_mode,
|
||||
QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
TrackList* track_list_;
|
||||
|
||||
QList<RippleInfo> info_;
|
||||
Timeline::MovementMode movement_mode_;
|
||||
|
||||
struct WorkingData {
|
||||
GapBlock* created_gap;
|
||||
Block* removed_gap_after;
|
||||
};
|
||||
|
||||
QVector<WorkingData> working_data_;
|
||||
|
||||
QObject memory_manager_;
|
||||
|
||||
bool all_tracks_unlocked_;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Destructively places `block` at the in point `start`
|
||||
*
|
||||
* The Block is guaranteed to be placed at the starting point specified. If there are Blocks in this area, they are
|
||||
* either trimmed or removed to make space for this Block. Additionally, if the Block is placed beyond the end of
|
||||
* the Sequence, a GapBlock is inserted to compensate.
|
||||
*/
|
||||
class TrackPlaceBlockCommand : public TrackRippleRemoveAreaCommand {
|
||||
public:
|
||||
TrackPlaceBlockCommand(TrackList *timeline, int track, Block* block, rational in, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
TrackList* timeline_;
|
||||
int track_index_;
|
||||
bool append_;
|
||||
GapBlock* gap_;
|
||||
QVector<Track*> added_tracks_;
|
||||
|
||||
};
|
||||
|
||||
class BlockSplitCommand : public UndoCommand {
|
||||
public:
|
||||
BlockSplitCommand(Track* track, Block* block, rational point, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
Block* new_block();
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Track* track_;
|
||||
Block* block_;
|
||||
Block* new_block_;
|
||||
|
||||
rational new_length_;
|
||||
rational old_length_;
|
||||
rational point_;
|
||||
|
||||
QList<NodeInput*> transitions_to_move_;
|
||||
|
||||
QObject memory_manager_;
|
||||
|
||||
QUndoCommand* add_command_;
|
||||
|
||||
};
|
||||
|
||||
class TrackSplitAtTimeCommand : public UndoCommand {
|
||||
public:
|
||||
TrackSplitAtTimeCommand(Track* track, rational point, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
private:
|
||||
Track* track_;
|
||||
|
||||
};
|
||||
|
||||
class BlockSplitPreservingLinksCommand : public UndoCommand {
|
||||
public:
|
||||
BlockSplitPreservingLinksCommand(const QVector<Block *> &blocks, const QList<rational>& times, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
private:
|
||||
QVector<Block *> blocks_;
|
||||
|
||||
QList<rational> times_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Replaces Block `old` with Block `replace`
|
||||
*
|
||||
* Both blocks must have equal lengths.
|
||||
*/
|
||||
class TrackReplaceBlockCommand : public UndoCommand {
|
||||
public:
|
||||
TrackReplaceBlockCommand(Track* track, Block* old, Block* replace, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Track* track_;
|
||||
Block* old_;
|
||||
Block* replace_;
|
||||
};
|
||||
|
||||
class TrackReplaceBlockWithGapCommand : public UndoCommand {
|
||||
public:
|
||||
TrackReplaceBlockWithGapCommand(Track* track, Block* block, QUndoCommand* command = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Track* track_;
|
||||
Block* block_;
|
||||
|
||||
GapBlock* existing_gap_;
|
||||
GapBlock* existing_merged_gap_;
|
||||
bool existing_gap_precedes_;
|
||||
GapBlock* our_gap_;
|
||||
|
||||
QObject memory_manager_;
|
||||
|
||||
};
|
||||
|
||||
class TimelineRippleDeleteGapsAtRegionsCommand : public UndoCommand {
|
||||
public:
|
||||
TimelineRippleDeleteGapsAtRegionsCommand(ViewerOutput* vo, const TimeRangeList& regions, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
ViewerOutput* timeline_;
|
||||
TimeRangeList regions_;
|
||||
|
||||
QList<UndoCommand*> commands_;
|
||||
|
||||
};
|
||||
|
||||
class WorkareaSetEnabledCommand : public UndoCommand {
|
||||
public:
|
||||
WorkareaSetEnabledCommand(Project *project, TimelinePoints* points, bool enabled, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Project* project_;
|
||||
|
||||
TimelinePoints* points_;
|
||||
|
||||
bool old_enabled_;
|
||||
|
||||
bool new_enabled_;
|
||||
|
||||
};
|
||||
|
||||
class WorkareaSetRangeCommand : public UndoCommand {
|
||||
public:
|
||||
WorkareaSetRangeCommand(Project *project, TimelinePoints* points, const TimeRange& range, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Project* project_;
|
||||
|
||||
TimelinePoints* points_;
|
||||
|
||||
TimeRange old_range_;
|
||||
|
||||
TimeRange new_range_;
|
||||
|
||||
};
|
||||
|
||||
class BlockLinkManyCommand : public UndoCommand {
|
||||
public:
|
||||
BlockLinkManyCommand(const QVector<Block*> blocks, bool link, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
private:
|
||||
QVector<Block*> blocks_;
|
||||
|
||||
};
|
||||
|
||||
class BlockLinkCommand : public UndoCommand {
|
||||
public:
|
||||
BlockLinkCommand(Block* a, Block* b, bool link, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Block* a_;
|
||||
|
||||
Block* b_;
|
||||
|
||||
bool link_;
|
||||
|
||||
bool done_;
|
||||
|
||||
};
|
||||
|
||||
class BlockUnlinkAllCommand : public UndoCommand {
|
||||
public:
|
||||
BlockUnlinkAllCommand(Block* block, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Block* block_;
|
||||
|
||||
QVector<Block*> unlinked_;
|
||||
|
||||
};
|
||||
|
||||
class BlockEnableDisableCommand : public UndoCommand {
|
||||
public:
|
||||
BlockEnableDisableCommand(Block* block, bool enabled, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Block* block_;
|
||||
|
||||
bool old_enabled_;
|
||||
|
||||
bool new_enabled_;
|
||||
|
||||
};
|
||||
|
||||
class TrackSlideCommand : public UndoCommand {
|
||||
public:
|
||||
TrackSlideCommand(Track* track, const QList<Block*>& moving_blocks, Block* in_adjacent, Block* out_adjacent, const rational& movement, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
void slide_internal(bool undo);
|
||||
|
||||
Track* track_;
|
||||
QList<Block*> blocks_;
|
||||
rational movement_;
|
||||
|
||||
bool we_created_in_adjacent_;
|
||||
Block* in_adjacent_;
|
||||
bool we_created_out_adjacent_;
|
||||
Block* out_adjacent_;
|
||||
|
||||
QObject memory_manager_;
|
||||
|
||||
};
|
||||
|
||||
class TrackListInsertGaps : public UndoCommand {
|
||||
public:
|
||||
TrackListInsertGaps(TrackList* track_list, const rational& point, const rational& length, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
TrackList* track_list_;
|
||||
|
||||
rational point_;
|
||||
|
||||
rational length_;
|
||||
|
||||
QList<Track*> working_tracks_;
|
||||
|
||||
bool all_tracks_unlocked_;
|
||||
|
||||
QList<Block*> gaps_to_extend_;
|
||||
|
||||
QList<GapBlock*> gaps_added_;
|
||||
|
||||
BlockSplitPreservingLinksCommand* split_command_;
|
||||
|
||||
QObject memory_manager_;
|
||||
|
||||
};
|
||||
|
||||
class TransitionRemoveCommand : public UndoCommand {
|
||||
public:
|
||||
TransitionRemoveCommand(Track *track, TransitionBlock* block, QUndoCommand *parent = nullptr);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Track* track_;
|
||||
|
||||
TransitionBlock* block_;
|
||||
|
||||
Block* out_block_;
|
||||
Block* in_block_;
|
||||
|
||||
};
|
||||
|
||||
class TimelineWidget;
|
||||
|
||||
class TimelineSetSelectionsCommand : public QUndoCommand {
|
||||
public:
|
||||
TimelineSetSelectionsCommand(TimelineWidget* timeline, const TimelineWidgetSelections& now, const TimelineWidgetSelections& old, QUndoCommand* parent = nullptr);
|
||||
|
||||
protected:
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
|
||||
private:
|
||||
TimelineWidget* timeline_;
|
||||
TimelineWidgetSelections old_;
|
||||
TimelineWidgetSelections now_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TIMELINEUNDOABLE_H
|
||||
@@ -31,8 +31,6 @@
|
||||
#include "timelineviewmouseevent.h"
|
||||
#include "timelineviewghostitem.h"
|
||||
#include "widget/timebased/timebasedview.h"
|
||||
#include "widget/timelinewidget/undo/undo.h"
|
||||
#include "undo/undostack.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user