diff options
-rw-r--r-- | src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp | 4 | ||||
-rw-r--r-- | src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp | 27 |
2 files changed, 19 insertions, 12 deletions
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp index 643d8f09..de682be3 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp @@ -360,9 +360,9 @@ void TimelineGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event) m_editedTimelineRow->getClickedControl(m_pressPos); // clicked an empty spot on a timeline row, start selection rect. - if (m_clickedTimelineControlType == TimelineControlType::None) + if (m_clickedTimelineControlType == TimelineControlType::None) { m_selectionRect->start(m_pressPos); - else if (m_clickedTimelineControlType == TimelineControlType::Duration) { + } else if (m_clickedTimelineControlType == TimelineControlType::Duration) { if (!ctrlKeyDown && m_rowManager->isRowSelected(m_editedTimelineRow->rowTree()) && !m_rowManager->isSingleSelected() ) { diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp index cb86d434..0c58f7dd 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp @@ -410,15 +410,22 @@ TimelineControlType RowTimeline::getClickedControl(const QPointF &scenePos) cons return TimelineControlType::None; QPointF p = mapFromScene(scenePos.x(), scenePos.y()); - if (p.x() > m_startX - TimelineConstants::DURATION_HANDLE_W * .5 - && p.x() < m_startX + TimelineConstants::DURATION_HANDLE_W * .5) { + const int halfHandle = TimelineConstants::DURATION_HANDLE_W * .5; + // Never choose start handle if end time is zero, as you cannot adjust it in that case + bool startHandle = p.x() > m_startX - halfHandle && p.x() < m_startX + halfHandle + && !qFuzzyIsNull(m_endTime); + bool endHandle = p.x() > m_endX - halfHandle && p.x() < m_endX + halfHandle; + if (startHandle && endHandle) { + // If handles overlap, choose the handle based on the side of the click relative to start + startHandle = p.x() < m_startX; + endHandle = !startHandle; + } + if (startHandle) return TimelineControlType::StartHandle; - } else if (p.x() > m_endX - TimelineConstants::DURATION_HANDLE_W * .5 - && p.x() < m_endX + TimelineConstants::DURATION_HANDLE_W * .5) { + else if (endHandle) return TimelineControlType::EndHandle; - } else if (p.x() > m_startX && p.x() < m_endX && !rowTree()->locked()) { + else if (p.x() > m_startX && p.x() < m_endX && !rowTree()->locked()) return TimelineControlType::Duration; - } return TimelineControlType::None; } @@ -537,8 +544,8 @@ void RowTimeline::setStartX(double startX) { if (startX < TimelineConstants::RULER_EDGE_OFFSET) startX = TimelineConstants::RULER_EDGE_OFFSET; - else if (startX > m_endX - 1) - startX = m_endX - 1; + else if (startX > m_endX) + startX = m_endX; double oldStartX = m_startX; m_startX = startX; @@ -557,8 +564,8 @@ void RowTimeline::setStartX(double startX) // Set the position of the end of the row duration void RowTimeline::setEndX(double endX) { - if (endX < m_startX + 1) - endX = m_startX + 1; + if (endX < m_startX) + endX = m_startX; double oldEndX = m_endX; m_endX = endX; |