started frontend for effect keyframes
This commit is contained in:
@@ -29,7 +29,7 @@ CollapsibleWidget::CollapsibleWidget(QWidget* parent) : QWidget(parent) {
|
||||
enabled_check->setChecked(true);
|
||||
header = new QLabel();
|
||||
collapse_button = new QPushButton("[-]");
|
||||
collapse_button->setStyleSheet("QPushButton { border: none; }");
|
||||
collapse_button->setStyleSheet("QPushButton { border: none; } QPushButton:hover { text-decoration: underline; }");
|
||||
collapse_button->setMaximumWidth(25);
|
||||
setText("<untitled>");
|
||||
title_bar_layout->addWidget(collapse_button);
|
||||
@@ -61,6 +61,10 @@ bool CollapsibleWidget::is_focused() {
|
||||
return title_bar->hasFocus();
|
||||
}
|
||||
|
||||
bool CollapsibleWidget::is_expanded() {
|
||||
return contents->isVisible();
|
||||
}
|
||||
|
||||
void CollapsibleWidget::setContents(QWidget* c) {
|
||||
bool existing = (contents != NULL);
|
||||
contents = c;
|
||||
@@ -82,6 +86,7 @@ void CollapsibleWidget::on_enabled_change(bool b) {
|
||||
void CollapsibleWidget::on_visible_change() {
|
||||
contents->setVisible(!contents->isVisible());
|
||||
collapse_button->setText(contents->isVisible() ? "[-]" : "[+]");
|
||||
emit visibleChanged();
|
||||
}
|
||||
|
||||
CollapsibleWidgetHeader::CollapsibleWidgetHeader(QWidget* parent) : QWidget(parent), selected(false) {}
|
||||
|
||||
@@ -30,19 +30,21 @@ public:
|
||||
void setContents(QWidget* c);
|
||||
void setText(const QString &);
|
||||
bool is_focused();
|
||||
bool is_expanded();
|
||||
|
||||
CheckboxEx* enabled_check;
|
||||
bool selected;
|
||||
QWidget* contents;
|
||||
CollapsibleWidgetHeader* title_bar;
|
||||
private:
|
||||
QLabel* header;
|
||||
CollapsibleWidgetHeader* title_bar;
|
||||
QVBoxLayout* layout;
|
||||
QPushButton* collapse_button;
|
||||
QWidget* contents;
|
||||
QFrame* line;
|
||||
|
||||
signals:
|
||||
void deselect_others(QWidget*);
|
||||
void visibleChanged();
|
||||
|
||||
private slots:
|
||||
void on_enabled_change(bool b);
|
||||
|
||||
+19
-5
@@ -1,6 +1,7 @@
|
||||
#include "comboboxex.h"
|
||||
|
||||
#include "project/undo.h"
|
||||
#include "panels/project.h"
|
||||
|
||||
#include <QUndoCommand>
|
||||
#include <QWheelEvent>
|
||||
@@ -8,32 +9,45 @@
|
||||
class ComboBoxExCommand : public QUndoCommand {
|
||||
public:
|
||||
ComboBoxExCommand(ComboBoxEx* obj, int old_index, int new_index) :
|
||||
combobox(obj), old_val(old_index), new_val(new_index), done(true) {}
|
||||
combobox(obj), old_val(old_index), new_val(new_index), done(true), old_project_changed(project_changed) {}
|
||||
void undo() {
|
||||
combobox->setCurrentIndex(old_val);
|
||||
done = false;
|
||||
project_changed = old_project_changed;
|
||||
}
|
||||
void redo() {
|
||||
if (!done) {
|
||||
combobox->setCurrentIndex(new_val);
|
||||
}
|
||||
project_changed = true;
|
||||
}
|
||||
private:
|
||||
ComboBoxEx* combobox;
|
||||
int old_val;
|
||||
int new_val;
|
||||
bool done;
|
||||
bool old_project_changed;
|
||||
};
|
||||
|
||||
ComboBoxEx::ComboBoxEx(QWidget *parent) : QComboBox(parent), index(0) {
|
||||
connect(this, SIGNAL(activated(int)), this, SLOT(index_changed(int)));
|
||||
}
|
||||
|
||||
void ComboBoxEx::setCurrentIndexEx(int i) {
|
||||
index = i;
|
||||
setCurrentIndex(i);
|
||||
}
|
||||
|
||||
void ComboBoxEx::setCurrentTextEx(const QString &text) {
|
||||
setCurrentText(text);
|
||||
index = currentIndex();
|
||||
}
|
||||
|
||||
void ComboBoxEx::index_changed(int i) {
|
||||
if (index != i) {
|
||||
undo_stack.push(new ComboBoxExCommand(this, index, i));
|
||||
index = i;
|
||||
}
|
||||
if (index != i) {
|
||||
undo_stack.push(new ComboBoxExCommand(this, index, i));
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
void ComboBoxEx::wheelEvent(QWheelEvent* e) {
|
||||
|
||||
+4
-2
@@ -8,10 +8,12 @@ class ComboBoxEx : public QComboBox {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ComboBoxEx(QWidget* parent = 0);
|
||||
void setCurrentIndexEx(int i);
|
||||
void setCurrentTextEx(const QString &text);
|
||||
private slots:
|
||||
void index_changed(int);
|
||||
void index_changed(int);
|
||||
private:
|
||||
int index;
|
||||
int index;
|
||||
void wheelEvent(QWheelEvent* e);
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
#include "keyframeview.h"
|
||||
|
||||
#include "effects/effect.h"
|
||||
#include "ui/collapsiblewidget.h"
|
||||
#include "panels/panels.h"
|
||||
#include "panels/effectcontrols.h"
|
||||
#include "project/clip.h"
|
||||
#include "panels/timeline.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QMouseEvent>
|
||||
|
||||
#define KEYFRAME_SIZE 5
|
||||
#define KEYFRAME_POINT_COUNT 4
|
||||
|
||||
KeyframeView::KeyframeView(QWidget *parent) : QWidget(parent), mouseover(false), visible_in(0), visible_out(0) {
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
setMouseTracking(true);
|
||||
reload();
|
||||
}
|
||||
|
||||
void KeyframeView::reload() {
|
||||
enable_reload = true;
|
||||
update();
|
||||
}
|
||||
|
||||
void KeyframeView::paintEvent(QPaintEvent*) {
|
||||
QPainter p(this);
|
||||
|
||||
setMinimumWidth(getScreenPointFromFrame(panel_effect_controls->zoom, visible_out - visible_in));
|
||||
|
||||
rowY.clear();
|
||||
for (int i=0;i<effects.size();i++) {
|
||||
Effect* e = effects.at(i);
|
||||
if (e->container->is_expanded()) {
|
||||
for (int j=0;j<e->row_count();j++) {
|
||||
QLabel* label = e->row(j)->label;
|
||||
QWidget* contents = e->container->contents;
|
||||
long frame = 20;
|
||||
int keyframe_y = label->y() + (label->height()>>1) + mapFrom(panel_effect_controls, contents->mapTo(panel_effect_controls, contents->pos())).y() - e->container->title_bar->height();
|
||||
draw_keyframe(p, getScreenPointFromFrame(panel_effect_controls->zoom, frame), keyframe_y, false);
|
||||
rowY.append(keyframe_y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rowY.size() > 0) {
|
||||
int playhead_x = getScreenPointFromFrame(panel_effect_controls->zoom, panel_timeline->playhead-visible_in);
|
||||
p.setPen(Qt::red);
|
||||
p.drawLine(playhead_x, 0, playhead_x, height());
|
||||
}
|
||||
|
||||
if (mouseover && mouseover_row < rowY.size()) {
|
||||
draw_keyframe(p, getScreenPointFromFrame(panel_effect_controls->zoom, mouseover_frame) - visible_in, rowY.at(mouseover_row), true);
|
||||
}
|
||||
}
|
||||
|
||||
void KeyframeView::draw_keyframe(QPainter &p, int x, int y, bool semiTransparent) {
|
||||
QPoint points[KEYFRAME_POINT_COUNT] = {QPoint(x-KEYFRAME_SIZE, y), QPoint(x, y-KEYFRAME_SIZE), QPoint(x+KEYFRAME_SIZE, y), QPoint(x, y+KEYFRAME_SIZE)};
|
||||
int alpha = (semiTransparent) ? 128 : 255;
|
||||
p.setPen(QColor(0, 0, 0, alpha));
|
||||
p.setBrush(QColor(160, 160, 160, alpha));
|
||||
p.drawPolygon(points, KEYFRAME_POINT_COUNT);
|
||||
}
|
||||
|
||||
void KeyframeView::mouseMoveEvent(QMouseEvent* event) {
|
||||
unsetCursor();
|
||||
bool new_mo = false;
|
||||
for (int i=0;i<rowY.size();i++) {
|
||||
if (event->y() > rowY.at(i)-KEYFRAME_SIZE-KEYFRAME_SIZE && event->y() < rowY.at(i)+KEYFRAME_SIZE+KEYFRAME_SIZE) {
|
||||
setCursor(Qt::CrossCursor);
|
||||
mouseover_frame = getFrameFromScreenPoint(panel_effect_controls->zoom, event->x()) + visible_in;
|
||||
mouseover_row = i;
|
||||
new_mo = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (new_mo || (new_mo != mouseover)) {
|
||||
update();
|
||||
}
|
||||
mouseover = new_mo;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef KEYFRAMEVIEW_H
|
||||
#define KEYFRAMEVIEW_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QPainter>
|
||||
|
||||
struct Clip;
|
||||
class Effect;
|
||||
class EffectRow;
|
||||
|
||||
class KeyframeView : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
KeyframeView(QWidget* parent = 0);
|
||||
QVector<Effect*> effects;
|
||||
|
||||
long visible_in;
|
||||
long visible_out;
|
||||
public slots:
|
||||
void reload();
|
||||
private:
|
||||
QVector<int> rowY;
|
||||
QVector<EffectRow*> rows;
|
||||
void mouseMoveEvent(QMouseEvent* event);
|
||||
/*void mousePressEvent(QMouseEvent* event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);*/
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void draw_keyframe(QPainter& p, int x, int y, bool semiTransparent);
|
||||
bool enable_reload;
|
||||
bool mouseover;
|
||||
long mouseover_frame;
|
||||
int mouseover_row;
|
||||
};
|
||||
|
||||
#endif // KEYFRAMEVIEW_H
|
||||
+21
-11
@@ -12,18 +12,23 @@
|
||||
#define CLICK_RANGE 5
|
||||
#define PLAYHEAD_SIZE 6
|
||||
|
||||
TimelineHeader::TimelineHeader(QWidget *parent) : QWidget(parent), dragging(false), resizing_workarea(false) {
|
||||
TimelineHeader::TimelineHeader(QWidget *parent) : QWidget(parent), dragging(false), resizing_workarea(false), zoom(1), in_visible(0), snapping(true) {
|
||||
setCursor(Qt::ArrowCursor);
|
||||
setMouseTracking(true);
|
||||
}
|
||||
|
||||
void set_playhead(int mouse_x) {
|
||||
long frame = panel_timeline->getFrameFromScreenPoint(mouse_x);
|
||||
panel_timeline->snap_to_clip(&frame, false);
|
||||
void TimelineHeader::set_playhead(int mouse_x) {
|
||||
long frame = getFrameFromScreenPoint(zoom, mouse_x);
|
||||
if (snapping) panel_timeline->snap_to_clip(&frame, false);
|
||||
panel_timeline->seek(frame);
|
||||
panel_timeline->repaint_timeline();
|
||||
}
|
||||
|
||||
void TimelineHeader::set_visible_in(long i) {
|
||||
in_visible = i;
|
||||
update();
|
||||
}
|
||||
|
||||
void TimelineHeader::set_in_point(long new_in) {
|
||||
long new_out = sequence->workarea_out;
|
||||
if (new_out == new_in) {
|
||||
@@ -66,7 +71,7 @@ void TimelineHeader::mousePressEvent(QMouseEvent* event) {
|
||||
void TimelineHeader::mouseMoveEvent(QMouseEvent* event) {
|
||||
if (dragging) {
|
||||
if (resizing_workarea) {
|
||||
long frame = panel_timeline->getFrameFromScreenPoint(event->pos().x());
|
||||
long frame = getFrameFromScreenPoint(zoom, event->pos().x());
|
||||
panel_timeline->snap_to_clip(&frame, true);
|
||||
if (resizing_workarea_in) {
|
||||
temp_workarea_in = qMax(qMin(temp_workarea_out-1, frame), 0L);
|
||||
@@ -81,8 +86,8 @@ void TimelineHeader::mouseMoveEvent(QMouseEvent* event) {
|
||||
resizing_workarea = false;
|
||||
unsetCursor();
|
||||
if (sequence->using_workarea) {
|
||||
long min_frame = panel_timeline->getFrameFromScreenPoint(event->pos().x() - CLICK_RANGE) - 1;
|
||||
long max_frame = panel_timeline->getFrameFromScreenPoint(event->pos().x() + CLICK_RANGE) + 1;
|
||||
long min_frame = getFrameFromScreenPoint(zoom, event->pos().x() - CLICK_RANGE) - 1;
|
||||
long max_frame = getFrameFromScreenPoint(zoom, event->pos().x() + CLICK_RANGE) + 1;
|
||||
if (sequence->workarea_in > min_frame && sequence->workarea_in < max_frame) {
|
||||
resizing_workarea = true;
|
||||
resizing_workarea_in = true;
|
||||
@@ -112,6 +117,11 @@ void TimelineHeader::mouseReleaseEvent(QMouseEvent*) {
|
||||
panel_timeline->repaint_timeline();
|
||||
}
|
||||
|
||||
void TimelineHeader::update_header(double z) {
|
||||
zoom = z;
|
||||
update();
|
||||
}
|
||||
|
||||
void TimelineHeader::paintEvent(QPaintEvent*) {
|
||||
if (sequence != NULL) {
|
||||
QPainter p(this);
|
||||
@@ -120,7 +130,7 @@ void TimelineHeader::paintEvent(QPaintEvent*) {
|
||||
int multiplier = 0;
|
||||
do {
|
||||
multiplier++;
|
||||
interval = panel_timeline->getScreenPointFromFrame(sequence->frame_rate*multiplier);
|
||||
interval = getScreenPointFromFrame(zoom, sequence->frame_rate*multiplier);
|
||||
} while (interval < 10);
|
||||
for (int i=0;i<width();i+=interval) {
|
||||
p.drawLine(i, 0, i, height());
|
||||
@@ -129,8 +139,8 @@ void TimelineHeader::paintEvent(QPaintEvent*) {
|
||||
// draw in/out selection
|
||||
int in_x;
|
||||
if (sequence->using_workarea) {
|
||||
in_x = panel_timeline->getScreenPointFromFrame(resizing_workarea ? temp_workarea_in : sequence->workarea_in);
|
||||
int out_x = panel_timeline->getScreenPointFromFrame(resizing_workarea ? temp_workarea_out :sequence->workarea_out);
|
||||
in_x = getScreenPointFromFrame(zoom, resizing_workarea ? temp_workarea_in : sequence->workarea_in);
|
||||
int out_x = getScreenPointFromFrame(zoom, resizing_workarea ? temp_workarea_out :sequence->workarea_out);
|
||||
p.fillRect(QRect(in_x, 0, out_x-in_x, height()), QColor(0, 192, 255, 128));
|
||||
p.setPen(Qt::white);
|
||||
p.drawLine(in_x, 0, in_x, height());
|
||||
@@ -138,7 +148,7 @@ void TimelineHeader::paintEvent(QPaintEvent*) {
|
||||
}
|
||||
|
||||
// draw playhead triangle
|
||||
in_x = panel_timeline->getScreenPointFromFrame(panel_timeline->playhead);
|
||||
in_x = getScreenPointFromFrame(zoom, panel_timeline->playhead - in_visible);
|
||||
QPoint start(in_x, height());
|
||||
QPainterPath path;
|
||||
path.moveTo(start);
|
||||
|
||||
+12
-1
@@ -7,9 +7,14 @@ class TimelineHeader : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TimelineHeader(QWidget *parent = 0);
|
||||
explicit TimelineHeader(QWidget *parent = 0);
|
||||
void set_in_point(long p);
|
||||
void set_out_point(long p);
|
||||
void set_visible_in(long i);
|
||||
|
||||
bool snapping;
|
||||
|
||||
void update_header(double z);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent*);
|
||||
@@ -26,6 +31,12 @@ private:
|
||||
long temp_workarea_out;
|
||||
long sequence_end;
|
||||
|
||||
long in_visible;
|
||||
|
||||
double zoom;
|
||||
|
||||
void set_playhead(int mouse_x);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
+25
-25
@@ -11,7 +11,7 @@
|
||||
#include "panels/effectcontrols.h"
|
||||
#include "project/undo.h"
|
||||
|
||||
#include "effects/effects.h"
|
||||
#include "effects/effect.h"
|
||||
#include "effects/transition.h"
|
||||
|
||||
#include <QPainter>
|
||||
@@ -123,8 +123,8 @@ void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) {
|
||||
if (got_video_values && got_audio_values) break;
|
||||
}
|
||||
} else {
|
||||
entry_point = panel_timeline->getFrameFromScreenPoint(pos.x());
|
||||
panel_timeline->drag_frame_start = entry_point + panel_timeline->getFrameFromScreenPoint(50);
|
||||
entry_point = panel_timeline->getTimelineFrameFromScreenPoint(pos.x());
|
||||
panel_timeline->drag_frame_start = entry_point + panel_timeline->getTimelineFrameFromScreenPoint(50);
|
||||
panel_timeline->drag_track_start = (bottom_align) ? -1 : 0;
|
||||
predicted_new_frame_rate = sequence->frame_rate;
|
||||
}
|
||||
@@ -369,7 +369,7 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) {
|
||||
panel_timeline->drag_track_start = panel_timeline->cursor_track;
|
||||
} else {
|
||||
QPoint pos = event->pos();
|
||||
panel_timeline->drag_frame_start = panel_timeline->getFrameFromScreenPoint(pos.x());
|
||||
panel_timeline->drag_frame_start = panel_timeline->getTimelineFrameFromScreenPoint(pos.x());
|
||||
panel_timeline->drag_track_start = getTrackFromScreenPoint(pos.y());
|
||||
}
|
||||
|
||||
@@ -867,7 +867,7 @@ void validate_snapping(const Ghost& g, long* frame_diff) {
|
||||
|
||||
void TimelineWidget::update_ghosts(QPoint& mouse_pos) {
|
||||
int mouse_track = getTrackFromScreenPoint(mouse_pos.y());
|
||||
long frame_diff = panel_timeline->getFrameFromScreenPoint(mouse_pos.x()) - panel_timeline->drag_frame_start;
|
||||
long frame_diff = panel_timeline->getTimelineFrameFromScreenPoint(mouse_pos.x()) - panel_timeline->drag_frame_start;
|
||||
int track_diff = (panel_timeline->tool == TIMELINE_TOOL_SLIDE || panel_timeline->transition_select != TA_NO_TRANSITION) ? 0 : mouse_track - panel_timeline->drag_track_start;
|
||||
long validator;
|
||||
|
||||
@@ -1073,7 +1073,7 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||
if (sequence != NULL) {
|
||||
bool alt = (event->modifiers() & Qt::AltModifier);
|
||||
|
||||
panel_timeline->cursor_frame = panel_timeline->getFrameFromScreenPoint(event->pos().x());
|
||||
panel_timeline->cursor_frame = panel_timeline->getTimelineFrameFromScreenPoint(event->pos().x());
|
||||
panel_timeline->cursor_track = getTrackFromScreenPoint(event->pos().y());
|
||||
|
||||
if (panel_timeline->tool == TIMELINE_TOOL_EDIT || panel_timeline->tool == TIMELINE_TOOL_RAZOR) {
|
||||
@@ -1359,8 +1359,8 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||
panel_timeline->rect_select_h = event->pos().y() - panel_timeline->rect_select_y;
|
||||
if (bottom_align) panel_timeline->rect_select_h -= height();
|
||||
|
||||
long frame_start = panel_timeline->getFrameFromScreenPoint(panel_timeline->rect_select_x);
|
||||
long frame_end = panel_timeline->getFrameFromScreenPoint(event->pos().x());
|
||||
long frame_start = panel_timeline->getTimelineFrameFromScreenPoint(panel_timeline->rect_select_x);
|
||||
long frame_end = panel_timeline->getTimelineFrameFromScreenPoint(event->pos().x());
|
||||
long frame_min = qMin(frame_start, frame_end);
|
||||
long frame_max = qMax(frame_start, frame_end);
|
||||
|
||||
@@ -1432,8 +1432,8 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||
|
||||
int lim = 5;
|
||||
int mouse_track = getTrackFromScreenPoint(pos.y());
|
||||
long mouse_frame_lower = panel_timeline->getFrameFromScreenPoint(pos.x()-lim)-1;
|
||||
long mouse_frame_upper = panel_timeline->getFrameFromScreenPoint(pos.x()+lim)+1;
|
||||
long mouse_frame_lower = panel_timeline->getTimelineFrameFromScreenPoint(pos.x()-lim)-1;
|
||||
long mouse_frame_upper = panel_timeline->getTimelineFrameFromScreenPoint(pos.x()+lim)+1;
|
||||
bool found = false;
|
||||
bool cursor_contains_clip = false;
|
||||
int closeness = INT_MAX;
|
||||
@@ -1563,7 +1563,7 @@ void TimelineWidget::redraw_clips() {
|
||||
audio_track_limit = qMax(audio_track_limit, clip->track);
|
||||
}
|
||||
}
|
||||
int panel_width = panel_timeline->getScreenPointFromFrame(end_frame) + 100;
|
||||
int panel_width = panel_timeline->getTimelineScreenPointFromFrame(end_frame) + 100;
|
||||
int panel_height = 0;
|
||||
if (bottom_align) {
|
||||
for (int i=-1;i>=video_track_limit;i--) {
|
||||
@@ -1589,7 +1589,7 @@ void TimelineWidget::redraw_clips() {
|
||||
for (int i=0;i<sequence->clip_count();i++) {
|
||||
Clip* clip = sequence->get_clip(i);
|
||||
if (clip != NULL && is_track_visible(clip->track)) {
|
||||
QRect clip_rect(panel_timeline->getScreenPointFromFrame(clip->timeline_in), getScreenPointFromTrack(clip->track), clip->getLength() * panel_timeline->zoom, panel_timeline->calculate_track_height(clip->track, -1));
|
||||
QRect clip_rect(panel_timeline->getTimelineScreenPointFromFrame(clip->timeline_in), getScreenPointFromTrack(clip->track), clip->getLength() * panel_timeline->zoom, panel_timeline->calculate_track_height(clip->track, -1));
|
||||
clip_painter.fillRect(clip_rect, QColor(clip->color_r, clip->color_g, clip->color_b));
|
||||
|
||||
int thumb_x = clip_rect.x() + 1;
|
||||
@@ -1606,7 +1606,7 @@ void TimelineWidget::redraw_clips() {
|
||||
} else if (ms->preview_done) {
|
||||
// draw thumbnail/waveform
|
||||
long media_length = m->get_length_in_frames(clip->sequence->frame_rate);
|
||||
int waveform_limit = qMin(clip_rect.width(), panel_timeline->getScreenPointFromFrame(media_length - clip->clip_in));
|
||||
int waveform_limit = qMin(clip_rect.width(), panel_timeline->getTimelineScreenPointFromFrame(media_length - clip->clip_in));
|
||||
|
||||
if (waveform_limit < clip_rect.width()) {
|
||||
draw_checkerboard = true;
|
||||
@@ -1616,12 +1616,12 @@ void TimelineWidget::redraw_clips() {
|
||||
if (clip->track < 0) {
|
||||
int space_for_thumb = clip_rect.width();
|
||||
if (clip->opening_transition != NULL) {
|
||||
int ot_width = panel_timeline->getScreenPointFromFrame(clip->opening_transition->length);
|
||||
int ot_width = panel_timeline->getTimelineScreenPointFromFrame(clip->opening_transition->length);
|
||||
thumb_x += ot_width;
|
||||
space_for_thumb -= ot_width;
|
||||
}
|
||||
if (clip->closing_transition != NULL) {
|
||||
space_for_thumb -= panel_timeline->getScreenPointFromFrame(clip->closing_transition->length);
|
||||
space_for_thumb -= panel_timeline->getTimelineScreenPointFromFrame(clip->closing_transition->length);
|
||||
}
|
||||
int thumb_y = clip_painter.fontMetrics().height()+CLIP_TEXT_PADDING+CLIP_TEXT_PADDING;
|
||||
int thumb_height = clip_rect.height()-thumb_y;
|
||||
@@ -1688,7 +1688,7 @@ void TimelineWidget::redraw_clips() {
|
||||
for (int i=0;i<2;i++) {
|
||||
Transition* t = (i == 0) ? clip->opening_transition : clip->closing_transition;
|
||||
if (t != NULL) {
|
||||
int transition_width = panel_timeline->getScreenPointFromFrame(t->length);
|
||||
int transition_width = panel_timeline->getTimelineScreenPointFromFrame(t->length);
|
||||
int transition_height = clip_rect.height();
|
||||
int tr_y = clip_rect.y();
|
||||
int tr_x = 0;
|
||||
@@ -1780,8 +1780,8 @@ void TimelineWidget::paintEvent(QPaintEvent*) {
|
||||
const Selection& s = panel_timeline->selections.at(i);
|
||||
if (is_track_visible(s.track)) {
|
||||
int selection_y = getScreenPointFromTrack(s.track);
|
||||
int selection_x = panel_timeline->getScreenPointFromFrame(s.in);
|
||||
p.fillRect(selection_x, selection_y, panel_timeline->getScreenPointFromFrame(s.out) - selection_x, panel_timeline->calculate_track_height(s.track, -1), QColor(0, 0, 0, 64));
|
||||
int selection_x = panel_timeline->getTimelineScreenPointFromFrame(s.in);
|
||||
p.fillRect(selection_x, selection_y, panel_timeline->getTimelineScreenPointFromFrame(s.out) - selection_x, panel_timeline->calculate_track_height(s.track, -1), QColor(0, 0, 0, 64));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1802,9 +1802,9 @@ void TimelineWidget::paintEvent(QPaintEvent*) {
|
||||
for (int i=0;i<panel_timeline->ghosts.size();i++) {
|
||||
const Ghost& g = panel_timeline->ghosts.at(i);
|
||||
if (is_track_visible(g.track)) {
|
||||
int ghost_x = panel_timeline->getScreenPointFromFrame(g.in);
|
||||
int ghost_x = panel_timeline->getTimelineScreenPointFromFrame(g.in);
|
||||
int ghost_y = getScreenPointFromTrack(g.track);
|
||||
int ghost_width = panel_timeline->getScreenPointFromFrame(g.out - g.in) - 1;
|
||||
int ghost_width = panel_timeline->getTimelineScreenPointFromFrame(g.out - g.in) - 1;
|
||||
int ghost_height = panel_timeline->calculate_track_height(g.track, -1) - 1;
|
||||
p.setPen(QColor(255, 255, 0));
|
||||
for (int j=0;j<GHOST_THICKNESS;j++) {
|
||||
@@ -1817,7 +1817,7 @@ void TimelineWidget::paintEvent(QPaintEvent*) {
|
||||
if (panel_timeline->splitting) {
|
||||
for (int i=0;i<panel_timeline->split_tracks.size();i++) {
|
||||
if (is_track_visible(panel_timeline->split_tracks.at(i))) {
|
||||
int cursor_x = panel_timeline->getScreenPointFromFrame(panel_timeline->drag_frame_start);
|
||||
int cursor_x = panel_timeline->getTimelineScreenPointFromFrame(panel_timeline->drag_frame_start);
|
||||
int cursor_y = getScreenPointFromTrack(panel_timeline->split_tracks.at(i));
|
||||
|
||||
p.setPen(QColor(64, 64, 64));
|
||||
@@ -1828,7 +1828,7 @@ void TimelineWidget::paintEvent(QPaintEvent*) {
|
||||
|
||||
// Draw playhead
|
||||
p.setPen(Qt::red);
|
||||
int playhead_x = panel_timeline->getScreenPointFromFrame(panel_timeline->playhead);
|
||||
int playhead_x = panel_timeline->getTimelineScreenPointFromFrame(panel_timeline->playhead);
|
||||
p.drawLine(playhead_x, rect().top(), playhead_x, rect().bottom());
|
||||
|
||||
// draw border
|
||||
@@ -1839,15 +1839,15 @@ void TimelineWidget::paintEvent(QPaintEvent*) {
|
||||
// draw snap point
|
||||
if (panel_timeline->snapped) {
|
||||
p.setPen(Qt::white);
|
||||
int snap_x = panel_timeline->getScreenPointFromFrame(panel_timeline->snap_point);
|
||||
int snap_x = panel_timeline->getTimelineScreenPointFromFrame(panel_timeline->snap_point);
|
||||
p.drawLine(snap_x, 0, snap_x, height());
|
||||
}
|
||||
|
||||
// Draw edit cursor
|
||||
if (panel_timeline->tool == TIMELINE_TOOL_EDIT || panel_timeline->tool == TIMELINE_TOOL_RAZOR) {
|
||||
if (is_track_visible(panel_timeline->cursor_track)) {
|
||||
int cursor_x = panel_timeline->getScreenPointFromFrame(panel_timeline->cursor_frame);
|
||||
int cursor_y = getScreenPointFromTrack(panel_timeline->cursor_track);
|
||||
int cursor_x = panel_timeline->getTimelineScreenPointFromFrame(panel_timeline->cursor_frame);
|
||||
int cursor_y = getScreenPointFromTrack(panel_timeline->cursor_track);
|
||||
|
||||
p.setPen(Qt::gray);
|
||||
p.drawLine(cursor_x, cursor_y, cursor_x, cursor_y + panel_timeline->calculate_track_height(panel_timeline->cursor_track, -1));
|
||||
|
||||
+24
-9
@@ -15,6 +15,7 @@
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QAudioOutput>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <QtMath>
|
||||
|
||||
extern "C" {
|
||||
@@ -171,18 +172,34 @@ void ViewerWidget::compose_sequence(QVector<Clip*>& nests, bool render_audio) {
|
||||
if (flip) half_height = -half_height;
|
||||
glOrtho(-half_width, half_width, half_height, -half_height, -1, 1);
|
||||
int anchor_x = ms->video_width/2;
|
||||
int anchor_y = ms->video_height/2;
|
||||
int anchor_y = ms->video_height/2;
|
||||
|
||||
// perform all transform effects
|
||||
c->run_video_pre_effect_stack(playhead, &anchor_x, &anchor_y);
|
||||
QOpenGLShaderProgram shader;
|
||||
|
||||
for (int i=nests.size()-1;i>=0;i--) {
|
||||
nests.at(i)->run_video_pre_effect_stack(playhead, &anchor_x, &anchor_y);
|
||||
for (int j=0;j<c->effects.size();j++) {
|
||||
if (c->effects.at(j)->enable_opengl && c->effects.at(j)->is_enabled()) c->effects.at(j)->process_gl(shader, &anchor_x, &anchor_y);
|
||||
}
|
||||
|
||||
if (c->opening_transition != NULL) {
|
||||
int transition_progress = playhead - c->timeline_in;
|
||||
if (transition_progress < c->opening_transition->length) {
|
||||
c->opening_transition->process_transition((double)transition_progress/(double)c->opening_transition->length);
|
||||
}
|
||||
}
|
||||
|
||||
if (c->closing_transition != NULL) {
|
||||
int transition_progress = c->closing_transition->length - (playhead - c->timeline_in - c->getLength() + c->closing_transition->length);
|
||||
if (transition_progress < c->closing_transition->length) {
|
||||
c->closing_transition->process_transition((double)transition_progress/(double)c->closing_transition->length);
|
||||
}
|
||||
}
|
||||
|
||||
int anchor_right = ms->video_width - anchor_x;
|
||||
int anchor_bottom = ms->video_height - anchor_y;
|
||||
|
||||
bool use_gl_shaders = shader.link();
|
||||
if (use_gl_shaders) shader.bind();
|
||||
|
||||
c->texture->bind();
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
@@ -196,10 +213,9 @@ void ViewerWidget::compose_sequence(QVector<Clip*>& nests, bool render_audio) {
|
||||
glVertex2f(-anchor_x, anchor_bottom);
|
||||
glEnd();
|
||||
|
||||
c->texture->release();
|
||||
c->texture->release();
|
||||
|
||||
// perform all transform effects
|
||||
c->run_video_post_effect_stack();
|
||||
if (use_gl_shaders) shader.release();
|
||||
}
|
||||
} else if (render_audio &&
|
||||
c->stream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
|
||||
@@ -212,7 +228,6 @@ void ViewerWidget::compose_sequence(QVector<Clip*>& nests, bool render_audio) {
|
||||
case MEDIA_TYPE_SEQUENCE:
|
||||
nests.append(c);
|
||||
compose_sequence(nests, render_audio);
|
||||
c->run_video_post_effect_stack();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user