rewrite nearly complete
This commit is contained in:
+89
-103
@@ -32,8 +32,8 @@
|
||||
#include "timeline/sequence.h"
|
||||
#include "panels/timeline.h"
|
||||
#include "project/media.h"
|
||||
#include "project/clipboard.h"
|
||||
#include "undo/undo.h"
|
||||
#include "global/clipboard.h"
|
||||
#include "global/debug.h"
|
||||
#include "global/timing.h"
|
||||
|
||||
@@ -46,7 +46,7 @@ Clip::Clip(Track *s) :
|
||||
timeline_out_(0),
|
||||
media_(nullptr),
|
||||
reverse_(false),
|
||||
autoscale_(olive::CurrentConfig.autoscale_by_default),
|
||||
autoscale_(olive::config.autoscale_by_default),
|
||||
opening_transition(nullptr),
|
||||
closing_transition(nullptr),
|
||||
undeletable(false),
|
||||
@@ -110,6 +110,11 @@ bool Clip::IsTransitionSelected(TransitionType type)
|
||||
}
|
||||
}
|
||||
|
||||
Selection Clip::ToSelection()
|
||||
{
|
||||
return Selection(timeline_in(), timeline_out(), track());
|
||||
}
|
||||
|
||||
Track::Type Clip::type()
|
||||
{
|
||||
return track()->type();
|
||||
@@ -158,6 +163,11 @@ void Clip::set_media(Media *m, int s)
|
||||
media_stream_ = s;
|
||||
}
|
||||
|
||||
void Clip::Move(ComboAction *ca, long iin, long iout, long iclip_in, Track *itrack, bool verify_transitions, bool relative)
|
||||
{
|
||||
track()->sequence()->MoveClip(this, ca, iin, iout, iclip_in, itrack, verify_transitions, relative);
|
||||
}
|
||||
|
||||
bool Clip::enabled()
|
||||
{
|
||||
return enabled_;
|
||||
@@ -168,39 +178,6 @@ void Clip::set_enabled(bool e)
|
||||
enabled_ = e;
|
||||
}
|
||||
|
||||
void Clip::move(ComboAction* ca, long iin, long iout, long iclip_in, int itrack, bool verify_transitions, bool relative)
|
||||
{
|
||||
ca->append(new MoveClipAction(this, iin, iout, iclip_in, itrack, relative));
|
||||
|
||||
if (verify_transitions) {
|
||||
|
||||
// if this is a shared transition, and the corresponding clip will be moved away somehow
|
||||
if (opening_transition != nullptr
|
||||
&& opening_transition->secondary_clip != nullptr
|
||||
&& opening_transition->secondary_clip->timeline_out() != iin) {
|
||||
// separate transition
|
||||
ca->append(new SetPointer(reinterpret_cast<void**>(&opening_transition->secondary_clip), nullptr));
|
||||
ca->append(new AddTransitionCommand(nullptr,
|
||||
opening_transition->secondary_clip,
|
||||
opening_transition,
|
||||
nullptr,
|
||||
0));
|
||||
}
|
||||
|
||||
if (closing_transition != nullptr
|
||||
&& closing_transition->secondary_clip != nullptr
|
||||
&& closing_transition->parent_clip->timeline_in() != iout) {
|
||||
// separate transition
|
||||
ca->append(new SetPointer(reinterpret_cast<void**>(&closing_transition->secondary_clip), nullptr));
|
||||
ca->append(new AddTransitionCommand(nullptr,
|
||||
this,
|
||||
closing_transition,
|
||||
nullptr,
|
||||
0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Clip::reset_audio() {
|
||||
if (UsesCacher()) {
|
||||
cacher.ResetAudio();
|
||||
@@ -260,6 +237,9 @@ Clip::~Clip() {
|
||||
|
||||
void Clip::Save(QXmlStreamWriter &stream)
|
||||
{
|
||||
stream.writeStartElement("clip");
|
||||
stream.writeAttribute("id", QString::number(load_id));
|
||||
|
||||
stream.writeAttribute("enabled", QString::number(enabled()));
|
||||
stream.writeAttribute("name", name());
|
||||
stream.writeAttribute("clipin", QString::number(clip_in()));
|
||||
@@ -312,21 +292,17 @@ void Clip::Save(QXmlStreamWriter &stream)
|
||||
if (transition != nullptr) {
|
||||
stream.writeStartElement((t == kTransitionOpening) ? "opening" : "closing");
|
||||
|
||||
// check if this is a shared transition and the transition has already been saved
|
||||
int transition_cache_index = transition_save_cache.indexOf(transition);
|
||||
|
||||
if (transition_cache_index > -1) {
|
||||
// check if this is a shared transition
|
||||
if (this == transition->secondary_clip) {
|
||||
// if so, just save a reference to the other clip
|
||||
stream.writeAttribute("shared",
|
||||
QString::number(transition_clip_save_cache.at(transition_cache_index)));
|
||||
QString::number(transition->parent_clip->load_id));
|
||||
} else {
|
||||
// otherwise save the whole transition
|
||||
transition->save(stream);
|
||||
transition_save_cache.append(transition);
|
||||
transition_clip_save_cache.append(j);
|
||||
}
|
||||
|
||||
stream.writeEndElement(); // opening
|
||||
stream.writeEndElement(); // opening/closing
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,7 +312,7 @@ void Clip::Save(QXmlStreamWriter &stream)
|
||||
stream.writeEndElement(); // effect
|
||||
}
|
||||
|
||||
|
||||
stream.writeEndElement(); // clip
|
||||
}
|
||||
|
||||
long Clip::clip_in(bool with_transition) {
|
||||
@@ -441,6 +417,15 @@ Track *Clip::track()
|
||||
|
||||
void Clip::set_track(Track *t)
|
||||
{
|
||||
// Ensure this clip has already been added to this track
|
||||
bool found = false;
|
||||
for (int i=0;i<t->ClipCount();i++) {
|
||||
if (t->GetClip(i).get() == this) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
track_ = t;
|
||||
}
|
||||
|
||||
@@ -510,13 +495,13 @@ int Clip::media_width() {
|
||||
}
|
||||
|
||||
int Clip::media_height() {
|
||||
if (media_ == nullptr && sequence != nullptr) return sequence->height;
|
||||
if (media_ == nullptr && track() != nullptr) return track()->sequence()->height;
|
||||
switch (media_->get_type()) {
|
||||
case MEDIA_TYPE_FOOTAGE:
|
||||
{
|
||||
const FootageStream* ms = media_stream();
|
||||
if (ms != nullptr) return ms->video_height;
|
||||
if (sequence != nullptr) return sequence->height;
|
||||
if (track() != nullptr) return track()->sequence()->height;
|
||||
}
|
||||
break;
|
||||
case MEDIA_TYPE_SEQUENCE:
|
||||
@@ -530,11 +515,12 @@ int Clip::media_height() {
|
||||
|
||||
void Clip::refactor_frame_rate(ComboAction* ca, double multiplier, bool change_timeline_points) {
|
||||
if (change_timeline_points) {
|
||||
this->move(ca,
|
||||
qRound(double(timeline_in_) * multiplier),
|
||||
qRound(double(timeline_out_) * multiplier),
|
||||
qRound(double(clip_in_) * multiplier),
|
||||
track_);
|
||||
track()->sequence()->MoveClip(this,
|
||||
ca,
|
||||
qRound(double(timeline_in_) * multiplier),
|
||||
qRound(double(timeline_out_) * multiplier),
|
||||
qRound(double(clip_in_) * multiplier),
|
||||
track_);
|
||||
}
|
||||
|
||||
// move keyframes
|
||||
@@ -645,79 +631,79 @@ bool Clip::Retrieve()
|
||||
|
||||
//if (frame->pts != texture_timestamp) {
|
||||
|
||||
bool allocate_data = false;
|
||||
bool allocate_data = false;
|
||||
|
||||
QOpenGLFunctions* f = QOpenGLContext::currentContext()->functions();
|
||||
QOpenGLFunctions* f = QOpenGLContext::currentContext()->functions();
|
||||
|
||||
// check if the opengl texture exists yet, create it if not
|
||||
if (texture == 0) {
|
||||
// check if the opengl texture exists yet, create it if not
|
||||
if (texture == 0) {
|
||||
|
||||
// create texture object
|
||||
f->glGenTextures(1, &texture);
|
||||
// create texture object
|
||||
f->glGenTextures(1, &texture);
|
||||
|
||||
f->glBindTexture(GL_TEXTURE_2D, texture);
|
||||
f->glBindTexture(GL_TEXTURE_2D, texture);
|
||||
|
||||
// set texture filtering to bilinear
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
// set texture filtering to bilinear
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
// set texture wrapping to clamp
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
// set texture wrapping to clamp
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
// queue an allocation ahead
|
||||
allocate_data = true;
|
||||
// queue an allocation ahead
|
||||
allocate_data = true;
|
||||
|
||||
} else {
|
||||
} else {
|
||||
|
||||
f->glBindTexture(GL_TEXTURE_2D, texture);
|
||||
f->glBindTexture(GL_TEXTURE_2D, texture);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int video_width = cacher.media_width();
|
||||
int video_height = cacher.media_height();
|
||||
int video_width = cacher.media_width();
|
||||
int video_height = cacher.media_height();
|
||||
|
||||
const olive::PixelFormatInfo& pix_fmt_info = olive::pixel_formats.at(cacher.media_pixel_format());
|
||||
const olive::PixelFormatInfo& pix_fmt_info = olive::pixel_formats.at(cacher.media_pixel_format());
|
||||
|
||||
f->glPixelStorei(GL_UNPACK_ROW_LENGTH, frame->linesize[0]/pix_fmt_info.bytes_per_pixel);
|
||||
f->glPixelStorei(GL_UNPACK_ROW_LENGTH, frame->linesize[0]/pix_fmt_info.bytes_per_pixel);
|
||||
|
||||
if (allocate_data) {
|
||||
if (allocate_data) {
|
||||
|
||||
// the raw frame size may differ from the one we're using (e.g. a lower resolution proxy), so we make sure
|
||||
// the texture is using the correct dimensions, but then treat it as if it's the original resolution in the
|
||||
// composition
|
||||
f->glTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
0,
|
||||
pix_fmt_info.internal_format,
|
||||
video_width,
|
||||
video_height,
|
||||
0,
|
||||
pix_fmt_info.pixel_format,
|
||||
pix_fmt_info.pixel_type,
|
||||
frame->data[0]
|
||||
);
|
||||
// the raw frame size may differ from the one we're using (e.g. a lower resolution proxy), so we make sure
|
||||
// the texture is using the correct dimensions, but then treat it as if it's the original resolution in the
|
||||
// composition
|
||||
f->glTexImage2D(
|
||||
GL_TEXTURE_2D,
|
||||
0,
|
||||
pix_fmt_info.internal_format,
|
||||
video_width,
|
||||
video_height,
|
||||
0,
|
||||
pix_fmt_info.pixel_format,
|
||||
pix_fmt_info.pixel_type,
|
||||
frame->data[0]
|
||||
);
|
||||
|
||||
} else {
|
||||
} else {
|
||||
|
||||
f->glTexSubImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
video_width,
|
||||
video_height,
|
||||
pix_fmt_info.pixel_format,
|
||||
pix_fmt_info.pixel_type,
|
||||
frame->data[0]
|
||||
);
|
||||
f->glTexSubImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
video_width,
|
||||
video_height,
|
||||
pix_fmt_info.pixel_format,
|
||||
pix_fmt_info.pixel_type,
|
||||
frame->data[0]
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
f->glBindTexture(GL_TEXTURE_2D, 0);
|
||||
f->glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
f->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
f->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
|
||||
texture_timestamp = frame->pts;
|
||||
texture_timestamp = frame->pts;
|
||||
|
||||
//}
|
||||
|
||||
|
||||
+7
-5
@@ -59,6 +59,8 @@ public:
|
||||
bool IsSelected(bool containing = true);
|
||||
bool IsTransitionSelected(TransitionType type);
|
||||
|
||||
Selection ToSelection();
|
||||
|
||||
Track::Type type();
|
||||
|
||||
const QColor& color();
|
||||
@@ -74,17 +76,17 @@ public:
|
||||
long media_length();
|
||||
void set_media(Media* m, int s);
|
||||
|
||||
bool enabled();
|
||||
void set_enabled(bool e);
|
||||
|
||||
void move(ComboAction* ca,
|
||||
void Move(ComboAction* ca,
|
||||
long iin,
|
||||
long iout,
|
||||
long iclip_in,
|
||||
int itrack,
|
||||
Track *itrack,
|
||||
bool verify_transitions = true,
|
||||
bool relative = false);
|
||||
|
||||
bool enabled();
|
||||
void set_enabled(bool e);
|
||||
|
||||
long clip_in(bool with_transition = false);
|
||||
void set_clip_in(long c);
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "ghost.h"
|
||||
|
||||
Selection Ghost::ToSelection() const
|
||||
{
|
||||
return Selection(in, out, track);
|
||||
}
|
||||
+15
-2
@@ -2,11 +2,22 @@
|
||||
#define GHOST_H
|
||||
|
||||
#include "effects/transition.h"
|
||||
#include "timelinefunctions.h"
|
||||
#include "track.h"
|
||||
|
||||
namespace olive {
|
||||
namespace timeline {
|
||||
|
||||
enum TrimType {
|
||||
TRIM_NONE,
|
||||
TRIM_IN,
|
||||
TRIM_OUT
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
struct Ghost {
|
||||
int clip;
|
||||
Clip* clip;
|
||||
long in;
|
||||
long out;
|
||||
Track* track;
|
||||
@@ -28,6 +39,8 @@ struct Ghost {
|
||||
|
||||
// transition trimming
|
||||
TransitionPtr transition;
|
||||
|
||||
Selection ToSelection() const;
|
||||
};
|
||||
|
||||
#endif // GHOST_H
|
||||
|
||||
+73
-44
@@ -49,22 +49,24 @@ void Marker::Draw(QPainter &p, int x, int y, int bottom, bool selected) {
|
||||
p.drawPolygon(points, 5);
|
||||
}
|
||||
|
||||
void set_marker_internal(Sequence* seq, const QVector<int>& clips) {
|
||||
// if clips is empty, the marker is being added to the sequence
|
||||
void Marker::SetOnClips(const QVector<Clip *> &clips)
|
||||
{
|
||||
// Don't bother if there are no clips
|
||||
if (clips.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// add_marker is used to determine whether we're adding a marker, depending on whether the user input a marker name
|
||||
// however if (config.set_name_with_marker) is true, we don't need a marker name so we just add
|
||||
bool add_marker = !olive::CurrentConfig.set_name_with_marker;
|
||||
bool add_marker = !olive::config.set_name_with_marker;
|
||||
|
||||
QString marker_name;
|
||||
|
||||
// if (config.set_name_with_marker) is false (set above), ask for a marker name
|
||||
// if Config::set_name_with_marker is true (set above), ask for a marker name
|
||||
if (!add_marker) {
|
||||
QInputDialog d(olive::MainWindow);
|
||||
d.setWindowTitle(QCoreApplication::translate("Marker", "Set Marker"));
|
||||
d.setLabelText(clips.size() > 0
|
||||
? QCoreApplication::translate("Marker", "Set clip marker name:")
|
||||
: QCoreApplication::translate("Marker", "Set sequence marker name:"));
|
||||
d.setLabelText(QCoreApplication::translate("Marker", "Set clip marker name:"));
|
||||
d.setInputMode(QInputDialog::TextInput);
|
||||
add_marker = (d.exec() == QDialog::Accepted);
|
||||
marker_name = d.textValue();
|
||||
@@ -75,43 +77,16 @@ void set_marker_internal(Sequence* seq, const QVector<int>& clips) {
|
||||
|
||||
ComboAction* ca = new ComboAction();
|
||||
|
||||
if (clips.size() > 0) {
|
||||
|
||||
// add a marker action for each clip
|
||||
foreach (int i, clips) {
|
||||
ClipPtr c = seq->clips.at(i);
|
||||
ca->append(new AddMarkerAction(&c->get_markers(),
|
||||
seq->playhead - c->timeline_in() + c->clip_in(),
|
||||
marker_name));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
// if no clips are selected, we're adding a marker to the sequence
|
||||
|
||||
// kind of hacky, we get the correct marker structure from the viewer panel object that the sequence is attached to
|
||||
if (seq == panel_footage_viewer->seq.get()) {
|
||||
|
||||
// get correct marker reference from footage viewer
|
||||
ca->append(new AddMarkerAction(panel_footage_viewer->marker_ref, seq->playhead, marker_name));
|
||||
|
||||
} else if (seq == panel_sequence_viewer->seq.get()) {
|
||||
|
||||
// get correct marker reference from sequence viewer
|
||||
ca->append(new AddMarkerAction(panel_sequence_viewer->marker_ref, seq->playhead, marker_name));
|
||||
|
||||
} else {
|
||||
|
||||
// fallback to using markers from sequence provided
|
||||
ca->append(new AddMarkerAction(&seq->markers, seq->playhead, marker_name));
|
||||
|
||||
}
|
||||
|
||||
// add a marker action for each clip
|
||||
foreach (Clip* c, clips) {
|
||||
ca->append(new AddMarkerAction(&c->get_markers(),
|
||||
c->track()->sequence()->playhead - c->timeline_in() + c->clip_in(),
|
||||
marker_name));
|
||||
}
|
||||
|
||||
|
||||
// push action
|
||||
olive::UndoStack.push(ca);
|
||||
olive::undo_stack.push(ca);
|
||||
|
||||
// redraw UI for new markers
|
||||
update_ui(false);
|
||||
@@ -120,11 +95,65 @@ void set_marker_internal(Sequence* seq, const QVector<int>& clips) {
|
||||
}
|
||||
}
|
||||
|
||||
void set_marker_internal(Sequence *seq) {
|
||||
// create empty clip array
|
||||
QVector<int> clips;
|
||||
void Marker::SetOnSequence(Sequence *seq) {
|
||||
|
||||
// Don't bother if there is no sequence
|
||||
if (seq == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// add_marker is used to determine whether we're adding a marker, depending on whether the user input a marker name
|
||||
// however if (config.set_name_with_marker) is true, we don't need a marker name so we just add
|
||||
bool add_marker = !olive::config.set_name_with_marker;
|
||||
|
||||
QString marker_name;
|
||||
|
||||
// if Config::set_name_with_marker is true (set above), ask for a marker name
|
||||
if (!add_marker) {
|
||||
QInputDialog d(olive::MainWindow);
|
||||
d.setWindowTitle(QCoreApplication::translate("Marker", "Set Marker"));
|
||||
d.setLabelText(QCoreApplication::translate("Marker", "Set sequence marker name:"));
|
||||
d.setInputMode(QInputDialog::TextInput);
|
||||
add_marker = (d.exec() == QDialog::Accepted);
|
||||
marker_name = d.textValue();
|
||||
}
|
||||
|
||||
// if we've decided to add a marker
|
||||
if (add_marker) {
|
||||
|
||||
ComboAction* ca = new ComboAction();
|
||||
|
||||
// FIXME kind of hacky, we get the correct marker structure from the viewer panel object that the sequence is
|
||||
// attached to, as the viewers will give us the footage marker set if its footage rather than the sequence marker
|
||||
// set
|
||||
|
||||
if (seq == panel_footage_viewer->seq.get()) {
|
||||
|
||||
// get correct marker reference from footage viewer
|
||||
ca->append(new AddMarkerAction(panel_footage_viewer->marker_ref, seq->playhead, marker_name));
|
||||
|
||||
} else if (seq == panel_sequence_viewer->seq.get()) {
|
||||
|
||||
// get correct marker reference from sequence viewer
|
||||
ca->append(new AddMarkerAction(panel_sequence_viewer->marker_ref, seq->playhead, marker_name));
|
||||
|
||||
} else {
|
||||
|
||||
// fallback to using markers from sequence provided
|
||||
ca->append(new AddMarkerAction(&seq->markers, seq->playhead, marker_name));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// push action
|
||||
olive::undo_stack.push(ca);
|
||||
|
||||
// redraw UI for new markers
|
||||
update_ui(false);
|
||||
panel_footage_viewer->update_viewer();
|
||||
|
||||
}
|
||||
|
||||
set_marker_internal(seq, clips);
|
||||
}
|
||||
|
||||
void Marker::Save(QXmlStreamWriter &stream) const
|
||||
|
||||
+5
-4
@@ -28,8 +28,8 @@
|
||||
#include <QXmlStreamWriter>
|
||||
#include <memory>
|
||||
|
||||
class Clip;
|
||||
class Sequence;
|
||||
using SequencePtr = std::shared_ptr<Sequence>;
|
||||
|
||||
struct Marker {
|
||||
long frame;
|
||||
@@ -37,9 +37,10 @@ struct Marker {
|
||||
|
||||
void Save(QXmlStreamWriter& stream) const;
|
||||
static void Draw(QPainter& p, int x, int y, int bottom, bool selected);
|
||||
|
||||
|
||||
static void SetOnClips(const QVector<Clip*>& clips);
|
||||
static void SetOnSequence(Sequence* seq);
|
||||
};
|
||||
|
||||
void set_marker_internal(Sequence *seq, const QVector<int>& clips);
|
||||
void set_marker_internal(Sequence* seq);
|
||||
|
||||
#endif // MARKER_H
|
||||
|
||||
+26
-7
@@ -1,12 +1,16 @@
|
||||
#include "selection.h"
|
||||
|
||||
#include "effects/transition.h"
|
||||
#include "timeline/clip.h"
|
||||
|
||||
Selection::Selection()
|
||||
{
|
||||
}
|
||||
|
||||
Selection::Selection(long in, long out, Track *track) :
|
||||
in_(in),
|
||||
out_(out),
|
||||
track_(track),
|
||||
old_in_(in),
|
||||
old_out_(out),
|
||||
old_track_(track)
|
||||
track_(track)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -35,7 +39,22 @@ void Selection::set_out(long out)
|
||||
out_ = out;
|
||||
}
|
||||
|
||||
void Selection::Tidy(QVector<Selection &> selections)
|
||||
bool Selection::ContainsTransition(Clip* c, int type) const
|
||||
{
|
||||
if (type == kTransitionOpening) {
|
||||
return c->opening_transition != nullptr
|
||||
&& out_ == c->timeline_in() + c->opening_transition->get_true_length()
|
||||
&& ((c->opening_transition->secondary_clip == nullptr && in_ == c->timeline_in())
|
||||
|| (c->opening_transition->secondary_clip != nullptr && in_ == c->timeline_in() - c->opening_transition->get_true_length()));
|
||||
} else {
|
||||
return c->closing_transition != nullptr
|
||||
&& in_ == c->timeline_out() - c->closing_transition->get_true_length()
|
||||
&& ((c->closing_transition->secondary_clip == nullptr && out_ == c->timeline_out())
|
||||
|| (c->closing_transition->secondary_clip != nullptr && out_ == c->timeline_out() + c->closing_transition->get_true_length()));
|
||||
}
|
||||
}
|
||||
|
||||
void Selection::Tidy(QVector<Selection>& selections)
|
||||
{
|
||||
for (int i=0;i<selections.size();i++) {
|
||||
Selection& s = selections[i];
|
||||
@@ -49,10 +68,10 @@ void Selection::Tidy(QVector<Selection &> selections)
|
||||
} else if (s.in() >= ss.in() && s.out() <= ss.out()) {
|
||||
remove = true;
|
||||
} else if (s.in() <= ss.out() && s.out() > ss.out()) {
|
||||
ss.out = s.out();
|
||||
ss.set_out(s.out());
|
||||
remove = true;
|
||||
} else if (s.out() >= ss.in() && s.in() < ss.in()) {
|
||||
ss.in = s.in();
|
||||
ss.set_in(s.in());
|
||||
remove = true;
|
||||
}
|
||||
if (remove) {
|
||||
|
||||
@@ -23,10 +23,12 @@
|
||||
|
||||
#include <QVector>
|
||||
|
||||
class Clip;
|
||||
class Track;
|
||||
|
||||
class Selection {
|
||||
public:
|
||||
Selection();
|
||||
Selection(long in, long out, Track* track);
|
||||
|
||||
long in() const;
|
||||
@@ -36,7 +38,9 @@ public:
|
||||
void set_in(long in);
|
||||
void set_out(long out);
|
||||
|
||||
static void Tidy(QVector<Selection&> selections);
|
||||
bool ContainsTransition(Clip* c, int type) const;
|
||||
|
||||
static void Tidy(QVector<Selection> &selections);
|
||||
|
||||
private:
|
||||
long in_;
|
||||
|
||||
+568
-27
@@ -22,8 +22,10 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include "timelinefunctions.h"
|
||||
#include "panels/panels.h"
|
||||
#include "project/clipboard.h"
|
||||
#include "global/clipboard.h"
|
||||
#include "global/config.h"
|
||||
#include "global/debug.h"
|
||||
|
||||
Sequence::Sequence() :
|
||||
@@ -77,7 +79,7 @@ void Sequence::Save(QXmlStreamWriter &stream)
|
||||
stream.writeAttribute("framerate", QString::number(frame_rate, 'f', 10));
|
||||
stream.writeAttribute("afreq", QString::number(audio_frequency));
|
||||
stream.writeAttribute("alayout", QString::number(audio_layout));
|
||||
if (this == olive::ActiveSequence.get()) {
|
||||
if (this == Timeline::GetTopSequence().get()) {
|
||||
stream.writeAttribute("open", "1");
|
||||
}
|
||||
stream.writeAttribute("workarea", QString::number(using_workarea));
|
||||
@@ -170,13 +172,303 @@ QVector<Clip *> Sequence::SelectedClips(bool containing)
|
||||
for (int j=0;j<tl->TrackCount();j++) {
|
||||
Track* t = tl->TrackAt(j);
|
||||
|
||||
selected_clips.append(t->GetAllClips());
|
||||
selected_clips.append(t->GetSelectedClips(containing));
|
||||
}
|
||||
}
|
||||
|
||||
return selected_clips;
|
||||
}
|
||||
|
||||
void Sequence::AddClipsFromGhosts(ComboAction* ca, const QVector<Ghost>& ghosts)
|
||||
{
|
||||
// add clips
|
||||
long earliest_point = LONG_MAX;
|
||||
QVector<ClipPtr> added_clips;
|
||||
for (int i=0;i<ghosts.size();i++) {
|
||||
const Ghost& g = ghosts.at(i);
|
||||
|
||||
earliest_point = qMin(earliest_point, g.in);
|
||||
|
||||
ClipPtr c = std::make_shared<Clip>(g.track);
|
||||
c->set_media(g.media, g.media_stream);
|
||||
c->set_timeline_in(g.in);
|
||||
c->set_timeline_out(g.out);
|
||||
c->set_clip_in(g.clip_in);
|
||||
c->set_track(g.track);
|
||||
if (c->media()->get_type() == MEDIA_TYPE_FOOTAGE) {
|
||||
Footage* m = c->media()->to_footage();
|
||||
if (m->video_tracks.size() == 0) {
|
||||
// audio only (greenish)
|
||||
c->set_color(128, 192, 128);
|
||||
} else if (m->audio_tracks.size() == 0) {
|
||||
// video only (orangeish)
|
||||
c->set_color(192, 160, 128);
|
||||
} else {
|
||||
// video and audio (blueish)
|
||||
c->set_color(128, 128, 192);
|
||||
}
|
||||
c->set_name(m->name);
|
||||
} else if (c->media()->get_type() == MEDIA_TYPE_SEQUENCE) {
|
||||
// sequence (red?ish?)
|
||||
c->set_color(192, 128, 128);
|
||||
|
||||
c->set_name(c->media()->to_sequence()->name);
|
||||
}
|
||||
c->refresh();
|
||||
added_clips.append(c);
|
||||
|
||||
}
|
||||
ca->append(new AddClipCommand(added_clips));
|
||||
|
||||
// link clips from the same media
|
||||
for (int i=0;i<added_clips.size();i++) {
|
||||
ClipPtr c = added_clips.at(i);
|
||||
for (int j=0;j<added_clips.size();j++) {
|
||||
ClipPtr cc = added_clips.at(j);
|
||||
if (c != cc && c->media() == cc->media()) {
|
||||
c->linked.append(cc.get());
|
||||
}
|
||||
}
|
||||
|
||||
if (olive::config.add_default_effects_to_clips) {
|
||||
if (c->type() == Track::kTypeVideo) {
|
||||
// add default video effects
|
||||
c->effects.append(Effect::Create(c.get(), Effect::GetInternalMeta(EFFECT_INTERNAL_TRANSFORM, EFFECT_TYPE_EFFECT)));
|
||||
} else if (c->type() == Track::kTypeAudio) {
|
||||
// add default audio effects
|
||||
c->effects.append(Effect::Create(c.get(), Effect::GetInternalMeta(EFFECT_INTERNAL_VOLUME, EFFECT_TYPE_EFFECT)));
|
||||
c->effects.append(Effect::Create(c.get(), Effect::GetInternalMeta(EFFECT_INTERNAL_PAN, EFFECT_TYPE_EFFECT)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (olive::config.enable_seek_to_import) {
|
||||
panel_sequence_viewer->seek(earliest_point);
|
||||
}
|
||||
|
||||
olive::timeline::snapped = false;
|
||||
}
|
||||
|
||||
void Sequence::MoveClip(Clip *c, ComboAction *ca, long iin, long iout, long iclip_in, Track *itrack, bool verify_transitions, bool relative)
|
||||
{
|
||||
ClipPtr clip_ptr = c->track()->GetClipObjectFromRawPtr(c);
|
||||
|
||||
ca->append(new MoveClipAction(clip_ptr, iin, iout, iclip_in, itrack, relative));
|
||||
|
||||
if (verify_transitions) {
|
||||
|
||||
// if this is a shared transition, and the corresponding clip will be moved away somehow
|
||||
if (c->opening_transition != nullptr
|
||||
&& c->opening_transition->secondary_clip != nullptr
|
||||
&& c->opening_transition->secondary_clip->timeline_out() != iin) {
|
||||
// separate transition
|
||||
ca->append(new SetPointer(reinterpret_cast<void**>(&c->opening_transition->secondary_clip), nullptr));
|
||||
ca->append(new AddTransitionCommand(nullptr,
|
||||
c->opening_transition->secondary_clip,
|
||||
c->opening_transition,
|
||||
nullptr,
|
||||
0));
|
||||
}
|
||||
|
||||
if (c->closing_transition != nullptr
|
||||
&& c->closing_transition->secondary_clip != nullptr
|
||||
&& c->closing_transition->parent_clip->timeline_in() != iout) {
|
||||
// separate transition
|
||||
ca->append(new SetPointer(reinterpret_cast<void**>(&c->closing_transition->secondary_clip), nullptr));
|
||||
ca->append(new AddTransitionCommand(nullptr,
|
||||
c,
|
||||
c->closing_transition,
|
||||
nullptr,
|
||||
0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Sequence::EditToPoint(bool in, bool ripple)
|
||||
{
|
||||
QVector<Clip*> all_clips = GetAllClips();
|
||||
|
||||
if (all_clips.size() > 0) {
|
||||
long sequence_end = 0;
|
||||
|
||||
bool playhead_falls_on_in = false;
|
||||
bool playhead_falls_on_out = false;
|
||||
long next_cut = LONG_MAX;
|
||||
long prev_cut = 0;
|
||||
|
||||
// find closest in point to playhead
|
||||
for (int i=0;i<all_clips.size();i++) {
|
||||
Clip* c = all_clips.at(i);
|
||||
|
||||
sequence_end = qMax(c->timeline_out(), sequence_end);
|
||||
|
||||
if (c->timeline_in() == playhead)
|
||||
playhead_falls_on_in = true;
|
||||
|
||||
if (c->timeline_out() == playhead)
|
||||
playhead_falls_on_out = true;
|
||||
|
||||
if (c->timeline_in() > playhead)
|
||||
next_cut = qMin(c->timeline_in(), next_cut);
|
||||
|
||||
if (c->timeline_out() > playhead)
|
||||
next_cut = qMin(c->timeline_out(), next_cut);
|
||||
|
||||
if (c->timeline_in() < playhead)
|
||||
prev_cut = qMax(c->timeline_in(), prev_cut);
|
||||
|
||||
if (c->timeline_out() < playhead)
|
||||
prev_cut = qMax(c->timeline_out(), prev_cut);
|
||||
|
||||
}
|
||||
|
||||
next_cut = qMin(sequence_end, next_cut);
|
||||
|
||||
QVector<Selection> areas;
|
||||
ComboAction* ca = new ComboAction();
|
||||
bool push_undo = true;
|
||||
long seek = playhead;
|
||||
|
||||
if ((in && (playhead_falls_on_out || (playhead_falls_on_in && playhead == 0)))
|
||||
|| (!in && (playhead_falls_on_in || (playhead_falls_on_out && playhead == sequence_end)))) { // one frame mode
|
||||
if (ripple) {
|
||||
// set up deletion areas based on track count
|
||||
long in_point = playhead;
|
||||
if (!in) {
|
||||
in_point--;
|
||||
seek--;
|
||||
}
|
||||
|
||||
if (in_point >= 0) {
|
||||
|
||||
for (int i=0;i<track_lists_.size();i++) {
|
||||
|
||||
TrackList* tl = track_lists_.at(i);
|
||||
|
||||
for (int j=0;j<tl->TrackCount();j++) {
|
||||
areas.append(Selection(in_point, in_point+1, tl->TrackAt(j)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// trim and move clips around the in point
|
||||
DeleteAreas(ca, areas, true);
|
||||
|
||||
if (ripple) {
|
||||
Ripple(ca, in_point, -1);
|
||||
}
|
||||
} else {
|
||||
push_undo = false;
|
||||
}
|
||||
} else {
|
||||
push_undo = false;
|
||||
}
|
||||
} else {
|
||||
// set up deletion areas based on track count
|
||||
|
||||
long area_in, area_out;
|
||||
|
||||
if (in) {
|
||||
seek = prev_cut;
|
||||
area_in = prev_cut;
|
||||
area_out = playhead;
|
||||
} else {
|
||||
area_in = playhead;
|
||||
area_out = next_cut;
|
||||
}
|
||||
|
||||
if (area_in == area_out) {
|
||||
|
||||
push_undo = false;
|
||||
|
||||
} else {
|
||||
|
||||
for (int i=0;i<track_lists_.size();i++) {
|
||||
|
||||
TrackList* tl = track_lists_.at(i);
|
||||
|
||||
for (int j=0;j<tl->TrackCount();j++) {
|
||||
areas.append(Selection(area_in, area_out, tl->TrackAt(j)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// trim and move clips around the in point
|
||||
DeleteAreas(ca, areas, true);
|
||||
if (ripple) {
|
||||
Ripple(ca, area_in, area_in - area_out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (push_undo) {
|
||||
olive::undo_stack.push(ca);
|
||||
|
||||
update_ui(true);
|
||||
|
||||
if (seek != playhead && ripple) {
|
||||
panel_sequence_viewer->seek(seek);
|
||||
}
|
||||
} else {
|
||||
delete ca;
|
||||
}
|
||||
} else {
|
||||
panel_sequence_viewer->seek(0);
|
||||
}
|
||||
}
|
||||
|
||||
bool Sequence::SnapPoint(long *l, double zoom, bool use_playhead, bool use_markers, bool use_workarea)
|
||||
{
|
||||
olive::timeline::snapped = false;
|
||||
if (olive::timeline::snapping) {
|
||||
if (use_playhead && !panel_sequence_viewer->playing) {
|
||||
// snap to playhead
|
||||
if (olive::timeline::SnapToPoint(playhead, l, zoom)) return true;
|
||||
}
|
||||
|
||||
// snap to marker
|
||||
if (use_markers) {
|
||||
for (int i=0;i<markers.size();i++) {
|
||||
if (olive::timeline::SnapToPoint(markers.at(i).frame, l, zoom)) return true;
|
||||
}
|
||||
}
|
||||
|
||||
// snap to in/out
|
||||
if (use_workarea && using_workarea) {
|
||||
if (olive::timeline::SnapToPoint(workarea_in, l, zoom)) return true;
|
||||
if (olive::timeline::SnapToPoint(workarea_out, l, zoom)) return true;
|
||||
}
|
||||
|
||||
// snap to clip/transition
|
||||
QVector<Clip*> all_clips = GetAllClips();
|
||||
for (int i=0;i<all_clips.size();i++) {
|
||||
|
||||
Clip* c = all_clips.at(i);
|
||||
if (olive::timeline::SnapToPoint(c->timeline_in(), l, zoom)) {
|
||||
return true;
|
||||
} else if (olive::timeline::SnapToPoint(c->timeline_out(), l, zoom)) {
|
||||
return true;
|
||||
} else if (c->opening_transition != nullptr
|
||||
&& olive::timeline::SnapToPoint(c->timeline_in() + c->opening_transition->get_true_length(), l, zoom)) {
|
||||
return true;
|
||||
} else if (c->closing_transition != nullptr
|
||||
&& olive::timeline::SnapToPoint(c->timeline_out() - c->closing_transition->get_true_length(), l, zoom)) {
|
||||
return true;
|
||||
} else {
|
||||
// try to snap to clip markers
|
||||
for (int j=0;j<c->get_markers().size();j++) {
|
||||
if (olive::timeline::SnapToPoint(c->get_markers().at(j).frame + c->timeline_in() - c->clip_in(), l, zoom)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Sequence::DeleteInToOut(bool ripple)
|
||||
{
|
||||
if (using_workarea) {
|
||||
@@ -198,13 +490,45 @@ void Sequence::DeleteInToOut(bool ripple)
|
||||
if (ripple) Ripple(ca,
|
||||
workarea_in,
|
||||
workarea_in - workarea_out);
|
||||
ca->append(new SetTimelineInOutCommand(olive::ActiveSequence.get(), false, 0, 0));
|
||||
olive::UndoStack.push(ca);
|
||||
ca->append(new SetTimelineInOutCommand(this, false, 0, 0));
|
||||
olive::undo_stack.push(ca);
|
||||
update_ui(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Sequence::Ripple(ComboAction *ca, long point, long length, const QVector<int> &ignore)
|
||||
void Sequence::DeleteClipsUsingMedia(const QVector<Media *>& media)
|
||||
{
|
||||
QVector<Clip*> all_clips = GetAllClips();
|
||||
|
||||
ComboAction* ca = new ComboAction();
|
||||
bool deleted = false;
|
||||
|
||||
for (int j=0;j<media.size();j++) {
|
||||
Media* m = media.at(j);
|
||||
|
||||
if (olive::clipboard.DeleteClipsWithMedia(ca, m)) {
|
||||
deleted = true;
|
||||
}
|
||||
|
||||
for (int i=0;i<all_clips.size();i++) {
|
||||
Clip* c = all_clips.at(i);
|
||||
|
||||
if (c->media() == media.at(j)) {
|
||||
ca->append(new DeleteClipAction(c));
|
||||
deleted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (deleted) {
|
||||
olive::undo_stack.push(ca);
|
||||
update_ui(true);
|
||||
} else {
|
||||
delete ca;
|
||||
}
|
||||
}
|
||||
|
||||
void Sequence::Ripple(ComboAction *ca, long point, long length, const QVector<Clip*> &ignore)
|
||||
{
|
||||
ca->append(new RippleAction(this, point, length, ignore));
|
||||
}
|
||||
@@ -222,14 +546,95 @@ void Sequence::ChangeTrackHeightsRelatively(int diff)
|
||||
}
|
||||
}
|
||||
|
||||
void Sequence::DeleteAreas(ComboAction* ca, QVector<Selection> areas, bool deselect_areas)
|
||||
void Sequence::ToggleLinksOnSelected()
|
||||
{
|
||||
QVector<Clip*> selected_clips = SelectedClips();
|
||||
|
||||
bool link = true;
|
||||
QVector<Clip*> link_clips;
|
||||
|
||||
for (int i=0;i<selected_clips.size();i++) {
|
||||
Clip* c = selected_clips.at(i);
|
||||
|
||||
if (!link_clips.contains(c)) {
|
||||
link_clips.append(c);
|
||||
}
|
||||
|
||||
if (c->linked.size() > 0) {
|
||||
link = false; // prioritize unlinking
|
||||
|
||||
for (int j=0;j<c->linked.size();j++) { // add links to the command
|
||||
if (!link_clips.contains(c->linked.at(j))) {
|
||||
link_clips.append(c->linked.at(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!link_clips.isEmpty()) {
|
||||
olive::undo_stack.push(new LinkCommand(link_clips, link));
|
||||
}
|
||||
}
|
||||
|
||||
void Sequence::Split()
|
||||
{
|
||||
ComboAction* ca = new ComboAction();
|
||||
bool split_selected = false;
|
||||
|
||||
QVector<Clip*> selected_clips = SelectedClips(true);
|
||||
if (selected_clips.size() > 0) {
|
||||
// see if whole clips are selected
|
||||
QVector<Clip*> pre_clips;
|
||||
QVector<ClipPtr> post_clips;
|
||||
|
||||
for (int i=0;i<selected_clips.size();i++) {
|
||||
Clip* c = selected_clips.at(i);
|
||||
|
||||
ClipPtr s = SplitClip(ca, true, c, playhead);
|
||||
|
||||
if (s != nullptr) {
|
||||
pre_clips.append(c);
|
||||
post_clips.append(s);
|
||||
split_selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (split_selected) {
|
||||
|
||||
// relink clips if we split
|
||||
olive::timeline::RelinkClips(pre_clips, post_clips);
|
||||
ca->append(new AddClipCommand(post_clips));
|
||||
|
||||
} else {
|
||||
|
||||
// split a selection if not
|
||||
// FIXME reimplement split selection
|
||||
//split_selected = split_selection(ca);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// if nothing was selected or no selections fell within playhead, simply split at playhead
|
||||
if (!split_selected) {
|
||||
split_selected = SplitAllClipsAtPoint(ca, playhead);
|
||||
}
|
||||
|
||||
if (split_selected) {
|
||||
olive::undo_stack.push(ca);
|
||||
update_ui(true);
|
||||
} else {
|
||||
delete ca;
|
||||
}
|
||||
}
|
||||
|
||||
void Sequence::DeleteAreas(ComboAction* ca, QVector<Selection> areas, bool deselect_areas, bool ripple)
|
||||
{
|
||||
Selection::Tidy(areas);
|
||||
|
||||
panel_graph_editor->set_row(nullptr);
|
||||
panel_effect_controls->Clear(true);
|
||||
|
||||
QVector<int> pre_clips;
|
||||
QVector<Clip*> pre_clips;
|
||||
QVector<ClipPtr> post_clips;
|
||||
|
||||
QVector<Clip*> all_clips = GetAllClips();
|
||||
@@ -239,10 +644,10 @@ void Sequence::DeleteAreas(ComboAction* ca, QVector<Selection> areas, bool desel
|
||||
for (int j=0;j<all_clips.size();j++) {
|
||||
Clip* c = all_clips.at(j);
|
||||
if (c->track() == s.track() && !c->undeletable) {
|
||||
if (selection_contains_transition(s, c, kTransitionOpening)) {
|
||||
if (s.ContainsTransition(c, kTransitionOpening)) {
|
||||
// delete opening transition
|
||||
ca->append(new DeleteTransitionCommand(c->opening_transition));
|
||||
} else if (selection_contains_transition(s, c, kTransitionClosing)) {
|
||||
} else if (s.ContainsTransition(c, kTransitionClosing)) {
|
||||
// delete closing transition
|
||||
ca->append(new DeleteTransitionCommand(c->closing_transition));
|
||||
} else if (c->timeline_in() >= s.in() && c->timeline_out() <= s.out()) {
|
||||
@@ -254,28 +659,30 @@ void Sequence::DeleteAreas(ComboAction* ca, QVector<Selection> areas, bool desel
|
||||
// duplicate clip
|
||||
ClipPtr post = SplitClip(ca, true, c, s.in(), s.out());
|
||||
|
||||
pre_clips.append(j);
|
||||
pre_clips.append(c);
|
||||
post_clips.append(post);
|
||||
} else if (c->timeline_in() < s.in() && c->timeline_out() > s.in()) {
|
||||
// only out point is in deletion area
|
||||
c->move(ca, c->timeline_in(), s.in(), c->clip_in(), c->track());
|
||||
MoveClip(c, ca, c->timeline_in(), s.in(), c->clip_in(), c->track());
|
||||
|
||||
if (c->closing_transition != nullptr) {
|
||||
if (s.in() < c->timeline_out() - c->closing_transition->get_true_length()) {
|
||||
ca->append(new DeleteTransitionCommand(c->closing_transition));
|
||||
} else {
|
||||
ca->append(new ModifyTransitionCommand(c->closing_transition, c->closing_transition->get_true_length() - (c->timeline_out() - s.in)));
|
||||
ca->append(new ModifyTransitionCommand(c->closing_transition,
|
||||
c->closing_transition->get_true_length() - (c->timeline_out() - s.in())));
|
||||
}
|
||||
}
|
||||
} else if (c->timeline_in() < s.out() && c->timeline_out() > s.out()) {
|
||||
// only in point is in deletion area
|
||||
c->move(ca, s.out(), c->timeline_out(), c->clip_in() + (s.out() - c->timeline_in()), c->track());
|
||||
MoveClip(c, ca, s.out(), c->timeline_out(), c->clip_in() + (s.out() - c->timeline_in()), c->track());
|
||||
|
||||
if (c->opening_transition != nullptr) {
|
||||
if (s.out() > c->timeline_in() + c->opening_transition->get_true_length()) {
|
||||
ca->append(new DeleteTransitionCommand(c->opening_transition));
|
||||
} else {
|
||||
ca->append(new ModifyTransitionCommand(c->opening_transition, c->opening_transition->get_true_length() - (s.out - c->timeline_in())));
|
||||
ca->append(new ModifyTransitionCommand(c->opening_transition,
|
||||
c->opening_transition->get_true_length() - (s.out() - c->timeline_in())));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,12 +695,16 @@ void Sequence::DeleteAreas(ComboAction* ca, QVector<Selection> areas, bool desel
|
||||
QVector<Selection> area_copy = areas;
|
||||
for (int i=0;i<area_copy.size();i++) {
|
||||
const Selection& s = area_copy.at(i);
|
||||
deselect_area(s.in, s.out, s.track);
|
||||
s.track()->DeselectArea(s.in(), s.out());
|
||||
}
|
||||
}
|
||||
|
||||
relink_clips_using_ids(pre_clips, post_clips);
|
||||
ca->append(new AddClipCommand(olive::ActiveSequence.get(), post_clips));
|
||||
if (ripple) {
|
||||
|
||||
}
|
||||
|
||||
olive::timeline::RelinkClips(pre_clips, post_clips);
|
||||
ca->append(new AddClipCommand(post_clips));
|
||||
}
|
||||
|
||||
bool Sequence::SplitAllClipsAtPoint(ComboAction *ca, long point)
|
||||
@@ -314,10 +725,12 @@ bool Sequence::SplitAllClipsAtPoint(ComboAction *ca, long point)
|
||||
return split;
|
||||
}
|
||||
|
||||
void Sequence::SplitClipAtPositions(ComboAction *ca, Clip* clip, QVector<long> positions, bool relink)
|
||||
bool Sequence::SplitClipAtPositions(ComboAction *ca, Clip* clip, QVector<long> positions, bool relink)
|
||||
{
|
||||
// Add the clip and each of its links to the pre_splits array
|
||||
|
||||
bool split_occurred = false;
|
||||
|
||||
QVector<Clip*> pre_splits;
|
||||
pre_splits.append(clip);
|
||||
|
||||
@@ -346,15 +759,102 @@ void Sequence::SplitClipAtPositions(ComboAction *ca, Clip* clip, QVector<long> p
|
||||
for (int j=0;j<pre_splits.size();j++) {
|
||||
post_splits[i][j] = SplitClip(ca, true, pre_splits.at(j), positions.at(i));
|
||||
|
||||
if (post_splits[i][j] != nullptr && i + 1 < positions.size()) {
|
||||
post_splits[i][j]->set_timeline_out(positions.at(i+1));
|
||||
if (post_splits[i][j] != nullptr) {
|
||||
split_occurred = true;
|
||||
|
||||
if (i + 1 < positions.size()) {
|
||||
post_splits[i][j]->set_timeline_out(positions.at(i+1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0;i<post_splits.size();i++) {
|
||||
olive::timeline::RelinkClips(pre_splits, post_splits[i]);
|
||||
ca->append(new AddClipCommand(olive::ActiveSequence.get(), post_splits[i]));
|
||||
ca->append(new AddClipCommand(post_splits[i]));
|
||||
}
|
||||
|
||||
return split_occurred;
|
||||
}
|
||||
|
||||
void Sequence::RippleDeleteEmptySpace(Track* track, long point)
|
||||
{
|
||||
QVector<Clip*> track_clips = track->GetAllClips();
|
||||
|
||||
long ripple_start = LONG_MAX;
|
||||
long ripple_end = LONG_MAX;
|
||||
|
||||
for (int i=0;i<track_clips.size();i++) {
|
||||
Clip* c = track_clips.at(i);
|
||||
|
||||
if (c->timeline_in() <= point && c->timeline_out() >= point) {
|
||||
// This point is not actually empty, so there's nothing to do here
|
||||
return;
|
||||
}
|
||||
|
||||
if (c->timeline_out() < point) {
|
||||
|
||||
ripple_start = qMin(c->timeline_out(), ripple_start);
|
||||
|
||||
} else if (c->timeline_in() > point) {
|
||||
|
||||
ripple_end = qMin(c->timeline_in(), ripple_end);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// We now know the maximum ripple we could do to clear this empty space, but we need to ensure it won't cause
|
||||
// overlaps of clips in other tracks
|
||||
|
||||
for (int i=0;i<track_lists_.size();i++) {
|
||||
TrackList* tl = track_lists_.at(i);
|
||||
|
||||
for (int j=0;j<tl->TrackCount();j++) {
|
||||
Track* t = tl->TrackAt(j);
|
||||
|
||||
// We've already tested `track`, so we don't need to test it again
|
||||
if (t != track) {
|
||||
|
||||
long first_in_point_after_point = LONG_MAX;
|
||||
long out_point_just_before_first_in_point = LONG_MIN;
|
||||
|
||||
QVector<Clip*> track_clips = t->GetAllClips();
|
||||
|
||||
// Find the in point of the clip directly after the point
|
||||
for (int k=0;k<track_clips.size();k++) {
|
||||
Clip* c = track_clips.at(k);
|
||||
|
||||
if (c->timeline_in() > point) {
|
||||
first_in_point_after_point = qMin(first_in_point_after_point, c->timeline_in());
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure we found a valid in point before proceeding
|
||||
if (first_in_point_after_point != LONG_MAX) {
|
||||
|
||||
// Find the out point of the clip directly before the clip found above
|
||||
for (int k=0;k<track_clips.size();k++) {
|
||||
Clip* c = track_clips.at(k);
|
||||
|
||||
if (c->timeline_out() < first_in_point_after_point) {
|
||||
out_point_just_before_first_in_point = qMax(out_point_just_before_first_in_point, c->timeline_out());
|
||||
}
|
||||
}
|
||||
|
||||
long gap_between_clips = first_in_point_after_point - out_point_just_before_first_in_point;
|
||||
|
||||
if (gap_between_clips > (ripple_end - ripple_start)) {
|
||||
ripple_end = ripple_start + gap_between_clips;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ripple_start != ripple_end) {
|
||||
ComboAction* ca = new ComboAction();
|
||||
Ripple(ca, ripple_start, ripple_start - ripple_end);
|
||||
olive::undo_stack.push(ca);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,7 +883,7 @@ Effect *Sequence::GetSelectedGizmo()
|
||||
for (int i=0;i<clips.size();i++) {
|
||||
Clip* c = clips.at(i);
|
||||
if (c->IsActiveAt(playhead)
|
||||
&& IsClipSelected(c, true)) {
|
||||
&& c->IsSelected()) {
|
||||
// This clip is selected and currently active - we'll use this for gizmos
|
||||
|
||||
if (!c->effects.isEmpty()) {
|
||||
@@ -516,7 +1016,7 @@ void Sequence::AddSelectionsToClipboard(bool delete_originals)
|
||||
if (delete_originals) {
|
||||
ComboAction* ca = new ComboAction();
|
||||
DeleteAreas(ca, selections, true);
|
||||
olive::UndoStack.push(ca);
|
||||
olive::undo_stack.push(ca);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -537,6 +1037,24 @@ QVector<Selection> Sequence::Selections()
|
||||
return selections;
|
||||
}
|
||||
|
||||
void Sequence::SetSelections(const QVector<Selection> &selections)
|
||||
{
|
||||
ClearSelections();
|
||||
|
||||
for (int i=0;i<selections.size();i++) {
|
||||
const Selection& s = selections.at(i);
|
||||
|
||||
s.track()->SelectArea(s.in(), s.out());
|
||||
}
|
||||
}
|
||||
|
||||
void Sequence::TidySelections()
|
||||
{
|
||||
QVector<Selection> selections = Selections();
|
||||
Selection::Tidy(selections);
|
||||
SetSelections(selections);
|
||||
}
|
||||
|
||||
ClipPtr Sequence::SplitClip(ComboAction *ca, bool transitions, Clip* pre, long frame)
|
||||
{
|
||||
return SplitClip(ca, transitions, pre, frame, frame);
|
||||
@@ -558,7 +1076,7 @@ ClipPtr Sequence::SplitClip(ComboAction *ca, bool transitions, Clip* pre, long f
|
||||
post->set_timeline_in(post_in);
|
||||
post->set_clip_in(pre->clip_in() + (post->timeline_in() - pre->timeline_in()));
|
||||
|
||||
pre->move(ca, pre->timeline_in(), frame, pre->clip_in(), pre->track(), false);
|
||||
MoveClip(pre, ca, pre->timeline_in(), frame, pre->clip_in(), pre->track(), false);
|
||||
|
||||
if (transitions) {
|
||||
|
||||
@@ -616,5 +1134,28 @@ ClipPtr Sequence::SplitClip(ComboAction *ca, bool transitions, Clip* pre, long f
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// static variable for the currently active sequence
|
||||
SequencePtr olive::ActiveSequence = nullptr;
|
||||
bool Sequence::SplitSelection(ComboAction *ca, QVector<Selection> selections)
|
||||
{
|
||||
QVector<Clip*> all_clips = GetAllClips();
|
||||
|
||||
for (int i=0;i<all_clips.size();i++) {
|
||||
Clip* c = all_clips.at(i);
|
||||
|
||||
QVector<long> points;
|
||||
|
||||
for (int j=0;j<selections.size();j++) {
|
||||
const Selection& s = selections.at(j);
|
||||
|
||||
if (s.track() == c->track()) {
|
||||
if (c->timeline_in() < s.in() && c->timeline_out() > s.in()) {
|
||||
points.append(s.in());
|
||||
}
|
||||
if (c->timeline_in() < s.out() && c->timeline_out() > s.out()) {
|
||||
points.append(s.out());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+28
-9
@@ -28,6 +28,7 @@
|
||||
#include "marker.h"
|
||||
#include "selection.h"
|
||||
#include "tracklist.h"
|
||||
#include "ghost.h"
|
||||
|
||||
class Sequence : public QObject {
|
||||
Q_OBJECT
|
||||
@@ -63,17 +64,37 @@ public:
|
||||
|
||||
void RefreshClipsUsingMedia(Media* m = nullptr);
|
||||
QVector<Clip*> SelectedClips(bool containing = true);
|
||||
//QVector<int> SelectedClipIndexes();
|
||||
|
||||
void DeleteAreas(ComboAction* ca, QVector<Selection> areas, bool deselect_areas);
|
||||
void AddClipsFromGhosts(ComboAction *ca, const QVector<Ghost> &ghosts);
|
||||
|
||||
void MoveClip(Clip* c,
|
||||
ComboAction* ca,
|
||||
long iin,
|
||||
long iout,
|
||||
long iclip_in,
|
||||
Track *itrack,
|
||||
bool verify_transitions = true,
|
||||
bool relative = false);
|
||||
|
||||
void EditToPoint(bool in, bool ripple);
|
||||
|
||||
bool SnapPoint(long* l, double zoom, bool use_playhead, bool use_markers, bool use_workarea);
|
||||
|
||||
void DeleteAreas(ComboAction* ca, QVector<Selection> areas, bool deselect_areas = false, bool ripple = false);
|
||||
void DeleteInToOut(bool ripple);
|
||||
void DeleteClipsUsingMedia(const QVector<Media *> &media);
|
||||
|
||||
void Ripple(ComboAction *ca, long point, long length, const QVector<int>& ignore = QVector<int>());
|
||||
void Ripple(ComboAction *ca, long point, long length, const QVector<Clip *> &ignore = QVector<Clip*>());
|
||||
|
||||
void ChangeTrackHeightsRelatively(int diff);
|
||||
|
||||
void ToggleLinksOnSelected();
|
||||
|
||||
void Split();
|
||||
bool SplitAllClipsAtPoint(ComboAction *ca, long point);
|
||||
void SplitClipAtPositions(ComboAction* ca, Clip *clip, QVector<long> positions, bool relink = true);
|
||||
bool SplitClipAtPositions(ComboAction* ca, Clip *clip, QVector<long> positions, bool relink = true);
|
||||
|
||||
void RippleDeleteEmptySpace(Track *track, long point);
|
||||
|
||||
Effect* GetSelectedGizmo();
|
||||
|
||||
@@ -85,6 +106,8 @@ public:
|
||||
void ClearSelections();
|
||||
void AddSelectionsToClipboard(bool delete_originals);
|
||||
QVector<Selection> Selections();
|
||||
void SetSelections(const QVector<Selection>& selections);
|
||||
void TidySelections();
|
||||
|
||||
long playhead;
|
||||
|
||||
@@ -102,13 +125,9 @@ private:
|
||||
|
||||
ClipPtr SplitClip(ComboAction* ca, bool transitions, Clip *clip, long frame);
|
||||
ClipPtr SplitClip(ComboAction* ca, bool transitions, Clip *clip, long frame, long post_in);
|
||||
bool SplitSelection(ComboAction* ca, QVector<Selection> selections);
|
||||
};
|
||||
|
||||
using SequencePtr = std::shared_ptr<Sequence>;
|
||||
|
||||
// static variable for the currently active sequence
|
||||
namespace olive {
|
||||
extern SequencePtr ActiveSequence;
|
||||
}
|
||||
|
||||
#endif // SEQUENCE_H
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
#include "timelinefunctions.h"
|
||||
|
||||
#include "global/math.h"
|
||||
#include "global/config.h"
|
||||
#include "global/timing.h"
|
||||
#include "sequence.h"
|
||||
|
||||
// snapping
|
||||
bool olive::timeline::snapping = true;
|
||||
bool olive::timeline::snapped = false;
|
||||
long olive::timeline::snap_point = 0;
|
||||
|
||||
void olive::timeline::RelinkClips(QVector<Clip *> &pre_clips, QVector<ClipPtr> &post_clips)
|
||||
{
|
||||
@@ -28,3 +36,137 @@ void olive::timeline::RelinkClips(QVector<Clip *> &pre_clips, QVector<ClipPtr> &
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool olive::timeline::SnapToPoint(long point, long* l, double zoom) {
|
||||
long limit = getFrameFromScreenPoint(zoom, 10); // FIXME magic number 10 used for on screen pixel threshold to snap to
|
||||
if (*l > point-limit-1 && *l < point+limit+1) {
|
||||
olive::timeline::snap_point = point;
|
||||
*l = point;
|
||||
olive::timeline::snapped = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
QVector<Ghost> olive::timeline::CreateGhostsFromMedia(Sequence *seq,
|
||||
long entry_point,
|
||||
QVector<olive::timeline::MediaImportData> &media_list)
|
||||
{
|
||||
QVector<Ghost> ghosts;
|
||||
|
||||
for (int i=0;i<media_list.size();i++) {
|
||||
bool can_import = true;
|
||||
|
||||
const olive::timeline::MediaImportData import_data = media_list.at(i);
|
||||
Media* medium = import_data.media();
|
||||
Footage* m = nullptr;
|
||||
Sequence* s = nullptr;
|
||||
long sequence_length = 0;
|
||||
long default_clip_in = 0;
|
||||
long default_clip_out = 0;
|
||||
|
||||
switch (medium->get_type()) {
|
||||
case MEDIA_TYPE_FOOTAGE:
|
||||
m = medium->to_footage();
|
||||
can_import = m->ready;
|
||||
if (m->using_inout) {
|
||||
double source_fr = 30;
|
||||
if (m->video_tracks.size() > 0 && !qIsNull(m->video_tracks.at(0).video_frame_rate)) {
|
||||
source_fr = m->video_tracks.at(0).video_frame_rate * m->speed;
|
||||
}
|
||||
default_clip_in = rescale_frame_number(m->in, source_fr, seq->frame_rate);
|
||||
default_clip_out = rescale_frame_number(m->out, source_fr, seq->frame_rate);
|
||||
}
|
||||
break;
|
||||
case MEDIA_TYPE_SEQUENCE:
|
||||
s = medium->to_sequence().get();
|
||||
sequence_length = s->GetEndFrame();
|
||||
if (seq != nullptr) sequence_length = rescale_frame_number(sequence_length, s->frame_rate, seq->frame_rate);
|
||||
can_import = (s != seq && sequence_length != 0);
|
||||
if (s->using_workarea) {
|
||||
default_clip_in = rescale_frame_number(s->workarea_in, s->frame_rate, seq->frame_rate);
|
||||
default_clip_out = rescale_frame_number(s->workarea_out, s->frame_rate, seq->frame_rate);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
can_import = false;
|
||||
}
|
||||
|
||||
if (can_import) {
|
||||
Ghost g;
|
||||
g.clip = nullptr;
|
||||
g.trim_type = olive::timeline::TRIM_NONE;
|
||||
g.old_clip_in = g.clip_in = default_clip_in;
|
||||
g.media = medium;
|
||||
g.in = entry_point;
|
||||
g.transition = nullptr;
|
||||
|
||||
switch (medium->get_type()) {
|
||||
case MEDIA_TYPE_FOOTAGE:
|
||||
// is video source a still image?
|
||||
if (m->video_tracks.size() > 0 && m->video_tracks.at(0).infinite_length && m->audio_tracks.size() == 0) {
|
||||
g.out = g.in + 100;
|
||||
} else {
|
||||
long length = m->get_length_in_frames(seq->frame_rate);
|
||||
g.out = entry_point + length - default_clip_in;
|
||||
if (m->using_inout) {
|
||||
g.out -= (length - default_clip_out);
|
||||
}
|
||||
}
|
||||
|
||||
if (import_data.type() == olive::timeline::kImportAudioOnly
|
||||
|| import_data.type() == olive::timeline::kImportBoth) {
|
||||
for (int j=0;j<m->audio_tracks.size();j++) {
|
||||
if (m->audio_tracks.at(j).enabled) {
|
||||
g.track = seq->GetTrackList(Track::kTypeAudio)->First() + j;
|
||||
g.media_stream = m->audio_tracks.at(j).file_index;
|
||||
ghosts.append(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (import_data.type() == olive::timeline::kImportVideoOnly
|
||||
|| import_data.type() == olive::timeline::kImportBoth) {
|
||||
for (int j=0;j<m->video_tracks.size();j++) {
|
||||
if (m->video_tracks.at(j).enabled) {
|
||||
g.track = seq->GetTrackList(Track::kTypeVideo)->First() + j;
|
||||
g.media_stream = m->video_tracks.at(j).file_index;
|
||||
ghosts.append(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MEDIA_TYPE_SEQUENCE:
|
||||
g.out = entry_point + sequence_length - default_clip_in;
|
||||
|
||||
if (s->using_workarea) {
|
||||
g.out -= (sequence_length - default_clip_out);
|
||||
}
|
||||
|
||||
if (import_data.type() == olive::timeline::kImportVideoOnly
|
||||
|| import_data.type() == olive::timeline::kImportBoth) {
|
||||
g.track = seq->GetTrackList(Track::kTypeVideo)->First();
|
||||
ghosts.append(g);
|
||||
}
|
||||
|
||||
if (import_data.type() == olive::timeline::kImportAudioOnly
|
||||
|| import_data.type() == olive::timeline::kImportBoth) {
|
||||
g.track = seq->GetTrackList(Track::kTypeAudio)->First();
|
||||
ghosts.append(g);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
entry_point = g.out;
|
||||
}
|
||||
}
|
||||
for (int i=0;i<ghosts.size();i++) {
|
||||
Ghost& g = ghosts[i];
|
||||
g.old_in = g.in;
|
||||
g.old_out = g.out;
|
||||
g.old_track = g.track;
|
||||
}
|
||||
|
||||
return ghosts;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <QVector>
|
||||
|
||||
#include "timeline/clip.h"
|
||||
#include "timeline/mediaimportdata.h"
|
||||
#include "ghost.h"
|
||||
|
||||
namespace olive {
|
||||
namespace timeline {
|
||||
@@ -17,12 +19,6 @@ enum CreateObjects {
|
||||
ADD_OBJ_AUDIO
|
||||
};
|
||||
|
||||
enum TrimType {
|
||||
TRIM_NONE,
|
||||
TRIM_IN,
|
||||
TRIM_OUT
|
||||
};
|
||||
|
||||
enum Alignment {
|
||||
kAlignmentTop,
|
||||
kAlignmentBottom,
|
||||
@@ -31,6 +27,15 @@ enum Alignment {
|
||||
|
||||
void RelinkClips(QVector<Clip*>& pre_clips, QVector<ClipPtr> &post_clips);
|
||||
|
||||
bool SnapToPoint(long point, long* l, double zoom);
|
||||
|
||||
QVector<Ghost> CreateGhostsFromMedia(Sequence *seq, long entry_point, QVector<olive::timeline::MediaImportData> &media_list);
|
||||
|
||||
// snapping
|
||||
extern bool snapping;
|
||||
extern bool snapped;
|
||||
extern long snap_point;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "timelinetools.h"
|
||||
|
||||
olive::timeline::Tool olive::timeline::current_tool = olive::timeline::TIMELINE_TOOL_POINTER;
|
||||
@@ -0,0 +1,47 @@
|
||||
/***
|
||||
|
||||
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/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TIMELINETOOLS_H
|
||||
#define TIMELINETOOLS_H
|
||||
|
||||
namespace olive {
|
||||
namespace timeline {
|
||||
|
||||
enum Tool {
|
||||
TIMELINE_TOOL_POINTER,
|
||||
TIMELINE_TOOL_EDIT,
|
||||
TIMELINE_TOOL_RAZOR,
|
||||
TIMELINE_TOOL_RIPPLE,
|
||||
TIMELINE_TOOL_ROLLING,
|
||||
TIMELINE_TOOL_SLIP,
|
||||
TIMELINE_TOOL_SLIDE,
|
||||
TIMELINE_TOOL_HAND,
|
||||
TIMELINE_TOOL_ZOOM,
|
||||
TIMELINE_TOOL_MENU,
|
||||
TIMELINE_TOOL_TRANSITION,
|
||||
TIMELINE_TOOL_COUNT
|
||||
};
|
||||
|
||||
extern Tool current_tool;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TIMELINETOOLS_H
|
||||
+32
-4
@@ -50,12 +50,8 @@ void Track::Save(QXmlStreamWriter &stream)
|
||||
for (int j=0;j<clips_.size();j++) {
|
||||
Clip* c = clips_.at(j).get();
|
||||
|
||||
stream.writeStartElement("clip");
|
||||
stream.writeAttribute("id", QString::number(c->load_id));
|
||||
|
||||
c->Save(stream);
|
||||
|
||||
stream.writeEndElement(); // clip
|
||||
}
|
||||
|
||||
stream.writeEndElement(); // track
|
||||
@@ -78,6 +74,10 @@ void Track::set_height(int h)
|
||||
|
||||
void Track::AddClip(ClipPtr clip)
|
||||
{
|
||||
if (clips_.contains(clip)) {
|
||||
return;
|
||||
}
|
||||
|
||||
clips_.append(clip);
|
||||
if (clip->track() != nullptr) {
|
||||
clip->track()->RemoveClip(clip.get());
|
||||
@@ -85,6 +85,16 @@ void Track::AddClip(ClipPtr clip)
|
||||
clip->set_track(this);
|
||||
}
|
||||
|
||||
int Track::ClipCount()
|
||||
{
|
||||
return clips_.size();
|
||||
}
|
||||
|
||||
ClipPtr Track::GetClip(int i)
|
||||
{
|
||||
return clips_.at(i);
|
||||
}
|
||||
|
||||
void Track::RemoveClip(int i)
|
||||
{
|
||||
clips_.removeAt(i);
|
||||
@@ -145,6 +155,19 @@ ClipPtr Track::GetClipObjectFromRawPtr(Clip *c)
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
Clip *Track::GetClipFromPoint(long point)
|
||||
{
|
||||
for (int i=0;i<clips_.size();i++) {
|
||||
Clip* c = clips_.at(i).get();
|
||||
|
||||
if (c->timeline_in() <= point && c->timeline_out() > point) {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int Track::Index()
|
||||
{
|
||||
return parent_->IndexOfTrack(this);
|
||||
@@ -209,6 +232,11 @@ bool Track::IsTransitionSelected(Transition *t)
|
||||
return false;
|
||||
}
|
||||
|
||||
void Track::SelectArea(long in, long out)
|
||||
{
|
||||
selections_.append(Selection(in, out, this));
|
||||
}
|
||||
|
||||
void Track::SelectClip(Clip* c)
|
||||
{
|
||||
selections_.append(Selection(c->timeline_in(), c->timeline_out(), this));
|
||||
|
||||
@@ -61,6 +61,7 @@ public:
|
||||
QVector<Clip*> GetAllClips();
|
||||
QVector<Clip*> GetSelectedClips(bool containing);
|
||||
ClipPtr GetClipObjectFromRawPtr(Clip* c);
|
||||
Clip* GetClipFromPoint(long point);
|
||||
|
||||
int Index();
|
||||
|
||||
@@ -71,6 +72,7 @@ public:
|
||||
void DeleteArea(ComboAction *ca, const Selection& s);
|
||||
void DeleteArea(ComboAction *ca, long in, long out);
|
||||
|
||||
void SelectArea(long in, long out);
|
||||
void SelectClip(Clip *c);
|
||||
void SelectAll();
|
||||
void SelectAtPoint(long point);
|
||||
|
||||
@@ -82,7 +82,17 @@ QVector<Track*> TrackList::tracks()
|
||||
return tracks_;
|
||||
}
|
||||
|
||||
Track::Type TrackList::type()
|
||||
{
|
||||
return type_;
|
||||
}
|
||||
|
||||
Sequence *TrackList::GetParent()
|
||||
{
|
||||
return static_cast<Sequence*>(parent());
|
||||
}
|
||||
|
||||
void TrackList::ResizeTrackArray(int i)
|
||||
{
|
||||
tracks_.resize(i);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ public:
|
||||
Track* TrackAt(int i);
|
||||
QVector<Track*> tracks();
|
||||
|
||||
Track::Type type();
|
||||
|
||||
Sequence* GetParent();
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user