From dd9a9ba4fd10fe95168bf6c3f63128dcfb101c12 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sat, 6 Apr 2019 19:59:49 +1100 Subject: [PATCH] fixed edit tool --- panels/timeline.cpp | 38 ++++++------------------------- panels/timeline.h | 2 +- ui/timelineview.cpp | 54 +++++++++++++++++++++++++++++++++++---------- 3 files changed, 50 insertions(+), 44 deletions(-) diff --git a/panels/timeline.cpp b/panels/timeline.cpp index bb09bb5b0..70efae94f 100644 --- a/panels/timeline.cpp +++ b/panels/timeline.cpp @@ -761,18 +761,15 @@ long Timeline::getTimelineFrameFromScreenPoint(int x) { return getFrameFromScreenPoint(zoom, x + scroll); } -QVector Timeline::GetClipsInRectangleSelection(bool autoselect_links) +QVector Timeline::GetTracksInRectangle(int global_top, int global_bottom) { - QVector selected_clips; + QVector tracks; TimelineArea* area; - long frame_min = qMin(drag_frame_start, cursor_frame); - long frame_max = qMax(drag_frame_start, cursor_frame); - foreach (area, areas) { - QPoint relative_tl = area->mapFromGlobal(rect_select_rect.topLeft()); - QPoint relative_br = area->mapFromGlobal(rect_select_rect.bottomRight()); + QPoint relative_tl = area->mapFromGlobal(QPoint(0, global_top)); + QPoint relative_br = area->mapFromGlobal(QPoint(0, global_bottom)); int rect_top = qMin(relative_tl.y(), relative_br.y()); int rect_bottom = qMax(relative_tl.y(), relative_br.y()); @@ -789,35 +786,14 @@ QVector Timeline::GetClipsInRectangleSelection(bool autoselect_links) if (!(track_bottom < rect_top || track_top > rect_bottom)) { - // Loop through track's clips for clips touching this rectangle - for (int i=0;iClipCount();i++) { - Clip* clip = track->GetClip(i).get(); - if (!(clip->timeline_out() < frame_min || clip->timeline_in() > frame_max) ) { + // It does, so we add it to the list + tracks.append(track); - // create a group of the clip (and its links if alt is not pressed) - QVector session_clips; - session_clips.append(clip); - - if (autoselect_links) { - session_clips.append(clip->linked); - } - - // for each of these clips, see if clip has already been added - - // this can easily happen due to adding linked clips - for (int j=0;j GetClipsInRectangleSelection(bool autoselect_links); + QVector GetTracksInRectangle(int global_top, int global_bottom); void set_marker(); diff --git a/ui/timelineview.cpp b/ui/timelineview.cpp index b545c4e9a..956a57b67 100644 --- a/ui/timelineview.cpp +++ b/ui/timelineview.cpp @@ -2016,20 +2016,15 @@ void TimelineView::mouseMoveEvent(QMouseEvent *event) { long selection_in = qMin(ParentTimeline()->drag_frame_start, ParentTimeline()->cursor_frame); long selection_out = qMax(ParentTimeline()->drag_frame_start, ParentTimeline()->cursor_frame); - int start_track = (ParentTimeline()->drag_track_start == nullptr) - ? track_list_->TrackCount() - 1 - : ParentTimeline()->drag_track_start->Index(); + int selection_top = mapToGlobal(QPoint(0, ParentTimeline()->drag_y_start)).y(); + int selection_bottom = mapToGlobal(event->pos()).y(); - int end_track = (ParentTimeline()->cursor_track == nullptr) - ? track_list_->TrackCount() - 1 - : ParentTimeline()->cursor_track->Index(); + QVector selected_tracks = ParentTimeline()->GetTracksInRectangle(selection_top, + selection_bottom); - int min_track = qMin(start_track, end_track); - int max_track = qMax(start_track, end_track); + Track* track; - for (int i=min_track;i<=max_track;i++) { - - Track* track = track_list_->TrackAt(i); + foreach (track, selected_tracks) { selections.append(Selection(selection_in, selection_out, track)); @@ -2402,7 +2397,42 @@ void TimelineView::mouseMoveEvent(QMouseEvent *event) { // (left/top were set to the starting drag position earlier) ParentTimeline()->rect_select_rect.setBottomRight(mapToGlobal(event->pos())); - QVector selected_clips = ParentTimeline()->GetClipsInRectangleSelection(!alt); + QVector selected_clips; + + QVector selected_tracks = ParentTimeline()->GetTracksInRectangle(ParentTimeline()->rect_select_rect.top(), + ParentTimeline()->rect_select_rect.bottom()); + + long frame_min = qMin(ParentTimeline()->drag_frame_start, ParentTimeline()->cursor_frame); + long frame_max = qMax(ParentTimeline()->drag_frame_start, ParentTimeline()->cursor_frame); + + Track* track; + + foreach (track, selected_tracks) { + // Loop through track's clips for clips touching this rectangle + for (int i=0;iClipCount();i++) { + Clip* clip = track->GetClip(i).get(); + if (!(clip->timeline_out() < frame_min || clip->timeline_in() > frame_max) ) { + + // create a group of the clip (and its links if alt is not pressed) + QVector session_clips; + session_clips.append(clip); + + if (!alt) { + session_clips.append(clip->linked); + } + + // for each of these clips, see if clip has already been added - + // this can easily happen due to adding linked clips + for (int j=0;j