From 77defa4ce99bb9162178de00c3deaefe990b0c48 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 5 Jul 2018 23:52:28 +0100 Subject: [PATCH] fixed selecting bug --- effects/crossdissolvetransition.cpp | 1 + effects/transition.cpp | 1 + effects/transition.h | 12 ++++++++++++ olive.pro.user | 2 +- panels/project.cpp | 10 ---------- panels/timeline.cpp | 10 ++++++---- project/clip.cpp | 16 ++++++++++++++++ project/clip.h | 6 ++++-- ui/timelinewidget.cpp | 27 ++++++++++----------------- ui/viewerwidget.cpp | 10 ++-------- ui/viewerwidget.h | 3 ++- 11 files changed, 55 insertions(+), 43 deletions(-) diff --git a/effects/crossdissolvetransition.cpp b/effects/crossdissolvetransition.cpp index a7cb5a976..c3e68c7eb 100644 --- a/effects/crossdissolvetransition.cpp +++ b/effects/crossdissolvetransition.cpp @@ -4,6 +4,7 @@ CrossDissolveTransition::CrossDissolveTransition() { name = "Cross Dissolve"; + id = VIDEO_DISSOLVE_TRANSITION; } void CrossDissolveTransition::process_transition(float progress) { diff --git a/effects/transition.cpp b/effects/transition.cpp index 1e748bbe2..ade3d2525 100644 --- a/effects/transition.cpp +++ b/effects/transition.cpp @@ -2,6 +2,7 @@ Transition::Transition() { length = 30; + link = NULL; } Transition* Transition::copy() { diff --git a/effects/transition.h b/effects/transition.h index 5f9020851..3473198d8 100644 --- a/effects/transition.h +++ b/effects/transition.h @@ -3,12 +3,24 @@ #include +enum VideoTransitions { + VIDEO_DISSOLVE_TRANSITION, + VIDEO_TRANSITION_COUNT +}; + +enum AudioTransitions { + AUDIO_LINEAR_FADE_TRANSITION, + AUDIO_TRANSITION_COUNT +}; + class Transition { public: Transition(); + int id; int length; QString name; + Transition* link; virtual void process_transition(float); virtual Transition* copy(); }; diff --git a/olive.pro.user b/olive.pro.user index eff894ea0..347b468fa 100644 --- a/olive.pro.user +++ b/olive.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/panels/project.cpp b/panels/project.cpp index 0c4f580a4..8713ff184 100644 --- a/panels/project.cpp +++ b/panels/project.cpp @@ -140,16 +140,6 @@ Media* Project::import_file(QString file) { ms->preview_lock.lock(); ms->file_index = i; if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { -// qDebug() << "[WARNING] INFINITE_LENGTH calculation is inaccurate in this build\n"; -// qDebug() << "INFINITE_LENGTH heuristics:"; -// qDebug() << " start_time:" << pFormatCtx->streams[i]->start_time; -// qDebug() << " duration:" << pFormatCtx->streams[i]->duration; -// qDebug() << " nb_frames:" << pFormatCtx->streams[i]->nb_frames; -// qDebug() << " avg_frame_rate:" << av_q2d(pFormatCtx->streams[i]->avg_frame_rate); -// qDebug() << " codec_info_nb_frames:" << pFormatCtx->streams[i]->codec_info_nb_frames; -// qDebug() << " nb_decoded_frames:" << pFormatCtx->streams[i]->nb_decoded_frames; -// qDebug() << " codec_id:" << pFormatCtx->streams[i]->codecpar->codec_id; - bool infinite_length = (pFormatCtx->streams[i]->avg_frame_rate.den == 0); ms->video_width = pFormatCtx->streams[i]->codecpar->width; ms->video_height = pFormatCtx->streams[i]->codecpar->height; diff --git a/panels/timeline.cpp b/panels/timeline.cpp index 4ea3b9005..b2376fdd8 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -84,10 +84,12 @@ void Timeline::previous_cut() { long p_cut = 0; for (int i=0;iclip_count();i++) { Clip* c = sequence->get_clip(i); - if (c->timeline_out > p_cut && c->timeline_out < playhead) { - p_cut = c->timeline_out; - } else if (c->timeline_in > p_cut && c->timeline_in < playhead) { - p_cut = c->timeline_in; + if (c != NULL) { + if (c->timeline_out > p_cut && c->timeline_out < playhead) { + p_cut = c->timeline_out; + } else if (c->timeline_in > p_cut && c->timeline_in < playhead) { + p_cut = c->timeline_in; + } } } seek(p_cut); diff --git a/project/clip.cpp b/project/clip.cpp index 9520d5b2e..2a8a75f83 100644 --- a/project/clip.cpp +++ b/project/clip.cpp @@ -99,6 +99,22 @@ Clip::~Clip() { delete pkt; } +long Clip::get_timeline_in_with_transition() { + if (opening_transition != NULL && opening_transition->link != NULL) { + return timeline_in - opening_transition->link->length; + } else { + return timeline_in; + } +} + +long Clip::get_timeline_out_with_transition() { + if (closing_transition != NULL && closing_transition->link != NULL) { + return timeline_out + closing_transition->link->length; + } else { + return timeline_out; + } +} + // timeline functions long Clip::getLength() { return timeline_out - timeline_in; diff --git a/project/clip.h b/project/clip.h index ba70de522..b1e94797f 100644 --- a/project/clip.h +++ b/project/clip.h @@ -42,9 +42,11 @@ struct Clip bool enabled; int id; QString name; + long get_timeline_in_with_transition(); + long get_timeline_out_with_transition(); + long timeline_in; + long timeline_out; long clip_in; - long timeline_in; - long timeline_out; int track; quint8 color_r; quint8 color_g; diff --git a/ui/timelinewidget.cpp b/ui/timelinewidget.cpp index 95b6ee1a7..077476abe 100644 --- a/ui/timelinewidget.cpp +++ b/ui/timelinewidget.cpp @@ -140,17 +140,6 @@ void TimelineWidget::dropEvent(QDropEvent* event) { c->effects.append(create_effect(AUDIO_PAN_EFFECT, c)); } - /* - * TEMP DEBUG CODE TO REMOVE LATER - */ - - c->opening_transition = new CrossDissolveTransition(); - c->closing_transition = new CrossDissolveTransition(); - - /* - * END OF TEMP DEBUG CODE - */ - sequence->add_clip(c); added_clips.append(c); } @@ -219,11 +208,6 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) { track_resize_mouse_cache = event->pos().y(); panel_timeline->moving_init = true; } else { - // if "shift" is not down - if (!shift) { - panel_timeline->selections.clear(); - } - if (clip_index >= 0) { Clip* c = sequence->get_clip(clip_index); if (panel_timeline->is_clip_selected(c)) { @@ -231,6 +215,11 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) { // TODO if shift is down, deselect it } } else { + // if "shift" is not down + if (!shift) { + panel_timeline->selections.clear(); + } + Clip* clip = sequence->get_clip(clip_index); if (clip != NULL) { panel_timeline->selections.append({clip->timeline_in, clip->timeline_out, clip->track}); @@ -248,6 +237,11 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) { } panel_timeline->moving_init = true; } else { + // if "shift" is not down + if (!shift) { + panel_timeline->selections.clear(); + } + panel_timeline->rect_select_init = true; } panel_timeline->repaint_timeline(); @@ -367,7 +361,6 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) { panel_timeline->ripple(ripple_point, -ripple_length); } } - panel_timeline->redraw_all_clips(true); } else if (panel_timeline->selecting) { // remove duplicate selections diff --git a/ui/viewerwidget.cpp b/ui/viewerwidget.cpp index 2a6f633bb..fbba9fc54 100644 --- a/ui/viewerwidget.cpp +++ b/ui/viewerwidget.cpp @@ -29,7 +29,7 @@ ViewerWidget::ViewerWidget(QWidget *parent) : QOpenGLWidget(parent) setFormat(format); // error handler - retries after 200ms if we couldn't get the entire image - retry_timer.setInterval(200); + retry_timer.setInterval(250); connect(&retry_timer, SIGNAL(timeout()), this, SLOT(retry())); } @@ -44,7 +44,6 @@ void ViewerWidget::initializeGL() { glMatrixMode(GL_PROJECTION); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); -// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } //void ViewerWidget::resizeGL(int w, int h) @@ -55,8 +54,7 @@ void ViewerWidget::paintEvent(QPaintEvent *e) { if (enable_paint) QOpenGLWidget::paintEvent(e); } -void ViewerWidget::paintGL() -{ +void ViewerWidget::paintGL() { bool loop = true; while (loop) { loop = false; @@ -188,10 +186,6 @@ void ViewerWidget::paintGL() } } - /*QPainter p(this); - p.drawText({0, 0, 200, 200}, "text!"); - p.end();*/ - if (texture_failed) { if (multithreaded) { retry_timer.start(); diff --git a/ui/viewerwidget.h b/ui/viewerwidget.h index d9885ae32..d8ee71225 100644 --- a/ui/viewerwidget.h +++ b/ui/viewerwidget.h @@ -6,6 +6,7 @@ #include #include #include + struct Clip; class Viewer; @@ -14,7 +15,7 @@ class ViewerWidget : public QOpenGLWidget, public QOpenGLFunctions { Q_OBJECT public: - ViewerWidget(QWidget *parent = 0); + ViewerWidget(QWidget *parent = 0); bool multithreaded; bool force_audio;