added playhead header
This commit is contained in:
@@ -51,7 +51,8 @@ SOURCES += \
|
||||
project/effect.cpp \
|
||||
effects/effects.cpp \
|
||||
playback/cacher.cpp \
|
||||
io/exportthread.cpp
|
||||
io/exportthread.cpp \
|
||||
ui/timelineheader.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
@@ -78,7 +79,8 @@ HEADERS += \
|
||||
panels/panels.h \
|
||||
playback/cacher.h \
|
||||
io/exportthread.h \
|
||||
ui/timelinetools.h
|
||||
ui/timelinetools.h \
|
||||
ui/timelineheader.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui \
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.6.1, 2018-06-07T21:15:23. -->
|
||||
<!-- Written by QtCreator 4.6.1, 2018-06-08T12:56:41. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
||||
+18
-6
@@ -41,7 +41,7 @@ Timeline::Timeline(QWidget *parent) :
|
||||
sequence = NULL;
|
||||
set_sequence(NULL);
|
||||
|
||||
connect(&playback_updater, SIGNAL(timeout()), this, SLOT(repaint_timeline()));
|
||||
connect(&playback_updater, SIGNAL(timeout()), this, SLOT(repaint_timeline()));
|
||||
}
|
||||
|
||||
Timeline::~Timeline()
|
||||
@@ -87,8 +87,7 @@ bool Timeline::toggle_play() {
|
||||
}
|
||||
|
||||
void Timeline::play() {
|
||||
playhead_start = playhead;
|
||||
playback_timer.start();
|
||||
playhead_start = playhead;
|
||||
start_msecs = QDateTime::currentMSecsSinceEpoch();
|
||||
playback_updater.start();
|
||||
playing = true;
|
||||
@@ -121,6 +120,7 @@ void Timeline::set_sequence(Sequence *s) {
|
||||
}
|
||||
ui->pushButton_4->setEnabled(!null_sequence);
|
||||
ui->pushButton_5->setEnabled(!null_sequence);
|
||||
ui->headers->setEnabled(!null_sequence);
|
||||
ui->video_area->setEnabled(!null_sequence);
|
||||
ui->audio_area->setEnabled(!null_sequence);
|
||||
|
||||
@@ -134,7 +134,7 @@ void Timeline::set_sequence(Sequence *s) {
|
||||
}
|
||||
|
||||
bool Timeline::focused() {
|
||||
return (ui->video_area->hasFocus() || ui->audio_area->hasFocus());
|
||||
return (ui->headers->hasFocus() || ui->video_area->hasFocus() || ui->audio_area->hasFocus());
|
||||
}
|
||||
|
||||
void Timeline::undo() {
|
||||
@@ -154,10 +154,10 @@ void Timeline::redo() {
|
||||
}
|
||||
|
||||
void Timeline::repaint_timeline() {
|
||||
if (playing) {
|
||||
// playhead = playhead_start + (playback_timer.elapsed() * 0.001 * sequence->frame_rate);
|
||||
if (playing) {
|
||||
playhead = round(playhead_start + ((QDateTime::currentMSecsSinceEpoch()-start_msecs) * 0.001 * sequence->frame_rate));
|
||||
}
|
||||
ui->headers->update();
|
||||
ui->video_area->update();
|
||||
ui->audio_area->update();
|
||||
if (last_frame != playhead) {
|
||||
@@ -379,3 +379,15 @@ void Timeline::split_at_playhead() {
|
||||
|
||||
if (split_selected) redraw_all_clips();
|
||||
}
|
||||
|
||||
long Timeline::getFrameFromScreenPoint(int x) {
|
||||
long f = round((float) x / zoom);
|
||||
if (f < 0) {
|
||||
return 0;
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
int Timeline::getScreenPointFromFrame(long frame) {
|
||||
return (int) round(frame*zoom);
|
||||
}
|
||||
|
||||
+3
-1
@@ -66,6 +66,9 @@ public:
|
||||
void split_at_playhead();
|
||||
void set_sequence(Sequence* s);
|
||||
|
||||
int getScreenPointFromFrame(long frame);
|
||||
long getFrameFromScreenPoint(int x);
|
||||
|
||||
Sequence* sequence;
|
||||
long playhead;
|
||||
|
||||
@@ -81,7 +84,6 @@ public:
|
||||
bool playing;
|
||||
long playhead_start;
|
||||
qint64 start_msecs;
|
||||
QTime playback_timer;
|
||||
QTimer playback_updater;
|
||||
|
||||
// shared information
|
||||
|
||||
+23
-4
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>840</width>
|
||||
<height>535</height>
|
||||
<width>523</width>
|
||||
<height>227</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -312,11 +312,14 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>796</width>
|
||||
<height>506</height>
|
||||
<width>479</width>
|
||||
<height>198</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@@ -329,6 +332,16 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="TimelineHeader" name="headers" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>15</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
@@ -372,6 +385,12 @@
|
||||
<header>ui/timelinewidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>TimelineHeader</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>ui/timelineheader.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../icons/icons.qrc"/>
|
||||
|
||||
@@ -114,8 +114,12 @@ void Sequence::split_clip(int i, long frame) {
|
||||
}
|
||||
|
||||
void Sequence::undo_add_current() {
|
||||
undo_pointer++;
|
||||
undo_stack.resize(undo_pointer);
|
||||
if (undo_stack.size() == UNDO_LIMIT) {
|
||||
undo_stack.removeFirst();
|
||||
} else {
|
||||
undo_pointer++;
|
||||
undo_stack.resize(undo_pointer);
|
||||
}
|
||||
undo_stack.append(clips);
|
||||
}
|
||||
|
||||
|
||||
+17
-33
@@ -42,8 +42,8 @@ void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) {
|
||||
QPoint pos = event->pos();
|
||||
event->accept();
|
||||
QList<QTreeWidgetItem*> items = panel_project->source_table->selectedItems();
|
||||
long entry_point = getFrameFromScreenPoint(pos.x(), false);
|
||||
panel_timeline->drag_frame_start = entry_point + getFrameFromScreenPoint(50, false);
|
||||
long entry_point = panel_timeline->getFrameFromScreenPoint(pos.x());
|
||||
panel_timeline->drag_frame_start = entry_point + panel_timeline->getFrameFromScreenPoint(50);
|
||||
panel_timeline->drag_track_start = (bottom_align) ? -1 : 0;
|
||||
for (int i=0;i<items.size();i++) {
|
||||
bool ignore_infinite_length = false;
|
||||
@@ -133,7 +133,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 = getFrameFromScreenPoint(pos.x(), false);
|
||||
panel_timeline->drag_frame_start = panel_timeline->getFrameFromScreenPoint(pos.x());
|
||||
panel_timeline->drag_track_start = getTrackFromScreenPoint(pos.y());
|
||||
}
|
||||
|
||||
@@ -347,7 +347,7 @@ void validate_snapping(Ghost& g, long* frame_diff) {
|
||||
|
||||
void TimelineWidget::update_ghosts(QPoint& mouse_pos) {
|
||||
int mouse_track = getTrackFromScreenPoint(mouse_pos.y());
|
||||
long frame_diff = getFrameFromScreenPoint(mouse_pos.x(), false) - panel_timeline->drag_frame_start;
|
||||
long frame_diff = panel_timeline->getFrameFromScreenPoint(mouse_pos.x()) - panel_timeline->drag_frame_start;
|
||||
int track_diff = mouse_track - panel_timeline->drag_track_start;
|
||||
|
||||
long validator;
|
||||
@@ -511,10 +511,10 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) {
|
||||
|
||||
void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||
if (panel_timeline->tool == TIMELINE_TOOL_EDIT || panel_timeline->tool == TIMELINE_TOOL_RAZOR) {
|
||||
panel_timeline->cursor_frame = getFrameFromScreenPoint(event->pos().x(), false);
|
||||
panel_timeline->cursor_frame = panel_timeline->getFrameFromScreenPoint(event->pos().x());
|
||||
panel_timeline->cursor_track = getTrackFromScreenPoint(event->pos().y());
|
||||
|
||||
int limit = getFrameFromScreenPoint(10, false);
|
||||
int limit = panel_timeline->getFrameFromScreenPoint(10);
|
||||
if (panel_timeline->snapping && panel_timeline->cursor_frame > panel_timeline->playhead-limit-1 && panel_timeline->cursor_frame < panel_timeline->playhead+limit+1) {
|
||||
panel_timeline->cursor_frame = panel_timeline->playhead;
|
||||
}
|
||||
@@ -634,8 +634,8 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||
|
||||
int lim = 5;
|
||||
int mouse_track = getTrackFromScreenPoint(pos.y());
|
||||
long mouse_frame_lower = getFrameFromScreenPoint(pos.x()-lim, false)-1;
|
||||
long mouse_frame_upper = getFrameFromScreenPoint(pos.x()+lim, false)+1;
|
||||
long mouse_frame_lower = panel_timeline->getFrameFromScreenPoint(pos.x()-lim)-1;
|
||||
long mouse_frame_upper = panel_timeline->getFrameFromScreenPoint(pos.x()+lim)+1;
|
||||
bool found = false;
|
||||
for (int i=0;i<panel_timeline->sequence->clip_count();i++) {
|
||||
Clip& c = panel_timeline->sequence->get_clip(i);
|
||||
@@ -671,7 +671,7 @@ int color_brightness(int r, int g, int b) {
|
||||
|
||||
void TimelineWidget::redraw_clips() {
|
||||
// Draw clips
|
||||
int panel_width = getScreenPointFromFrame(panel_timeline->sequence->getEndFrame()) + 100;
|
||||
int panel_width = panel_timeline->getScreenPointFromFrame(panel_timeline->sequence->getEndFrame()) + 100;
|
||||
setMinimumWidth(panel_width);
|
||||
|
||||
clip_pixmap = QPixmap(panel_width, height());
|
||||
@@ -688,7 +688,7 @@ void TimelineWidget::redraw_clips() {
|
||||
audio_track_limit = clip.track;
|
||||
}
|
||||
|
||||
QRect clip_rect(getScreenPointFromFrame(clip.timeline_in), getScreenPointFromTrack(clip.track), clip.getLength() * panel_timeline->zoom, track_height);
|
||||
QRect clip_rect(panel_timeline->getScreenPointFromFrame(clip.timeline_in), getScreenPointFromTrack(clip.track), clip.getLength() * panel_timeline->zoom, track_height);
|
||||
clip_painter.fillRect(clip_rect, QColor(clip.color_r, clip.color_g, clip.color_b));
|
||||
clip_painter.setPen(Qt::white);
|
||||
clip_painter.drawLine(clip_rect.bottomLeft(), clip_rect.topLeft());
|
||||
@@ -742,8 +742,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 = getScreenPointFromFrame(s.in);
|
||||
p.fillRect(selection_x, selection_y, getScreenPointFromFrame(s.out) - selection_x, track_height, QColor(0, 0, 0, 64));
|
||||
int selection_x = panel_timeline->getScreenPointFromFrame(s.in);
|
||||
p.fillRect(selection_x, selection_y, panel_timeline->getScreenPointFromFrame(s.out) - selection_x, track_height, QColor(0, 0, 0, 64));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -751,9 +751,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 = getScreenPointFromFrame(g.in);
|
||||
int ghost_x = panel_timeline->getScreenPointFromFrame(g.in);
|
||||
int ghost_y = getScreenPointFromTrack(g.track);
|
||||
int ghost_width = getScreenPointFromFrame(g.out - g.in) - 1;
|
||||
int ghost_width = panel_timeline->getScreenPointFromFrame(g.out - g.in) - 1;
|
||||
int ghost_height = track_height - 1;
|
||||
p.setPen(QColor(255, 255, 0));
|
||||
for (int j=0;j<GHOST_THICKNESS;j++) {
|
||||
@@ -764,7 +764,7 @@ void TimelineWidget::paintEvent(QPaintEvent*) {
|
||||
|
||||
// Draw playhead
|
||||
p.setPen(Qt::red);
|
||||
int playhead_x = getScreenPointFromFrame(panel_timeline->playhead);
|
||||
int playhead_x = panel_timeline->getScreenPointFromFrame(panel_timeline->playhead);
|
||||
p.drawLine(playhead_x, rect().top(), playhead_x, rect().bottom());
|
||||
|
||||
p.setPen(QColor(0, 0, 0, 64));
|
||||
@@ -774,14 +774,14 @@ void TimelineWidget::paintEvent(QPaintEvent*) {
|
||||
// draw snap point
|
||||
if (panel_timeline->snapping && panel_timeline->snapped) {
|
||||
p.setPen(Qt::white);
|
||||
int snap_x = getScreenPointFromFrame(panel_timeline->snap_point);
|
||||
int snap_x = panel_timeline->getScreenPointFromFrame(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 = getScreenPointFromFrame(panel_timeline->cursor_frame);
|
||||
int cursor_x = panel_timeline->getScreenPointFromFrame(panel_timeline->cursor_frame);
|
||||
int cursor_y = getScreenPointFromTrack(panel_timeline->cursor_track);
|
||||
|
||||
p.setPen(Qt::gray);
|
||||
@@ -799,18 +799,6 @@ bool TimelineWidget::is_track_visible(int track) {
|
||||
// screen point <-> frame/track functions
|
||||
// **************************************
|
||||
|
||||
long TimelineWidget::getFrameFromScreenPoint(int x, bool f) {
|
||||
float div = (float) x / panel_timeline->zoom;
|
||||
if (div < 0) {
|
||||
return 0;
|
||||
}
|
||||
if (f) {
|
||||
return floor(div);
|
||||
} else {
|
||||
return round(div);
|
||||
}
|
||||
}
|
||||
|
||||
int TimelineWidget::getTrackFromScreenPoint(int y) {
|
||||
if (bottom_align) {
|
||||
y -= rect().bottom();
|
||||
@@ -823,10 +811,6 @@ int TimelineWidget::getTrackFromScreenPoint(int y) {
|
||||
return (int)floor((float) (y)/ (float) temp_track_height);
|
||||
}
|
||||
|
||||
int TimelineWidget::getScreenPointFromFrame(long frame) {
|
||||
return (int) round(frame*panel_timeline->zoom);
|
||||
}
|
||||
|
||||
int TimelineWidget::getScreenPointFromTrack(int track) {
|
||||
int temp_track_height = track_height;
|
||||
if (show_track_lines) temp_track_height++;
|
||||
|
||||
+2
-4
@@ -35,10 +35,8 @@ protected:
|
||||
private:
|
||||
void init_ghosts();
|
||||
void update_ghosts(QPoint& mouse_pos);
|
||||
bool is_track_visible(int track);
|
||||
long getFrameFromScreenPoint(int x, bool floor);
|
||||
int getTrackFromScreenPoint(int y);
|
||||
int getScreenPointFromFrame(long frame);
|
||||
bool is_track_visible(int track);
|
||||
int getTrackFromScreenPoint(int y);
|
||||
int getScreenPointFromTrack(int track);
|
||||
int getClipIndexFromCoords(long frame, int track);
|
||||
int track_height;
|
||||
|
||||
Reference in New Issue
Block a user