diff options
Diffstat (limited to 'js/panels')
-rw-r--r-- | js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | 94 |
1 files changed, 60 insertions, 34 deletions
diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 556c082d..5ae59c4e 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | |||
@@ -31,7 +31,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
31 | set:function (newVal) { | 31 | set:function (newVal) { |
32 | this._arrLayers = newVal; | 32 | this._arrLayers = newVal; |
33 | this.needsDraw = true; | 33 | this.needsDraw = true; |
34 | this._cacheArrays(); | 34 | this.cacheTimeline(); |
35 | } | 35 | } |
36 | }, | 36 | }, |
37 | 37 | ||
@@ -64,15 +64,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
64 | } | 64 | } |
65 | }, | 65 | }, |
66 | 66 | ||
67 | _cacheArrays:{ | ||
68 | value:function () { | ||
69 | if (this._boolCacheArrays) { | ||
70 | this.application.ninja.currentDocument.tlArrLayers = this.arrLayers; | ||
71 | this.application.ninja.currentDocument.tlCurrentSelectedContainer=this.application.ninja.currentSelectedContainer; | ||
72 | } | ||
73 | } | ||
74 | }, | ||
75 | |||
76 | // Set to false to skip array caching array sets in current document | 67 | // Set to false to skip array caching array sets in current document |
77 | _boolCacheArrays:{ | 68 | _boolCacheArrays:{ |
78 | value:true | 69 | value:true |
@@ -89,15 +80,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
89 | set:function (newVal) { | 80 | set:function (newVal) { |
90 | if (newVal !== this._currentLayerNumber) { | 81 | if (newVal !== this._currentLayerNumber) { |
91 | this._currentLayerNumber = newVal; | 82 | this._currentLayerNumber = newVal; |
92 | this._setCurrentLayerNumber(); | 83 | this.cacheTimeline(); |
93 | } | ||
94 | } | ||
95 | }, | ||
96 | |||
97 | _setCurrentLayerNumber:{ | ||
98 | value:function () { | ||
99 | if (this._boolCacheArrays) { | ||
100 | this.application.ninja.currentDocument.tllayerNumber = this.currentLayerNumber; | ||
101 | } | 84 | } |
102 | } | 85 | } |
103 | }, | 86 | }, |
@@ -111,7 +94,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
111 | }, | 94 | }, |
112 | set:function (newVal) { | 95 | set:function (newVal) { |
113 | this._currentLayerSelected = newVal; | 96 | this._currentLayerSelected = newVal; |
114 | this.application.ninja.currentDocument.tlCurrentLayerSelected = newVal; | 97 | this.cacheTimeline(); |
115 | } | 98 | } |
116 | }, | 99 | }, |
117 | 100 | ||
@@ -300,7 +283,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
300 | 283 | ||
301 | this.arrLayers.splice(dragLayerIndex, 1); | 284 | this.arrLayers.splice(dragLayerIndex, 1); |
302 | this.arrLayers.splice(dropLayerIndex, 0, dragLayer); | 285 | this.arrLayers.splice(dropLayerIndex, 0, dragLayer); |
303 | this.application.ninja.currentDocument.tlArrLayers = this.arrLayers; | 286 | this.cacheTimeline(); |
304 | 287 | ||
305 | // Clear for future DnD | 288 | // Clear for future DnD |
306 | this._dropLayerID = null; | 289 | this._dropLayerID = null; |
@@ -432,6 +415,31 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
432 | } | 415 | } |
433 | }, | 416 | }, |
434 | 417 | ||
418 | // cache Timeline data in currentDocument. | ||
419 | cacheTimeline: { | ||
420 | value: function() { | ||
421 | // Store the timeline data in currentDocument... | ||
422 | if (this._boolCacheArrays) { | ||
423 | // ... but only if we're supposed to. | ||
424 | this.application.ninja.currentDocument.tlArrLayers = this.arrLayers; | ||
425 | this.application.ninja.currentDocument.tlCurrentSelectedContainer = this.currentSelectedContainer; | ||
426 | this.application.ninja.currentDocument.tllayerNumber = this.currentLayerNumber; | ||
427 | this.application.ninja.currentDocument.tlCurrentLayerSelected = this.currentLayerSelected; | ||
428 | } | ||
429 | } | ||
430 | }, | ||
431 | // Initialize Timeline cache in currentDocument. | ||
432 | initTimelineCache: { | ||
433 | value: function() { | ||
434 | // Initialize the currentDocument for a new set of timeline data. | ||
435 | this.application.ninja.currentDocument.isTimelineInitialized = true; | ||
436 | this.application.ninja.currentDocument.tlArrLayers = []; | ||
437 | this.application.ninja.currentDocument.tlCurrentSelectedContainer = this.application.ninja.currentSelectedContainer; | ||
438 | this.application.ninja.currentDocument.tllayerNumber = this.currentLayerNumber; | ||
439 | this.application.ninja.currentDocument.tlCurrentLayerSelected = null; | ||
440 | } | ||
441 | }, | ||
442 | |||
435 | // Create an array of style objects for an element, for use | 443 | // Create an array of style objects for an element, for use |
436 | // in creating a new layer | 444 | // in creating a new layer |
437 | createLayerStyles : { | 445 | createLayerStyles : { |
@@ -532,12 +540,11 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
532 | this.drawTimeMarkers(); | 540 | this.drawTimeMarkers(); |
533 | // Document switching | 541 | // Document switching |
534 | // Check to see if we have saved timeline information in the currentDocument. | 542 | // Check to see if we have saved timeline information in the currentDocument. |
543 | |||
544 | |||
535 | if (typeof(this.application.ninja.currentDocument.isTimelineInitialized) === "undefined" || this.application.ninja.breadCrumbClick) { | 545 | if (typeof(this.application.ninja.currentDocument.isTimelineInitialized) === "undefined" || this.application.ninja.breadCrumbClick) { |
536 | // No, we have no information stored. Create it. | 546 | // No, we have no information stored. Create it. |
537 | this.application.ninja.currentDocument.isTimelineInitialized = true; | 547 | this.initTimelineCache(); |
538 | this.application.ninja.currentDocument.tlArrLayers = []; | ||
539 | this.application.ninja.currentDocument.tllayerNumber = 0; | ||
540 | this.application.ninja.currentDocument.tlCurrentSelectedContainer = null; | ||
541 | this.temparrLayers = []; | 548 | this.temparrLayers = []; |
542 | 549 | ||
543 | // Are we opening an existing doc? | 550 | // Are we opening an existing doc? |
@@ -549,7 +556,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
549 | this._openDoc = true; | 556 | this._openDoc = true; |
550 | this.restoreLayer(parentNode.children[myIndex]); | 557 | this.restoreLayer(parentNode.children[myIndex]); |
551 | } | 558 | } |
552 | |||
553 | }else if (this.application.ninja.currentDocument.documentRoot.children[0]) { | 559 | }else if (this.application.ninja.currentDocument.documentRoot.children[0]) { |
554 | // Yes, it has DOM elements. Loop through them and create a new object for each. | 560 | // Yes, it has DOM elements. Loop through them and create a new object for each. |
555 | for (myIndex = 0; this.application.ninja.currentDocument.documentRoot.children[myIndex]; myIndex++) { | 561 | for (myIndex = 0; this.application.ninja.currentDocument.documentRoot.children[myIndex]; myIndex++) { |
@@ -557,41 +563,60 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
557 | this.restoreLayer(this.application.ninja.currentDocument.documentRoot.children[myIndex]); | 563 | this.restoreLayer(this.application.ninja.currentDocument.documentRoot.children[myIndex]); |
558 | } | 564 | } |
559 | } | 565 | } |
560 | // Feed the new array of objects into the repetitions. | 566 | // }else if(this.application.ninja.breadCrumbClick){ |
561 | this.arrLayers = this.temparrLayers; | 567 | } else { |
562 | }else if(this.application.ninja.breadCrumbClick){ | 568 | |
563 | var parentNode = this.application.ninja.currentSelectedContainer; | 569 | var parentNode = this.application.ninja.currentSelectedContainer; |
564 | for (myIndex = 0; parentNode.children[myIndex]; myIndex++) { | 570 | for (myIndex = 0; parentNode.children[myIndex]; myIndex++) { |
565 | this._openDoc = true; | 571 | this._openDoc = true; |
566 | this.restoreLayer(parentNode.children[myIndex]); | 572 | this.restoreLayer(parentNode.children[myIndex]); |
567 | } | 573 | } |
568 | this.arrLayers = this.temparrLayers; | ||
569 | |||
570 | } | 574 | } |
571 | 575 | ||
572 | // After recreating the tracks and layers, store the result in the currentDocument. | 576 | // After recreating the tracks and layers, store the result in the currentDocument. |
577 | /* | ||
573 | this.application.ninja.currentDocument.tlArrLayers = this.arrLayers; | 578 | this.application.ninja.currentDocument.tlArrLayers = this.arrLayers; |
574 | this.application.ninja.currentDocument.tllayerNumber = this.currentLayerNumber; | 579 | this.application.ninja.currentDocument.tllayerNumber = this.currentLayerNumber; |
575 | this.application.ninja.currentDocument.tlCurrentSelectedContainer=this.application.ninja.currentSelectedContainer; | 580 | this.application.ninja.currentDocument.tlCurrentSelectedContainer=this.application.ninja.currentSelectedContainer; |
581 | */ | ||
582 | this.arrLayers = this.temparrLayers; | ||
583 | this.cacheTimeline(); | ||
576 | 584 | ||
577 | } else { | 585 | } else { |
578 | // we do have information stored. Use it. | 586 | // we do have information stored. Use it. |
579 | this._boolCacheArrays = false; | 587 | var i = 0, |
580 | for (var i = 0; i < this.application.ninja.currentDocument.tlArrLayers.length; i++) { | 588 | tlArrLayersLength = this.application.ninja.currentDocument.tlArrLayers.length; |
589 | |||
590 | // We're reading from the cache, not writing to it. | ||
591 | this._boolCacheArrays = false; | ||
592 | |||
593 | for (i = 0; i < tlArrLayersLength; i++) { | ||
581 | if (this.application.ninja.currentDocument.tlArrLayers[i].layerData.isSelected === true) { | 594 | if (this.application.ninja.currentDocument.tlArrLayers[i].layerData.isSelected === true) { |
582 | this.application.ninja.currentDocument.tlArrLayers[i].layerData._isFirstDraw = true; | 595 | this.application.ninja.currentDocument.tlArrLayers[i].layerData._isFirstDraw = true; |
596 | } else { | ||
597 | this.application.ninja.currentDocument.tlArrLayers[i].layerData._isFirstDraw = false; | ||
583 | } | 598 | } |
584 | } | 599 | } |
600 | |||
585 | this.arrLayers = this.application.ninja.currentDocument.tlArrLayers; | 601 | this.arrLayers = this.application.ninja.currentDocument.tlArrLayers; |
586 | this.currentLayerNumber = this.application.ninja.currentDocument.tllayerNumber; | 602 | this.currentLayerNumber = this.application.ninja.currentDocument.tllayerNumber; |
587 | this.currentLayerSelected = this.application.ninja.currentDocument.tlCurrentLayerSelected; | 603 | this.currentLayerSelected = this.application.ninja.currentDocument.tlCurrentLayerSelected; |
588 | this.application.ninja.currentSelectedContainer=this.application.ninja.currentDocument.tlCurrentSelectedContainer; | 604 | |
605 | if (typeof(this.application.ninja.currentDocument.tlCurrentSelectedContainer) !== "undefined") { | ||