aboutsummaryrefslogtreecommitdiff
path: root/js/stage
diff options
context:
space:
mode:
Diffstat (limited to 'js/stage')
-rwxr-xr-xjs/stage/stage.reel/stage.js70
1 files changed, 61 insertions, 9 deletions
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js
index 340bbff2..8cbe3210 100755
--- a/js/stage/stage.reel/stage.js
+++ b/js/stage/stage.reel/stage.js
@@ -19,6 +19,7 @@ exports.Stage = Montage.create(Component, {
19 // TODO - Need to figure out how to remove this dependency 19 // TODO - Need to figure out how to remove this dependency
20 // Needed by some tools that depend on selectionDrawn event to set up some logic 20 // Needed by some tools that depend on selectionDrawn event to set up some logic
21 drawNow: { value : false }, 21 drawNow: { value : false },
22 switchedFromCodeDoc: { value : false },
22 23
23 // TO REVIEW 24 // TO REVIEW
24 zoomFactor: {value : 1 }, 25 zoomFactor: {value : 1 },
@@ -252,9 +253,15 @@ exports.Stage = Montage.create(Component, {
252 this.currentDocument.model.documentOffsetTop = this._documentOffsetTop; 253 this.currentDocument.model.documentOffsetTop = this._documentOffsetTop;
253 this.currentDocument.model.userContentLeft = this._userContentLeft; 254 this.currentDocument.model.userContentLeft = this._userContentLeft;
254 this.currentDocument.model.userContentTop = this._userContentTop; 255 this.currentDocument.model.userContentTop = this._userContentTop;
256 this.currentDocument.model.templateLeft = this.templateLeft;
257 this.currentDocument.model.templateTop = this.templateTop;
258 this.currentDocument.model.minLeftElement = this.minLeftElement;
259 this.currentDocument.model.minTopElement = this.minTopElement;
255 260
256 //call configure false with the old document on the selected tool to tear down down any temp. stuff 261 //call configure false with the old document on the selected tool to tear down down any temp. stuff
257 this.application.ninja.toolsData.selectedToolInstance._configure(false); 262 this.application.ninja.toolsData.selectedToolInstance._configure(false);
263 } else if(this.currentDocument && (this.currentDocument.currentView === "code")) {
264 this.switchedFromCodeDoc = true; // Switching from code document affects stage's size and scrollbar
258 } 265 }
259 266
260 this._currentDocument = value; 267 this._currentDocument = value;
@@ -265,7 +272,8 @@ exports.Stage = Montage.create(Component, {
265 drawUtils._eltArray.length = 0; 272 drawUtils._eltArray.length = 0;
266 drawUtils._planesArray.length = 0; 273 drawUtils._planesArray.length = 0;
267 } else if(this._currentDocument.currentView === "design") { 274 } else if(this._currentDocument.currentView === "design") {
268 this.restoreAllPanels(); 275 this.restoreAllPanels(this.switchedFromCodeDoc);
276 this.switchedFromCodeDoc = false;
269 this.hideCanvas(false); 277 this.hideCanvas(false);
270 this.showRulers(); 278 this.showRulers();
271 279
@@ -282,6 +290,13 @@ exports.Stage = Montage.create(Component, {
282 _userPaddingLeft: { value: 0 }, 290 _userPaddingLeft: { value: 0 },
283 _userPaddingTop: { value: 0 }, 291 _userPaddingTop: { value: 0 },
284 292
293 templateLeft: { value: 0 },
294 templateTop: { value: 0 },
295
296 // keep track of the elements that determine the minimum left and top scrollable amount
297 minLeftElement: { value: null },
298 minTopElement: { value: null },
299
285 userPaddingLeft: { 300 userPaddingLeft: {
286 get: function() { return this._userPaddingLeft; }, 301 get: function() { return this._userPaddingLeft; },
287 set: function(value) { 302 set: function(value) {
@@ -345,8 +360,6 @@ exports.Stage = Montage.create(Component, {
345 // Hide the canvas 360 // Hide the canvas
346 this.hideCanvas(true); 361 this.hideCanvas(true);
347 362
348 this.eventManager.addEventListener( "appMouseUp", this, false);
349
350 this.eventManager.addEventListener( "enableStageMove", this, false); 363 this.eventManager.addEventListener( "enableStageMove", this, false);
351 this.eventManager.addEventListener( "disableStageMove", this, false); 364 this.eventManager.addEventListener( "disableStageMove", this, false);
352 365
@@ -376,6 +389,10 @@ exports.Stage = Montage.create(Component, {
376 this._userContentTop = this.currentDocument.model.userContentTop; 389 this._userContentTop = this.currentDocument.model.userContentTop;
377 this._scrollLeft = this.currentDocument.model.scrollLeft; 390 this._scrollLeft = this.currentDocument.model.scrollLeft;
378 this._scrollTop = this.currentDocument.model.scrollTop; 391 this._scrollTop = this.currentDocument.model.scrollTop;
392 this.templateLeft = this.currentDocument.model.templateLeft;
393 this.templateTop = this.currentDocument.model.templateTop;
394 this.minLeftElement = this.currentDocument.model.minLeftElement;
395 this.minTopElement = this.currentDocument.model.minTopElement;
379 } else { 396 } else {
380 this._userPaddingLeft = 0; 397 this._userPaddingLeft = 0;
381 this._userPaddingTop = 0; 398 this._userPaddingTop = 0;
@@ -385,6 +402,10 @@ exports.Stage = Montage.create(Component, {
385 this._userContentTop = 0; 402 this._userContentTop = 0;
386 this._scrollLeft = 0; 403 this._scrollLeft = 0;
387 this._scrollTop = 0; 404 this._scrollTop = 0;
405 this.templateLeft = 0;
406 this.templateTop = 0;
407 this.minLeftElement = null;
408 this.minTopElement = null;
388 } 409 }
389 410
390 // Recalculate the canvas sizes because of splitter resizing 411 // Recalculate the canvas sizes because of splitter resizing
@@ -402,9 +423,11 @@ exports.Stage = Montage.create(Component, {
402 var initialTop = parseInt((this.canvas.height - designView._template.size.height)/2); 423 var initialTop = parseInt((this.canvas.height - designView._template.size.height)/2);
403 if(initialLeft > this.documentOffsetLeft) { 424 if(initialLeft > this.documentOffsetLeft) {
404 this.userPaddingLeft = -initialLeft; 425 this.userPaddingLeft = -initialLeft;
426 this.templateLeft = -initialLeft;
405 } 427 }
406 if(initialTop > this.documentOffsetTop) { 428 if(initialTop > this.documentOffsetTop) {
407 this.userPaddingTop = -initialTop; 429 this.userPaddingTop = -initialTop;
430 this.templateTop = -initialTop;
408 } 431 }
409 } 432 }
410 433
@@ -456,6 +479,7 @@ exports.Stage = Montage.create(Component, {
456 479
457 enableMouseInOut: { 480 enableMouseInOut: {
458 value: function() { 481 value: function() {
482 document.addEventListener("mouseup", this, true);
459 this._drawingCanvas.addEventListener("mouseout", this, false); 483 this._drawingCanvas.addEventListener("mouseout", this, false);
460 this._drawingCanvas.addEventListener("mouseover", this, false); 484 this._drawingCanvas.addEventListener("mouseover", this, false);
461 } 485 }
@@ -468,6 +492,19 @@ exports.Stage = Montage.create(Component, {
468 } 492 }
469 }, 493 },
470 494
495 captureMouseup: {
496 value: function(event) {
497 var target = event._event.target.getAttribute("data-montage-id");
498
499 if(target && target === "drawingCanvas") {
500 return true;
501 } else {
502 this.handleAppMouseUp(event);
503 return true;
504 }
505 }
506 },
507
471 handleMouseout: { 508 handleMouseout: {
472 value: function(event) { 509 value: function(event) {
473 this.outFlag = true; 510 this.outFlag = true;
@@ -482,6 +519,11 @@ exports.Stage = Montage.create(Component, {
482 519
483 handleMousedown: { 520 handleMousedown: {
484 value: function(event) { 521 value: function(event) {
522
523 // Increase the canvas to cover the scroll bars
524 this._drawingCanvas.height = this._drawingCanvas.height + 11;
525 this._drawingCanvas.width = this._drawingCanvas.width + 11;
526
485 // Call the focus manager to set focus to blur any focus'd elements 527 // Call the focus manager to set focus to blur any focus'd elements
486 this.focusManager.setFocus(); 528 this.focusManager.setFocus();
487 529
@@ -511,13 +553,18 @@ exports.Stage = Montage.create(Component, {
511 553
512 handleMouseup: { 554 handleMouseup: {
513 value: function(event) { 555 value: function(event) {
556 // Restore canvas to un-cover the scroll bars.
557 this._drawingCanvas.height = this._drawingCanvas.height - 11;
558 this._drawingCanvas.width = this._drawingCanvas.width - 11;
514 // If the mouse up comes from dismissing the context menu return 559 // If the mouse up comes from dismissing the context menu return
560
515 if(this.contextMenu) { 561 if(this.contextMenu) {
516 this.contextMenu = false; 562 this.contextMenu = false;
517 return; 563 return;
518 } 564 }
519 565
520 //this.disableMouseInOut(); 566 this.disableMouseInOut();
567 document.removeEventListener("mouseup", this, true);
521 568
522 this.application.ninja.toolsData.selectedToolInstance.HandleLeftButtonUp(event); 569 this.application.ninja.toolsData.selectedToolInstance.HandleLeftButtonUp(event);
523 570
@@ -565,12 +612,17 @@ exports.Stage = Montage.create(Component, {
565 handleAppMouseUp: { 612 handleAppMouseUp: {
566 value: function(event) { 613 value: function(event) {
567 if(this.outFlag) { 614 if(this.outFlag) {
615 this._drawingCanvas.height = this._drawingCanvas.height - 11;
616 this._drawingCanvas.width = this._drawingCanvas.width - 11;
617
568 if(this.application.ninja.toolsData.selectedToolInstance.isDrawing) { 618 if(this.application.ninja.toolsData.selectedToolInstance.isDrawing) {
569 this.application.ninja.toolsData.selectedToolInstance.HandleLeftButtonUp(event); 619 this.application.ninja.toolsData.selectedToolInstance.HandleLeftButtonUp(event);
570 } 620 }
571 this.disableMouseInOut(); 621 this.disableMouseInOut();
572 this.outFlag = false; 622 this.outFlag = false;
573 } 623 }
624
625 document.removeEventListener("mouseup", this, true);
574 } 626 }
575 }, 627 },
576 628
@@ -1252,11 +1304,11 @@ exports.Stage = Montage.create(Component, {
1252 } 1304 }
1253 }, 1305 },
1254 restoreAllPanels:{ 1306 restoreAllPanels:{
1255 value:function(){ 1307 value:function(onSwitchDocument){
1256 this.application.ninja.panelSplitter.restore(); 1308 this.application.ninja.panelSplitter.restore(onSwitchDocument);
1257 this.application.ninja.timelineSplitter.restore(); 1309 this.application.ninja.timelineSplitter.restore(onSwitchDocument);
1258 this.application.ninja.toolsSplitter.restore(); 1310 this.application.ninja.toolsSplitter.restore(onSwitchDocument);
1259 this.application.ninja.optionsSplitter.restore(); 1311 this.application.ninja.optionsSplitter.restore(onSwitchDocument);
1260 } 1312 }
1261 }, 1313 },
1262 1314