aboutsummaryrefslogtreecommitdiff
path: root/js/stage
diff options
context:
space:
mode:
authorValerio Virgillito2012-04-26 15:33:48 -0700
committerValerio Virgillito2012-04-26 15:33:48 -0700
commit238586be0df568c6804268d97bf9d3ef7cd33fda (patch)
tree582041d53a3d91ac50771849f3e4e26c85d69b81 /js/stage
parent01e17da83667b6ad808721687b2dd9b67f1812e6 (diff)
downloadninja-238586be0df568c6804268d97bf9d3ef7cd33fda.tar.gz
Simplifying the getElement method from stage and adding an exclusion list to the new template
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/stage')
-rwxr-xr-xjs/stage/stage.reel/stage.js73
1 files changed, 35 insertions, 38 deletions
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js
index 8382135d..fb7abf48 100755
--- a/js/stage/stage.reel/stage.js
+++ b/js/stage/stage.reel/stage.js
@@ -521,62 +521,59 @@ exports.Stage = Montage.create(Component, {
521 }, 521 },
522 522
523 /** 523 /**
524 * GetSelectableElement: Returns a selectable object (direct child of current container) at clicked point 524 * GetElement: Returns the element or selectable element under the X,Y coordinates passed as an obj with x,y
525 * 525 *
526 * @param: X,Y 526 * @param position: mouse event
527 * @return: Returns the current container if the the X,Y hits an element in the exclusion list 527 * @param selectable (default == null) if true this will return the current container element
528 * @return: Returns the element or container or null if the the X,Y hits the exclusion list and tool cannot operate on stage
528 */ 529 */
529 GetSelectableElement: { 530 getElement: {
530 value: function(pos) { 531 value: function(position, selectable) {
531 var item = this.GetElement(pos); 532 var point, element;
532 if(this.application.ninja.currentDocument.inExclusion(item) !== -1) { 533
533 return this.application.ninja.currentSelectedContainer; 534 point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX, position.pageY));
535 element = this.application.ninja.currentDocument.GetElementFromPoint(point.x + this.scrollLeft,point.y + this.scrollTop);
536
537 // workaround Chrome 3d bug
538 if(this.application.ninja.toolsData.selectedToolInstance._canSnap && this.application.ninja.currentDocument.inExclusion(element) !== -1) {
539 element = this.getElementUsingSnapping(point);
534 } 540 }
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 541
541 while(outerElement.parentNode && outerElement.parentNode.uuid !== activeContainerId) { 542 if(selectable) {
542 // If element is higher up than current container then return 543
543 if(outerElement.id === "UserContent") return; 544 if(this.application.ninja.currentDocument.inExclusion(element) !== -1) {
544 // else keep going up the chain 545 return this.application.ninja.currentSelectedContainer;
545 outerElement = outerElement.parentNode;
546 } 546 }
547 547
548 return outerElement; 548 var activeContainerId = this.application.ninja.currentSelectedContainer.uuid;
549 } 549 if(element.parentNode.uuid === activeContainerId) {
550 } 550 return element;
551 }, 551 } else {
552 var outerElement = element.parentNode;
552 553
553 /** 554 while(outerElement.parentNode && outerElement.parentNode.uuid !== activeContainerId) {
554 * GetElement: Returns the object under the X,Y coordinates passed as an obj with x,y 555 // If element is higher up than current container then return
555 * 556 if(outerElement.id === "UserContent") return;
556 * @param: X,Y 557 // 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 558 outerElement = outerElement.parentNode;
558 */ 559 }
559 GetElement: { 560
560 value: function(pos) { 561 return outerElement;
561 var point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(pos.pageX, pos.pageY)), 562 }
562 elt = this.application.ninja.currentDocument.GetElementFromPoint(point.x + this.scrollLeft,point.y + this.scrollTop);
563 563
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 { 564 } else {
568 return elt; 565 return element;
569 } 566 }
570 } 567 }
571 }, 568 },
572 569
573 /** 570 /**
574 * _getElementUsingSnapping: Returns the object at point using snap manager 571 * getElementUsingSnapping: Returns the object at point using snap manager
575 * 572 *
576 * @param: point 573 * @param: point
577 * @return: Returns the Object in the user document under the point 574 * @return: Returns the Object in the user document under the point
578 */ 575 */
579 _getElementUsingSnapping: { 576 getElementUsingSnapping: {
580 value: function(point) { 577 value: function(point) {
581 this.stageDeps.snapManager.enableElementSnap( true ); 578 this.stageDeps.snapManager.enableElementSnap( true );
582 var hitRec = this.stageDeps.snapManager.snap(point.x, point.y, true); 579 var hitRec = this.stageDeps.snapManager.snap(point.x, point.y, true);