From 1bf2df5b328e38bbae1dccc4a19d15494dd66782 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 5 Jul 2018 15:19:46 +0300 Subject: 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 Reviewed-by: Jere Tuliniemi Reviewed-by: Miikka Heikkinen --- .../Palettes/TimelineGraphicsView/RowManager.cpp | 8 +- .../TimelineGraphicsView/TimelineControl.cpp | 2 + .../TimelineGraphicsView/TimelineGraphicsScene.cpp | 3 + .../TimelineGraphicsView/ui/RowTimeline.cpp | 93 ++++++++++++---------- .../Palettes/TimelineGraphicsView/ui/RowTimeline.h | 9 ++- 5 files changed, 70 insertions(+), 45 deletions(-) diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp index 565960cf..0c85f225 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp @@ -94,9 +94,11 @@ RowTree *RowManager::createRowFromBinding(ITimelineItemBinding *binding, RowTree // set row start/end time & color ITimelineTimebar *timebar = binding->GetTimelineItem()->GetTimebar(); - newRow->rowTimeline()->setStartTime(timebar->GetStartTime() * .001); - newRow->rowTimeline()->setEndTime(timebar->GetEndTime() * .001); - newRow->rowTimeline()->setBarColor(timebar->GetTimebarColor()); + RowTimeline *rowTimeline = newRow->rowTimeline(); + rowTimeline->clearBoundChildren(); + rowTimeline->setStartTime(timebar->GetStartTime() * .001); + rowTimeline->setEndTime(timebar->GetEndTime() * .001); + rowTimeline->setBarColor(timebar->GetTimebarColor()); // create property rows for (int i = 0; i < binding->GetPropertyCount(); i++) { diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineControl.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineControl.cpp index a6a06521..a1f1a8a0 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineControl.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineControl.cpp @@ -47,6 +47,8 @@ void TimelineControl::setRowTimeline(RowTimeline *rowTimeline) m_timebar = m_rowTimeline->rowTree()->getBinding()->GetTimelineItem()->GetTimebar(); m_startTime = m_rowTimeline->getStartTime(); m_endTime = m_rowTimeline->getEndTime(); + m_rowTimeline->updateBoundChildren(true); + m_rowTimeline->updateBoundChildren(false); } void TimelineControl::showDurationEditDialog() diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp index 847713e2..ee6bfdf4 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp @@ -526,6 +526,9 @@ void TimelineGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event) m_editedTimelineRow->startDurationMove(m_pressPos.x() - m_ruler->x()); } else if (m_clickedTimelineControlType == TimelineControlType::StartHandle || m_clickedTimelineControlType == TimelineControlType::EndHandle) { + m_editedTimelineRow->updateBoundChildren( + m_clickedTimelineControlType + == TimelineControlType::StartHandle); } m_autoScrollTimelineTimer.start(); } 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 &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 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 m_keyframes; QColor m_barColor; + QVector> m_boundChildrenStart; + QVector> m_boundChildrenEnd; friend class RowTree; }; -- cgit v1.2.3