summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp')
-rw-r--r--src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp51
1 files changed, 23 insertions, 28 deletions
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
index 6fab4e3e..7f608683 100644
--- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
+++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp
@@ -80,16 +80,15 @@ TimelineGraphicsScene::TimelineGraphicsScene(TimelineWidget *timelineWidget)
, m_layoutTimeline(new QGraphicsLinearLayout(Qt::Vertical))
, m_ruler(new Ruler)
, m_playHead(new PlayHead(m_ruler))
- , m_selectionRect(new SelectionRect())
- , m_rowMover(new RowMover(this))
, m_widgetTimeline(timelineWidget)
, m_widgetRoot(new QGraphicsWidget)
+ , m_rowMover(new RowMover(this))
+ , m_selectionRect(new SelectionRect())
, m_rowManager(new RowManager(this, m_layoutTree, m_layoutTimeline))
, m_keyframeManager(new KeyframeManager(this))
, m_pressPos(invalidPoint)
, m_pressScreenPos(invalidPoint)
, m_timelineControl(new TimelineControl(this))
- , m_currentCursor(-1)
{
addItem(m_playHead);
addItem(m_selectionRect);
@@ -164,8 +163,7 @@ TimelineGraphicsScene::TimelineGraphicsScene(TimelineWidget *timelineWidget)
}
if (m_selectionRect->isActive()) {
- p -= QPoint(0, m_widgetTimeline->navigationBar()->height()
- + TimelineConstants::ROW_H);
+ p -= QPoint(0, m_widgetTimeline->navigationBar()->height() + TimelineConstants::ROW_H);
const double bottom = timelineContent->contentsRect().height() - scrollBarOffsets.y();
if (m_lastAutoScrollX != p.x() || p.x() <= 0 || p.x() >= right
|| m_lastAutoScrollY != p.y() || p.y() <= 0 || p.y() >= bottom) {
@@ -200,7 +198,7 @@ TimelineGraphicsScene::TimelineGraphicsScene(TimelineWidget *timelineWidget)
if (scroll != 0)
scroll -= TimelineConstants::TREE_BOUND_W;
- double distance = p.x() + scroll;
+ double distance = p.x() + scroll - TimelineConstants::RULER_EDGE_OFFSET;
if (m_clickedTimelineControlType == TimelineControlType::Duration
&& !m_editedTimelineRow.isNull()) {
distance -= m_editedTimelineRow->getDurationMoveOffsetX();
@@ -210,8 +208,7 @@ TimelineGraphicsScene::TimelineGraphicsScene(TimelineWidget *timelineWidget)
snap(distance, !m_rulerPressed);
if (m_rulerPressed) {
- long time = m_ruler->distanceToTime(
- distance - TimelineConstants::RULER_EDGE_OFFSET);
+ long time = m_ruler->distanceToTime(distance);
if (time < 0)
time = 0;
g_StudioApp.GetCore()->GetDoc()->NotifyTimeChanged(time);
@@ -223,22 +220,21 @@ TimelineGraphicsScene::TimelineGraphicsScene(TimelineWidget *timelineWidget)
if (m_dragging) {
if (m_clickedTimelineControlType == TimelineControlType::StartHandle) {
- double visiblePtX = distance > TimelineConstants::RULER_EDGE_OFFSET
- ? m_editedTimelineRow->getStartX() : 0;
+ double visiblePtX = distance > 0 ? m_editedTimelineRow->getStartX() : 0;
if (distance > m_editedTimelineRow->getEndX())
visiblePtX += TimelineConstants::RULER_EDGE_OFFSET;
m_editedTimelineRow->setStartX(distance);
m_editedTimelineRow->showToolTip(QCursor::pos());
- timelineContent->ensureVisible(TimelineConstants::TREE_BOUND_W + visiblePtX,
+ timelineContent->ensureVisible(TimelineConstants::TREE_BOUND_W
+ + TimelineConstants::RULER_EDGE_OFFSET
+ + visiblePtX,
m_editedTimelineRow->y(), 0, 0, 0, 0);
} else if (m_clickedTimelineControlType == TimelineControlType::EndHandle) {
- long time = m_ruler->distanceToTime(
- distance - TimelineConstants::RULER_EDGE_OFFSET);
+ long time = m_ruler->distanceToTime(distance);
double edgeMargin = 0;
if (time > TimelineConstants::MAX_SLIDE_TIME) {
- distance = m_ruler->timeToDistance(TimelineConstants::MAX_SLIDE_TIME)
- + TimelineConstants::RULER_EDGE_OFFSET;
+ distance = m_ruler->timeToDistance(TimelineConstants::MAX_SLIDE_TIME);
edgeMargin = TimelineConstants::RULER_EDGE_OFFSET;
} else if (time < m_editedTimelineRow->getStartTime()) {
edgeMargin = -TimelineConstants::RULER_EDGE_OFFSET;
@@ -248,18 +244,17 @@ TimelineGraphicsScene::TimelineGraphicsScene(TimelineWidget *timelineWidget)
rowManager()->updateRulerDuration(p.x() > right);
timelineContent->ensureVisible(
TimelineConstants::TREE_BOUND_W
+ + TimelineConstants::RULER_EDGE_OFFSET
+ m_editedTimelineRow->getEndX() + edgeMargin,
m_editedTimelineRow->y(), 0, 0, 0, 0);
} else if (m_clickedTimelineControlType == TimelineControlType::Duration) {
- long time = m_ruler->distanceToTime(
- distance - TimelineConstants::RULER_EDGE_OFFSET)
- + m_editedTimelineRow->getDuration(); // milliseconds
+ long time = m_ruler->distanceToTime(distance)
+ + m_editedTimelineRow->getDuration(); // milliseconds
double visiblePtX = distance
+ m_editedTimelineRow->getDurationMoveOffsetX();
if (time > TimelineConstants::MAX_SLIDE_TIME) {
distance = m_ruler->timeToDistance(TimelineConstants::MAX_SLIDE_TIME
- - m_editedTimelineRow->getDuration())
- + TimelineConstants::RULER_EDGE_OFFSET;
+ - m_editedTimelineRow->getDuration());
visiblePtX = m_editedTimelineRow->getEndX()
+ TimelineConstants::RULER_EDGE_OFFSET;
}
@@ -268,7 +263,8 @@ TimelineGraphicsScene::TimelineGraphicsScene(TimelineWidget *timelineWidget)
m_editedTimelineRow->showToolTip(QCursor::pos());
rowManager()->updateRulerDuration(p.x() > right);
timelineContent->ensureVisible(
- TimelineConstants::TREE_BOUND_W + visiblePtX,
+ TimelineConstants::TREE_BOUND_W
+ + TimelineConstants::RULER_EDGE_OFFSET + visiblePtX,
m_editedTimelineRow->y(), 0, 0, 0, 0);
}
}
@@ -690,17 +686,15 @@ void TimelineGraphicsScene::stopAutoScroll() {
void TimelineGraphicsScene::updateSnapSteps()
{
m_snapSteps.clear();
- // i = 1 is always the scene row
+ // i = 1 is always the scene row (or component root)
for (int i = 2; i < m_layoutTimeline->count(); i++) {
- RowTree *rowTree = static_cast<RowTree *>
- (m_layoutTree->itemAt(i)->graphicsItem());
+ RowTree *rowTree = static_cast<RowTree *>(m_layoutTree->itemAt(i)->graphicsItem());
if (rowTree->hasDurationBar() && rowTree->isVisible()) {
- auto startX = rowTree->rowTimeline()->getStartX()
- - TimelineConstants::RULER_EDGE_OFFSET;
+ double startX = rowTree->rowTimeline()->getStartX();
if (!m_snapSteps.contains(startX))
m_snapSteps.push_back(startX);
- auto endX = rowTree->rowTimeline()->getEndX() - TimelineConstants::RULER_EDGE_OFFSET;
+ double endX = rowTree->rowTimeline()->getEndX();
if (!m_snapSteps.contains(endX))
m_snapSteps.push_back(endX);
@@ -759,7 +753,8 @@ void TimelineGraphicsScene::snap(double &value, bool snapToPlayHead)
{
// snap to play head
if (snapToPlayHead) {
- double playHeadX = m_playHead->x() - m_ruler->x();
+ double playHeadX = m_playHead->x() - TimelineConstants::TREE_BOUND_W
+ - TimelineConstants::RULER_EDGE_OFFSET;
if (abs(value - playHeadX) < CStudioPreferences::GetSnapRange()) {
value = playHeadX;
return;