diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-06-06 12:38:59 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-06-06 10:14:02 +0000 |
commit | dfa966e0d32041b1df0acd6db7733d22614b38b0 (patch) | |
tree | fd9e2daae3cc646203de76a44ea866e342db4507 | |
parent | 0bd168dc0e53af8fee8a0084cf3d57dda00bcb81 (diff) |
Fix adjusting timebar by dragging start/end handles
In case of overlapping start and end handles, now choose the handle
depending on the click position relative to start of the bar.
Never select start handle if end time is zero.
Also allow adjusting the duration to actual zero instead of just very
close to it.
Task-number: QT3DS-1869
Change-Id: I57d06c6e70bb22fd320bcd01adf021a15f13caf6
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-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; |