fixed edit tool

This commit is contained in:
itsmattkc
2019-04-06 19:59:49 +11:00
parent c922bbfa9d
commit dd9a9ba4fd
3 changed files with 50 additions and 44 deletions
+7 -31
View File
@@ -761,18 +761,15 @@ long Timeline::getTimelineFrameFromScreenPoint(int x) {
return getFrameFromScreenPoint(zoom, x + scroll);
}
QVector<Clip *> Timeline::GetClipsInRectangleSelection(bool autoselect_links)
QVector<Track *> Timeline::GetTracksInRectangle(int global_top, int global_bottom)
{
QVector<Clip*> selected_clips;
QVector<Track*> 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<Clip *> 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;i<track->ClipCount();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<Clip*> 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<session_clips.size();j++) {
Clip* c = session_clips.at(j);
if (!selected_clips.contains(c)) {
selected_clips.append(c);
}
}
}
}
}
}
}
return selected_clips;
return tracks;
}
int Timeline::getTimelineScreenPointFromFrame(long frame) {
+1 -1
View File
@@ -63,7 +63,7 @@ public:
int getDisplayScreenPointFromFrame(long frame);
long getDisplayFrameFromScreenPoint(int x);
QVector<Clip*> GetClipsInRectangleSelection(bool autoselect_links);
QVector<Track*> GetTracksInRectangle(int global_top, int global_bottom);
void set_marker();
+42 -12
View File
@@ -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<Track*> 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<Clip*> selected_clips = ParentTimeline()->GetClipsInRectangleSelection(!alt);
QVector<Clip*> selected_clips;
QVector<Track*> 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;i<track->ClipCount();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<Clip*> 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<session_clips.size();j++) {
Clip* c = session_clips.at(j);
if (!selected_clips.contains(c)) {
selected_clips.append(c);
}
}
}
}
}
// add each of the selected clips to the main sequence's selections
for (int i=0;i<selected_clips.size();i++) {