added playhead header
This commit is contained in:
+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"/>
|
||||
|
||||
Reference in New Issue
Block a user