From 673bcc0bf70179e1395138b7e3c69cd56ef8325b Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 3 Apr 2019 23:59:36 +1100 Subject: [PATCH] fixed last references to track as an integer --- dialogs/speeddialog.cpp | 2 +- panels/timeline.cpp | 8 ++++++-- rendering/renderfunctions.cpp | 4 ++-- timeline/clip.cpp | 2 +- timeline/track.h | 2 ++ ui/timelinearea.cpp | 4 +++- ui/timelineview.cpp | 20 ++++++++++++++++---- 7 files changed, 31 insertions(+), 11 deletions(-) diff --git a/dialogs/speeddialog.cpp b/dialogs/speeddialog.cpp index 0e11063f9..b1482e2eb 100644 --- a/dialogs/speeddialog.cpp +++ b/dialogs/speeddialog.cpp @@ -418,7 +418,7 @@ void SpeedDialog::accept() { if (i > 0 && !qFuzzyCompare(cached_speed, c->speed().value)) { can_change_all = false; } - if (c->track() < 0) { + if (c->type() == Track::kTypeVideo) { if (qIsNaN(cached_fr)) { cached_fr = c->media_frame_rate(); } else if (!qFuzzyCompare(cached_fr, c->media_frame_rate())) { diff --git a/panels/timeline.cpp b/panels/timeline.cpp index 8483aaaeb..7308b6c72 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -90,7 +90,7 @@ Timeline::Timeline(QWidget *parent) : headers->viewer = panel_sequence_viewer; - video_area->SetAlignment(olive::timeline::kAlignmentBottom); + //video_area->SetAlignment(olive::timeline::kAlignmentBottom); tool_buttons.append(toolArrowButton); tool_buttons.append(toolEditButton); @@ -993,8 +993,11 @@ void Timeline::setup_ui() { timeline_area_layout->setSpacing(0); timeline_area_layout->setContentsMargins(0, 0, 0, 0); + QHBoxLayout* timeline_header_layout = new QHBoxLayout(); + timeline_header_layout->addSpacing(olive::timeline::kTimelineLabelFixedWidth); headers = new TimelineHeader(); - timeline_area_layout->addWidget(headers); + timeline_header_layout->addWidget(headers); + timeline_area_layout->addLayout(timeline_header_layout); editAreas = new QWidget(); QHBoxLayout* editAreaLayout = new QHBoxLayout(editAreas); @@ -1063,4 +1066,5 @@ void olive::timeline::MultiplyTrackSizesByDPI() kTrackDefaultHeight *= QApplication::desktop()->devicePixelRatio(); kTrackMinHeight *= QApplication::desktop()->devicePixelRatio(); kTrackHeightIncrement *= QApplication::desktop()->devicePixelRatio(); + kTimelineLabelFixedWidth *= QApplication::desktop()->devicePixelRatio(); } diff --git a/rendering/renderfunctions.cpp b/rendering/renderfunctions.cpp index 719554479..40e22cc0d 100644 --- a/rendering/renderfunctions.cpp +++ b/rendering/renderfunctions.cpp @@ -370,7 +370,7 @@ GLuint olive::rendering::compose_sequence(ComposeSequenceParams ¶ms) { if (got_mutex && c->IsOpen()) { // if clip is a video clip - if (c->track() < 0) { + if (c->type() == Track::kTypeVideo) { // textureID variable contains texture to be drawn on screen at the end GLuint textureID = 0; @@ -750,7 +750,7 @@ GLuint olive::rendering::compose_sequence(ComposeSequenceParams ¶ms) { // == END FINAL DRAW ON SEQUENCE BUFFER == } } - } else { + } else if (c->type() == Track::kTypeAudio) { if (c->media() != nullptr && c->media()->get_type() == MEDIA_TYPE_SEQUENCE) { params.nests.append(c); compose_sequence(params); diff --git a/timeline/clip.cpp b/timeline/clip.cpp index cac020813..2d15bc18b 100644 --- a/timeline/clip.cpp +++ b/timeline/clip.cpp @@ -721,7 +721,7 @@ bool Clip::Retrieve() bool Clip::UsesCacher() { - return track() >= 0 || (media() != nullptr && media()->get_type() == MEDIA_TYPE_FOOTAGE); + return type() == Track::kTypeAudio || (media() != nullptr && media()->get_type() == MEDIA_TYPE_FOOTAGE); } ClipSpeed::ClipSpeed() : diff --git a/timeline/track.h b/timeline/track.h index 52f98a7a5..c684014f5 100644 --- a/timeline/track.h +++ b/timeline/track.h @@ -24,6 +24,8 @@ namespace olive { extern int kTrackDefaultHeight; extern int kTrackMinHeight; extern int kTrackHeightIncrement; + + extern int kTimelineLabelFixedWidth; } } diff --git a/ui/timelinearea.cpp b/ui/timelinearea.cpp index 739180d20..982d447b6 100644 --- a/ui/timelinearea.cpp +++ b/ui/timelinearea.cpp @@ -1,5 +1,7 @@ #include "timelinearea.h" +int olive::timeline::kTimelineLabelFixedWidth = 200; + TimelineArea::TimelineArea(Timeline* timeline) : timeline_(timeline), track_list_(nullptr), @@ -11,7 +13,7 @@ TimelineArea::TimelineArea(Timeline* timeline) : // LABELS QWidget* label_container = new QWidget(); - label_container->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding); + label_container->setFixedWidth(olive::timeline::kTimelineLabelFixedWidth); label_container_layout_ = new QVBoxLayout(label_container); label_container_layout_->setMargin(0); label_container_layout_->setSpacing(0); diff --git a/ui/timelineview.cpp b/ui/timelineview.cpp index c147c30c9..f78c02fda 100644 --- a/ui/timelineview.cpp +++ b/ui/timelineview.cpp @@ -536,6 +536,8 @@ void TimelineView::dropEvent(QDropEvent* event) { ParentTimeline()->ghosts.clear(); + ParentTimeline()->importing = false; + olive::undo_stack.push(ca); setFocus(); @@ -1914,7 +1916,10 @@ void TimelineView::update_ghosts(const QPoint& mouse_pos, bool lock_frame) { } else if (g.old_track->type() == ParentTimeline()->drag_track_start->type()) { - g.track += track_diff; + if (mouse_track != nullptr) { + g.track = g.track->track_list()->TrackAt(mouse_track->Index()); + } + //g.track += track_diff; } } else if (effective_tool == olive::timeline::TIMELINE_TOOL_TRANSITION) { @@ -3310,11 +3315,18 @@ void TimelineView::resizeEvent(QResizeEvent *) { // ************************************** Track *TimelineView::getTrackFromScreenPoint(int y) { + if (y < 0 || y > height()) { + return nullptr; + } + y += scroll; int heights = 0; - for (int i=0;iTrackCount();i++) { + //for (int i=0;iTrackCount();i++) { + int i = 0; + while (true) { + int new_heights = heights + 1; new_heights += track_list_->TrackAt(i)->height(); @@ -3324,9 +3336,9 @@ Track *TimelineView::getTrackFromScreenPoint(int y) { } heights = new_heights; - } - return nullptr; + i++; + } } int TimelineView::getScreenPointFromTrack(Track *track) {