aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Reid2012-02-29 09:56:56 -0800
committerJon Reid2012-02-29 09:56:56 -0800
commit38d8d4ea7d033b35f95e38ebb7d6abfd81bd2c69 (patch)
treefac3756c49d5aa45537773c326bd87a1fcc71f65
parent538db48f38ad3d5d22e99c2881745fc916e7e8a2 (diff)
downloadninja-38d8d4ea7d033b35f95e38ebb7d6abfd81bd2c69.tar.gz
Timeline: document switching + new document.
-rw-r--r--js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js98
1 files changed, 68 insertions, 30 deletions
diff --git a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
index 01b03531..6a9e0140 100644
--- a/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
+++ b/js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
@@ -28,7 +28,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
28 }, 28 },
29 set:function (newVal) { 29 set:function (newVal) {
30 this._arrLayers = newVal; 30 this._arrLayers = newVal;
31 this.application.ninja.currentDocument.tlArrLayers = newVal; 31 this.updateLayers();
32 } 32 }
33 }, 33 },
34 34
@@ -44,6 +44,18 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
44 this._layerRepetition = newVal; 44 this._layerRepetition = newVal;
45 } 45 }
46 }, 46 },
47 updateLayers : {
48 value: function() {
49 this.application.ninja.currentDocument.tlArrLayers = this.arrLayers;
50 // this.application.ninja.currentDocument.tlArrTracks = this.arrTracks;
51 console.log('inside of updateLayers ');
52 console.log(this.application.ninja.currentDocument.tlArrTracks);
53
54 }
55 },
56 boolUpdateLayers : {
57 value: true
58 },
47 59
48 _currentLayerNumber:{ 60 _currentLayerNumber:{
49 value:0 61 value:0
@@ -100,7 +112,7 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
100 }, 112 },
101 set:function (newVal) { 113 set:function (newVal) {
102 this._arrTracks = newVal; 114 this._arrTracks = newVal;
103 this.application.ninja.currentDocument.tlArrTracks = newVal; 115 this.updateLayers();
104 } 116 }
105 }, 117 },
106 118
@@ -182,7 +194,9 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
182 194
183 handleOnOpenDocument:{ 195 handleOnOpenDocument:{
184 value:function(){ 196 value:function(){
197 this.boolUpdateLayers = false;
185 this.clearTimelinePanel(); 198 this.clearTimelinePanel();
199 this.boolUpdateLayers = true;
186 this.eventManager.addEventListener("deleteLayerClick", this, false); 200 this.eventManager.addEventListener("deleteLayerClick", this, false);
187 this.eventManager.addEventListener("newLayer", this, false); 201 this.eventManager.addEventListener("newLayer", this, false);
188 this.eventManager.addEventListener("deleteLayer", this, false); 202 this.eventManager.addEventListener("deleteLayer", this, false);
@@ -204,6 +218,8 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
204 handleCloseDocument: { 218 handleCloseDocument: {
205 value: function(event) { 219 value: function(event) {
206 this.clearTimelinePanel(); 220 this.clearTimelinePanel();
221 this.arrTracks = [];
222 this.arrLayers = [];
207 } 223 }
208 }, 224 },
209 225
@@ -245,31 +261,55 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
245 initTimelineView:{ 261 initTimelineView:{
246 value:function () { 262 value:function () {
247 var myIndex; 263 var myIndex;
248
249 this.drawTimeMarkers(); 264 this.drawTimeMarkers();
265 this._hashKey = "123";
266
267
268 // Document switching
269 // Check to see if we have saved timeline information in the currentDocument.
270 if (typeof(this.application.ninja.currentDocument.isTimelineInitialized) === "undefined") {
271 // No, we have no information stored. Create it.
272 console.log('newfile!')
273 this.application.ninja.currentDocument.isTimelineInitialized = true;
274 this.application.ninja.currentDocument.tlArrLayers = [];
275 this.application.ninja.currentDocument.tlArrTracks = [];
276 _firstLayerDraw = false;
277 if(!this.application.ninja.documentController.creatingNewFile){
278 if(this.application.ninja.currentDocument.documentRoot.children[0]){
279 myIndex=0;
280 while(this.application.ninja.currentDocument.documentRoot.children[myIndex])
281 {
282 this._openDoc=true;
283 NJevent('newLayer',{key:this._hashKey,ele:this.application.ninja.currentDocument.documentRoot.children[myIndex]})
284 myIndex++;
285 }
286 }
287 else{
288 NJevent('newLayer', this._hashKey);
289 this.selectLayer(0);
290 }
291 }else{
292 NJevent('newLayer', this._hashKey);
293 this.selectLayer(0);
294
295 }
296 _firstLayerDraw = true;
297 this.application.ninja.currentDocument.tlArrTracks = this.arrTracks;
298 } else {
299 // we do have information stored. Use it.
300 console.log('oldfile!')
301 console.log("tlArrLayers: " , this.application.ninja.currentDocument.tlArrLayers);
302 console.log("tlArrTracks: " , this.application.ninja.currentDocument.tlArrTracks);
303 this.arrLayers = this.application.ninja.currentDocument.tlArrLayers;
304 this.arrTracks = this.application.ninja.currentDocument.tlArrTracks;
305 }
306
307 // Redraw all the things
308 this.layerRepetition.needsDraw = true;
309 this.trackRepetition.needsDraw = true;
310 this.needsDraw = true;
250 311
251 this._hashKey = "123";
252 _firstLayerDraw = false;
253 if(!this.application.ninja.documentController.creatingNewFile){
254 if(this.application.ninja.currentDocument.documentRoot.children[0]){
255 myIndex=0;
256 while(this.application.ninja.currentDocument.documentRoot.children[myIndex])
257 {
258 this._openDoc=true;
259 NJevent('newLayer',{key:this._hashKey,ele:this.application.ninja.currentDocument.documentRoot.children[myIndex]})
260 myIndex++;
261 }
262 }
263 else{
264 NJevent('newLayer', this._hashKey);
265 this.selectLayer(0);
266 }
267 }else{
268 NJevent('newLayer', this._hashKey);
269 this.selectLayer(0);
270 312
271 }
272 _firstLayerDraw = true;
273 } 313 }
274 }, 314 },
275 315
@@ -299,8 +339,10 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
299 this.hashTrackInstance = null; 339 this.hashTrackInstance = null;
300 this.hashLayerNumber = null; 340 this.hashLayerNumber = null;
301 this.hashElementMapToLayer = null; 341 this.hashElementMapToLayer = null;
302 this.arrTracks = []; 342 if (!this.boolUpdateLayers) {
303 this.arrLayers = []; 343
344 }
345
304 this.currentLayerNumber = 0; 346 this.currentLayerNumber = 0;
305 this.currentLayerSelected = false; 347 this.currentLayerSelected = false;
306 this.currentTrackSelected = false; 348 this.currentTrackSelected = false;
@@ -311,10 +353,6 @@ var TimelinePanel = exports.TimelinePanel = Montage.create(Component, {
311 this.end_hottext.value = 25; 353 this.end_hottext.value = 25;
312 this.updateTrackContainerWidth(); 354 this.updateTrackContainerWidth();
313 355
314 // Redraw all the things
315 this.layerRepetition.needsDraw = true;
316 this.trackRepetition.needsDraw = true;
317 this.needsDraw = true;
318 } 356 }
319 }, 357 },
320 358