fixed selecting bug

This commit is contained in:
itsmattkc
2018-07-05 23:52:28 +01:00
parent 00959ca50a
commit 77defa4ce9
11 changed files with 55 additions and 43 deletions
+1
View File
@@ -4,6 +4,7 @@
CrossDissolveTransition::CrossDissolveTransition() { CrossDissolveTransition::CrossDissolveTransition() {
name = "Cross Dissolve"; name = "Cross Dissolve";
id = VIDEO_DISSOLVE_TRANSITION;
} }
void CrossDissolveTransition::process_transition(float progress) { void CrossDissolveTransition::process_transition(float progress) {
+1
View File
@@ -2,6 +2,7 @@
Transition::Transition() { Transition::Transition() {
length = 30; length = 30;
link = NULL;
} }
Transition* Transition::copy() { Transition* Transition::copy() {
+12
View File
@@ -3,12 +3,24 @@
#include <QString> #include <QString>
enum VideoTransitions {
VIDEO_DISSOLVE_TRANSITION,
VIDEO_TRANSITION_COUNT
};
enum AudioTransitions {
AUDIO_LINEAR_FADE_TRANSITION,
AUDIO_TRANSITION_COUNT
};
class Transition class Transition
{ {
public: public:
Transition(); Transition();
int id;
int length; int length;
QString name; QString name;
Transition* link;
virtual void process_transition(float); virtual void process_transition(float);
virtual Transition* copy(); virtual Transition* copy();
}; };
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.6.2, 2018-07-04T12:50:34. --> <!-- Written by QtCreator 4.6.2, 2018-07-05T22:05:57. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
-10
View File
@@ -140,16 +140,6 @@ Media* Project::import_file(QString file) {
ms->preview_lock.lock(); ms->preview_lock.lock();
ms->file_index = i; ms->file_index = i;
if (pFormatCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { 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); bool infinite_length = (pFormatCtx->streams[i]->avg_frame_rate.den == 0);
ms->video_width = pFormatCtx->streams[i]->codecpar->width; ms->video_width = pFormatCtx->streams[i]->codecpar->width;
ms->video_height = pFormatCtx->streams[i]->codecpar->height; ms->video_height = pFormatCtx->streams[i]->codecpar->height;
+6 -4
View File
@@ -84,10 +84,12 @@ void Timeline::previous_cut() {
long p_cut = 0; long p_cut = 0;
for (int i=0;i<sequence->clip_count();i++) { for (int i=0;i<sequence->clip_count();i++) {
Clip* c = sequence->get_clip(i); Clip* c = sequence->get_clip(i);
if (c->timeline_out > p_cut && c->timeline_out < playhead) { if (c != NULL) {
p_cut = c->timeline_out; if (c->timeline_out > p_cut && c->timeline_out < playhead) {
} else if (c->timeline_in > p_cut && c->timeline_in < playhead) { p_cut = c->timeline_out;
p_cut = c->timeline_in; } else if (c->timeline_in > p_cut && c->timeline_in < playhead) {
p_cut = c->timeline_in;
}
} }
} }
seek(p_cut); seek(p_cut);
+16
View File
@@ -99,6 +99,22 @@ Clip::~Clip() {
delete pkt; 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 // timeline functions
long Clip::getLength() { long Clip::getLength() {
return timeline_out - timeline_in; return timeline_out - timeline_in;
+4 -2
View File
@@ -42,9 +42,11 @@ struct Clip
bool enabled; bool enabled;
int id; int id;
QString name; QString name;
long get_timeline_in_with_transition();
long get_timeline_out_with_transition();
long timeline_in;
long timeline_out;
long clip_in; long clip_in;
long timeline_in;
long timeline_out;
int track; int track;
quint8 color_r; quint8 color_r;
quint8 color_g; quint8 color_g;
+10 -17
View File
@@ -140,17 +140,6 @@ void TimelineWidget::dropEvent(QDropEvent* event) {
c->effects.append(create_effect(AUDIO_PAN_EFFECT, c)); 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); sequence->add_clip(c);
added_clips.append(c); added_clips.append(c);
} }
@@ -219,11 +208,6 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) {
track_resize_mouse_cache = event->pos().y(); track_resize_mouse_cache = event->pos().y();
panel_timeline->moving_init = true; panel_timeline->moving_init = true;
} else { } else {
// if "shift" is not down
if (!shift) {
panel_timeline->selections.clear();
}
if (clip_index >= 0) { if (clip_index >= 0) {
Clip* c = sequence->get_clip(clip_index); Clip* c = sequence->get_clip(clip_index);
if (panel_timeline->is_clip_selected(c)) { if (panel_timeline->is_clip_selected(c)) {
@@ -231,6 +215,11 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) {
// TODO if shift is down, deselect it // TODO if shift is down, deselect it
} }
} else { } else {
// if "shift" is not down
if (!shift) {
panel_timeline->selections.clear();
}
Clip* clip = sequence->get_clip(clip_index); Clip* clip = sequence->get_clip(clip_index);
if (clip != NULL) { if (clip != NULL) {
panel_timeline->selections.append({clip->timeline_in, clip->timeline_out, clip->track}); 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; panel_timeline->moving_init = true;
} else { } else {
// if "shift" is not down
if (!shift) {
panel_timeline->selections.clear();
}
panel_timeline->rect_select_init = true; panel_timeline->rect_select_init = true;
} }
panel_timeline->repaint_timeline(); panel_timeline->repaint_timeline();
@@ -367,7 +361,6 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
panel_timeline->ripple(ripple_point, -ripple_length); panel_timeline->ripple(ripple_point, -ripple_length);
} }
} }
panel_timeline->redraw_all_clips(true); panel_timeline->redraw_all_clips(true);
} else if (panel_timeline->selecting) { } else if (panel_timeline->selecting) {
// remove duplicate selections // remove duplicate selections
+2 -8
View File
@@ -29,7 +29,7 @@ ViewerWidget::ViewerWidget(QWidget *parent) : QOpenGLWidget(parent)
setFormat(format); setFormat(format);
// error handler - retries after 200ms if we couldn't get the entire image // 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())); connect(&retry_timer, SIGNAL(timeout()), this, SLOT(retry()));
} }
@@ -44,7 +44,6 @@ void ViewerWidget::initializeGL() {
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND); glEnable(GL_BLEND);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
} }
//void ViewerWidget::resizeGL(int w, int h) //void ViewerWidget::resizeGL(int w, int h)
@@ -55,8 +54,7 @@ void ViewerWidget::paintEvent(QPaintEvent *e) {
if (enable_paint) QOpenGLWidget::paintEvent(e); if (enable_paint) QOpenGLWidget::paintEvent(e);
} }
void ViewerWidget::paintGL() void ViewerWidget::paintGL() {
{
bool loop = true; bool loop = true;
while (loop) { while (loop) {
loop = false; 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 (texture_failed) {
if (multithreaded) { if (multithreaded) {
retry_timer.start(); retry_timer.start();
+2 -1
View File
@@ -6,6 +6,7 @@
#include <QMatrix4x4> #include <QMatrix4x4>
#include <QOpenGLTexture> #include <QOpenGLTexture>
#include <QTimer> #include <QTimer>
struct Clip; struct Clip;
class Viewer; class Viewer;
@@ -14,7 +15,7 @@ class ViewerWidget : public QOpenGLWidget, public QOpenGLFunctions
{ {
Q_OBJECT Q_OBJECT
public: public:
ViewerWidget(QWidget *parent = 0); ViewerWidget(QWidget *parent = 0);
bool multithreaded; bool multithreaded;
bool force_audio; bool force_audio;