aboutsummaryrefslogtreecommitdiff
path: root/js/stage
diff options
context:
space:
mode:
authorValerio Virgillito2012-04-26 17:10:03 -0700
committerValerio Virgillito2012-04-26 17:10:03 -0700
commit6c1aa27b7753bc9007514859b42160fae265740d (patch)
treef9a01321bafbc8baf91b0d8b0f6c43ddf5453c5d /js/stage
parent7968f3a9cf56392c914d6bd44cc90145b6d807a3 (diff)
parenta0ba2437965f486667d07bba60c031a11d778e6a (diff)
downloadninja-6c1aa27b7753bc9007514859b42160fae265740d.tar.gz
Merge branch 'stage-document-architecture' of https://github.com/mencio/ninja-internal into serialization
Diffstat (limited to 'js/stage')
-rwxr-xr-xjs/stage/stage.reel/stage.js87
1 files changed, 40 insertions, 47 deletions
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js
index 8382135d..1ea14d64 100755
--- a/js/stage/stage.reel/stage.js
+++ b/js/stage/stage.reel/stage.js
@@ -224,14 +224,6 @@ exports.Stage = Montage.create(Component, {
224 // Event details will contain the active document prior to opening a new one 224 // Event details will contain the active document prior to opening a new one
225 handleOpenDocument: { 225 handleOpenDocument: {
226 value: function(evt) { 226 value: function(evt) {
227
228 var prevActiveDocument = evt.detail;
229 // Hide current document is one is open
230 if(prevActiveDocument) {
231 prevActiveDocument.container.style["display"] = "none";
232 if(prevActiveDocument.documentType === "htm" || prevActiveDocument.documentType === "html") this.hideCanvas(true);
233 }
234
235 this.hideCanvas(false); 227 this.hideCanvas(false);
236 228
237 // Recalculate the canvas sizes because of splitter resizing 229 // Recalculate the canvas sizes because of splitter resizing
@@ -254,7 +246,11 @@ exports.Stage = Montage.create(Component, {
254 246
255 // Hardcode this value so that it does not fail for the new stage architecture 247 // Hardcode this value so that it does not fail for the new stage architecture
256 // TODO: Remove marker for old template: NINJA-STAGE-REWORK 248 // TODO: Remove marker for old template: NINJA-STAGE-REWORK
257 this.userContentBorder = 1; //parseInt(this._documentRoot.elementModel.controller.getProperty(this._documentRoot, "border")); 249 if(this.application.ninja.currentDocument.documentRoot.id === "UserContent") {
250 this.userContentBorder = 1; //parseInt(this._documentRoot.elementModel.controller.getProperty(this._documentRoot, "border"));
251 } else {
252 this.userContentBorder = 0;
253 }
258 254
259 this._userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder; 255 this._userContentLeft = this._documentOffsetLeft - this._scrollLeft + this._userContentBorder;
260 this._userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder; 256 this._userContentTop = this._documentOffsetTop - this._scrollTop + this._userContentBorder;
@@ -521,62 +517,59 @@ exports.Stage = Montage.create(Component, {
521 }, 517 },
522 518
523 /** 519 /**
524 * GetSelectableElement: Returns a selectable object (direct child of current container) at clicked point 520 * GetElement: Returns the element or selectable element under the X,Y coordinates passed as an obj with x,y
525 * 521 *
526 * @param: X,Y 522 * @param position: mouse event
527 * @return: Returns the current container if the the X,Y hits an element in the exclusion list 523 * @param selectable (default == null) if true this will return the current container element
524 * @return: Returns the element or container or null if the the X,Y hits the exclusion list and tool cannot operate on stage
528 */ 525 */
529 GetSelectableElement: { 526 getElement: {
530 value: function(pos) { 527 value: function(position, selectable) {
531 var item = this.GetElement(pos); 528 var point, element;
532 if(this.application.ninja.currentDocument.inExclusion(item) !== -1) { 529
533 return this.application.ninja.currentSelectedContainer; 530 point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX, position.pageY));
531 element = this.application.ninja.currentDocument.GetElementFromPoint(point.x + this.scrollLeft,point.y + this.scrollTop);
532
533 // workaround Chrome 3d bug
534 if(this.application.ninja.toolsData.selectedToolInstance._canSnap && this.application.ninja.currentDocument.inExclusion(element) !== -1) {
535 element = this.getElementUsingSnapping(point);
534 } 536 }
535 var activeContainerId = this.application.ninja.currentSelectedContainer.uuid;
536 if(item.parentNode.uuid === activeContainerId) {
537 return item;
538 } else {
539 var outerElement = item.parentNode;
540 537
541 while(outerElement.parentNode && outerElement.parentNode.uuid !== activeContainerId) { 538 if(selectable) {
542 // If element is higher up than current container then return 539
543 if(outerElement.id === "UserContent") return; 540 if(this.application.ninja.currentDocument.inExclusion(element) !== -1) {
544 // else keep going up the chain 541 return this.application.ninja.currentSelectedContainer;
545 outerElement = outerElement.parentNode;
546 } 542 }
547 543
548 return outerElement; 544 var activeContainerId = this.application.ninja.currentSelectedContainer.uuid;
549 } 545 if(element.parentNode.uuid === activeContainerId) {
550 } 546 return element;
551 }, 547 } else {
548 var outerElement = element.parentNode;
552 549
553 /** 550 while(outerElement.parentNode && outerElement.parentNode.uuid !== activeContainerId) {
554 * GetElement: Returns the object under the X,Y coordinates passed as an obj with x,y 551 // If element is higher up than current container then return
555 * 552 if(outerElement.id === "UserContent") return;
556 * @param: X,Y 553 // else keep going up the chain
557 * @return: Returns the Object or null if the the X,Y hits the exclusion list and tool cannot operate on stage 554 outerElement = outerElement.parentNode;
558 */ 555 }
559 GetElement: { 556
560 value: function(pos) { 557 return outerElement;
561 var point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(pos.pageX, pos.pageY)), 558 }
562 elt = this.application.ninja.currentDocument.GetElementFromPoint(point.x + this.scrollLeft,point.y + this.scrollTop);
563 559
564 // workaround Chrome 3d bug
565 if(this.application.ninja.toolsData.selectedToolInstance._canSnap && this.application.ninja.currentDocument.inExclusion(elt) !== -1) {
566 return this._getElementUsingSnapping(point);
567 } else { 560 } else {
568 return elt; 561 return element;
569 } 562 }
570 } 563 }
571 }, 564 },
572 565
573 /** 566 /**
574 * _getElementUsingSnapping: Returns the object at point using snap manager 567 * getElementUsingSnapping: Returns the object at point using snap manager
575 * 568 *
576 * @param: point 569 * @param: point
577 * @return: Returns the Object in the user document under the point 570 * @return: Returns the Object in the user document under the point
578 */ 571 */
579 _getElementUsingSnapping: { 572 getElementUsingSnapping: {
580 value: function(point) { 573 value: function(point) {
581 this.stageDeps.snapManager.enableElementSnap( true ); 574 this.stageDeps.snapManager.enableElementSnap( true );
582 var hitRec = this.stageDeps.snapManager.snap(point.x, point.y, true); 575 var hitRec = this.stageDeps.snapManager.snap(point.x, point.y, true);