timeline: fix bug in trackviewitem drag/drop
This commit is contained in:
@@ -87,8 +87,14 @@ void ImportTool::DragEnter(TimelineViewMouseEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrepGhosts(drag_start_.GetFrame() - parent()->SceneToTime(import_pre_buffer_),
|
// Create a reasonable amount of space to inset the cursor by when importing
|
||||||
drag_start_.GetTrack().index());
|
ghost_offset_ = drag_start_.GetFrame();
|
||||||
|
|
||||||
|
if (!event->GetBypassImportBuffer()) {
|
||||||
|
ghost_offset_ -= parent()->SceneToTime(import_pre_buffer_);
|
||||||
|
}
|
||||||
|
|
||||||
|
PrepGhosts(ghost_offset_, drag_start_.GetTrack().index());
|
||||||
|
|
||||||
if (parent()->HasGhosts() || !parent()->GetConnectedNode()) {
|
if (parent()->HasGhosts() || !parent()->GetConnectedNode()) {
|
||||||
event->accept();
|
event->accept();
|
||||||
@@ -107,6 +113,12 @@ void ImportTool::DragMove(TimelineViewMouseEvent *event)
|
|||||||
|
|
||||||
if (parent()->HasGhosts()) {
|
if (parent()->HasGhosts()) {
|
||||||
rational time_movement = event->GetFrame() - drag_start_.GetFrame();
|
rational time_movement = event->GetFrame() - drag_start_.GetFrame();
|
||||||
|
|
||||||
|
// Keep ghost offset no lower than 0
|
||||||
|
if (ghost_offset_ + time_movement < 0) {
|
||||||
|
time_movement = -ghost_offset_;
|
||||||
|
}
|
||||||
|
|
||||||
int track_movement = event->GetTrack().index() - drag_start_.GetTrack().index();
|
int track_movement = event->GetTrack().index() - drag_start_.GetTrack().index();
|
||||||
|
|
||||||
time_movement = ValidateTimeMovement(time_movement);
|
time_movement = ValidateTimeMovement(time_movement);
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ private:
|
|||||||
|
|
||||||
int import_pre_buffer_;
|
int import_pre_buffer_;
|
||||||
|
|
||||||
|
rational ghost_offset_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ void TrackViewItem::dragEnterEvent(QDragEnterEvent *event)
|
|||||||
TimelineViewMouseEvent e(0, 1, 1, track_->ToReference(), Qt::NoButton, event->keyboardModifiers());
|
TimelineViewMouseEvent e(0, 1, 1, track_->ToReference(), Qt::NoButton, event->keyboardModifiers());
|
||||||
e.SetMimeData(event->mimeData());
|
e.SetMimeData(event->mimeData());
|
||||||
e.SetEvent(event);
|
e.SetEvent(event);
|
||||||
|
e.SetBypassImportBuffer(true);
|
||||||
emit DragEntered(&e);
|
emit DragEntered(&e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ public:
|
|||||||
button_(button),
|
button_(button),
|
||||||
modifiers_(modifiers),
|
modifiers_(modifiers),
|
||||||
source_event_(nullptr),
|
source_event_(nullptr),
|
||||||
mime_data_(nullptr)
|
mime_data_(nullptr),
|
||||||
|
bypass_import_buffer_(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,6 +118,9 @@ public:
|
|||||||
source_event_->ignore();
|
source_event_->ignore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GetBypassImportBuffer() const { return bypass_import_buffer_; }
|
||||||
|
void SetBypassImportBuffer(bool e) { bypass_import_buffer_ = e; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal scene_x_;
|
qreal scene_x_;
|
||||||
double scale_x_;
|
double scale_x_;
|
||||||
@@ -132,6 +136,8 @@ private:
|
|||||||
|
|
||||||
const QMimeData* mime_data_;
|
const QMimeData* mime_data_;
|
||||||
|
|
||||||
|
bool bypass_import_buffer_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user