diff options
author | Mahmoud Badri <mahmoud.badri@qt.io> | 2018-05-17 12:59:19 +0300 |
---|---|---|
committer | Mahmoud Badri <mahmoud.badri@qt.io> | 2018-05-17 11:28:22 +0000 |
commit | f4645e0e2fdb8aad08d456efc2369cd80ffdabe0 (patch) | |
tree | 6e13d9ba00e8b55effded422f751ca831e3d6fdd /src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp | |
parent | 84a7afb1dfdab2324748758395a1789af5a26019 (diff) |
Prevent dragging effects to non-layer objects
Task-number: QT3DS-1690
Change-Id: Iba806f878f933648f9620482d367375a67ded09b
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp')
-rw-r--r-- | src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp index 7861023c..c13b237f 100644 --- a/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp +++ b/src/Authoring/Studio/Palettes/TimelineGraphicsView/RowMover.cpp @@ -175,23 +175,20 @@ void RowMover::updateTargetRow(const QPointF &scenePos) // calc insertion depth int depth; + int depthMin = rowInsert2 ? rowInsert2->depth() : 3; + int depthMax = rowInsert1->depth(); + if (rowInsert1->isContainer() && rowInsert1 != m_sourceRow) + depthMax++; // Container: allow insertion as a child + else if (rowInsert1->isPropertyOrMaterial() && !rowInsert1->parentRow()->isContainer()) + depthMax--; // non-container with properties and/or a material + if (m_sourceRow && m_sourceRow->rowType() == OBJTYPE_LAYER) { depth = 2; // layers can only be moved on depth 2 + } else if (m_sourceRow && m_sourceRow->rowType() == OBJTYPE_EFFECT) { + depth = 3; // effects can only be moved on depth 3 (layer direct child) } else if (m_sourceRow && m_sourceRow->rowType() == OBJTYPE_MATERIAL) { depth = m_sourceRow->depth(); // materials cannot change parent - if (rowInsert2 && depth < rowInsert2->depth()) - valid = false; } else { - int depthMin = rowInsert2 ? rowInsert2->depth() : 3; - int depthMax = rowInsert1->depth(); - - if (rowInsert1->isContainer() && rowInsert1 != m_sourceRow) { - depthMax++; // Container: allow insertion as a child - } else if (rowInsert1->isPropertyOrMaterial() - && !rowInsert1->parentRow()->isContainer()) { - depthMax--; // non-container with properties and/or a material - } - static const int LEFT_MARGIN = 20; depth = (scenePos.x() - LEFT_MARGIN) / TimelineConstants::ROW_DEPTH_STEP; depth = qBound(depthMin, depth, depthMax); @@ -204,6 +201,9 @@ void RowMover::updateTargetRow(const QPointF &scenePos) resetInsertionParent(insertParent); + if (depth < depthMin || depth > depthMax) + valid = false; + if (m_sourceRow && m_sourceRow->rowType() == OBJTYPE_MATERIAL && m_sourceRow->parentRow() != m_insertionParent) { valid = false; // not moving a material row outside its parent |