aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js')
-rw-r--r--js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js143
1 files changed, 88 insertions, 55 deletions
diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
index 7deaf0d1..ba745c82 100644
--- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
+++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
@@ -239,6 +239,18 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
239 } 239 }
240 }, 240 },
241 241
242 _lastInsertionIndex: {
243 value: false
244 },
245 lastInsertionIndex: {
246 get: function() {
247 return this._lastInsertionIndex;
248 },
249 set: function(newVal) {
250 this._lastInsertionIndex = newVal;
251 }
252 },
253
242 _areTracksScrolling: { 254 _areTracksScrolling: {
243 value: false 255 value: false
244 }, 256 },
@@ -1504,65 +1516,59 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
1504 } 1516 }
1505 } 1517 }
1506 }, 1518 },
1507 createstageElement:{
1508 value:function (object) {
1509 var stageElementName = "",
1510 thingToPush = this.createLayerTemplate(),
1511 myIndex = 0,
1512 i = 0,
1513 arrLayersLength = this.arrLayers.length;
1514 1519
1515 // Make up a layer name. 1520
1516 this.currentLayerNumber = this.currentLayerNumber + 1; 1521 createStageElementsAt: {
1517// stageElementName = "Layer " + this.currentLayerNumber; 1522 value:function (isPaste, arrElements) {
1518 stageElementName=" "; 1523
1519 1524 var i = 0,
1520 // Possibly currentLayerNumber doesn't correctly reflect the 1525 j = 0,
1521 // number of layers. Check that. 1526 arrElementsLength = arrElements.length,
1522 // Commented out to fix WebGL rendering bug 1527 arrNewLayers = [],
1523 /*for(k = 0; k < arrLayersLength; k++){ 1528 arrNewLayersLength = 0,
1524 if(this.arrLayers[k].layerData.layerName === stageElementName){ 1529 stageElementName = "",
1525 this.currentLayerNumber = this.currentLayerNumber + 1; 1530 targetIndex = 0;
1526 stageElementName = "Layer " + this.currentLayerNumber; 1531 if (this.lastInsertionIndex !== false) {
1527 break; 1532 targetIndex = this.lastInsertionIndex;
1528 } 1533 this.lastInsertionIndex = false;
1529 }*/ 1534 }
1535
1530 // We will no longer have multiple things selected, so wipe that info out 1536 // We will no longer have multiple things selected, so wipe that info out
1531 // if it isn't already gone. 1537 // if it isn't already gone.
1532 this.currentLayersSelected = false; 1538 this.currentLayersSelected = false;
1533
1534 // thingToPush is the template we just got. Now fill it in.
1535 thingToPush.layerData.layerName = stageElementName;
1536 thingToPush.layerData.layerTag = "<" + object.nodeName.toLowerCase() + ">";
1537 thingToPush.layerData.layerID = this.currentLayerNumber;
1538 thingToPush.parentElement = this.currentDocument.model.domContainer;
1539 thingToPush.layerData.isSelected = true;
1540 thingToPush.layerData._isFirstDraw = true;
1541 thingToPush.layerData.created = true;
1542 thingToPush.layerData.stageElement = object;
1543 thingToPush.layerData.isLock = false;
1544 thingToPush.layerData.isHidden = false;
1545 1539
1540 for (i = arrElementsLength-1; i >= 0; i--) {
1541 var thingToPush = this.createLayerTemplate();
1542
1543 // Make up a layer name.
1544 this.currentLayerNumber = this.currentLayerNumber + 1;
1545 stageElementName="";
1546
1547 // thingToPush is the template we just got. Now fill it in.
1548 thingToPush.layerData.layerName = stageElementName;
1549 thingToPush.layerData.layerTag = "<" + arrElements[i].nodeName.toLowerCase() + ">";
1550 thingToPush.layerData.layerID = this.currentLayerNumber;
1551 thingToPush.parentElement = this.currentDocument.model.domContainer;
1552 thingToPush.layerData.isSelected = true;
1553 thingToPush.layerData._isFirstDraw = true;
1554 thingToPush.layerData.created = true;
1555 thingToPush.layerData.stageElement = arrElements[i];
1556 thingToPush.layerData.isLock = false;
1557 thingToPush.layerData.isHidden = false;
1558 thingToPush.layerData.created = !isPaste;
1559 thingToPush.created = !isPaste;
1560
1561 if (this.checkable_animated.classList.contains("checked")) {
1562 thingToPush.layerData.isVisible = false;
1563 }
1564 //arrNewLayers.push(thingToPush);
1565 this.arrLayers.splice(targetIndex, 0, thingToPush);
1566 }
1567 //console.log(arrNewLayers);
1568 //console.log(thingToPush);
1569
1570 //this.arrLayers.splice(targetIndex, 0, arrNewLayers);
1546 1571
1547 if (this.checkable_animated.classList.contains("checked")) {
1548 thingToPush.layerData.isVisible = false;
1549 }
1550
1551 // Determine where the new array should be inserted in arrLayers.
1552 // Ordinarily we could use this.getInsertionIndex BUT the new element
1553 // insertion and selection has already fired, so getInsertionIndex will return
1554 // incorrect info. So we need to look at the DOM.
1555 var childrenLength = this.application.ninja.currentDocument.model.domContainer.children.length,
1556 newIndex = childrenLength -1;
1557 for (i = 0; i < childrenLength; i++) {
1558 var currTest = this.application.ninja.currentDocument.model.domContainer.children[i];
1559 if (object == currTest) {
1560 myIndex = newIndex - i;
1561 }
1562 }
1563
1564 this.arrLayers.splice(myIndex, 0, thingToPush);
1565 this.selectLayers([myIndex]);
1566 } 1572 }
1567 }, 1573 },
1568 1574
@@ -1647,8 +1653,32 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
1647 }, 1653 },
1648 1654
1649 handleElementAdded:{ 1655 handleElementAdded:{
1650 value:function() { 1656 value:function(event) {
1651 this.createstageElement(this.application.ninja.selectedElements[0]); 1657 var i = 0,
1658 targetIndex = 0;
1659 // One or more elements have been added to the stage.
1660 // We need to add them to the timeline.
1661 // But where?
1662 // If there are no layers, we can just leave targetIndex at 0.
1663 if (this.arrLayers.length !== 0) {
1664 // If nothing is selected, we can leave
1665 var firstInsertedElement;
1666 if (typeof(event.detail.length) === "undefined") {
1667 firstInsertedElement = event.detail;
1668 } else {
1669 firstInsertedElement = event.detail[0];
1670 }
1671
1672
1673 }
1674
1675 if (typeof(event.detail.length) === "undefined") {
1676 // This is a standard element creation event.
1677 this.createStageElementsAt(false, [event.detail]);
1678 } else {
1679 // This is a paste action, because event.detail has more than one item in it.
1680 this.createStageElementsAt(true, event.detail);
1681 }
1652 } 1682 }
1653 }, 1683 },
1654 1684
@@ -1750,9 +1780,11 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
1750 arrLayersLength = this.arrLayers.length, 1780 arrLayersLength = this.arrLayers.length,
1751 returnVal = arrLayersLength -1; 1781 returnVal = arrLayersLength -1;
1752 if (returnVal === -1) { 1782 if (returnVal === -1) {
1783 this.lastInsertionIndex = 0;
1753 return false; 1784 return false;
1754 } 1785 }
1755 if (this.currentLayersSelected === false) { 1786 if (this.currentLayersSelected === false) {
1787 this.lastInsertionIndex = 0;
1756 return false; 1788 return false;
1757 } 1789 }
1758 1790
@@ -1761,6 +1793,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
1761 returnVal = i; 1793 returnVal = i;
1762 } 1794 }
1763 } 1795 }
1796 this.lastInsertionIndex = returnVal;
1764 return returnVal; 1797 return returnVal;
1765 } 1798 }
1766 }, 1799 },