started base transition type
Like the base "Block" type, the "Transition" type will not be a node used on its own, it will have to be derived. This type defines some basic behavior for a transition (e.g. how much it overlaps its "from" and "to" blocks).
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
add_subdirectory(clip)
|
||||
add_subdirectory(gap)
|
||||
add_subdirectory(transition)
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
|
||||
@@ -42,7 +42,8 @@ public:
|
||||
enum Type {
|
||||
kClip,
|
||||
kGap,
|
||||
kTrack
|
||||
kTrack,
|
||||
kTransition
|
||||
};
|
||||
|
||||
virtual Type type() const = 0;
|
||||
@@ -54,9 +55,9 @@ public:
|
||||
void set_in(const rational& in);
|
||||
void set_out(const rational& out);
|
||||
|
||||
const rational &length() const;
|
||||
void set_length(const rational &length);
|
||||
void set_length_and_media_in(const rational &length);
|
||||
const rational& length() const;
|
||||
virtual void set_length(const rational &length);
|
||||
virtual void set_length_and_media_in(const rational &length);
|
||||
|
||||
Block* previous();
|
||||
Block* next();
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2019 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}
|
||||
node/block/transition/transition.h
|
||||
node/block/transition/transition.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,62 @@
|
||||
#include "transition.h"
|
||||
|
||||
TransitionBlock::TransitionBlock()
|
||||
{
|
||||
out_block_input_ = new NodeInput("out_block_in");
|
||||
AddInput(out_block_input_);
|
||||
|
||||
in_block_input_ = new NodeInput("in_block_in");
|
||||
AddInput(in_block_input_);
|
||||
}
|
||||
|
||||
Block::Type TransitionBlock::type() const
|
||||
{
|
||||
return kTransition;
|
||||
}
|
||||
|
||||
NodeInput *TransitionBlock::out_block_input() const
|
||||
{
|
||||
return out_block_input_;
|
||||
}
|
||||
|
||||
NodeInput *TransitionBlock::in_block_input() const
|
||||
{
|
||||
return in_block_input_;
|
||||
}
|
||||
|
||||
void TransitionBlock::Retranslate()
|
||||
{
|
||||
out_block_input_->set_name(tr("From"));
|
||||
in_block_input_->set_name(tr("To"));
|
||||
}
|
||||
|
||||
void TransitionBlock::set_length(const rational &length)
|
||||
{
|
||||
Q_UNUSED(length)
|
||||
qCritical() << "Set length is not permitted on a transition";
|
||||
abort();
|
||||
}
|
||||
|
||||
void TransitionBlock::set_length_and_media_in(const rational &length)
|
||||
{
|
||||
Q_UNUSED(length)
|
||||
qCritical() << "Set length and media in is not permitted on a transition";
|
||||
abort();
|
||||
}
|
||||
|
||||
void TransitionBlock::set_in_offset(const rational &in_offset)
|
||||
{
|
||||
in_offset_ = in_offset;
|
||||
RecalculateLength();
|
||||
}
|
||||
|
||||
void TransitionBlock::set_out_offset(const rational &out_offset)
|
||||
{
|
||||
out_offset_ = out_offset;
|
||||
RecalculateLength();
|
||||
}
|
||||
|
||||
void TransitionBlock::RecalculateLength()
|
||||
{
|
||||
Block::set_length(in_offset_ + out_offset_);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef TRANSITIONBLOCK_H
|
||||
#define TRANSITIONBLOCK_H
|
||||
|
||||
#include "node/block/block.h"
|
||||
|
||||
class TransitionBlock : public Block
|
||||
{
|
||||
public:
|
||||
TransitionBlock();
|
||||
|
||||
virtual Type type() const override;
|
||||
|
||||
NodeInput* out_block_input() const;
|
||||
|
||||
NodeInput* in_block_input() const;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
virtual void set_length(const rational &length) override;
|
||||
virtual void set_length_and_media_in(const rational &length) override;
|
||||
|
||||
void set_in_offset(const rational& in_offset);
|
||||
void set_out_offset(const rational& out_offset);
|
||||
|
||||
private:
|
||||
void RecalculateLength();
|
||||
|
||||
NodeInput* out_block_input_;
|
||||
|
||||
NodeInput* in_block_input_;
|
||||
|
||||
rational in_offset_;
|
||||
|
||||
rational out_offset_;
|
||||
|
||||
};
|
||||
|
||||
#endif // TRANSITIONBLOCK_H
|
||||
@@ -573,6 +573,7 @@ void TimelineWidget::AddBlock(Block *block, TrackReference track)
|
||||
{
|
||||
switch (block->type()) {
|
||||
case Block::kClip:
|
||||
case Block::kTransition:
|
||||
case Block::kGap:
|
||||
{
|
||||
TimelineViewBlockItem* item = new TimelineViewBlockItem();
|
||||
|
||||
@@ -79,6 +79,7 @@ void TimelineViewBlockItem::paint(QPainter *painter, const QStyleOptionGraphicsI
|
||||
|
||||
switch (block_->type()) {
|
||||
case Block::kClip:
|
||||
case Block::kTransition: // FIXME: Temporary, the transition should have its own UI representation at some point
|
||||
/*QLinearGradient grad;
|
||||
grad.setStart(0, rect().top());
|
||||
grad.setFinalStop(0, rect().bottom());
|
||||
|
||||
Reference in New Issue
Block a user