track movement with pointer tool

This commit is contained in:
itsmattkc
2019-08-22 10:33:40 +10:00
parent f03cc8fe07
commit 0ede7bd319
8 changed files with 70 additions and 22 deletions
+16 -2
View File
@@ -57,12 +57,26 @@ QGraphicsItem *TimelineView::Tool::GetItemAtScenePos(const QPointF &scene_pos)
return parent()->scene_.itemAt(scene_pos, parent()->transform());
}
rational TimelineView::Tool::ValidateMovement(rational movement, const QVector<TimelineViewGhostItem *> ghosts)
rational TimelineView::Tool::ValidateFrameMovement(rational movement, const QVector<TimelineViewGhostItem *> ghosts)
{
foreach (TimelineViewGhostItem* ghost, ghosts) {
// Prevents any ghosts from going below 0:00:00 time
rational validator = ghost->In() + movement;
if (validator < 0) {
movement = rational(0) - ghost->In();
movement = -ghost->In();
}
}
return movement;
}
int TimelineView::Tool::ValidateTrackMovement(int movement, const QVector<TimelineViewGhostItem *> ghosts)
{
foreach (TimelineViewGhostItem* ghost, ghosts) {
// Prevents any ghosts from going to a non-existent negative track
int validator = ghost->Track() + movement;
if (validator < 0) {
movement = -ghost->Track();
}
}