connect timelines to sequence viewer

This commit is contained in:
itsmattkc
2019-04-03 12:05:54 +11:00
parent 365d96f83e
commit d504ee6302
14 changed files with 115 additions and 34 deletions
+9 -2
View File
@@ -114,9 +114,9 @@ Timeline::Timeline(QWidget *parent) :
toolArrowButton->click();
connect(horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(setScroll(int)));
//connect(videoScrollbar, SIGNAL(valueChanged(int)), video_area, SLOT(setScroll(int)));
//connect(audioScrollbar, SIGNAL(valueChanged(int)), audio_area, SLOT(setScroll(int)));
connect(horizontalScrollBar, SIGNAL(resize_move(double)), this, SLOT(resize_move(double)));
connect(this, SIGNAL(SequenceChanged(SequencePtr)), panel_sequence_viewer, SLOT(set_sequence(SequencePtr)));
connect(this, SIGNAL(visibilityChanged(bool)), this, SLOT(visibility_changed_slot(bool)));
update_sequence();
@@ -1051,6 +1051,13 @@ void Timeline::set_tool() {
}
}
void Timeline::visibility_changed_slot(bool visibility)
{
if (visibility) {
emit SequenceChanged(sequence_);
}
}
void olive::timeline::MultiplyTrackSizesByDPI()
{
kTrackDefaultHeight *= QApplication::desktop()->devicePixelRatio();
+1
View File
@@ -185,6 +185,7 @@ private slots:
void transition_menu_select(QAction*);
void resize_move(double d);
void set_tool();
void visibility_changed_slot(bool visibility);
private:
SequencePtr sequence_;
+2 -2
View File
@@ -53,7 +53,6 @@ public:
Mode mode();
virtual bool focused() override;
bool is_main_sequence();
void set_media(Media *m);
void compose();
void set_playpause_icon(bool play);
@@ -110,6 +109,8 @@ protected:
virtual void resizeEvent(QResizeEvent *event) override;
public slots:
void set_sequence(SequencePtr s);
void play_wake();
void go_to_start();
void go_to_in();
@@ -138,7 +139,6 @@ private slots:
private:
void update_window_title();
void clean_created_seq();
void set_sequence(SequencePtr s);
bool created_sequence;
long cached_end_frame;
QString panel_name;
+4
View File
@@ -209,6 +209,8 @@ void AudioSenderThread::run() {
int AudioSenderThread::send_audio_to_output(qint64 offset, int max) {
// send audio to device
audio_write_lock.lock();
qint64 actual_write = audio_io_device->write(reinterpret_cast<const char*>(audio_ibuffer)+offset, max);
qint64 audio_ibuffer_limit = audio_ibuffer_read + actual_write;
@@ -239,6 +241,8 @@ int AudioSenderThread::send_audio_to_output(qint64 offset, int max) {
audio_ibuffer_read = audio_ibuffer_limit;
audio_write_lock.unlock();
return actual_write;
}
+2 -1
View File
@@ -160,7 +160,8 @@ bool ExportThread::SetupVideo() {
break;
}
break;
default:
break;
}
// Set export to be multithreaded
+2 -2
View File
@@ -119,7 +119,7 @@ QVector<Ghost> olive::timeline::CreateGhostsFromMedia(Sequence *seq,
|| import_data.type() == olive::timeline::kImportBoth) {
for (int j=0;j<m->audio_tracks.size();j++) {
if (m->audio_tracks.at(j).enabled) {
g.track = seq->GetTrackList(Track::kTypeAudio)->First() + j;
g.track = seq->GetTrackList(Track::kTypeAudio)->TrackAt(j);
g.media_stream = m->audio_tracks.at(j).file_index;
ghosts.append(g);
}
@@ -130,7 +130,7 @@ QVector<Ghost> olive::timeline::CreateGhostsFromMedia(Sequence *seq,
|| import_data.type() == olive::timeline::kImportBoth) {
for (int j=0;j<m->video_tracks.size();j++) {
if (m->video_tracks.at(j).enabled) {
g.track = seq->GetTrackList(Track::kTypeVideo)->First() + j;
g.track = seq->GetTrackList(Track::kTypeVideo)->TrackAt(j);
g.media_stream = m->video_tracks.at(j).file_index;
ghosts.append(g);
}
+25
View File
@@ -73,6 +73,31 @@ void Track::set_height(int h)
height_ = qMax(h, olive::timeline::kTrackMinHeight);
}
QString Track::name()
{
if (name_.isEmpty()) {
int display_index = Index() + 1;
switch (type_) {
case kTypeVideo:
return tr("Video %1").arg(display_index);
case kTypeAudio:
return tr("Audio %1").arg(display_index);
case kTypeSubtitle:
return tr("Subtitle %1").arg(display_index);
default:
return tr("Unknown %1").arg(display_index);
}
}
return name_;
}
void Track::SetName(const QString &s)
{
name_ = s;
}
void Track::AddClip(ClipPtr clip)
{
if (clips_.contains(clip)) {
+5
View File
@@ -53,6 +53,9 @@ public:
int height();
void set_height(int h);
QString name();
void SetName(const QString& s);
void AddClip(ClipPtr clip);
int ClipCount();
ClipPtr GetClip(int i);
@@ -105,6 +108,8 @@ private:
bool muted_;
bool soloed_;
bool locked_;
QString name_;
};
#endif // TRACK_H
+5
View File
@@ -31,3 +31,8 @@ ClickableLabel::ClickableLabel(const QString &text, QWidget *parent, Qt::WindowF
void ClickableLabel::mousePressEvent(QMouseEvent *) {
emit clicked();
}
void ClickableLabel::mouseDoubleClickEvent(QMouseEvent *ev)
{
emit double_clicked();
}
+5 -3
View File
@@ -31,11 +31,13 @@
class ClickableLabel : public QLabel {
Q_OBJECT
public:
ClickableLabel(QWidget * parent = 0, Qt::WindowFlags f = 0);
ClickableLabel(const QString & text, QWidget * parent = 0, Qt::WindowFlags f = 0);
void mousePressEvent(QMouseEvent *ev);
ClickableLabel(QWidget * parent = nullptr, Qt::WindowFlags f = nullptr);
ClickableLabel(const QString & text, QWidget * parent = nullptr, Qt::WindowFlags f = nullptr);
virtual void mousePressEvent(QMouseEvent *ev) override;
virtual void mouseDoubleClickEvent(QMouseEvent *ev) override;
signals:
void clicked();
void double_clicked();
};
#endif // CLICKABLELABEL_H
+1
View File
@@ -49,6 +49,7 @@ void TimelineArea::SetTrackList(Sequence *sequence, Track::Type track_list)
labels_.resize(track_list_->TrackCount());
for (int i=0;i<labels_.size();i++) {
labels_[i] = std::make_shared<TimelineLabel>();
labels_[i]->SetTrack(track_list_->TrackAt(i));
label_container_layout_->addWidget(labels_[i].get());
}
+33 -8
View File
@@ -1,17 +1,19 @@
#include "timelinelabel.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QInputDialog>
TimelineLabel::TimelineLabel() :
track_(nullptr)
{
QHBoxLayout* layout = new QHBoxLayout(this);
layout->setMargin(0);
layout->setSpacing(layout->spacing()/2);
QLabel* label = new QLabel("Track!");
layout->addWidget(label);
label_ = new ClickableLabel();
layout->addWidget(label_);
connect(label_, SIGNAL(double_clicked()), this, SLOT(RenameTrack()));
mute_button_ = new QPushButton("M");
QSize fixed_size(mute_button_->sizeHint().height(), mute_button_->sizeHint().height());
@@ -44,13 +46,36 @@ void TimelineLabel::SetTrack(Track *track)
track_ = track;
if (track != nullptr) {
mute_button_->setChecked(track->IsMuted());
solo_button_->setChecked(track->IsSoloed());
lock_button_->setChecked(track->IsLocked());
if (track_ != nullptr) {
UpdateState();
connect(mute_button_, SIGNAL(toggled(bool)), track_, SLOT(SetMuted(bool)));
connect(solo_button_, SIGNAL(toggled(bool)), track_, SLOT(SetSoloed(bool)));
connect(lock_button_, SIGNAL(toggled(bool)), track_, SLOT(SetLocked(bool)));
}
}
void TimelineLabel::UpdateState()
{
label_->setText(track_->name());
mute_button_->setChecked(track_->IsMuted());
solo_button_->setChecked(track_->IsSoloed());
lock_button_->setChecked(track_->IsLocked());
}
void TimelineLabel::RenameTrack()
{
bool ok;
QString new_name = QInputDialog::getText(this,
tr("Rename Track"),
tr("Enter the new name for this track"),
QLineEdit::Normal,
track_->name(),
&ok);
if (ok) {
track_->SetName(new_name);
UpdateState();
}
}
+6
View File
@@ -4,6 +4,7 @@
#include <QWidget>
#include <memory>
#include "ui/clickablelabel.h"
#include "timeline/track.h"
class TimelineLabel : public QWidget
@@ -13,12 +14,17 @@ public:
TimelineLabel();
void SetTrack(Track* track);
void UpdateState();
private:
QPushButton* mute_button_;
QPushButton* solo_button_;
QPushButton* lock_button_;
ClickableLabel* label_;
Track* track_;
private slots:
void RenameTrack();
};
using TimelineLabelPtr = std::shared_ptr<TimelineLabel>;
+15 -16
View File
@@ -534,6 +534,8 @@ void TimelineView::dropEvent(QDropEvent* event) {
s->AddClipsFromGhosts(ca, ParentTimeline()->ghosts);
ParentTimeline()->ghosts.clear();
olive::undo_stack.push(ca);
setFocus();
@@ -1905,20 +1907,15 @@ void TimelineView::update_ghosts(const QPoint& mouse_pos, bool lock_frame) {
}
if (ParentTimeline()->importing) {
/*
if ((ParentTimeline()->video_ghosts && mouse_track->type() == Track::kTypeVideo)
|| (ParentTimeline()->audio_ghosts && mouse_track->type() == Track::kTypeAudio)) {
int abs_track_diff = abs(track_diff);
if (g.old_track < 0) { // clip is video
g.track -= abs_track_diff;
} else { // clip is audio
g.track += abs_track_diff;
}
if (mouse_track != nullptr) {
g.track = g.track->track_list()->TrackAt(mouse_track->Index());
}
*/
g.track = track_list_->First();
} else if (g.old_track->type() == ParentTimeline()->drag_track_start->type()) {
g.track += track_diff;
}
} else if (effective_tool == olive::timeline::TIMELINE_TOOL_TRANSITION) {
if (ParentTimeline()->transition_tool_open_clip != nullptr
@@ -2891,12 +2888,8 @@ void TimelineView::paintEvent(QPaintEvent*) {
Track* track = track_list_->TrackAt(i);
qDebug() << "track clip cound was" << track->ClipCount();
for (int j=0;j<track->ClipCount();j++) {
qDebug() << "going to draw a clip!!!";
Clip* clip = track->GetClip(j).get();
QRect clip_rect(ParentTimeline()->getTimelineScreenPointFromFrame(clip->timeline_in()),
@@ -3291,11 +3284,13 @@ void TimelineView::paintEvent(QPaintEvent*) {
}
// draw border
/*
p.setPen(QColor(0, 0, 0, 64));
int edge_y = 0;
p.drawLine(0, edge_y, rect().width(), edge_y);
edge_y = rect().height()-1;
p.drawLine(0, edge_y, rect().width(), edge_y);
*/
// draw snap point
if (olive::timeline::snapped) {
@@ -3318,8 +3313,11 @@ Track *TimelineView::getTrackFromScreenPoint(int y) {
y += scroll;
int heights = 0;
for (int i=0;i<track_list_->TrackCount();i++) {
int new_heights = heights + track_list_->TrackAt(i)->height() + 1;
int new_heights = heights + 1;
new_heights += track_list_->TrackAt(i)->height();
if (y >= heights && y < new_heights) {
return track_list_->TrackAt(i);
@@ -3333,6 +3331,7 @@ Track *TimelineView::getTrackFromScreenPoint(int y) {
int TimelineView::getScreenPointFromTrack(Track *track) {
int point = 0;
for (int i=0;i<track_list_->TrackCount();i++) {
if (track == track_list_->TrackAt(i)) {
return point;