aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js153
1 files changed, 91 insertions, 62 deletions
diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
index 556c082d..a69f131d 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 : {
@@ -445,14 +453,16 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
445 newStyle = {}, 453 newStyle = {},
446 styleID = "1@0"; // format: layerID + "@" + style counter 454 styleID = "1@0"; // format: layerID + "@" + style counter
447 455
456 /* Example new style
448 newStyle.styleID = styleID; 457 newStyle.styleID = styleID;
449 newStyle.whichView = "propval"; 458 newStyle.whichView = "propval"; // Which view do we want to show, usually property/value view (see Style)
450 newStyle.editorProperty = "top"; 459 newStyle.editorProperty = "top"; // the style property
451 newStyle.editorValue = 0; 460 newStyle.editorValue = 0; // The current value
452 newStyle.ruleTweener = false; 461 newStyle.ruleTweener = false;
453 newStyle.isSelected = false; 462 newStyle.isSelected = false;
454 463
455 returnArray.push(newStyle); 464 returnArray.push(newStyle);
465 */
456 466
457 return returnArray; 467 return returnArray;
458 468
@@ -532,66 +542,82 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
532 this.drawTimeMarkers(); 542 this.drawTimeMarkers();
533 // Document switching 543 // Document switching
534 // Check to see if we have saved timeline information in the currentDocument. 544 // Check to see if we have saved timeline information in the currentDocument.
535 if (typeof(this.application.ninja.currentDocument.isTimelineInitialized) === "undefined" || this.application.ninja.breadCrumbClick) { 545 if (typeof(this.application.ninja.currentDocument.isTimelineInitialized) === "undefined") {
536 // No, we have no information stored. Create it. 546 // No, we have no information stored.
537 this.application.ninja.currentDocument.isTimelineInitialized = true; 547 // This could mean we are creating a new file, OR are opening an existing file.
538 this.application.ninja.currentDocument.tlArrLayers = []; 548
539 this.application.ninja.currentDocument.tllayerNumber = 0; 549 // First, initialize the caches.
540 this.application.ninja.currentDocument.tlCurrentSelectedContainer = null; 550 this.initTimelineCache();
541 this.temparrLayers = []; 551 this.temparrLayers = [];
542 552
543 // Are we opening an existing doc? 553 // That's all we need to do for a brand new file.
554 // But what if we're opening an existing document?
544 if (!this.application.ninja.documentController.creatingNewFile) { 555 if (!this.application.ninja.documentController.creatingNewFile) {
545 // Opening an existing document. Does it have any DOM elements? 556 // Opening an existing document. If it has DOM elements we need to restore their timeline info
546 if(this.application.ninja.breadCrumbClick){ 557 if (this.application.ninja.currentDocument.documentRoot.children[0]) {
547 var parentNode = this.application.ninja.currentSelectedContainer;
548 for (myIndex = 0; parentNode.children[myIndex]; myIndex++) {
549 this._openDoc = true;
550 this.restoreLayer(parentNode.children[myIndex]);
551 }
552
553 }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. 558 // 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++) { 559 for (myIndex = 0; this.application.ninja.currentDocument.documentRoot.children[myIndex]; myIndex++) {
556 this._openDoc = true; 560 this._openDoc = true;
557 this.restoreLayer(this.application.ninja.currentDocument.documentRoot.children[myIndex]); 561 this.restoreLayer(this.application.ninja.currentDocument.documentRoot.children[myIndex]);
558 } 562 }
559 } 563 }
560 // Feed the new array of objects into the repetitions.
561 this.arrLayers = this.temparrLayers;
562 }else if(this.application.ninja.breadCrumbClick){
563 var parentNode = this.application.ninja.currentSelectedContainer;
564 for (myIndex = 0; parentNode.children[myIndex]; myIndex++) {
565 this._openDoc = true;
566 this.restoreLayer(parentNode.children[myIndex]);
567 }
568 this.arrLayers = this.temparrLayers;
569
570 } 564 }
571 565
572 // After recreating the tracks and layers, store the result in the currentDocument. 566 // Draw the repetition.
573 this.application.ninja.currentDocument.tlArrLayers = this.arrLayers; 567 this.arrLayers = this.temparrLayers;
574 this.application.ninja.currentDocument.tllayerNumber = this.currentLayerNumber; 568 this.currentLayerNumber = this.arrLayers.length;
575 this.application.ninja.currentDocument.tlCurrentSelectedContainer=this.application.ninja.currentSelectedContainer; 569
576 570 } else if (this.application.ninja.breadCrumbClick) {
571 // Information stored, but we're moving up or down in the breadcrumb.
572 // Get the current selection and restore timeline info for its children.