From fc22cd3b5c65dc6f137fbb59443e2061cbbcac26 Mon Sep 17 00:00:00 2001 From: Jon Reid Date: Thu, 19 Apr 2012 14:26:57 -0700 Subject: Timeline: Bug fix: Maintain selection between document switching. --- js/panels/Timeline/Layer.reel/Layer.js | 48 ++++++++++------------ .../Timeline/TimelinePanel.reel/TimelinePanel.js | 15 +++---- 2 files changed, 28 insertions(+), 35 deletions(-) (limited to 'js/panels/Timeline') diff --git a/js/panels/Timeline/Layer.reel/Layer.js b/js/panels/Timeline/Layer.reel/Layer.js index 36c77018..5b1ce594 100644 --- a/js/panels/Timeline/Layer.reel/Layer.js +++ b/js/panels/Timeline/Layer.reel/Layer.js @@ -113,7 +113,18 @@ var Layer = exports.Layer = Montage.create(Component, { this.layerData.layerTag = newVal; } }, - + _docUUID : { + value: null + }, + docUUID : { + serializable: true, + get: function() { + return this._docUUID; + }, + set: function(newVal) { + this._docUUID = newVal; + } + }, /* Position and Transform hottext values */ _dtextPositionX : { value:null, @@ -555,10 +566,15 @@ var Layer = exports.Layer = Montage.create(Component, { }, didDraw: { value: function() { - if ((this.isSelected === true) && (this._isFirstDraw === true)) { - // Once we're done drawing the first time we need to tell the TimelinePanel if - // this layer is supposed to be selected. - this.parentComponent.parentComponent.selectedLayerID = this.layerID; + if (this._isFirstDraw === true) { + if (this.isSelected === true) { + if (this.application.ninja.currentDocument._uuid === this._docUUID) { + // Once we're done drawing the first time we need to tell the TimelinePanel if + // this layer is supposed to be selected. + //console.log('layerName ' + this.layerName); + this.parentComponent.parentComponent.selectedLayerID = this.layerID; + } + } this._isFirstDraw = false; } } @@ -567,36 +583,16 @@ var Layer = exports.Layer = Montage.create(Component, { /* Begin: Controllers */ - // Initialize a just-created layer with some basic defaults and needed selectors. + // Initialize a just-created layer init: { value: function() { - // Default some vars - //this.arrLayerStyles = []; - // Get some selectors. this.label = this.element.querySelector(".label-layer"); this.titleSelector = this.label.querySelector(".collapsible-label"); this.buttonAddStyle = this.element.querySelector(".button-add"); this.buttonDeleteStyle = this.element.querySelector(".button-delete"); - - - } }, - selectLayer:{ - value:function(){ - // this.mainCollapser.header.classList.add("layerSelected"); - this.element.classList.add("layerSelected"); - this.isSelected = true; - } - }, - deselectLayer:{ - value:function(){ - // this.mainCollapser.header.classList.remove("layerSelected"); - this.element.classList.remove("layerSelected"); - this.isSelected = false; - } - }, addStyle : { value: function() { // Add a new style rule. It should be added above the currently selected rule, diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 33b99760..eeb74625 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -112,7 +112,9 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { var selectIndex = this.getLayerIndexByID(newVal); this._selectedLayerID = newVal; this._captureSelection = true; - this.selectLayer(selectIndex); + //console.log(selectIndex); + //debugger; + this.selectLayer(selectIndex, true); } } }, @@ -410,6 +412,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { returnObj.layerData.isTrackAnimated = false; returnObj.parentElementUUID = null; returnObj.parentElement = null; + returnObj.docUUID = this.application.ninja.currentDocument._uuid; return returnObj; } @@ -536,14 +539,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { // Initialize BreadCrumb this.application.ninja.breadCrumbClick = false; this.enablePanel(false); - - /* - Object.defineBinding(this, "breadCrumbContainer", { - boundObject:this.application.ninja, - boundObjectPropertyPath:"currentSelectedContainer", - oneway:true - }); - */ + } }, @@ -684,6 +680,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { // Clear the timeline but not the cache //console.log('TimelinePanel.handleDocumentChange'); if ((event.type === "closeDocument") && (this.application.ninja.documentController._documents.length > 0)) { + // Ignore extra closeDocument event that fires while there are still documents open. return; } this._boolCacheArrays = false; -- cgit v1.2.3 From 9ec3e457db069f5a6195c8c07f85fcb3a4e0c031 Mon Sep 17 00:00:00 2001 From: Jon Reid Date: Thu, 19 Apr 2012 14:35:37 -0700 Subject: Timeline: Bug fix: check for uninitialized currentDocument in intialization routine. --- js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/panels/Timeline') diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index 0b688139..a2f19b28 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -675,7 +675,9 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { handleBreadCrumbBinding:{ value:function(event){ - + if (this.application.ninja.currentDocument == null) { + return; + } if((typeof(this.application.ninja.currentDocument.isTimelineInitialized) === "undefined")) return; if(this.application.ninja.currentDocument.breadCrumbClick){ -- cgit v1.2.3 From 57a0ca060f34297923e2e891ee25e5c928c09f00 Mon Sep 17 00:00:00 2001 From: Jon Reid Date: Thu, 19 Apr 2012 16:35:05 -0700 Subject: Timeline: More bug fixes for selection with multiple documents opening and closing. --- js/panels/Timeline/Layer.reel/Layer.js | 1 + js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js | 17 +++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'js/panels/Timeline') diff --git a/js/panels/Timeline/Layer.reel/Layer.js b/js/panels/Timeline/Layer.reel/Layer.js index 5b1ce594..1b8d73c0 100644 --- a/js/panels/Timeline/Layer.reel/Layer.js +++ b/js/panels/Timeline/Layer.reel/Layer.js @@ -482,6 +482,7 @@ var Layer = exports.Layer = Montage.create(Component, { this.layerTag = this.layerData.layerTag; this.isVisible = this.layerData.isVisible; this.isAnimated = this.layerData.isAnimated; + this.docUUID = this.layerData.docUUID; this.needsDraw = boolNeedsDraw; } }, diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js index a2f19b28..92c0766b 100644 --- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js +++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js @@ -26,7 +26,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { return this._arrLayers; }, set:function (newVal) { -// debugger; this._arrLayers = newVal; this.needsDraw = true; this.cacheTimeline(); @@ -113,8 +112,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { var selectIndex = this.getLayerIndexByID(newVal); this._selectedLayerID = newVal; this._captureSelection = true; - //console.log(selectIndex); - //debugger; this.selectLayer(selectIndex, true); } } @@ -386,10 +383,10 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { returnObj.layerData.tweens = []; returnObj.layerData.layerTag = ""; returnObj.layerData.isVisible = true; + returnObj.layerData.docUUID = this.application.ninja.currentDocument._uuid; returnObj.layerData.isTrackAnimated = false; returnObj.parentElementUUID = null; returnObj.parentElement = null; - returnObj.docUUID = this.application.ninja.currentDocument._uuid; return returnObj; } @@ -525,6 +522,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.drawTimeMarkers(); // Document switching // Check to see if we have saved timeline information in the currentDocument. + //debugger; if ((typeof(this.application.ninja.currentDocument.isTimelineInitialized) === "undefined") && (!this.application.ninja.currentDocument.breadCrumbClick)) { //console.log('TimelinePanel.initTimelineForDocument: new Document'); @@ -581,7 +579,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { // We're reading from the cache, not writing to it. this._boolCacheArrays = false; - for (i = 0; i < tlArrLayersLength; i++) { if (this.application.ninja.currentDocument.tlArrLayers[i].layerData.isSelected === true) { this.application.ninja.currentDocument.tlArrLayers[i].layerData._isFirstDraw = true; @@ -675,11 +672,16 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { handleBreadCrumbBinding:{ value:function(event){ + // Might fire if currentDocument has not yet been initialized. if (this.application.ninja.currentDocument == null) { return; } - if((typeof(this.application.ninja.currentDocument.isTimelineInitialized) === "undefined")) - return; + // Might fire if currentDocument is initialized but cache has not been initialized + if(typeof(this.application.ninja.currentDocument.isTimelineInitialized) === "undefined") { + return; + } + + // If the breadCrumb has been clicked, we need to change documents. if(this.application.ninja.currentDocument.breadCrumbClick){ this.handleDocumentChange(event); } @@ -1040,7 +1042,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, { this.layerRepetition.selectedIndexes = [layerIndex]; this.currentLayerSelected = this.arrLayers[layerIndex]; - if (userSelection) { if (this._captureSelection) { -- cgit v1.2.3