aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/document/document-html.js15
-rwxr-xr-xjs/stage/stage.reel/stage.js73
-rwxr-xr-xjs/tools/EyedropperTool.js2
-rwxr-xr-xjs/tools/FillTool.js2
-rwxr-xr-xjs/tools/InkBottleTool.js2
-rwxr-xr-xjs/tools/ShapeTool.js2
-rwxr-xr-xjs/tools/ToolBase.js4
-rwxr-xr-xjs/tools/TranslateObject3DTool.js2
-rwxr-xr-xjs/tools/modifier-tool-base.js2
9 files changed, 58 insertions, 46 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js
index 24eb4f47..d9789cd2 100755
--- a/js/document/document-html.js
+++ b/js/document/document-html.js
@@ -31,6 +31,10 @@ exports.HtmlDocument = Montage.create(Component, {
31 value: null 31 value: null
32 }, 32 },
33 33
34 exclusionList: {
35 value: ["HTML"]
36 },
37
34 // Getters for the model. 38 // Getters for the model.
35 // TODO: Change how these properties are accessed through Ninja 39 // TODO: Change how these properties are accessed through Ninja
36 name: { 40 name: {
@@ -316,6 +320,17 @@ exports.HtmlDocument = Montage.create(Component, {
316 } 320 }
317 }, 321 },
318 322
323 inExclusion: {
324 value: function(element) {
325 if(this.exclusionList.indexOf(element.nodeName) === -1) {
326 return -1;
327 }
328
329 return 1;
330
331 }
332 },
333
319 // Handler for user content main reel. Gets called once the main reel of the template 334 // Handler for user content main reel. Gets called once the main reel of the template
320 // gets deserialized. 335 // gets deserialized.
321 // Setting up the currentSelectedContainer to the document body. 336 // Setting up the currentSelectedContainer to the document body.
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);
diff --git a/js/tools/EyedropperTool.js b/js/tools/EyedropperTool.js
index d627f03b..346975b2 100755
--- a/js/tools/EyedropperTool.js
+++ b/js/tools/EyedropperTool.js
@@ -104,7 +104,7 @@ exports.EyedropperTool = Montage.create(toolBase, {
104 value : function (event) { 104 value : function (event) {
105 var c, 105 var c,
106 color, 106 color,
107 obj = this.application.ninja.stage.GetElement(event); 107 obj = this.application.ninja.stage.getElement(event);
108 if (obj) 108 if (obj)
109 { 109 {
110 if(this.application.ninja.currentDocument.inExclusion(obj) !== -1) 110 if(this.application.ninja.currentDocument.inExclusion(obj) !== -1)
diff --git a/js/tools/FillTool.js b/js/tools/FillTool.js
index 746f20cf..87a093ff 100755
--- a/js/tools/FillTool.js
+++ b/js/tools/FillTool.js
@@ -22,7 +22,7 @@ exports.FillTool = Montage.create(ModifierToolBase, {
22 HandleMouseMove: { 22 HandleMouseMove: {
23 value : function (event) 23 value : function (event)
24 { 24 {
25 var obj = this.application.ninja.stage.GetSelectableElement(event); 25 var obj = this.application.ninja.stage.getElement(event, true);
26 var cursor = "url('images/cursors/fill.png') 14 14, default"; 26 var cursor = "url('images/cursors/fill.png') 14 14, default";
27 var canColor = true; 27 var canColor = true;
28 if (obj) 28 if (obj)
diff --git a/js/tools/InkBottleTool.js b/js/tools/InkBottleTool.js
index 960c19fa..fd17f4d6 100755
--- a/js/tools/InkBottleTool.js
+++ b/js/tools/InkBottleTool.js
@@ -16,7 +16,7 @@ exports.InkBottleTool = Montage.create(ModifierToolBase, {
16 HandleMouseMove: { 16 HandleMouseMove: {
17 value : function (event) 17 value : function (event)
18 { 18 {
19 var obj = this.application.ninja.stage.GetSelectableElement(event); 19 var obj = this.application.ninja.stage.getElement(event, true);
20 var cursor = "url('images/cursors/ink.png') 6 11, default"; 20 var cursor = "url('images/cursors/ink.png') 6 11, default";
21 var canColor = true; 21 var canColor = true;
22 if (obj) 22 if (obj)
diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js
index f3b5e92d..21a5a025 100755
--- a/js/tools/ShapeTool.js
+++ b/js/tools/ShapeTool.js
@@ -138,7 +138,7 @@ exports.ShapeTool = Montage.create(DrawingTool, {
138 _showFeedbackOnMouseMove: { 138 _showFeedbackOnMouseMove: {
139 value: function (event) { 139 value: function (event) {
140 // TODO - This call is causing the canvas to redraw 3 times per mouse move 140 // TODO - This call is causing the canvas to redraw 3 times per mouse move
141 var targetedObject = this.application.ninja.stage.GetSelectableElement(event); 141 var targetedObject = this.application.ninja.stage.getElement(event, true);
142 142
143 if (targetedObject) { 143 if (targetedObject) {
144 if((targetedObject.nodeName === "CANVAS") && !ShapesController.isElementAShape(targetedObject)) 144 if((targetedObject.nodeName === "CANVAS") && !ShapesController.isElementAShape(targetedObject))
diff --git a/js/tools/ToolBase.js b/js/tools/ToolBase.js
index 69ac5727..f43b1b58 100755
--- a/js/tools/ToolBase.js
+++ b/js/tools/ToolBase.js
@@ -89,9 +89,9 @@ exports.toolBase = Montage.create(Component, {
89 89
90 if(this._canOperateOnStage) { 90 if(this._canOperateOnStage) {
91 if(event.shiftKey) { 91 if(event.shiftKey) {
92 this.application.ninja.selectionController.shiftSelectElement(this.application.ninja.stage.GetElement(event)); 92 this.application.ninja.selectionController.shiftSelectElement(this.application.ninja.stage.getElement(event));
93 } else { 93 } else {
94 this.application.ninja.selectionController.selectElement(this.application.ninja.stage.GetElement(event)); 94 this.application.ninja.selectionController.selectElement(this.application.ninja.stage.getElement(event));
95 } 95 }
96 } 96 }
97 97
diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js
index 72a55322..b4f55bd9 100755
--- a/js/tools/TranslateObject3DTool.js
+++ b/js/tools/TranslateObject3DTool.js
@@ -83,7 +83,7 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, {
83 // Check that hitRec's element matches element that browser says we clicked on 83 // Check that hitRec's element matches element that browser says we clicked on
84 // TODO - This is still not working when using a handle that is on top of an 84 // TODO - This is still not working when using a handle that is on top of an
85 // element that is not currently selected 85 // element that is not currently selected
86 var elt = this.application.ninja.stage.GetSelectableElement(event); 86 var elt = this.application.ninja.stage.getElement(event, true);
87 if(elt && (elt !== hitRec.getElement())) 87 if(elt && (elt !== hitRec.getElement()))
88 { 88 {
89 hitRec = snapM