diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-07-05 15:19:46 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-07-05 12:37:28 +0000 |
commit | 1bf2df5b328e38bbae1dccc4a19d15494dd66782 (patch) | |
tree | 90f3011c4c009d86fdaadb77e0e6c016a9f25e7a /src/Authoring/Studio/Palettes/TimelineGraphicsView/ui | |
parent | ae206ce4aaed605a16510233cc6eb17d1840efa3 (diff) |
Only check for bound children at the start of the drag/set bar time
Checking for bound children at every mouse move/set bar time change
caused child bars to be added to the drag/time change set if some
intermediate start/end value matched the child bar start/end value.
The document didn't update start/end for these bars, however, leading
to inconsistent state between UI and document.
Task-number: QT3DS-1979
Change-Id: I2d7b3877d82ddfd26989d6b6ae620cda7e3ca783
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Jere Tuliniemi <jere.tuliniemi@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/TimelineGraphicsView/ui')
-rw-r--r-- | src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp | 93 | ||||
-rw-r--r-- | src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.h | 9 |
2 files changed, 60 insertions, 42 deletions
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp index b7364be2..18b309ce 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp @@ -360,6 +360,7 @@ void RowTimeline::updateDurationFromBinding() return; ITimelineTimebar *timebar = m_rowTree->m_binding->GetTimelineItem()->GetTimebar(); + clearBoundChildren(); setStartTime(timebar->GetStartTime() * .001); setEndTime(timebar->GetEndTime() * .001); } @@ -481,6 +482,37 @@ void RowTimeline::startDurationMove(double clickX) m_startDurationMoveOffsetX = clickX - m_startX; } +void RowTimeline::updateBoundChildren(bool start) +{ + // Collect all bound children + // Children are considered bound if the start/end time matches the parent time + if (start) + m_boundChildrenStart.clear(); + else + m_boundChildrenEnd.clear(); + if (m_rowTree->hasDurationBar()) { + const auto childRows = m_rowTree->childRows(); + for (auto child : childRows) { + if (child->hasDurationBar()) { + RowTimeline *rowTimeline = child->rowTimeline(); + if (start && rowTimeline->m_startX == m_startX) { + m_boundChildrenStart.append(rowTimeline); + rowTimeline->updateBoundChildren(start); + } else if (!start && rowTimeline->m_endX == m_endX) { + m_boundChildrenEnd.append(rowTimeline); + rowTimeline->updateBoundChildren(start); + } + } + } + } +} + +void RowTimeline::clearBoundChildren() +{ + m_boundChildrenStart.clear(); + m_boundChildrenEnd.clear(); +} + // move the duration area (start/end x) void RowTimeline::moveDurationBy(double dx) { @@ -596,8 +628,9 @@ void RowTimeline::collectChildKeyframeTimes(QVector<double> &childKeyframeTimes) // called after timeline scale is changed to update duration star/end positions void RowTimeline::updatePosition() { - setStartX(timeToX(m_startTime)); - setEndX(timeToX(m_endTime)); + clearBoundChildren(); + setStartTime(m_startTime); + setEndTime(m_endTime); } // Set the position of the start of the row duration @@ -608,7 +641,6 @@ void RowTimeline::setStartX(double startX) else if (startX > m_endX) startX = m_endX; - double oldStartX = m_startX; m_startX = startX; m_startTime = xToTime(startX); @@ -617,7 +649,7 @@ void RowTimeline::setStartX(double startX) m_minStartX = 0; } - updateChildrenStartRecursive(m_rowTree, oldStartX); + updateChildrenStartRecursive(); updateChildrenMinStartXRecursive(m_rowTree); update(); } @@ -628,7 +660,6 @@ void RowTimeline::setEndX(double endX) if (endX < m_startX) endX = m_startX; - double oldEndX = m_endX; m_endX = endX; m_endTime = xToTime(endX); @@ -637,7 +668,7 @@ void RowTimeline::setEndX(double endX) m_maxEndX = 999999; } - updateChildrenEndRecursive(m_rowTree, oldEndX); + updateChildrenEndRecursive(); updateChildrenMaxEndXRecursive(m_rowTree); update(); } @@ -659,42 +690,26 @@ void RowTimeline::setControllerText(const QString &controller) update(); } -void RowTimeline::updateChildrenStartRecursive(RowTree *rowTree, double oldStartX) +void RowTimeline::updateChildrenStartRecursive() { - // Update all bound childred - // Rows are considered to be bound when their times match - if (!rowTree->empty()) { - const auto childRows = rowTree->childRows(); - for (auto child : childRows) { - RowTimeline *rowTimeline = child->rowTimeline(); - if (rowTimeline->m_startX == oldStartX) { - rowTimeline->m_startX = m_startX; - rowTimeline->m_startTime = m_startTime; - rowTimeline->updateChildrenStartRecursive(child, oldStartX); - rowTimeline->update(); - } + for (auto child : qAsConst(m_boundChildrenStart)) { + if (!child.isNull()) { + child->m_startX = m_startX; + child->m_startTime = m_startTime; + child->updateChildrenStartRecursive(); + child->update(); } } } -void RowTimeline::updateChildrenEndRecursive(RowTree *rowTree, double oldEndX) +void RowTimeline::updateChildrenEndRecursive() { - // Update all bound childred - // Rows are considered to be bound when their times match - // Do not inherit endtime when it is set for scene/component, as for this case - // start-end equals global animation min - max range and is set to illustrate the - // range in timeline view when datainput control is active - if (!rowTree->empty() && rowTree->rowType() != OBJTYPE_SCENE - && rowTree->rowType() != OBJTYPE_COMPONENT) { - const auto childRows = rowTree->childRows(); - for (auto child : childRows) { - RowTimeline *rowTimeline = child->rowTimeline(); - if (rowTimeline->m_endX == oldEndX) { - rowTimeline->m_endX = m_endX; - rowTimeline->m_endTime = m_endTime; - rowTimeline->updateChildrenEndRecursive(child, oldEndX); - rowTimeline->update(); - } + for (auto child : qAsConst(m_boundChildrenEnd)) { + if (!child.isNull()) { + child->m_endX = m_endX; + child->m_endTime = m_endTime; + child->updateChildrenEndRecursive(); + child->update(); } } } @@ -741,7 +756,6 @@ void RowTimeline::updateChildrenMaxEndXRecursive(RowTree *rowTree) void RowTimeline::setStartTime(double startTime) { - double oldStartX = m_startX; m_startTime = startTime; m_startX = timeToX(startTime); @@ -750,14 +764,13 @@ void RowTimeline::setStartTime(double startTime) m_minStartX = 0; } - updateChildrenStartRecursive(m_rowTree, oldStartX); + updateChildrenStartRecursive(); updateChildrenMinStartXRecursive(m_rowTree); update(); } void RowTimeline::setEndTime(double endTime) { - double oldEndX = m_endX; m_endTime = endTime; m_endX = timeToX(endTime); @@ -766,7 +779,7 @@ void RowTimeline::setEndTime(double endTime) m_maxEndX = 999999; } - updateChildrenEndRecursive(m_rowTree, oldEndX); + updateChildrenEndRecursive(); updateChildrenMaxEndXRecursive(m_rowTree); update(); } diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.h index 677bd6bd..4bf24bb6 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.h +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.h @@ -32,6 +32,7 @@ #include "InteractiveTimelineItem.h" #include "RowTypes.h" #include "Bindings/Qt3DSDMTimelineItemProperty.h" +#include <QtCore/qpointer.h> class RowTree; class RowTimelinePropertyGraph; @@ -51,6 +52,8 @@ public: void setRowTree(RowTree *rowTree); void updatePosition(); void startDurationMove(double clickX); + void updateBoundChildren(bool start); + void clearBoundChildren(); void moveDurationBy(double dx); void moveDurationTo(double newX); void setStartTime(double startTime); @@ -86,8 +89,8 @@ protected: void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; private: - void updateChildrenStartRecursive(RowTree *rowTree, double oldStartX); - void updateChildrenEndRecursive(RowTree *rowTree, double oldEndX); + void updateChildrenStartRecursive(); + void updateChildrenEndRecursive(); void updateChildrenMinStartXRecursive(RowTree *rowTree); void updateChildrenMaxEndXRecursive(RowTree *rowTree); void drawColorPropertyGradient(QPainter *painter, int width); @@ -111,6 +114,8 @@ private: QString m_controllerDataInput; QList<Keyframe *> m_keyframes; QColor m_barColor; + QVector<QPointer<RowTimeline>> m_boundChildrenStart; + QVector<QPointer<RowTimeline>> m_boundChildrenEnd; friend class RowTree; }; |