diff options
Diffstat (limited to 'js/panels/Timeline/TimelinePanel.reel')
-rw-r--r-- | js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | 121 | ||||
-rw-r--r-- | js/panels/Timeline/TimelinePanel.reel/css/TimelinePanel.css | 4 |
2 files changed, 78 insertions, 47 deletions
diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 1afb9e5a..033d0f79 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | |||
@@ -139,6 +139,28 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
139 | } | 139 | } |
140 | }, | 140 | }, |
141 | 141 | ||
142 | _selectedLayerID:{ | ||
143 | value: false | ||
144 | }, | ||
145 | selectedLayerID : { | ||
146 | get: function() { | ||
147 | return this._selectedLayerID; | ||
148 | }, | ||
149 | set: function(newVal) { | ||
150 | if (newVal === false) { | ||
151 | // We are clearing the timeline, so just set the value and return. | ||
152 | this._selectedLayerID = newVal; | ||
153 | return; | ||
154 | } | ||
155 | if (newVal !== this._selectedLayerID) { | ||
156 | var selectIndex = this.getLayerIndexByID(newVal); | ||
157 | this._selectedLayerID = newVal; | ||
158 | this._captureSelection = true; | ||
159 | this.selectLayer(selectIndex, true); | ||
160 | } | ||
161 | } | ||
162 | }, | ||
163 | |||
142 | millisecondsOffset:{ | 164 | millisecondsOffset:{ |
143 | value:1000 | 165 | value:1000 |
144 | }, | 166 | }, |
@@ -296,7 +318,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
296 | "newLayer", | 318 | "newLayer", |
297 | "deleteLayer", | 319 | "deleteLayer", |
298 | "elementAdded", | 320 | "elementAdded", |
299 | "elementDeleted", | 321 | "elementsRemoved", |
300 | "selectionChange"], | 322 | "selectionChange"], |
301 | i, | 323 | i, |
302 | arrEventsLength = arrEvents.length; | 324 | arrEventsLength = arrEvents.length; |
@@ -374,14 +396,11 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
374 | 396 | ||
375 | // Feed the new array of objects into the repetitions | 397 | // Feed the new array of objects into the repetitions |
376 | // and select the first layer. | 398 | // and select the first layer. |
399 | this.temparrLayers[0].layerData.isSelected = true; | ||
400 | this.temparrLayers[0].layerData._isFirstDraw = true; | ||
401 | |||
377 | this.arrLayers=this.temparrLayers; | 402 | this.arrLayers=this.temparrLayers; |
378 | 403 | ||
379 | // TODO: We need a better solution to this race condition than a timeout. | ||
380 | this._captureSelection = true; | ||
381 | var that = this; | ||
382 | setTimeout(function() { | ||
383 | that.selectLayer(0, true); | ||
384 | }, 1000) | ||
385 | } else { | 404 | } else { |
386 | // New document. Create default layer. | 405 | // New document. Create default layer. |
387 | this.createNewLayer(1); | 406 | this.createNewLayer(1); |
@@ -397,31 +416,21 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
397 | } else { | 416 | } else { |
398 | // we do have information stored. Use it. | 417 | // we do have information stored. Use it. |
399 | this._boolCacheArrays = false; | 418 | this._boolCacheArrays = false; |
419 | //var myIndex = 0; | ||
420 | for (var i = 0; i < this.application.ninja.currentDocument.tlArrLayers.length; i++) { | ||
421 | if ( this.application.ninja.currentDocument.tlArrLayers[i].layerData.isSelected === true ) { | ||
422 | this.application.ninja.currentDocument.tlArrLayers[i].layerData._isFirstDraw = true; | ||
423 | } | ||
424 | } | ||
425 | |||
426 | |||
400 | this.arrLayers = this.application.ninja.currentDocument.tlArrLayers; | 427 | this.arrLayers = this.application.ninja.currentDocument.tlArrLayers; |
401 | this.currentLayerNumber = this.application.ninja.currentDocument.tllayerNumber; | 428 | this.currentLayerNumber = this.application.ninja.currentDocument.tllayerNumber; |
402 | this.currentLayerSelected = this.application.ninja.currentDocument.tlCurrentLayerSelected; | 429 | this.currentLayerSelected = this.application.ninja.currentDocument.tlCurrentLayerSelected; |
403 | this.hashInstance = this.application.ninja.currentDocument.tlLayerHashTable; | 430 | this.hashInstance = this.application.ninja.currentDocument.tlLayerHashTable; |
404 | this.hashElementMapToLayer = this.application.ninja.currentDocument.tlElementHashTable; | 431 | this.hashElementMapToLayer = this.application.ninja.currentDocument.tlElementHashTable; |
405 | this.hashKey = this.application.ninja.currentDocument.hashKey; | 432 | this.hashKey = this.application.ninja.currentDocument.hashKey; |
406 | this._boolCacheArrays = true; | ||
407 | |||
408 | // Search through the arrLayers and select the layer that's already selected | ||
409 | var i = 0, | ||
410 | selectMe = 0, | ||
411 | arrLayersLength = this.arrLayers.length; | ||
412 | for (i = 0; i < arrLayersLength; i++) { | ||
413 | if (this.arrLayers[i].isSelected === true) { | ||
414 | selectMe = i; | ||
415 | } | ||
416 | } | ||
417 | |||
418 | 433 | ||
419 | this._captureSelection = true; | ||
420 | // TODO: Better solution than a timer. | ||
421 | var that = this; | ||
422 | setTimeout(function() { | ||
423 | that.selectLayer(selectMe, true); | ||
424 | }, 300) | ||
425 | } | 434 | } |
426 | } | 435 | } |
427 | }, | 436 | }, |
@@ -454,6 +463,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
454 | this._firstTimeLoaded=true; | 463 | this._firstTimeLoaded=true; |
455 | this.end_hottext.value = 25; | 464 | this.end_hottext.value = 25; |
456 | this.updateTrackContainerWidth(); | 465 | this.updateTrackContainerWidth(); |
466 | this.selectedLayerID = false; | ||
457 | 467 | ||
458 | // Clear the repetitions | 468 | // Clear the repetitions |
459 | if (this.arrLayers.length > 0) { | 469 | if (this.arrLayers.length > 0) { |
@@ -464,9 +474,12 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
464 | 474 | ||
465 | handleDocumentChange:{ | 475 | handleDocumentChange:{ |
466 | value:function(event){ | 476 | value:function(event){ |
477 | // Clear the timeline but not the cache | ||
467 | this._boolCacheArrays = false; | 478 | this._boolCacheArrays = false; |
468 | this.clearTimelinePanel(); | 479 | this.clearTimelinePanel(); |
469 | this._boolCacheArrays = true; | 480 | this._boolCacheArrays = true; |
481 | |||
482 | // Rebind the document events for the new document context | ||
470 | this._bindDocumentEvents(); | 483 | this._bindDocumentEvents(); |
471 | 484 | ||
472 | this.hashInstance = this.createLayerHashTable(); | 485 | this.hashInstance = this.createLayerHashTable(); |
@@ -673,6 +686,13 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
673 | thingToPush.layerData.layerID = this.currentLayerNumber; | 686 | thingToPush.layerData.layerID = this.currentLayerNumber; |
674 | thingToPush.parentElementUUID = this.hashKey; | 687 | thingToPush.parentElementUUID = this.hashKey; |
675 | thingToPush.parentElement = this.application.ninja.currentSelectedContainer; | 688 | thingToPush.parentElement = this.application.ninja.currentSelectedContainer; |
689 | thingToPush.layerData.isSelected = true; | ||
690 | thingToPush.layerData._isFirstDraw = true; | ||
691 | |||
692 | for (var i = 0; i < this.arrLayers.length; i++) { | ||
693 | this.arrLayers[i].layerData.isSelected = false; | ||
694 | this.arrLayers[i].layerData._isFirstDraw = false; | ||
695 | } | ||
676 | 696 | ||
677 | if (!!this.layerRepetition.selectedIndexes) { | 697 | if (!!this.layerRepetition.selectedIndexes) { |
678 | // There is a selected layer, so we need to splice the new | 698 | // There is a selected layer, so we need to splice the new |
@@ -699,14 +719,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
699 | this._LayerUndoIndex = thingToPush.layerData.layerID; | 719 | this._LayerUndoIndex = thingToPush.layerData.layerID; |
700 | this._LayerUndoStatus = true; | 720 | this._LayerUndoStatus = true; |
701 | 721 | ||
702 | this._captureSelection = true; | ||
703 | |||
704 | // TODO: Find a better solution than a timout here. | ||
705 | var that = this; | ||
706 | setTimeout(function() { | ||
707 | that.selectLayer(indexToSelect, true); | ||
708 | }, 500); | ||
709 | |||
710 | } | 722 | } |
711 | 723 | ||
712 | } | 724 | } |
@@ -814,7 +826,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
814 | for(var index=0;index<arrLayerLength;index++){ | 826 | for(var index=0;index<arrLayerLength;index++){ |
815 | if(this.arrLayers[index].layerData.layerID===dLayer[hashVariable].layerID){ | 827 | if(this.arrLayers[index].layerData.layerID===dLayer[hashVariable].layerID){ |
816 | dLayer[hashVariable].deleted = true; | 828 | dLayer[hashVariable].deleted = true; |
817 | ElementMediator.deleteElements(dLayer[hashVariable].elementsList); | 829 | ElementMediator.removeElements(dLayer[hashVariable].elementsList); |
818 | this.arrLayers.splice(index, 1); | 830 | this.arrLayers.splice(index, 1); |
819 | break; | 831 | break; |
820 | } | 832 | } |
@@ -849,18 +861,37 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { | |||
849 | } | 861 | } |
850 | }, | 862 | }, |
851 | 863 | ||
852 | handleElementDeleted:{ | 864 | handleElementsRemoved:{ |
853 | value:function (event) { | 865 | value:function (event) { |
854 | var length,lengthVal; | 866 | var length,lengthVal; |
855 | this.deleteElement = event.detail; | 867 | this.deleteElement = event.detail; |
856 | lengthVal = this.currentLayerSelected.layerData.elementsList.length - 1; | 868 | |
857 | for (length = lengthVal ;length >= 0 ;length--) { | 869 | // Handling deletion of multiple elements. |
858 | if (this.currentLayerSelected.layerData.elementsList[length] === this.deleteElement) { | 870 | // TODO: Optimize this double array loop |
859 | this.currentLayerSelected.layerData.elementsList.splice(length, 1); |