arranged items so they are inputs of folder rather than outputs
This commit is contained in:
@@ -20,7 +20,5 @@ add_subdirectory(sequence)
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
project/item/item.h
|
||||
project/item/item.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
@@ -27,8 +27,13 @@
|
||||
|
||||
namespace olive {
|
||||
|
||||
#define super Node
|
||||
|
||||
const QString Folder::kChildInput = QStringLiteral("child_in");
|
||||
|
||||
Folder::Folder()
|
||||
{
|
||||
AddInput(kChildInput, NodeValue::kNone, InputFlags(kInputFlagArray | kInputFlagNotKeyframable));
|
||||
}
|
||||
|
||||
QIcon Folder::icon() const
|
||||
@@ -36,6 +41,13 @@ QIcon Folder::icon() const
|
||||
return icon::Folder;
|
||||
}
|
||||
|
||||
void Folder::Retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
|
||||
SetInputName(kChildInput, tr("Children"));
|
||||
}
|
||||
|
||||
bool ChildExistsWithNameInternal(const Folder* n, const QString& s)
|
||||
{
|
||||
foreach (const Node::OutputConnection& c, n->output_connections()) {
|
||||
@@ -60,33 +72,69 @@ bool Folder::ChildExistsWithName(const QString &s) const
|
||||
return ChildExistsWithNameInternal(this, s);
|
||||
}
|
||||
|
||||
void Folder::OutputConnectedEvent(const QString &output, const NodeInput &input)
|
||||
int Folder::index_of_child_in_array(Node *item) const
|
||||
{
|
||||
Q_UNUSED(output)
|
||||
int index_of_item = item_children_.indexOf(item);
|
||||
|
||||
Item* item = dynamic_cast<Item*>(input.node());
|
||||
if (index_of_item == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return item_element_index_.at(index_of_item);
|
||||
}
|
||||
|
||||
void Folder::InputConnectedEvent(const QString &input, int element, const NodeOutput &output)
|
||||
{
|
||||
if (input == kChildInput && element != -1) {
|
||||
Node* item = output.node();
|
||||
|
||||
if (item) {
|
||||
// The insert index is always our "count" because we only support appending in our internal
|
||||
// model. For sorting/organizing, a QSortFilterProxyModel is used instead.
|
||||
emit BeginInsertItem(item, item_child_count());
|
||||
item_children_.append(item);
|
||||
item_element_index_.append(element);
|
||||
item->SetFolder(this);
|
||||
emit EndInsertItem();
|
||||
}
|
||||
}
|
||||
|
||||
void Folder::OutputDisconnectedEvent(const QString &output, const NodeInput &input)
|
||||
void Folder::InputDisconnectedEvent(const QString &input, int element, const NodeOutput &output)
|
||||
{
|
||||
Q_UNUSED(output)
|
||||
if (input == kChildInput && element != -1) {
|
||||
Node* item = output.node();
|
||||
|
||||
Item* item = dynamic_cast<Item*>(input.node());
|
||||
|
||||
if (item) {
|
||||
int child_index = item_children_.indexOf(item);
|
||||
emit BeginRemoveItem(item, child_index);
|
||||
item_children_.removeAt(child_index);
|
||||
item_element_index_.removeAt(child_index);
|
||||
item->SetFolder(nullptr);
|
||||
emit EndRemoveItem();
|
||||
}
|
||||
}
|
||||
|
||||
FolderAddChild::FolderAddChild(Folder *folder, Node *child, bool autoposition) :
|
||||
folder_(folder),
|
||||
child_(child),
|
||||
autoposition_(autoposition)
|
||||
{
|
||||
}
|
||||
|
||||
Project *FolderAddChild::GetRelevantProject() const
|
||||
{
|
||||
return folder_->project();
|
||||
}
|
||||
|
||||
void FolderAddChild::redo()
|
||||
{
|
||||
int array_index = folder_->InputArraySize(Folder::kChildInput);
|
||||
folder_->InputArrayAppend(Folder::kChildInput, false);
|
||||
Node::ConnectEdge(child_, NodeInput(folder_, Folder::kChildInput, array_index));
|
||||
}
|
||||
|
||||
void FolderAddChild::undo()
|
||||
{
|
||||
Node::DisconnectEdge(child_, NodeInput(folder_, Folder::kChildInput, folder_->InputArraySize(Folder::kChildInput)-1));
|
||||
folder_->InputArrayRemoveLast(Folder::kChildInput);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#define FOLDER_H
|
||||
|
||||
#include "node/node.h"
|
||||
#include "project/item/item.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
@@ -32,7 +31,7 @@ namespace olive {
|
||||
* The Item base class already has support for children, but this functionality is disabled by default
|
||||
* (see CanHaveChildren() override). The Folder is a specific type that enables this functionality.
|
||||
*/
|
||||
class Folder : public Item
|
||||
class Folder : public Node
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -65,6 +64,8 @@ public:
|
||||
|
||||
virtual QIcon icon() const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
bool ChildExistsWithName(const QString& s) const;
|
||||
|
||||
int item_child_count() const
|
||||
@@ -72,16 +73,21 @@ public:
|
||||
return item_children_.size();
|
||||
}
|
||||
|
||||
Item* item_child(int i) const
|
||||
Node* item_child(int i) const
|
||||
{
|
||||
return item_children_.at(i);
|
||||
}
|
||||
|
||||
const QVector<Item*>& children() const
|
||||
const QVector<Node*>& children() const
|
||||
{
|
||||
return item_children_;
|
||||
}
|
||||
|
||||
virtual bool IsItem() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns a list of nodes that are of a certain type that this node outputs to
|
||||
*/
|
||||
@@ -95,24 +101,28 @@ public:
|
||||
return list;
|
||||
}
|
||||
|
||||
int index_of_child(Item* item) const
|
||||
int index_of_child(Node* item) const
|
||||
{
|
||||
return item_children_.indexOf(item);
|
||||
}
|
||||
|
||||
int index_of_child_in_array(Node* item) const;
|
||||
|
||||
static const QString kChildInput;
|
||||
|
||||
signals:
|
||||
void BeginInsertItem(Item* n, int index);
|
||||
void BeginInsertItem(Node* n, int index);
|
||||
|
||||
void EndInsertItem();
|
||||
|
||||
void BeginRemoveItem(Item* n, int index);
|
||||
void BeginRemoveItem(Node* n, int index);
|
||||
|
||||
void EndRemoveItem();
|
||||
|
||||
protected:
|
||||
virtual void OutputConnectedEvent(const QString& output, const NodeInput& input) override;
|
||||
virtual void InputConnectedEvent(const QString& input, int element, const NodeOutput& output) override;
|
||||
|
||||
virtual void OutputDisconnectedEvent(const QString& output, const NodeInput& input) override;
|
||||
virtual void InputDisconnectedEvent(const QString& input, int element, const NodeOutput& output) override;
|
||||
|
||||
private:
|
||||
template<typename T>
|
||||
@@ -140,7 +150,30 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
QVector<Item*> item_children_;
|
||||
QVector<Node*> item_children_;
|
||||
QVector<int> item_element_index_;
|
||||
|
||||
};
|
||||
|
||||
class FolderAddChild : public UndoCommand
|
||||
{
|
||||
public:
|
||||
FolderAddChild(Folder* folder, Node* child, bool autoposition = true);
|
||||
|
||||
virtual Project * GetRelevantProject() const override;
|
||||
|
||||
virtual void redo() override;
|
||||
|
||||
virtual void undo() override;
|
||||
|
||||
private:
|
||||
Folder* folder_;
|
||||
|
||||
Node* child_;
|
||||
|
||||
bool autoposition_;
|
||||
|
||||
QPointF old_position_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -38,10 +38,9 @@ namespace olive {
|
||||
const QString Footage::kFilenameInput = QStringLiteral("file_in");
|
||||
const QString Footage::kStreamPropertiesFormat = QStringLiteral("stream_properties:%1");
|
||||
|
||||
#define super Item
|
||||
#define super Node
|
||||
|
||||
Footage::Footage(const QString &filename) :
|
||||
super(true, false),
|
||||
cancelled_(nullptr)
|
||||
{
|
||||
AddInput(kFilenameInput, NodeValue::kFile, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
|
||||
@@ -381,7 +380,7 @@ QIcon Footage::icon() const
|
||||
return icon::Error;
|
||||
}
|
||||
|
||||
QString Footage::duration()
|
||||
QString Footage::duration() const
|
||||
{
|
||||
// Try video first
|
||||
VideoParams video = GetFirstEnabledVideoStream();
|
||||
@@ -420,7 +419,7 @@ QString Footage::duration()
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString Footage::rate()
|
||||
QString Footage::rate() const
|
||||
{
|
||||
if (inputs_for_stream_properties_.isEmpty()) {
|
||||
return QString();
|
||||
@@ -431,12 +430,12 @@ QString Footage::rate()
|
||||
VideoParams video_stream = GetFirstEnabledVideoStream();
|
||||
|
||||
if (video_stream.video_type() != VideoParams::kVideoTypeStill) {
|
||||
return QCoreApplication::translate("Footage", "%1 FPS").arg(video_stream.frame_rate().toDouble());
|
||||
return tr("%1 FPS").arg(video_stream.frame_rate().toDouble());
|
||||
}
|
||||
} else if (HasEnabledAudioStreams()) {
|
||||
// No video streams, return audio
|
||||
AudioParams audio_stream = GetFirstEnabledAudioStream();
|
||||
return QCoreApplication::translate("Footage", "%1 Hz").arg(audio_stream.sample_rate());
|
||||
return tr("%1 Hz").arg(audio_stream.sample_rate());
|
||||
}
|
||||
|
||||
return QString();
|
||||
@@ -620,7 +619,7 @@ QString Footage::GetStreamTypeName(Stream::Type type)
|
||||
void Footage::UpdateTooltip()
|
||||
{
|
||||
if (valid_) {
|
||||
QString tip = QCoreApplication::translate("Footage", "Filename: %1").arg(filename());
|
||||
QString tip = tr("Filename: %1").arg(filename());
|
||||
|
||||
for (auto it=inputs_for_stream_properties_.cbegin(); it!=inputs_for_stream_properties_.cend(); it++) {
|
||||
if (it.key().type() == Stream::kVideo) {
|
||||
@@ -640,9 +639,9 @@ void Footage::UpdateTooltip()
|
||||
}
|
||||
}
|
||||
|
||||
set_tooltip(tip);
|
||||
SetToolTip(tip);
|
||||
} else {
|
||||
set_tooltip(QCoreApplication::translate("Footage", "This footage is not valid for use"));
|
||||
SetToolTip(tr("This footage is not valid for use"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "common/rational.h"
|
||||
#include "footagedescription.h"
|
||||
#include "node/node.h"
|
||||
#include "project/item/item.h"
|
||||
#include "render/audioparams.h"
|
||||
#include "render/videoparams.h"
|
||||
#include "stream.h"
|
||||
@@ -42,7 +41,7 @@ namespace olive {
|
||||
* Footage objects store a list of Stream objects which store the majority of video/audio metadata. These streams
|
||||
* are identical to the stream data in the files.
|
||||
*/
|
||||
class Footage : public Item, public TimelinePoints
|
||||
class Footage : public Node, public TimelinePoints
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -263,9 +262,14 @@ public:
|
||||
|
||||
virtual QIcon icon() const override;
|
||||
|
||||
virtual QString duration() override;
|
||||
virtual QString duration() const override;
|
||||
|
||||
virtual QString rate() override;
|
||||
virtual QString rate() const override;
|
||||
|
||||
virtual bool IsItem() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HasEnabledVideoStreams() const;
|
||||
bool HasEnabledAudioStreams() const;
|
||||
|
||||
@@ -1,72 +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 "item.h"
|
||||
|
||||
#include "folder/folder.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
#define super QObject
|
||||
|
||||
const QString Item::kParentInput = QStringLiteral("parent_in");
|
||||
|
||||
Item::Item(bool create_folder_input, bool create_default_output) :
|
||||
Node(create_default_output)
|
||||
{
|
||||
if (create_folder_input) {
|
||||
// Hierarchy input for items
|
||||
AddInput(kParentInput, NodeValue::kNone);
|
||||
IgnoreHashingFrom(kParentInput);
|
||||
IgnoreInvalidationsFrom(kParentInput);
|
||||
}
|
||||
}
|
||||
|
||||
const QString &Item::tooltip() const
|
||||
{
|
||||
return tooltip_;
|
||||
}
|
||||
|
||||
void Item::set_tooltip(const QString &t)
|
||||
{
|
||||
tooltip_ = t;
|
||||
}
|
||||
|
||||
QString Item::duration()
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString Item::rate()
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
Folder *Item::item_parent() const
|
||||
{
|
||||
return dynamic_cast<Folder*>(GetConnectedNode(kParentInput));
|
||||
}
|
||||
|
||||
void Item::Retranslate()
|
||||
{
|
||||
SetInputName(kParentInput, tr("Folder"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,75 +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 ITEM_H
|
||||
#define ITEM_H
|
||||
|
||||
#include <memory>
|
||||
#include <QIcon>
|
||||
#include <QList>
|
||||
#include <QMutex>
|
||||
#include <QString>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
#include "common/threadedobject.h"
|
||||
#include "common/xmlutils.h"
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class Folder;
|
||||
class Project;
|
||||
|
||||
/**
|
||||
* @brief A base-class representing any element in a Project
|
||||
*
|
||||
* Project objects implement a parent-child hierarchy of Items that can be used throughout the Project. The Item class
|
||||
* itself is abstract and will need to be subclassed to be used in a Project.
|
||||
*/
|
||||
class Item : public Node
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Item constructor
|
||||
*/
|
||||
Item(bool create_folder_input = true, bool create_default_output = true);
|
||||
|
||||
const QString& tooltip() const;
|
||||
void set_tooltip(const QString& t);
|
||||
|
||||
virtual QString duration();
|
||||
|
||||
virtual QString rate();
|
||||
|
||||
Folder *item_parent() const;
|
||||
|
||||
static const QString kParentInput;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
private:
|
||||
QString tooltip_;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // ITEM_H
|
||||
@@ -46,10 +46,9 @@ const QString Sequence::kTrackInputFormat = QStringLiteral("track_in_%1");
|
||||
|
||||
const uint64_t Sequence::kVideoParamEditMask = VideoParamEdit::kWidthHeight | VideoParamEdit::kInterlacing | VideoParamEdit::kFrameRate | VideoParamEdit::kPixelAspect;
|
||||
|
||||
#define super Item
|
||||
#define super Node
|
||||
|
||||
Sequence::Sequence(bool viewer_only_mode) :
|
||||
Item(!viewer_only_mode, true),
|
||||
video_frame_cache_(this),
|
||||
audio_playback_cache_(this),
|
||||
operation_stack_(0)
|
||||
@@ -104,7 +103,7 @@ QIcon Sequence::icon() const
|
||||
return icon::Sequence;
|
||||
}
|
||||
|
||||
QString Sequence::duration()
|
||||
QString Sequence::duration() const
|
||||
{
|
||||
rational timeline_length = GetLength();
|
||||
|
||||
@@ -113,7 +112,7 @@ QString Sequence::duration()
|
||||
return Timecode::timestamp_to_timecode(timestamp, video_params().time_base(), Core::instance()->GetTimecodeDisplay());
|
||||
}
|
||||
|
||||
QString Sequence::rate()
|
||||
QString Sequence::rate() const
|
||||
{
|
||||
return tr("%1 FPS").arg(video_params().time_base().flipped().toDouble());
|
||||
}
|
||||
@@ -341,7 +340,7 @@ void Sequence::InvalidateCache(const TimeRange& range, const QString& from, int
|
||||
super::InvalidateCache(range, from, element, job_time);
|
||||
}
|
||||
|
||||
rational Sequence::GetLength()
|
||||
const rational& Sequence::GetLength() const
|
||||
{
|
||||
return last_length_;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "node/output/track/tracklist.h"
|
||||
#include "node/traverser.h"
|
||||
#include "project/item/footage/footage.h"
|
||||
#include "project/item/item.h"
|
||||
#include "render/audioparams.h"
|
||||
#include "render/audioplaybackcache.h"
|
||||
#include "render/framehashcache.h"
|
||||
@@ -46,7 +45,7 @@ namespace olive {
|
||||
/**
|
||||
* @brief The main timeline object, an graph of edited clips that forms a complete edit
|
||||
*/
|
||||
class Sequence : public Item, public TimelinePoints
|
||||
class Sequence : public Node, public TimelinePoints
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -83,8 +82,8 @@ public:
|
||||
|
||||
virtual QIcon icon() const override;
|
||||
|
||||
virtual QString duration() override;
|
||||
virtual QString rate() override;
|
||||
virtual QString duration() const override;
|
||||
virtual QString rate() const override;
|
||||
|
||||
void set_default_parameters();
|
||||
|
||||
@@ -136,7 +135,7 @@ public:
|
||||
SetStandardValue(kAudioParamsInput, QVariant::fromValue(audio));
|
||||
}
|
||||
|
||||
rational GetLength();
|
||||
const rational &GetLength() const;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
@@ -173,6 +172,11 @@ public:
|
||||
return uuid_;
|
||||
}
|
||||
|
||||
virtual bool IsItem() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
signals:
|
||||
void TimebaseChanged(const rational&);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user