forked from qt-creator/qt-creator
Prevent timeline bar item from going off limits
When dragging a timeline bar item or one of its edges, confine edges so that they do not go beyond the timeline limits. Task-number: QDS-1074 Change-Id: I029cfbe02cf07d1f9e5e5119283d2b94fca2b2f6 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
@@ -801,10 +801,19 @@ void TimelineBarItem::itemMoved(const QPointF &start, const QPointF &end)
|
|||||||
if (isActiveHandle(Location::Undefined))
|
if (isActiveHandle(Location::Undefined))
|
||||||
dragInit(rect(), start);
|
dragInit(rect(), start);
|
||||||
|
|
||||||
const qreal min = qreal(TimelineConstants::sectionWidth + TimelineConstants::timelineLeftOffset
|
qreal min = qreal(TimelineConstants::sectionWidth + TimelineConstants::timelineLeftOffset
|
||||||
- scrollOffset());
|
- scrollOffset());
|
||||||
const qreal max = qreal(timelineScene()->rulerWidth() - TimelineConstants::sectionWidth
|
qreal max = qreal(timelineScene()->rulerWidth() - TimelineConstants::sectionWidth
|
||||||
+ rect().width());
|
+ rect().width());
|
||||||
|
|
||||||
|
const qreal minFrameX = mapFromFrameToScene(timelineScene()->startFrame());
|
||||||
|
const qreal maxFrameX = mapFromFrameToScene(timelineScene()->endFrame());
|
||||||
|
|
||||||
|
if (min < minFrameX)
|
||||||
|
min = minFrameX;
|
||||||
|
|
||||||
|
if (max > maxFrameX)
|
||||||
|
max = maxFrameX;
|
||||||
|
|
||||||
if (isActiveHandle(Location::Center))
|
if (isActiveHandle(Location::Center))
|
||||||
dragCenter(rect(), end, min, max);
|
dragCenter(rect(), end, min, max);
|
||||||
|
Reference in New Issue
Block a user