#475 and some clip pointer changes
This commit is contained in:
@@ -100,7 +100,7 @@ void EffectControls::set_zoom(bool in) {
|
||||
void EffectControls::menu_select(QAction* q) {
|
||||
ComboAction* ca = new ComboAction();
|
||||
for (int i=0;i<selected_clips.size();i++) {
|
||||
const ClipPtr& c = olive::ActiveSequence->clips.at(selected_clips.at(i));
|
||||
Clip* c = olive::ActiveSequence->clips.at(selected_clips.at(i)).get();
|
||||
if ((c->track() < 0) == (effect_menu_subtype == EFFECT_TYPE_VIDEO)) {
|
||||
const EffectMeta* meta = reinterpret_cast<const EffectMeta*>(q->data().value<quintptr>());
|
||||
if (effect_menu_type == EFFECT_TYPE_TRANSITION) {
|
||||
@@ -148,7 +148,7 @@ void EffectControls::copy(bool del) {
|
||||
ComboAction* ca = new ComboAction();
|
||||
EffectDeleteCommand* del_com = (del) ? new EffectDeleteCommand() : nullptr;
|
||||
for (int i=0;i<selected_clips.size();i++) {
|
||||
const ClipPtr& c = olive::ActiveSequence->clips.at(selected_clips.at(i));
|
||||
Clip* c = olive::ActiveSequence->clips.at(selected_clips.at(i)).get();
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
EffectPtr effect = c->effects.at(j);
|
||||
if (effect->container->selected) {
|
||||
@@ -566,7 +566,7 @@ void EffectControls::delete_effects() {
|
||||
if (mode == kTransitionNone) {
|
||||
EffectDeleteCommand* command = new EffectDeleteCommand();
|
||||
for (int i=0;i<selected_clips.size();i++) {
|
||||
ClipPtr c = olive::ActiveSequence->clips.at(selected_clips.at(i));
|
||||
Clip* c = olive::ActiveSequence->clips.at(selected_clips.at(i)).get();
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
EffectPtr effect = c->effects.at(j);
|
||||
if (effect->container->selected) {
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ void update_effect_controls() {
|
||||
int mode = kTransitionNone;
|
||||
if (olive::ActiveSequence != nullptr) {
|
||||
for (int i=0;i<olive::ActiveSequence->clips.size();i++) {
|
||||
ClipPtr clip = olive::ActiveSequence->clips.at(i);
|
||||
Clip* clip = olive::ActiveSequence->clips.at(i).get();
|
||||
if (clip != nullptr) {
|
||||
for (int j=0;j<olive::ActiveSequence->selections.size();j++) {
|
||||
const Selection& s = olive::ActiveSequence->selections.at(j);
|
||||
|
||||
+36
-53
@@ -54,6 +54,10 @@
|
||||
#include <QSplitter>
|
||||
#include <QStatusBar>
|
||||
|
||||
int olive::timeline::kTrackDefaultHeight = 40;
|
||||
int olive::timeline::kTrackMinHeight = 30;
|
||||
int olive::timeline::kTrackHeightIncrement = 10;
|
||||
|
||||
Timeline::Timeline(QWidget *parent) :
|
||||
Panel(parent),
|
||||
cursor_frame(0),
|
||||
@@ -301,7 +305,7 @@ void Timeline::add_clips_from_ghosts(ComboAction* ca, SequencePtr s) {
|
||||
|
||||
earliest_point = qMin(earliest_point, g.in);
|
||||
|
||||
ClipPtr c = ClipPtr(new Clip(s));
|
||||
ClipPtr c = std::make_shared<Clip>(s);
|
||||
c->set_media(g.media, g.media_stream);
|
||||
c->set_timeline_in(g.in);
|
||||
c->set_timeline_out(g.out);
|
||||
@@ -345,11 +349,11 @@ void Timeline::add_clips_from_ghosts(ComboAction* ca, SequencePtr s) {
|
||||
if (olive::CurrentConfig.add_default_effects_to_clips) {
|
||||
if (c->track() < 0) {
|
||||
// add default video effects
|
||||
c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_TRANSFORM, EFFECT_TYPE_EFFECT)));
|
||||
c->effects.append(create_effect(c.get(), get_internal_meta(EFFECT_INTERNAL_TRANSFORM, EFFECT_TYPE_EFFECT)));
|
||||
} else {
|
||||
// add default audio effects
|
||||
c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_VOLUME, EFFECT_TYPE_EFFECT)));
|
||||
c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_PAN, EFFECT_TYPE_EFFECT)));
|
||||
c->effects.append(create_effect(c.get(), get_internal_meta(EFFECT_INTERNAL_VOLUME, EFFECT_TYPE_EFFECT)));
|
||||
c->effects.append(create_effect(c.get(), get_internal_meta(EFFECT_INTERNAL_PAN, EFFECT_TYPE_EFFECT)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -366,7 +370,7 @@ void Timeline::add_transition() {
|
||||
bool adding = false;
|
||||
|
||||
for (int i=0;i<olive::ActiveSequence->clips.size();i++) {
|
||||
ClipPtr c = olive::ActiveSequence->clips.at(i);
|
||||
Clip* c = olive::ActiveSequence->clips.at(i).get();
|
||||
if (c != nullptr && is_clip_selected(c, true)) {
|
||||
int transition_to_add = (c->track() < 0) ? TRANSITION_INTERNAL_CROSSDISSOLVE : TRANSITION_INTERNAL_LINEARFADE;
|
||||
if (c->opening_transition == nullptr) {
|
||||
@@ -404,7 +408,7 @@ void Timeline::nest() {
|
||||
|
||||
// get selected clips
|
||||
for (int i=0;i<olive::ActiveSequence->clips.size();i++) {
|
||||
ClipPtr c = olive::ActiveSequence->clips.at(i);
|
||||
Clip* c = olive::ActiveSequence->clips.at(i).get();
|
||||
if (c != nullptr && is_clip_selected(c, true)) {
|
||||
selected_clips.append(i);
|
||||
earliest_point = qMin(c->timeline_in(), earliest_point);
|
||||
@@ -658,7 +662,7 @@ void Timeline::toggle_enable_on_selected_clips() {
|
||||
bool push_undo = false;
|
||||
|
||||
for (int i=0;i<olive::ActiveSequence->clips.size();i++) {
|
||||
ClipPtr c = olive::ActiveSequence->clips.at(i);
|
||||
Clip* c = olive::ActiveSequence->clips.at(i).get();
|
||||
if (c != nullptr && is_clip_selected(c, true)) {
|
||||
set_action->AddSetting(c, !c->enabled());
|
||||
push_undo = true;
|
||||
@@ -824,7 +828,7 @@ void Timeline::DecreaseTrackHeight() {
|
||||
repaint_timeline();
|
||||
}
|
||||
|
||||
bool is_clip_selected(ClipPtr clip, bool containing) {
|
||||
bool is_clip_selected(Clip *clip, bool containing) {
|
||||
for (int i=0;i<clip->sequence->selections.size();i++) {
|
||||
const Selection& s = clip->sequence->selections.at(i);
|
||||
if (clip->track() == s.track && ((clip->timeline_in() >= s.in && clip->timeline_out() <= s.out && containing) ||
|
||||
@@ -845,7 +849,7 @@ ClipPtr Timeline::split_clip(ComboAction* ca, bool transitions, int p, long fram
|
||||
}
|
||||
|
||||
ClipPtr Timeline::split_clip(ComboAction* ca, bool transitions, int p, long frame, long post_in) {
|
||||
ClipPtr pre = olive::ActiveSequence->clips.at(p);
|
||||
Clip* pre = olive::ActiveSequence->clips.at(p).get();
|
||||
if (pre != nullptr) {
|
||||
|
||||
if (pre->timeline_in() < frame && pre->timeline_out() > frame) {
|
||||
@@ -858,7 +862,7 @@ ClipPtr Timeline::split_clip(ComboAction* ca, bool transitions, int p, long fram
|
||||
post->set_timeline_in(post_in);
|
||||
post->set_clip_in(pre->clip_in() + (post->timeline_in() - pre->timeline_in()));
|
||||
|
||||
move_clip(ca, pre, pre->timeline_in(), frame, pre->clip_in(), pre->track(), false);
|
||||
pre->move(ca, pre->timeline_in(), frame, pre->clip_in(), pre->track(), false);
|
||||
|
||||
if (transitions) {
|
||||
|
||||
@@ -925,7 +929,7 @@ bool Timeline::split_clip_and_relink(ComboAction *ca, int clip, long frame, bool
|
||||
|
||||
split_cache.append(clip);
|
||||
|
||||
ClipPtr c = olive::ActiveSequence->clips.at(clip);
|
||||
Clip* c = olive::ActiveSequence->clips.at(clip).get();
|
||||
if (c != nullptr) {
|
||||
QVector<int> pre_clips;
|
||||
QVector<ClipPtr> post_clips;
|
||||
@@ -947,7 +951,7 @@ bool Timeline::split_clip_and_relink(ComboAction *ca, int clip, long frame, bool
|
||||
for (int i=0;i<c->linked.size();i++) {
|
||||
int l = c->linked.at(i);
|
||||
if (!split_cache.contains(l)) {
|
||||
ClipPtr link = olive::ActiveSequence->clips.at(l);
|
||||
Clip* link = olive::ActiveSequence->clips.at(l).get();
|
||||
if ((original_clip_is_selected && is_clip_selected(link, true)) || !original_clip_is_selected) {
|
||||
split_cache.append(l);
|
||||
ClipPtr s = split_clip(ca, true, l, frame);
|
||||
@@ -998,7 +1002,7 @@ void Timeline::clean_up_selections(QVector<Selection>& areas) {
|
||||
}
|
||||
}
|
||||
|
||||
bool selection_contains_transition(const Selection& s, ClipPtr c, int type) {
|
||||
bool selection_contains_transition(const Selection& s, Clip* c, int type) {
|
||||
if (type == kTransitionOpening) {
|
||||
return c->opening_transition != nullptr
|
||||
&& s.out == c->timeline_in() + c->opening_transition->get_true_length()
|
||||
@@ -1022,7 +1026,7 @@ void Timeline::delete_areas_and_relink(ComboAction* ca, QVector<Selection>& area
|
||||
for (int i=0;i<areas.size();i++) {
|
||||
const Selection& s = areas.at(i);
|
||||
for (int j=0;j<olive::ActiveSequence->clips.size();j++) {
|
||||
ClipPtr c = olive::ActiveSequence->clips.at(j);
|
||||
Clip* c = olive::ActiveSequence->clips.at(j).get();
|
||||
if (c != nullptr && c->track() == s.track && !c->undeletable) {
|
||||
if (selection_contains_transition(s, c, kTransitionOpening)) {
|
||||
// delete opening transition
|
||||
@@ -1043,7 +1047,7 @@ void Timeline::delete_areas_and_relink(ComboAction* ca, QVector<Selection>& area
|
||||
post_clips.append(post);
|
||||
} else if (c->timeline_in() < s.in && c->timeline_out() > s.in) {
|
||||
// only out point is in deletion area
|
||||
move_clip(ca, c, c->timeline_in(), s.in, c->clip_in(), c->track());
|
||||
c->move(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()) {
|
||||
@@ -1054,7 +1058,7 @@ void Timeline::delete_areas_and_relink(ComboAction* ca, QVector<Selection>& area
|
||||
}
|
||||
} else if (c->timeline_in() < s.out && c->timeline_out() > s.out) {
|
||||
// only in point is in deletion area
|
||||
move_clip(ca, c, s.out, c->timeline_out(), c->clip_in() + (s.out - c->timeline_in()), c->track());
|
||||
c->move(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()) {
|
||||
@@ -1236,7 +1240,7 @@ void Timeline::paste(bool insert) {
|
||||
bool ask_conflict = true;
|
||||
|
||||
for (int i=0;i<olive::ActiveSequence->clips.size();i++) {
|
||||
ClipPtr c = olive::ActiveSequence->clips.at(i);
|
||||
Clip* c = olive::ActiveSequence->clips.at(i).get();
|
||||
if (c != nullptr && is_clip_selected(c, true)) {
|
||||
for (int j=0;j<clipboard.size();j++) {
|
||||
EffectPtr e = std::static_pointer_cast<Effect>(clipboard.at(j));
|
||||
@@ -1405,7 +1409,9 @@ void Timeline::edit_to_point_internal(bool in, bool ripple) {
|
||||
|
||||
update_ui(true);
|
||||
|
||||
if (seek != olive::ActiveSequence->playhead && ripple) panel_sequence_viewer->seek(seek);
|
||||
if (seek != olive::ActiveSequence->playhead && ripple) {
|
||||
panel_sequence_viewer->seek(seek);
|
||||
}
|
||||
} else {
|
||||
delete ca;
|
||||
}
|
||||
@@ -1484,7 +1490,7 @@ void Timeline::split_at_playhead() {
|
||||
QVector<int> pre_clips;
|
||||
QVector<ClipPtr> post_clips;
|
||||
for (int j=0;j<olive::ActiveSequence->clips.size();j++) {
|
||||
ClipPtr clip = olive::ActiveSequence->clips.at(j);
|
||||
Clip* clip = olive::ActiveSequence->clips.at(j).get();
|
||||
if (clip != nullptr && is_clip_selected(clip, true)) {
|
||||
ClipPtr s = split_clip(ca, true, j, olive::ActiveSequence->playhead);
|
||||
if (s != nullptr) {
|
||||
@@ -1626,7 +1632,7 @@ void Timeline::set_marker() {
|
||||
bool clip_mode = false;
|
||||
|
||||
for (int i=0;i<olive::ActiveSequence->clips.size();i++) {
|
||||
ClipPtr c = olive::ActiveSequence->clips.at(i);
|
||||
Clip* c = olive::ActiveSequence->clips.at(i).get();
|
||||
if (c != nullptr
|
||||
&& is_clip_selected(c, true)) {
|
||||
|
||||
@@ -1681,7 +1687,7 @@ void Timeline::toggle_links() {
|
||||
LinkCommand* command = new LinkCommand();
|
||||
command->s = olive::ActiveSequence;
|
||||
for (int i=0;i<olive::ActiveSequence->clips.size();i++) {
|
||||
ClipPtr c = olive::ActiveSequence->clips.at(i);
|
||||
Clip* c = olive::ActiveSequence->clips.at(i).get();
|
||||
if (c != nullptr && is_clip_selected(c, true)) {
|
||||
if (!command->clips.contains(i)) command->clips.append(i);
|
||||
|
||||
@@ -2034,38 +2040,6 @@ void Timeline::setup_ui() {
|
||||
setWidget(dockWidgetContents);
|
||||
}
|
||||
|
||||
void move_clip(ComboAction* ca, ClipPtr c, long iin, long iout, long iclip_in, int itrack, bool verify_transitions, bool relative) {
|
||||
ca->append(new MoveClipAction(c, 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 Timeline::set_tool() {
|
||||
QPushButton* button = static_cast<QPushButton*>(sender());
|
||||
decheck_tool_buttons(button);
|
||||
@@ -2083,3 +2057,12 @@ void Timeline::set_tool() {
|
||||
timeline_area->setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
}
|
||||
|
||||
void olive::timeline::MultiplyTrackSizesByDPI()
|
||||
{
|
||||
qDebug() << QApplication::desktop()->devicePixelRatio();
|
||||
|
||||
kTrackDefaultHeight *= QApplication::desktop()->devicePixelRatio();
|
||||
kTrackMinHeight *= QApplication::desktop()->devicePixelRatio();
|
||||
kTrackHeightIncrement *= QApplication::desktop()->devicePixelRatio();
|
||||
}
|
||||
|
||||
+23
-3
@@ -50,11 +50,31 @@ enum TrimType {
|
||||
TRIM_OUT
|
||||
};
|
||||
|
||||
bool is_clip_selected(ClipPtr clip, bool containing);
|
||||
namespace olive {
|
||||
namespace timeline {
|
||||
const int kGhostThickness = 2;
|
||||
const int kClipTextPadding = 3;
|
||||
|
||||
/**
|
||||
* @brief Set default track sizes
|
||||
*
|
||||
* Olive has a few default constants used for adjusting track heights in the Timeline. For HiDPI, it makes
|
||||
* sense to multiply these by the current DPI scale. It uses a variable from QApplication to do this multiplication,
|
||||
* which means the QApplication instance needs to be instantiated before these are calculated. Therefore, call this
|
||||
* function ONCE after QApplication is created to multiply the track heights correctly.
|
||||
*/
|
||||
void MultiplyTrackSizesByDPI();
|
||||
|
||||
extern int kTrackDefaultHeight;
|
||||
extern int kTrackMinHeight;
|
||||
extern int kTrackHeightIncrement;
|
||||
}
|
||||
}
|
||||
|
||||
bool is_clip_selected(Clip* clip, bool containing);
|
||||
int getScreenPointFromFrame(double zoom, long frame);
|
||||
long getFrameFromScreenPoint(double zoom, int x);
|
||||
bool selection_contains_transition(const Selection& s, ClipPtr c, int type);
|
||||
void move_clip(ComboAction *ca, ClipPtr c, long iin, long iout, long iclip_in, int itrack, bool verify_transitions = true, bool relative = false);
|
||||
bool selection_contains_transition(const Selection& s, Clip *c, int type);
|
||||
void ripple_clips(ComboAction *ca, SequencePtr s, long point, long length, const QVector<int>& ignore = QVector<int>());
|
||||
|
||||
struct Ghost {
|
||||
|
||||
+3
-3
@@ -448,7 +448,7 @@ void Viewer::pause() {
|
||||
panel_project->process_file_list(file_list);
|
||||
|
||||
// add it to the sequence
|
||||
ClipPtr c = ClipPtr(new Clip(seq));
|
||||
ClipPtr c = std::make_shared<Clip>(seq);
|
||||
Media* m = panel_project->last_imported_media.at(0);
|
||||
FootagePtr f = m->to_footage();
|
||||
|
||||
@@ -745,7 +745,7 @@ void Viewer::set_media(Media* m) {
|
||||
seq->height = video_stream.video_height;
|
||||
if (video_stream.video_frame_rate > 0 && !video_stream.infinite_length) seq->frame_rate = video_stream.video_frame_rate * footage->speed;
|
||||
|
||||
ClipPtr c = ClipPtr(new Clip(seq));
|
||||
ClipPtr c = std::make_shared<Clip>(seq);
|
||||
c->set_media(media, video_stream.file_index);
|
||||
c->set_timeline_in(0);
|
||||
c->set_timeline_out(footage->get_length_in_frames(seq->frame_rate));
|
||||
@@ -765,7 +765,7 @@ void Viewer::set_media(Media* m) {
|
||||
const FootageStream& audio_stream = footage->audio_tracks.at(0);
|
||||
seq->audio_frequency = audio_stream.audio_frequency;
|
||||
|
||||
ClipPtr c = ClipPtr(new Clip(seq));
|
||||
ClipPtr c = std::make_shared<Clip>(seq);
|
||||
c->set_media(media, audio_stream.file_index);
|
||||
c->set_timeline_in(0);
|
||||
c->set_timeline_out(footage->get_length_in_frames(seq->frame_rate));
|
||||
|
||||
Reference in New Issue
Block a user