added cross dissolve transitions (but they're uneditable)

This commit is contained in:
itsmattkc
2018-07-03 06:45:32 +01:00
parent 0ae230ac29
commit 5a60e2d2c6
16 changed files with 123 additions and 34 deletions
-1
View File
@@ -59,5 +59,4 @@ void SourceTable::dropEvent(QDropEvent* event) {
}
event->acceptProposedAction();
}
QTreeWidget::dropEvent(event);
}
+35 -4
View File
@@ -11,6 +11,7 @@
#include "panels/effectcontrols.h"
#include "effects/effects.h"
#include "effects/transition.h"
#include <QPainter>
#include <QColor>
@@ -138,6 +139,17 @@ 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);
}
@@ -963,6 +975,7 @@ void TimelineWidget::redraw_clips() {
QPainter clip_painter(&clip_pixmap);
int video_track_limit = 0;
int audio_track_limit = 0;
QColor transition_color(160, 128, 192);
for (int i=0;i<sequence->clip_count();i++) {
Clip* clip = sequence->get_clip(i);
if (clip != NULL && is_track_visible(clip->track)) {
@@ -1005,6 +1018,25 @@ void TimelineWidget::redraw_clips() {
}
}
QRect text_rect(clip_rect.left() + CLIP_TEXT_PADDING, clip_rect.top() + CLIP_TEXT_PADDING, clip_rect.width() - CLIP_TEXT_PADDING - CLIP_TEXT_PADDING, clip_rect.height() - CLIP_TEXT_PADDING - CLIP_TEXT_PADDING);
if (clip->opening_transition != NULL) {
int transition_width = panel_timeline->getScreenPointFromFrame(clip->opening_transition->length);
QRect transition_rect(clip_rect.x(), clip_rect.y(), transition_width, clip_rect.height());
text_rect.setX(text_rect.x()+transition_width);
clip_painter.fillRect(transition_rect, transition_color);
clip_painter.setPen(Qt::black);
clip_painter.drawRect(transition_rect);
}
if (clip->closing_transition != NULL) {
int transition_width = panel_timeline->getScreenPointFromFrame(clip->opening_transition->length);
QRect transition_rect(clip_rect.right()-transition_width, clip_rect.y(), transition_width, clip_rect.height());
text_rect.setWidth(text_rect.width()-transition_width);
clip_painter.fillRect(transition_rect, transition_color);
clip_painter.setPen(Qt::black);
clip_painter.drawRect(transition_rect);
}
// top left bevel
clip_painter.setPen(Qt::white);
clip_painter.drawLine(clip_rect.bottomLeft(), clip_rect.topLeft());
@@ -1015,13 +1047,12 @@ void TimelineWidget::redraw_clips() {
// set to black if color is bright
clip_painter.setPen(Qt::black);
}
QRect text_rect(clip_rect.left() + CLIP_TEXT_PADDING, clip_rect.top() + CLIP_TEXT_PADDING, clip_rect.width() - CLIP_TEXT_PADDING - CLIP_TEXT_PADDING, clip_rect.height() - CLIP_TEXT_PADDING - CLIP_TEXT_PADDING);
clip_painter.drawText(text_rect, 0, clip->name, &text_rect);
if (clip->linked.size() > 0) {
int underline_y = CLIP_TEXT_PADDING + clip_painter.fontMetrics().height() + clip_rect.top();
int underline_width = qMin(clip_rect.left() + clip_rect.width() - CLIP_TEXT_PADDING, clip_rect.left() + CLIP_TEXT_PADDING + clip_painter.fontMetrics().width(clip->name));
clip_painter.drawLine(clip_rect.left() + CLIP_TEXT_PADDING, underline_y, underline_width, underline_y);
int underline_width = qMin(text_rect.width(), clip_painter.fontMetrics().width(clip->name));
clip_painter.drawLine(text_rect.x(), underline_y, text_rect.x() + underline_width, underline_y);
}
clip_painter.drawText(text_rect, 0, clip->name, &text_rect);
// bottom right gray
clip_painter.setPen(Qt::gray);
+15 -1
View File
@@ -5,6 +5,7 @@
#include "panels/timeline.h"
#include "project/sequence.h"
#include "project/effect.h"
#include "effects/transition.h"
#include "playback/playback.h"
#include "playback/audio.h"
#include "io/media.h"
@@ -58,8 +59,8 @@ void ViewerWidget::paintGL()
if (multithreaded) retry_timer.stop();
glClear(GL_COLOR_BUFFER_BIT);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(1.0, 1.0, 1.0, 1.0);
current_clips.clear();
@@ -125,6 +126,19 @@ void ViewerWidget::paintGL()
c->effects.at(j)->process_gl(&anchor_x, &anchor_y);
}
if (c->opening_transition != NULL) {
int transition_progress = panel_timeline->playhead-c->timeline_in;
if (transition_progress < c->opening_transition->length) {
c->opening_transition->process_transition((float)transition_progress/(float)c->opening_transition->length);
}
}
if (c->closing_transition != NULL) {
int transition_progress = c->closing_transition->length-(panel_timeline->playhead-c->timeline_in-c->getLength()+c->closing_transition->length);
if (transition_progress < c->closing_transition->length) {
c->closing_transition->process_transition((float)transition_progress/(float)c->closing_transition->length);
}
}
int anchor_right = c->media_stream->video_width - anchor_x;
int anchor_bottom = c->media_stream->video_height - anchor_y;