diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-07-06 15:41:34 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2018-08-08 07:51:45 +0000 |
commit | d54689e9cbf931b6c97353001ac722f4877fae5d (patch) | |
tree | bd88cc8ff7fa869003f66b668d4370a193bcee74 | |
parent | 7c7e694096a3d225c5cc68711cd79ab443f97279 (diff) |
Make locked rows more locked
- Don't allow opening context menus for locked rows
- Don't allow editing locked row name
- Don't allow adjusting locked row timebar length
- Lock property rows of locked rows
- Disable and deselect keyframes of locked rows
- Adjusting timebar length/position of a parent row of a locked row
does no longer affect locked children.
- Allow expand/collapse of a locked row via arrow button
Task-number: QT3DS-1990
Change-Id: I4089956fbe2a3c1364e4f8f5772ad4d60459e61c
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
9 files changed, 124 insertions, 62 deletions
diff --git a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp index 87bc5d6d..d25c9790 100644 --- a/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp +++ b/src/Authoring/Client/Code/Core/Doc/DocumentEditor.cpp @@ -1951,17 +1951,23 @@ public: GetAssetChildrenInActiveSlide(inInstance, theChildren); for (; !theChildren.IsDone(); ++theChildren) { TInstanceHandle theChild = theChildren.GetCurrent(); - std::pair<long, long> theChildTimeRange = GetTimeRange(theChild); - if (inSetStart) { - // If we are resizing start time, if child's start time == parent's child time - // then we need to resize child as well - if (theChildTimeRange.first == theTimeRange.first) - ResizeTimeRange(theChild, inTime, inSetStart); - } else { - // If we are resizing end time, if child's end time == parent's end time - // then we need to resize child as well - if (theChildTimeRange.second == theTimeRange.second) - ResizeTimeRange(theChild, inTime, inSetStart); + // Do not adjust locked children + SValue locked; + m_PropertySystem.GetInstancePropertyValue( + theChild, m_Bridge.GetSceneAsset().m_Locked, locked); + if (!qt3dsdm::get<bool>(locked)) { + std::pair<long, long> theChildTimeRange = GetTimeRange(theChild); + if (inSetStart) { + // If we are resizing start time, if child's start time == parent's child time + // then we need to resize child as well + if (theChildTimeRange.first == theTimeRange.first) + ResizeTimeRange(theChild, inTime, inSetStart); + } else { + // If we are resizing end time, if child's end time == parent's end time + // then we need to resize child as well + if (theChildTimeRange.second == theTimeRange.second) + ResizeTimeRange(theChild, inTime, inSetStart); + } } } } @@ -1983,7 +1989,13 @@ public: CGraphIterator theChildren; GetAssetChildrenInActiveSlide(inInstance, theChildren); for (; !theChildren.IsDone(); ++theChildren) { - OffsetTimeRange(theChildren.GetCurrent(), inOffset); + TInstanceHandle theChild = theChildren.GetCurrent(); + // Do not adjust locked children + SValue locked; + m_PropertySystem.GetInstancePropertyValue( + theChild, m_Bridge.GetSceneAsset().m_Locked, locked); + if (!qt3dsdm::get<bool>(locked)) + OffsetTimeRange(theChild, inOffset); } } @@ -2007,8 +2019,15 @@ public: CGraphIterator theChildren; GetAssetChildrenInActiveSlide(inInstance, theChildren); - for (; !theChildren.IsDone(); ++theChildren) - TruncateTimeRange(theChildren.GetCurrent(), inSetStart, inTime); + for (; !theChildren.IsDone(); ++theChildren) { + TInstanceHandle theChild = theChildren.GetCurrent(); + // Do not adjust locked children + SValue locked; + m_PropertySystem.GetInstancePropertyValue( + theChild, m_Bridge.GetSceneAsset().m_Locked, locked); + if (!qt3dsdm::get<bool>(locked)) + TruncateTimeRange(theChild, inSetStart, inTime); + } } void SetTimebarColor(TInstanceHandle inInstance, ::CColor inColor) override diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp index cab31750..13908be2 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.cpp @@ -169,16 +169,17 @@ void KeyframeManager::selectKeyframesInRect(const QRectF &rect) RowTree *row = m_scene->rowManager()->getRowAtPos(QPointF(0, rect.top())); while (row && row->y() < rect.bottom()) { - const auto keyframes = row->rowTimeline()->getKeyframesInRange(rect); - for (auto keyframe : keyframes) { - if (!m_selectedKeyframes.contains(keyframe)) { - m_selectedKeyframes.append(keyframe); - - if (!m_selectedKeyframesMasterRows.contains(keyframe->rowMaster)) - m_selectedKeyframesMasterRows.append(keyframe->rowMaster); + if (!row->locked()) { + const auto keyframes = row->rowTimeline()->getKeyframesInRange(rect); + for (auto keyframe : keyframes) { + if (!m_selectedKeyframes.contains(keyframe)) { + m_selectedKeyframes.append(keyframe); + + if (!m_selectedKeyframesMasterRows.contains(keyframe->rowMaster)) + m_selectedKeyframesMasterRows.append(keyframe->rowMaster); + } } } - row = m_scene->rowManager()->getRowAtPos(QPointF(0, row->y() + row->size().height())); } @@ -225,6 +226,17 @@ void KeyframeManager::deselectAllKeyframes() m_selectedKeyframesMasterRows.clear(); } +void KeyframeManager::deselectRowKeyframes(RowTree *row) +{ + const QList<Keyframe *> keyframes = row->rowTimeline()->keyframes(); + for (const auto keyframe : keyframes) { + if (row->isProperty()) + deselectKeyframe(keyframe); + else + deselectConnectedKeyframes(keyframe); + } +} + bool KeyframeManager::deleteSelectedKeyframes() { if (!m_selectedKeyframes.empty()) { diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.h index 05626726..6af9896f 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.h +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/KeyframeManager.h @@ -59,6 +59,7 @@ public: void deselectKeyframe(Keyframe *keyframe); void deselectConnectedKeyframes(Keyframe *keyframe); void deselectAllKeyframes(); + void deselectRowKeyframes(RowTree *row); void deleteKeyframes(RowTimeline *row, bool repaint = true); void copySelectedKeyframes(); void pasteKeyframes(); diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp index 6c4437b2..7a087b78 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowManager.cpp @@ -142,10 +142,12 @@ void RowManager::createRowsFromBindingRecursive(ITimelineItemBinding *binding, R RowTree *RowManager::getOrCreatePropertyRow(RowTree *masterRow, const QString &propType, int index) { RowTree *propertyRow = masterRow->getPropertyRow(propType); - if (propertyRow) - return propertyRow; + if (!propertyRow) + propertyRow = createRow(OBJTYPE_UNKNOWN, masterRow, 0, propType, index); - return createRow(OBJTYPE_UNKNOWN, masterRow, 0, propType, index); + propertyRow->updateLock(masterRow->locked()); + + return propertyRow; } RowTree *RowManager::createRow(EStudioObjectType rowType, RowTree *parentRow, const QString &label, diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp index 38be631d..0a21c1fc 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/TimelineGraphicsScene.cpp @@ -790,7 +790,7 @@ void TimelineGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *even RowTreeLabelItem *treeLabelItem = static_cast<RowTreeLabelItem *>(item); if (treeLabelItem->parentRow()->isProperty()) { treeLabelItem->parentRow()->togglePropertyExpanded(); - } else { + } else if (!treeLabelItem->isLocked()) { // Tree labels text can be edited with double-click treeLabelItem->setEnabled(true); treeLabelItem->setFocus(); @@ -804,7 +804,8 @@ void TimelineGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *even timeEditDlg.setKeyframesManager(m_keyframeManager); timeEditDlg.showDialog(clickedKeyframe->time * 1000, doc, ASSETKEYFRAME); } else { - handleSetTimeBarTime(); + if (!rowTimeline->rowTree()->locked()) + handleSetTimeBarTime(); } } } @@ -853,7 +854,7 @@ void TimelineGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *eve RowTree *row = m_rowManager->getRowAtPos(QPointF(0, event->scenePos().y())); if (!row || m_widgetTimeline->isFullReconstructPending() || m_dragging - || m_startRowMoverOnNextDrag) { + || m_startRowMoverOnNextDrag || row->locked()) { return; } diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp index 60583eb2..c7ad859a 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTimeline.cpp @@ -225,10 +225,13 @@ void RowTimeline::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio = QPixmap(":/images/Keyframe-MasterDynamic-Normal.png"); static const QPixmap pixKeyframeMasterDynamicSelected = QPixmap(":/images/Keyframe-MasterDynamic-Selected.png"); - + static const QPixmap pixKeyframeMasterDisabled + = QPixmap(":/images/Keyframe-Master-Disabled.png"); for (auto keyframe : qAsConst(m_keyframes)) { QPixmap pixmap; - if (keyframe->selected()) { + if (m_rowTree->locked()) { + pixmap = pixKeyframeMasterDisabled; + } else if (keyframe->selected()) { if (keyframe->dynamic) pixmap = pixKeyframeMasterDynamicSelected; else @@ -250,10 +253,13 @@ void RowTimeline::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio = QPixmap(":/images/Keyframe-PropertyDynamic-Normal.png"); static const QPixmap pixKeyframePropertyDynamicSelected = QPixmap(":/images/Keyframe-PropertyDynamic-Selected.png"); - + static const QPixmap pixKeyframePropertyDisabled + = QPixmap(":/images/Keyframe-Property-Disabled.png"); for (auto keyframe : qAsConst(m_keyframes)) { QPixmap pixmap; - if (keyframe->selected()) { + if (m_rowTree->locked()) { + pixmap = pixKeyframePropertyDisabled; + } else if (keyframe->selected()) { if (keyframe->dynamic) pixmap = pixKeyframePropertyDynamicSelected; else @@ -313,6 +319,9 @@ void RowTimeline::drawColorPropertyGradient(QPainter *painter, int width) Keyframe *RowTimeline::getClickedKeyframe(const QPointF &scenePos) { + if (rowTree()->locked()) + return nullptr; + QPointF p = mapFromScene(scenePos.x(), scenePos.y()); double x; @@ -455,23 +464,25 @@ TimelineControlType RowTimeline::getClickedControl(const QPointF &scenePos) cons if (!m_rowTree->hasDurationBar()) return TimelineControlType::None; - QPointF p = mapFromScene(scenePos.x(), scenePos.y()); - 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 (endHandle) - return TimelineControlType::EndHandle; - else if (p.x() > m_startX && p.x() < m_endX && !rowTree()->locked()) - return TimelineControlType::Duration; + if (!m_rowTree->locked()) { + QPointF p = mapFromScene(scenePos.x(), scenePos.y()); + 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 (endHandle) + return TimelineControlType::EndHandle; + else if (p.x() > m_startX && p.x() < m_endX && !rowTree()->locked()) + return TimelineControlType::Duration; + } return TimelineControlType::None; } @@ -494,7 +505,7 @@ void RowTimeline::updateBoundChildren(bool start) if (m_rowTree->hasDurationBar()) { const auto childRows = m_rowTree->childRows(); for (auto child : childRows) { - if (child->hasDurationBar()) { + if (child->hasDurationBar() && !child->locked()) { RowTimeline *rowTimeline = child->rowTimeline(); if (start && rowTimeline->m_startX == m_startX) { m_boundChildrenStart.append(rowTimeline); @@ -544,8 +555,10 @@ void RowTimeline::moveDurationBy(double dx) updateChildrenMinStartXRecursive(m_rowTree); updateChildrenMaxEndXRecursive(m_rowTree); - for (RowTree *child : qAsConst(m_rowTree->m_childRows)) - child->m_rowTimeline->moveDurationBy(dx); + for (RowTree *child : qAsConst(m_rowTree->m_childRows)) { + if (!child->locked()) + child->m_rowTimeline->moveDurationBy(dx); + } } } @@ -581,8 +594,10 @@ void RowTimeline::moveDurationTo(double newX) updateChildrenMinStartXRecursive(m_rowTree); updateChildrenMaxEndXRecursive(m_rowTree); - for (RowTree *child : qAsConst(m_rowTree->m_childRows)) - child->m_rowTimeline->moveDurationBy(dx); + for (RowTree *child : qAsConst(m_rowTree->m_childRows)) { + if (!child->locked()) + child->m_rowTimeline->moveDurationBy(dx); + } } } diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp index 1ffcc0c4..60e76447 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.cpp @@ -37,6 +37,7 @@ #include "Qt3DSString.h" #include "TreeHeader.h" #include "StudioPreferences.h" +#include "KeyframeManager.h" #include <QtGui/qpainter.h> #include "QtGui/qtextcursor.h" @@ -714,13 +715,12 @@ void RowTree::updateFromBinding() // update view (shy, visible, locked) m_shy = m_binding->GetTimelineItem()->IsShy(); m_visible = m_binding->GetTimelineItem()->IsVisible(); - m_locked = m_binding->GetTimelineItem()->IsLocked(); + updateLock(m_binding->GetTimelineItem()->IsLocked()); m_visibilityCtrld = m_binding->GetTimelineItem()->IsVisibilityControlled(); - // Update label locking & color + // Update label color Qt3DSDMTimelineItemBinding *itemBinding = static_cast<Qt3DSDMTimelineItemBinding *>(m_binding); - m_labelItem.setLocked(m_locked); m_master = itemBinding->IsMaster(); m_labelItem.setMaster(m_master); } @@ -767,7 +767,7 @@ void RowTree::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) TreeControlType RowTree::getClickedControl(const QPointF &scenePos) { QPointF p = mapFromScene(scenePos.x(), scenePos.y()); - if (m_arrowVisible && m_rectArrow.contains(p.x(), p.y()) && !m_locked) { + if (m_arrowVisible && m_rectArrow.contains(p.x(), p.y())) { updateExpandStatus(m_expandState == ExpandState::Expanded ? ExpandState::Collapsed : ExpandState::Expanded, false); update(); @@ -845,16 +845,26 @@ void RowTree::updateExpandStatus(ExpandState state, bool animate, bool forceChil void RowTree::updateLockRecursive(bool state) { - m_locked = state; - m_labelItem.setLocked(m_locked); - update(); - + updateLock(state); if (!m_childRows.empty()) { for (auto child : qAsConst(m_childRows)) child->updateLockRecursive(m_locked); } } +void RowTree::updateLock(bool state) +{ + m_locked = state; + m_labelItem.setLocked(m_locked); + update(); + if (!m_childProps.empty()) { + for (auto child : qAsConst(m_childProps)) + child->updateLock(m_locked); + } + if (m_locked) + m_scene->keyframeManager()->deselectRowKeyframes(this); +} + void RowTree::updateLabelPosition() { int offset = 5 + m_depth * TimelineConstants::ROW_DEPTH_STEP + 30; diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h index 2e0f09c1..b714765c 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTree.h @@ -145,6 +145,7 @@ public: void updateExpandStatus(ExpandState state, bool animate = true, bool forceChildUpdate = false); void updateArrowVisibility(); void updateFilter(); + void updateLock(bool state); protected: void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h index 01d4be48..edffbef5 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/ui/RowTreeLabelItem.h @@ -50,6 +50,7 @@ public: RowTree *parentRow() const; void setParentRow(RowTree *row); int type() const; + bool isLocked() const { return m_locked; } protected: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; |