From 11f39321cf1f2b5f3790ed819051f56411e98261 Mon Sep 17 00:00:00 2001 From: Kruti Shah Date: Mon, 5 Mar 2012 11:59:31 -0800 Subject: Timeline: Removing Events for Adding and Deleting Layer, Taking care of BreadCrumb Signed-off-by: Kruti Shah --- .../Timeline/TimelinePanel.reel/TimelinePanel.js | 326 +++++++++------------ 1 file changed, 141 insertions(+), 185 deletions(-) (limited to 'js/panels/Timeline') diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 93fd170e..48181ae7 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -156,6 +156,22 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { } }, + _breadCrumbContainer:{ + value:null + }, + + breadCrumbContainer: { + set: function(value) { + if(this._breadCrumbContainer !== value) { + this._breadCrumbContainer = value; + this.LayerBinding(this.application.ninja.currentSelectedContainer); + } + }, + get: function() { + return this._breadCrumbContainer; + } + }, + _isLayer:{ value:false }, @@ -221,6 +237,11 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { for (i = 0; i < arrEventsLength; i++) { this.eventManager.addEventListener(arrEvents[i], this, false); } + Object.defineBinding(this, "breadCrumbContainer", { + boundObject: this.application.ninja, + boundObjectPropertyPath:"currentSelectedContainer", + oneway: true + }); } } }, @@ -247,8 +268,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { value:function () { var myIndex; this.drawTimeMarkers(); - this._hashKey = "123"; - + this._hashKey = this.application.ninja.currentSelectedContainer.uuid; // Document switching // Check to see if we have saved timeline information in the currentDocument. if (typeof(this.application.ninja.currentDocument.isTimelineInitialized) === "undefined") { @@ -268,16 +288,16 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { while(this.application.ninja.currentDocument.documentRoot.children[myIndex]) { this._openDoc=true; - NJevent('newLayer',{key:this._hashKey,ele:this.application.ninja.currentDocument.documentRoot.children[myIndex]}) + this.restoreLayer(this.application.ninja.currentDocument.documentRoot.children[myIndex]); myIndex++; } } else{ - NJevent('newLayer', this._hashKey); + this.restoreLayer(1); this.selectLayer(0); } }else{ - NJevent('newLayer', this._hashKey); + this.createNewLayer(1); this.selectLayer(0); } @@ -332,6 +352,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.selectedTweens = []; this._captureSelection = false; this._openDoc = false; + this._firstTimeLoaded=true; this.end_hottext.value = 25; this.updateTrackContainerWidth(); } @@ -345,7 +366,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this._bindDocumentEvents(); this.hashInstance = this.createLayerHashTable(); - this.hashTrackInstance = this.createTrackHashTable(); this.hashLayerNumber = this.createLayerNumberHash(); this.hashElementMapToLayer = this.createElementMapToLayer(); this.initTimelineForDocument(); @@ -456,34 +476,26 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { // nothing is selected, do not delete return; } - this._deleteKeyDown = false; - if (this.application.ninja.currentSelectedContainer.id === "UserContent") { - this._hashKey = "123"; - } this.removeLayer(); } }, - handleLayerBinding:{ - value:function (event) { + LayerBinding:{ + value:function (node) { var i = 0; + if (this._firstTimeLoaded) { this._firstTimeLoaded = false; } else { this.arrLayers.length = 0; this.arrTracks.length = 0; + this._hashKey = node.uuid; - if (event.detail.element.id === "UserContent") { - this._hashKey = "123"; - } else { - this._hashKey = event.detail.element.uuid; - } if (this.returnedObject = this.hashInstance.getItem(this._hashKey)) { - this.returnedTrack = this.hashTrackInstance.getItem(this._hashKey); this._hashFind = true; } this.currentLayerNumber = 0; - NJevent('newLayer', event.detail); + this.createNewLayer(1); this.selectLayer(0); } } @@ -499,44 +511,15 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { } }, - handleNewLayer:{ - value:function (event) { - var hashIndex = 0 , hashVariable = 0, layerResult, trackResult, layerObject, trackObject, dLayer, parentNode; - if (this._hashFind) { - while (layerResult = this.returnedObject[hashIndex]) { - trackResult = this.returnedTrack[hashIndex]; - if (layerResult.deleted !== true) { - - // TODO: Help from Kruti - this.arrTracks.push(trackResult); - this.arrLayers.push(layerResult); - - } - hashIndex++; - } - this._hashFind = false; - return; - } - if (event.detail._undoStatus) { - if (this.application.ninja.currentSelectedContainer.id === "UserContent" && event.detail._el.parentElementUUID === 123) { - dLayer = this.hashInstance.getItem(event.detail._el.parentElementUUID); - while (dLayer[hashVariable]) { - if (dLayer[hashVariable]._layerID === event.detail._el._layerID) { - dLayer[hashVariable].deleted = false; - - // TODO: Help from Kruti - this.arrTracks.splice(event.detail._layerPosition, 0, event.detail._track); - this.arrLayers.splice(event.detail._layerPosition, 0, event.detail._el); - this.selectLayer(event.detail._layerPosition); - break; + createNewLayer:{ + value:function(object){ + var hashVariable = 0; - } - hashVariable++; - } - } else if (event.detail._el.parentElementUUID !== this.application.ninja.currentSelectedContainer.uuid) { - dLayer = this.hashInstance.getItem(event.detail._el.parentElementUUID); + if (object._undoStatus) { + if (object._el.parentElementUUID !== this.application.ninja.currentSelectedContainer.uuid) { + dLayer = this.hashInstance.getItem(object._el.parentElementUUID); while (dLayer[hashVariable]) { - if (dLayer[hashVariable]._layerID === event.detail._el._layerID) { + if (dLayer[hashVariable]._layerID === object._el._layerID) { dLayer[hashVariable].deleted = false; parentNode = dLayer[hashVariable].parentElement; break; @@ -544,26 +527,97 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { hashVariable++; } this.application.ninja.currentSelectedContainer = parentNode; + this.LayerBinding(parentNode); } else { - dLayer = this.hashInstance.getItem(event.detail._el.parentElementUUID); + dLayer = this.hashInstance.getItem(object._el.parentElementUUID); while (dLayer[hashVariable]) { - if (dLayer[hashVariable]._layerID === event.detail._el._layerID) { + if (dLayer[hashVariable]._layerID === object._el._layerID) { dLayer[hashVariable].deleted = false; - - // TODO: Help from Kruti - this.arrTracks.splice(event.detail._layerPosition, 0, event.detail._track); - this.arrLayers.splice(event.detail._layerPosition, 0, event.detail._el); - this.selectLayer(event.detail._layerPosition); + + this.arrLayers.splice(object._layerPosition, 0, object._el); + this.selectLayer(object._layerPosition); break; } hashVariable++; } } + }else{ + + var newLayerName = "", + thingToPush = {}, + myIndex = 0; + + this.currentLayerNumber = this.hashLayerNumber.getItem(this._hashKey); + if (this.currentLayerNumber === undefined) { + this.currentLayerNumber = 0; } + this.currentLayerNumber = this.currentLayerNumber + 1; + newLayerName = "Layer " + this.currentLayerNumber; + thingToPush.layerName = newLayerName; + thingToPush.layerID = this.currentLayerNumber; + thingToPush.isMainCollapsed = true; + thingToPush.isPositionCollapsed = true; + thingToPush.isTransformCollapsed = true; + thingToPush.isStyleCollapsed = true; + thingToPush.arrLayerStyles = []; + thingToPush.elementsList = []; + thingToPush.deleted = false; + thingToPush.isSelected = false; + thingToPush.created=false; + thingToPush.isTrackAnimated = false; + thingToPush.currentKeyframeRule = null; + thingToPush.trackPosition = 0; + thingToPush.arrStyleTracks = []; + thingToPush.tweens = []; + + thingToPush.parentElementUUID = this._hashKey; + thingToPush.parentElement = this.application.ninja.currentSelectedContainer; + + if (!!this.layerRepetition.selectedIndexes) { + myIndex = this.layerRepetition.selectedIndexes[0]; + thingToPush.layerPosition = myIndex; + thingToPush.isSelected = true; + thingToPush.trackPosition = myIndex; + this.arrLayers.splice(myIndex, 0, thingToPush); + this._LayerUndoPosition = myIndex; + this.selectLayer(myIndex); + this.hashLayerNumber.setItem(this._hashKey, thingToPush); + this.hashInstance.setItem(this._hashKey, thingToPush, myIndex); - else { + } else { + this.arrLayers.splice(0, 0, thingToPush); + thingToPush.layerPosition = this.arrLayers.length - 1; + this._LayerUndoPosition = this.arrLayers.length - 1; + this.hashLayerNumber.setItem(this._hashKey, thingToPush); + this.hashInstance.setItem(this._hashKey, thingToPush, thingToPush.layerPosition); + this.selectLayer(0); + + } + + this._LayerUndoObject = thingToPush; + this._LayerUndoIndex = thingToPush.layerID; + this._LayerUndoStatus = true; + } + + } + }, + + restoreLayer:{ + value:function (ele) { + var hashIndex = 0 ,layerResult + if (this._hashFind) { + while (layerResult = this.returnedObject[hashIndex]) { + if (layerResult.deleted !== true) { + this.arrLayers.push(layerResult); + + } + hashIndex++; + } + this._hashFind = false; + return; + }else { var newLayerName = "", thingToPush = {}, newTrack = {}, @@ -593,24 +647,12 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { thingToPush.arrStyleTracks = []; thingToPush.tweens = []; - if (_firstLayerDraw) { - - this.application.ninja.currentSelectedContainer.uuid=this._hashKey; - thingToPush.parentElementUUID = this._hashKey; - thingToPush.parentElement = this.application.ninja.currentSelectedContainer; - } + thingToPush.parentElementUUID = this._hashKey; + thingToPush.parentElement = this.application.ninja.currentSelectedContainer; if(this._openDoc){ - event.detail.ele.uuid =nj.generateRandom(); - thingToPush.elementsList.push(event.detail.ele); - } - - if (_firstLayerDraw) { - if (this.application.ninja.currentSelectedContainer.id === "UserContent") { - this._hashKey = "123"; - this.application.ninja.currentSelectedContainer.uuid=this._hashKey; - thingToPush.parentElementUUID = 123; - } + ele.uuid =nj.generateRandom(); + thingToPush.elementsList.push(ele); } if (!!this.layerRepetition.selectedIndexes) { @@ -623,91 +665,58 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.selectLayer(myIndex); this.hashLayerNumber.setItem(this._hashKey, thingToPush); this.hashInstance.setItem(this._hashKey, thingToPush, myIndex); - - // TODO: Help from Kruti - this.hashTrackInstance.setItem(this._hashKey, newTrack, myIndex); + } else { this.arrLayers.splice(0, 0, thingToPush); thingToPush.layerPosition = this.arrLayers.length - 1; - - // TODO: Help from Kruti - newTrack.trackPosition = this.arrTracks.length - 1; this._LayerUndoPosition = this.arrLayers.length - 1; this.hashLayerNumber.setItem(this._hashKey, thingToPush); this.hashInstance.setItem(this._hashKey, thingToPush, thingToPush.layerPosition); - this.hashTrackInstance.setItem(this._hashKey, newTrack, newTrack.trackPosition); this.selectLayer(0); } if(this._openDoc){ var selectedIndex = this.getLayerIndexByID(thingToPush.layerID) - this.hashElementMapToLayer.setItem(event.detail.ele.uuid, event.detail.ele,this.arrLayers[selectedIndex]); + this.hashElementMapToLayer.setItem(ele.uuid,ele,this.arrLayers[selectedIndex]); this._openDoc=false; } this._LayerUndoObject = thingToPush; this._LayerUndoIndex = thingToPush.layerID; this._LayerUndoStatus = true; - this._TrackUndoObject = newTrack; + } } }, - handleDeleteLayer:{ - value:function (event) { - var dLayer, dTrack, parentNode, hashVariable = 0, k = 0, index = 0, j = 0; + deleteLayer:{ + value:function (object) { + var dLayer,parentNode, hashVariable = 0, k = 0, index = 0, j = 0; if (this.arrLayers.length > 0) { - if (event.detail._undoStatus) { - if (this.application.ninja.currentSelectedContainer.id === "UserContent" && event.detail._el.parentElementUUID === 123) { - dLayer = this.hashInstance.getItem(event.detail._el.parentElementUUID); + if (object._undoStatus) { + if (object._el.parentElementUUID !== this.application.ninja.currentSelectedContainer.uuid) { + dLayer = this.hashInstance.getItem(object._el.parentElementUUID); while (dLayer[hashVariable]) { - if (dLayer[hashVariable].deleted === true) { - - } else if (dLayer[hashVariable]._layerID === event.detail._el._layerID) { - while (this.arrLayers.length) { - if (dLayer[hashVariable]._layerID === this.arrLayers[k]._layerID) { - dLayer[hashVariable].deleted = true; -// ElementMediator.deleteElements(dLayer[myIndex].element); - this.arrLayers.splice(k, 1); - //this.arrTracks.splice(k, 1); - if(k>0){ - this.selectLayer(k-1); - }else{ - this.selectLayer(k) - } - break; - } - k++; - } - } - hashVariable++; - } - - } else if (event.detail._el.parentElementUUID !== this.application.ninja.currentSelectedContainer.uuid) { - dLayer = this.hashInstance.getItem(event.detail._el.parentElementUUID); - while (dLayer[hashVariable]) { - if (dLayer[hashVariable]._layerID === event.detail._el._layerID) { + if (dLayer[hashVariable]._layerID === object._el._layerID) { dLayer[hashVariable].deleted = true; -// ElementMediator.deleteElements(dLayer[myIndex].element); parentNode = dLayer[hashVariable].parentElement; break; } hashVariable++; } this.application.ninja.currentSelectedContainer = parentNode; + this.LayerBinding(parentNode); } else { - dLayer = this.hashInstance.getItem(event.detail._el.parentElementUUID); + dLayer = this.hashInstance.getItem(object._el.parentElementUUID); while (dLayer[hashVariable]) { if (dLayer[hashVariable].deleted === true) { - } else if (dLayer[hashVariable]._layerID === event.detail._el._layerID) { + } else if (dLayer[hashVariable]._layerID === object._el._layerID) { while (this.arrLayers.length) { if (dLayer[hashVariable]._layerID === this.arrLayers[k]._layerID) { dLayer[hashVariable].deleted = true; -// ElementMediator.deleteElements(dLayer[myIndex].element); this.arrLayers.splice(k, 1); - //this.arrTracks.splice(k, 1); if(k>0){ this.selectLayer(k-1); }else{ @@ -726,16 +735,11 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { if (!!this.layerRepetition.selectedIndexes) { var myIndex = this.layerRepetition.selectedIndexes[0]; this._LayerUndoObject = this.arrLayers[myIndex]; - - // TODO: Help from Kruti - this._TrackUndoObject = this.arrTracks[myIndex]; dLayer = this.hashInstance.getItem(this._hashKey); - dTrack = this.hashTrackInstance.getItem(this._hashKey); dLayer[myIndex].deleted = true; this.arrLayers.splice(myIndex, 1); - //this.arrTracks.splice(myIndex, 1); this._LayerUndoIndex = this._LayerUndoObject.layerID; this._LayerUndoPosition = myIndex; @@ -749,15 +753,12 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { } else { dLayer = this.hashInstance.getItem(this._hashKey); - dTrack = this.hashTrackInstance.getItem(this._hashKey); dLayer[this.arrLayers.length - 1].deleted = true; ElementMediator.deleteElements(dLayer[this.arrLayers.length - 1].elementsList); this._LayerUndoPosition = this.arrLayers.length - 1; this._LayerUndoObject = this.arrLayers.pop(); this._LayerUndoIndex = this._LayerUndoObject.layerID; - - // TODO: Help from Kruti - this._TrackUndoObject = this.arrTracks.pop(); + } } } @@ -883,46 +884,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { } }, - createTrackHashTable:{ - value:function (key, value) { - var hashTrackObject; - hashTrackObject = Object.create(Object.prototype, { - counter:{ - value:0, - writable:true - }, - - setItem:{ - value:function (key, value, index) { - if (hashTrackObject[key] === undefined) { - hashTrackObject[key] = {}; - - } - if (hashTrackObject[key][index] !== undefined) { - this.counter = index; - while (hashTrackObject[key][this.counter]) { - this.counter++; - } - while (this.counter !== index) { - hashTrackObject[key][this.counter] = hashTrackObject[key][this.counter - 1]; - this.counter = this.counter - 1; - } - } - hashTrackObject[key][index] = value; - this.counter = 0; - } - }, - - getItem:{ - value:function (key) { - return hashTrackObject[key]; - } - } - }); - return hashTrackObject; - } - }, - createLayerNumberHash:{ value:function (key, value) { var hashLayerNumberObject; @@ -1067,7 +1028,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { cmd._layerID = this._LayerUndoIndex; cmd._layerPosition = this._LayerUndoPosition; cmd._undoStatus = this._LayerUndoStatus; - cmd._track = this._TrackUndoObject; NJevent("sendToUndo", cmd); } }, @@ -1080,7 +1040,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { cmd._layerID = this._LayerUndoIndex; cmd._layerPosition = this._LayerUndoPosition; cmd._undoStatus = this._LayerUndoStatus; - cmd._track = this._TrackUndoObject; NJevent("sendToUndo", cmd); } @@ -1089,26 +1048,22 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { addLayerCommand:{ value:function () { var command; + var that=this; command = Object.create(Object.prototype, { _el:{value:null, writable:true}, _layerID:{value:null, writable:true}, _layerPosition:{value:null, writable:true}, _undoStatus:{value:false, writable:true}, - _track:{value:null, writable:true}, description:{ value:"Add Layer"}, receiver:{value:TimelinePanel}, execute:{ value:function () { - - NJevent('newLayer', this) - - + that.createNewLayer(this); } }, unexecute:{ value:function () { - NJevent('deleteLayer', this) - + that.deleteLayer(this); } } }); @@ -1119,17 +1074,18 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { deleteLayerCommand:{ value:function () { var command; + var that=this; command = Object.create(Object.prototype, { description:{ value:"Delete Layer"}, receiver:{value:TimelinePanel}, execute:{ value:function () { - NJevent('deleteLayer', this) + that.deleteLayer(this); } }, unexecute:{ value:function () { - NJevent('newLayer', this) + that.createNewLayer(this); } } }); -- cgit v1.2.3 From e9f46776738343af427260190d0eddbd41fbbba3 Mon Sep 17 00:00:00 2001 From: Kruti Shah Date: Mon, 5 Mar 2012 16:21:11 -0800 Subject: Timeline: Fixing the layer switching Signed-off-by: Kruti Shah --- .../Timeline/TimelinePanel.reel/TimelinePanel.js | 42 +++++++++++++--------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'js/panels/Timeline') diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 48181ae7..4e7c71d0 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -277,11 +277,11 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.application.ninja.currentDocument.isTimelineInitialized = true; this.application.ninja.currentDocument.tlArrLayers = []; this.application.ninja.currentDocument.tlArrTracks = []; +// this.application.ninja.currentDocument.layerNumber = 0; // Loop through the DOM of the document to find layers and animations. // Fire off events as they are found. - _firstLayerDraw = false; if(!this.application.ninja.documentController.creatingNewFile){ if(this.application.ninja.currentDocument.documentRoot.children[0]){ myIndex=0; @@ -301,11 +301,12 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.selectLayer(0); } - _firstLayerDraw = true; - // After recreating the tracks and layers, store the result in the currentDocument. this.application.ninja.currentDocument.tlArrTracks = this.arrTracks; this.application.ninja.currentDocument.tlArrLayers = this.arrLayers; +// this.application.ninja.currentDocument.layerNumber = this.layerNumber; +// console.log(this.application.ninja.currentDocument) +// console.log(this.application.ninja.currentDocument.tlArrLayers); } else { // we do have information stored. Use it. @@ -314,6 +315,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.arrTracks = []; this.arrLayers = this.application.ninja.currentDocument.tlArrLayers; this.arrTracks = this.application.ninja.currentDocument.tlArrTracks; +// this.layerNumber = this.application.ninja.currentDocument.layerNumber; this._boolCacheArrays = true; } @@ -340,7 +342,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { // Clear variables--including repetitions. this.hashInstance = null; - this.hashTrackInstance = null; this.hashLayerNumber = null; this.hashElementMapToLayer = null; this.arrTracks = []; @@ -481,22 +482,24 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { }, LayerBinding:{ - value:function (node) { - var i = 0; + value:function (node) { + var i = 0; - if (this._firstTimeLoaded) { - this._firstTimeLoaded = false; - } else { - this.arrLayers.length = 0; - this.arrTracks.length = 0; - this._hashKey = node.uuid; + if(typeof(this.application.ninja.currentDocument.isTimelineInitialized) === "undefined"){ + if (this._firstTimeLoaded) { + this._firstTimeLoaded = false; + } else { + this.arrLayers.length = 0; + this.arrTracks.length = 0; + this._hashKey = node.uuid; - if (this.returnedObject = this.hashInstance.getItem(this._hashKey)) { - this._hashFind = true; + if (this.returnedObject = this.hashInstance.getItem(this._hashKey)) { + this._hashFind = true; + } + this.currentLayerNumber = 0; + this.createNewLayer(1); + this.selectLayer(0); } - this.currentLayerNumber = 0; - this.createNewLayer(1); - this.selectLayer(0); } } }, @@ -547,6 +550,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { var newLayerName = "", thingToPush = {}, myIndex = 0; +// console.log(this.application.ninja.currentDocument.layerNumber); this.currentLayerNumber = this.hashLayerNumber.getItem(this._hashKey); if (this.currentLayerNumber === undefined) { @@ -585,6 +589,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.selectLayer(myIndex); this.hashLayerNumber.setItem(this._hashKey, thingToPush); this.hashInstance.setItem(this._hashKey, thingToPush, myIndex); + this.layerNumber = thingToPush.layerID; } else { this.arrLayers.splice(0, 0, thingToPush); @@ -592,6 +597,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this._LayerUndoPosition = this.arrLayers.length - 1; this.hashLayerNumber.setItem(this._hashKey, thingToPush); this.hashInstance.setItem(this._hashKey, thingToPush, thingToPush.layerPosition); + this.layerNumber = thingToPush.layerID; this.selectLayer(0); } @@ -665,6 +671,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.selectLayer(myIndex); this.hashLayerNumber.setItem(this._hashKey, thingToPush); this.hashInstance.setItem(this._hashKey, thingToPush, myIndex); + this.layerNumber = thingToPush.layerID; } else { this.arrLayers.splice(0, 0, thingToPush); @@ -672,6 +679,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this._LayerUndoPosition = this.arrLayers.length - 1; this.hashLayerNumber.setItem(this._hashKey, thingToPush); this.hashInstance.setItem(this._hashKey, thingToPush, thingToPush.layerPosition); + this.layerNumber = thingToPush.layerID; this.selectLayer(0); } -- cgit v1.2.3 From c0beb03439c3d29051eff4362257e83c1d97d9c9 Mon Sep 17 00:00:00 2001 From: Kruti Shah Date: Tue, 6 Mar 2012 15:32:42 -0800 Subject: Timeline:Storing HashTable for switching docs Signed-off-by: Kruti Shah --- .../Timeline/TimelinePanel.reel/TimelinePanel.js | 115 ++++++++++++++------- 1 file changed, 76 insertions(+), 39 deletions(-) (limited to 'js/panels/Timeline') diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 4e7c71d0..3c3e0651 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -49,6 +49,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { value: function() { if (this._boolCacheArrays) { this.application.ninja.currentDocument.tlArrLayers = this.arrLayers; + } } }, @@ -69,6 +70,39 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { set:function (newVal) { if (newVal !== this._currentLayerNumber) { this._currentLayerNumber = newVal; + this._setCurrentLayerNumber(); + } + } + }, + + _setCurrentLayerNumber:{ + value:function(){ + if (this._boolCacheArrays) { + this.application.ninja.currentDocument.tllayerNumber = this.currentLayerNumber; + } + } + }, + + _hashKey:{ + value:0 + }, + + hashKey:{ + get:function () { + return this._hashKey; + }, + set:function (newVal) { + if (newVal !== this._hashKey) { + this._hashKey = newVal; + this._setHashKey(); + } + } + }, + + _setHashKey:{ + value:function(){ + if (this._boolCacheArrays) { + this.application.ninja.currentDocument.hashKey = this.hashKey; } } }, @@ -220,11 +254,9 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { value: function(boolUnbind) { var arrEvents = ["deleteLayerClick", "newLayer", - "deleteLayer", - "layerBinding", + "deleteLayer", "elementAdded", - "elementDeleted", - "deleteSelection", + "elementDeleted", "selectionChange"], i, arrEventsLength = arrEvents.length; @@ -268,7 +300,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { value:function () { var myIndex; this.drawTimeMarkers(); - this._hashKey = this.application.ninja.currentSelectedContainer.uuid; + // Document switching // Check to see if we have saved timeline information in the currentDocument. if (typeof(this.application.ninja.currentDocument.isTimelineInitialized) === "undefined") { @@ -277,9 +309,10 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.application.ninja.currentDocument.isTimelineInitialized = true; this.application.ninja.currentDocument.tlArrLayers = []; this.application.ninja.currentDocument.tlArrTracks = []; -// this.application.ninja.currentDocument.layerNumber = 0; - - + this.application.ninja.currentDocument.tllayerNumber = 0; + this.application.ninja.currentDocument.tlLayerHashTable=[]; + this.hashKey = this.application.ninja.currentSelectedContainer.uuid; + // Loop through the DOM of the document to find layers and animations. // Fire off events as they are found. if(!this.application.ninja.documentController.creatingNewFile){ @@ -304,9 +337,11 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { // After recreating the tracks and layers, store the result in the currentDocument. this.application.ninja.currentDocument.tlArrTracks = this.arrTracks; this.application.ninja.currentDocument.tlArrLayers = this.arrLayers; -// this.application.ninja.currentDocument.layerNumber = this.layerNumber; -// console.log(this.application.ninja.currentDocument) -// console.log(this.application.ninja.currentDocument.tlArrLayers); + this.application.ninja.currentDocument.tllayerNumber = this.currentLayerNumber; + this.application.ninja.currentDocument.tlLayerHashTable = this.hashInstance; + this.application.ninja.currentDocument.hashKey=this.hashKey; + + } else { // we do have information stored. Use it. @@ -315,8 +350,13 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.arrTracks = []; this.arrLayers = this.application.ninja.currentDocument.tlArrLayers; this.arrTracks = this.application.ninja.currentDocument.tlArrTracks; -// this.layerNumber = this.application.ninja.currentDocument.layerNumber; + this.currentLayerNumber = this.application.ninja.currentDocument.tllayerNumber; + this.hashInstance = this.application.ninja.currentDocument.tlLayerHashTable; + this.hashKey = this.application.ninja.currentDocument.hashKey; + this.selectLayer(0); this._boolCacheArrays = true; + + } // Redraw all the things @@ -491,9 +531,9 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { } else { this.arrLayers.length = 0; this.arrTracks.length = 0; - this._hashKey = node.uuid; + this.hashKey = node.uuid; - if (this.returnedObject = this.hashInstance.getItem(this._hashKey)) { + if (this.returnedObject = this.hashInstance.getItem(this.hashKey)) { this._hashFind = true; } this.currentLayerNumber = 0; @@ -550,12 +590,11 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { var newLayerName = "", thingToPush = {}, myIndex = 0; -// console.log(this.application.ninja.currentDocument.layerNumber); - this.currentLayerNumber = this.hashLayerNumber.getItem(this._hashKey); - if (this.currentLayerNumber === undefined) { - this.currentLayerNumber = 0; - } +// this.currentLayerNumber = this.hashLayerNumber.getItem(this._hashKey); +// if (this.currentLayerNumber === undefined) { +// this.currentLayerNumber = 0; +// } this.currentLayerNumber = this.currentLayerNumber + 1; newLayerName = "Layer " + this.currentLayerNumber; @@ -576,7 +615,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { thingToPush.arrStyleTracks = []; thingToPush.tweens = []; - thingToPush.parentElementUUID = this._hashKey; + thingToPush.parentElementUUID = this.hashKey; thingToPush.parentElement = this.application.ninja.currentSelectedContainer; if (!!this.layerRepetition.selectedIndexes) { @@ -587,17 +626,16 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.arrLayers.splice(myIndex, 0, thingToPush); this._LayerUndoPosition = myIndex; this.selectLayer(myIndex); - this.hashLayerNumber.setItem(this._hashKey, thingToPush); - this.hashInstance.setItem(this._hashKey, thingToPush, myIndex); - this.layerNumber = thingToPush.layerID; + this.hashLayerNumber.setItem(this.hashKey, thingToPush); + this.hashInstance.setItem(this.hashKey, thingToPush, myIndex); + } else { this.arrLayers.splice(0, 0, thingToPush); thingToPush.layerPosition = this.arrLayers.length - 1; this._LayerUndoPosition = this.arrLayers.length - 1; - this.hashLayerNumber.setItem(this._hashKey, thingToPush); - this.hashInstance.setItem(this._hashKey, thingToPush, thingToPush.layerPosition); - this.layerNumber = thingToPush.layerID; + this.hashLayerNumber.setItem(this.hashKey, thingToPush); + this.hashInstance.setItem(this.hashKey, thingToPush, thingToPush.layerPosition); this.selectLayer(0); } @@ -629,10 +667,10 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { newTrack = {}, myIndex = 0; - this.currentLayerNumber = this.hashLayerNumber.getItem(this._hashKey); - if (this.currentLayerNumber === undefined) { - this.currentLayerNumber = 0; - } +// this.currentLayerNumber = this.hashLayerNumber.getItem(this._hashKey); +// if (this.currentLayerNumber === undefined) { +// this.currentLayerNumber = 0; +// } this.currentLayerNumber = this.currentLayerNumber + 1; newLayerName = "Layer " + this.currentLayerNumber; @@ -653,7 +691,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { thingToPush.arrStyleTracks = []; thingToPush.tweens = []; - thingToPush.parentElementUUID = this._hashKey; + thingToPush.parentElementUUID = this.hashKey; thingToPush.parentElement = this.application.ninja.currentSelectedContainer; if(this._openDoc){ @@ -669,17 +707,15 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.arrLayers.splice(myIndex, 0, thingToPush); this._LayerUndoPosition = myIndex; this.selectLayer(myIndex); - this.hashLayerNumber.setItem(this._hashKey, thingToPush); - this.hashInstance.setItem(this._hashKey, thingToPush, myIndex); - this.layerNumber = thingToPush.layerID; + this.hashLayerNumber.setItem(this.hashKey, thingToPush); + this.hashInstance.setItem(this.hashKey, thingToPush, myIndex); } else { this.arrLayers.splice(0, 0, thingToPush); thingToPush.layerPosition = this.arrLayers.length - 1; this._LayerUndoPosition = this.arrLayers.length - 1; - this.hashLayerNumber.setItem(this._hashKey, thingToPush); - this.hashInstance.setItem(this._hashKey, thingToPush, thingToPush.layerPosition); - this.layerNumber = thingToPush.layerID; + this.hashLayerNumber.setItem(this.hashKey, thingToPush); + this.hashInstance.setItem(this.hashKey, thingToPush, thingToPush.layerPosition); this.selectLayer(0); } @@ -741,10 +777,11 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { } else { if (!!this.layerRepetition.selectedIndexes) { + var myIndex = this.layerRepetition.selectedIndexes[0]; this._LayerUndoObject = this.arrLayers[myIndex]; - dLayer = this.hashInstance.getItem(this._hashKey); + dLayer = this.hashInstance.getItem(this.hashKey); dLayer[myIndex].deleted = true; this.arrLayers.splice(myIndex, 1); @@ -760,7 +797,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { ElementMediator.deleteElements(dLayer[myIndex].elementsList); } else { - dLayer = this.hashInstance.getItem(this._hashKey); + dLayer = this.hashInstance.getItem(this.hashKey); dLayer[this.arrLayers.length - 1].deleted = true; ElementMediator.deleteElements(dLayer[this.arrLayers.length - 1].elementsList); this._LayerUndoPosition = this.arrLayers.length - 1; -- cgit v1.2.3 From c6c03fff50aaad7f7f8d02690f761358d3da9335 Mon Sep 17 00:00:00 2001 From: Kruti Shah Date: Tue, 6 Mar 2012 15:38:38 -0800 Subject: Timeline: Storing Hashtable for element Mapping Signed-off-by: Kruti Shah --- js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js/panels/Timeline') diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 3c3e0651..c17a3290 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -339,6 +339,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.application.ninja.currentDocument.tlArrLayers = this.arrLayers; this.application.ninja.currentDocument.tllayerNumber = this.currentLayerNumber; this.application.ninja.currentDocument.tlLayerHashTable = this.hashInstance; + this.application.ninja.currentDocument.tlElementHashTable = this.hashElementMapToLayer; this.application.ninja.currentDocument.hashKey=this.hashKey; @@ -352,6 +353,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.arrTracks = this.application.ninja.currentDocument.tlArrTracks; this.currentLayerNumber = this.application.ninja.currentDocument.tllayerNumber; this.hashInstance = this.application.ninja.currentDocument.tlLayerHashTable; + this.hashElementMapToLayer = this.application.ninja.currentDocument.tlElementHashTable; this.hashKey = this.application.ninja.currentDocument.hashKey; this.selectLayer(0); this._boolCacheArrays = true; -- cgit v1.2.3