aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/3D/view-utils.js
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-07-19 10:55:22 -0700
committerNivesh Rajbhandari2012-07-19 10:55:22 -0700
commitfc13ef1e806116bb7ece5bb06604fa4f5714a6ed (patch)
tree8e8d87b31fffb7163aff0634ba4128f08be66343 /js/helper-classes/3D/view-utils.js
parent16d06bac95ce8334f8c5586750e98360dbc9cbd9 (diff)
downloadninja-fc13ef1e806116bb7ece5bb06604fa4f5714a6ed.tar.gz
Squashed commit of the following:
commit 0285afe3d4bd458a51f11241f13ea6ffdb0283ed Merge: 2f9f5e3 16d06ba Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Jul 19 10:54:25 2012 -0700 Merge branch 'refs/heads/ninja-mqg734-master' into StageToolDrawingOptimizations commit 2f9f5e369eb96f6c81b5e4bcbe09b418825e2864 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Wed Jul 18 17:15:19 2012 -0700 Fixed selection bounds not drawing in nested tags. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit b0a3507f9d27579ad511c69314a09136d7f7c6a0 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Wed Jul 18 11:07:44 2012 -0700 Layout info needs to redraw if stage is updated. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 63c5e0bf52c33706ba597cb69f7794e287bd0f06 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Tue Jul 17 15:40:54 2012 -0700 Per feedback from QE, we are still going to draw tool feedback on each mouse move so the selection bounds are not out of sync with the elements. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 0599a742092b985c4002977e501e3b457173f1d9 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Tue Jul 17 15:28:25 2012 -0700 Fixed grid not drawing correctly when switching documents and when adding/removing elements. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit fd9410606ee6358910d65b2cb5f71812fd44a7c4 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Tue Jul 17 11:36:09 2012 -0700 Updated drawing feedback to handle matrix 2d values entered via CSS Panel. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 559c16c7ac8c9f40b94a011a6f932d4f97df66a7 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Mon Jul 16 17:14:28 2012 -0700 IKNinja-751 - Selection boundary doesn't follow the transform applied in the CSS Panel. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit e2da5340159db5cd6f75bf6c9b7eb9cbf959e5cd Merge: 7cc5de3 5146f22 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Mon Jul 16 15:36:28 2012 -0700 Merge branch 'refs/heads/ninja-mqg734-master' into StageToolDrawingOptimizations commit 7cc5de39e41b4220f53c91b15b0cf0ed53e0b0f6 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Mon Jul 16 14:52:06 2012 -0700 Check if ownerDocument.defaultValue is null. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 5ae97995a28a4b06fb7f8703eb8090ea16d88acd Merge: d17974d 0ede302 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Mon Jul 16 09:27:22 2012 -0700 Merge branch 'refs/heads/ninja-mqg734-master' into StageToolDrawingOptimizations commit d17974d77273bb635311cb6466f4427cf4d9e5d4 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Mon Jul 16 08:45:05 2012 -0700 Pass in selectedElements array directly to drawUtils when drawing selection bounds instead of creating a duplicate array. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 0b1ea3144cb3e2c1d272f60da32423d0604ace3b Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Jul 13 14:03:40 2012 -0700 Fixed line tool not drawing the width and height info. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit b9c70e8d9ae324aa21fa5490edc71d8503bcefbc Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Jul 13 12:42:25 2012 -0700 Used cached offsetWidth and offsetHeight. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 9e17ac7124745ba745014efe149b31dee4fe658f Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Jul 12 16:25:41 2012 -0700 Converting tabs to spaces … again! Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 351726c951bb73c28f0e15ea1ab32e85cc735688 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Jul 12 16:14:31 2012 -0700 Tabs should be 4 spaces. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 250c419aa2dbcb10f012817ee7039aca77cb2518 Merge: 3f8d61a 2880e1d Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Jul 12 16:08:31 2012 -0700 Merge branch 'refs/heads/ninja-mqg734-master' into StageToolDrawingOptimizations commit 3f8d61a676da3992947ed9a2ed0e449780fcfbe0 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Jul 12 15:53:44 2012 -0700 Rotate tool was not working immediately after switching selection and selection bounds were not drawing after resizing canvases. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit e2e1f81e3b6917e1032e1b99b79c266937f3bb25 Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Thu Jul 12 12:15:59 2012 -0700 Single draw cycle for stage updates and tool drawings. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 95a90b4c95ee3163c97bea317144366674e49ade Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Mon Jun 18 11:46:38 2012 -0700 Single draw cycle for the stage and layout. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 21966b1515d80d2161a14e5a19bc66f3f49a92ce Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Fri Jun 15 13:33:14 2012 -0700 Cache element offsets, including offsetParent. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> commit 80c563c8ba06149691c6c1e754dd9a5e43bc7d4b Author: Nivesh Rajbhandari <mqg734@motorola.com> Date: Mon Jul 9 17:30:00 2012 -0700 Open materials editor popup next to PI button. Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com> Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/helper-classes/3D/view-utils.js')
-rwxr-xr-xjs/helper-classes/3D/view-utils.js99
1 files changed, 76 insertions, 23 deletions
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js
index 25e40bac..3b9c44b2 100755
--- a/js/helper-classes/3D/view-utils.js
+++ b/js/helper-classes/3D/view-utils.js
@@ -239,6 +239,27 @@ exports.ViewUtils = Montage.create(Component, {
239 } 239 }
240 }, 240 },
241 241
242 getOffsetParent: {
243 value: function( elt ) {
244 var parent = elt.elementModel.getProperty("offsetParent");
245 if(parent === "none") {
246 return null;
247 }
248 else if(parent) {
249 return parent;
250 } else {
251 parent = elt.offsetParent;
252 if(parent) {
253 elt.elementModel.setProperty("offsetParent", parent);
254 return parent;
255 } else {
256 elt.elementModel.setProperty("offsetParent", "none");
257 return null;
258 }
259 }
260 }
261 },
262
242 getEyePoint: { 263 getEyePoint: {
243 value:function() { 264 value:function() {
244 // this function should use the center of projection - it is currently hard wired to (0,0). 265 // this function should use the center of projection - it is currently hard wired to (0,0).
@@ -360,7 +381,7 @@ exports.ViewUtils = Montage.create(Component, {
360 381
361 // transform the point up the tree 382 // transform the point up the tree
362 var child = elt; 383 var child = elt;
363 var parent = elt.offsetParent; 384 var parent = this.getOffsetParent(elt);
364 while ( parent ) 385 while ( parent )
365 { 386 {
366 // go to screen space of the current child 387 // go to screen space of the current child
@@ -388,7 +409,7 @@ exports.ViewUtils = Montage.create(Component, {
388 } 409 }
389 410
390 child = parent; 411 child = parent;
391 parent = parent.offsetParent; 412 parent = this.getOffsetParent(parent);
392 } 413 }
393 414
394 return pt; 415 return pt;
@@ -413,7 +434,7 @@ exports.ViewUtils = Montage.create(Component, {
413 434
414 if (child === this._stageElement) break; 435 if (child === this._stageElement) break;
415 if (child === this._rootElement) break; 436 if (child === this._rootElement) break;
416 child = child.offsetParent; 437 child = this.getOffsetParent(child);
417 if (child === this._rootElement) break; 438 if (child === this._rootElement) break;
418 } 439 }
419 440
@@ -449,7 +470,7 @@ exports.ViewUtils = Montage.create(Component, {
449 if (pt.length == 2) pt[2] = 0; 470 if (pt.length == 2) pt[2] = 0;
450 471
451 // transform the bounds up the tree 472 // transform the bounds up the tree
452 var parent = child.offsetParent; 473 var parent = this.getOffsetParent(child);
453 // TODO - Should have a different way to check for new template mode 474 // TODO - Should have a different way to check for new template mode
454 if ( parent || (child === this.application.ninja.currentDocument.model.documentRoot) ) 475 if ( parent || (child === this.application.ninja.currentDocument.model.documentRoot) )
455 { 476 {
@@ -498,7 +519,7 @@ exports.ViewUtils = Montage.create(Component, {
498 pt[3] = 1; 519 pt[3] = 1;
499 520
500 // transform the bounds up the tree 521 // transform the bounds up the tree
501 var parent = child.offsetParent; 522 var parent = this.getOffsetParent(child);
502 if ( parent ) 523 if ( parent )
503 { 524 {
504 this.setViewportObj( child ); 525 this.setViewportObj( child );
@@ -701,11 +722,25 @@ exports.ViewUtils = Montage.create(Component, {
701 // optional argument localSpace, if true, puts the top left at (0,0). 722 // optional argument localSpace, if true, puts the top left at (0,0).
702 if (arguments.length < 2) localSpace = false; 723 if (arguments.length < 2) localSpace = false;
703 724
704 var bounds; 725 var bounds, left, top, w, h;
705 var left = elt.offsetLeft, 726 if(elt.elementModel.getProperty("offsetCache")) {
706 top = elt.offsetTop, 727 left = elt.elementModel.getProperty("offsetLeft");
707 w = elt.offsetWidth, 728 top = elt.elementModel.getProperty("offsetTop");
729 w = elt.elementModel.getProperty("offsetWidth");
730 h = elt.elementModel.getProperty("offsetHeight");
731 } else {
732 left = elt.offsetLeft;
733 top = elt.offsetTop;
734 w = elt.offsetWidth;
708 h = elt.offsetHeight; 735 h = elt.offsetHeight;
736 elt.elementModel.setProperty("offsetLeft", left);
737 elt.elementModel.setProperty("offsetTop", top);
738 elt.elementModel.setProperty("offsetWidth", w);
739 elt.elementModel.setProperty("offsetHeight", h);
740 elt.elementModel.setProperty("offsetCache", true);
741 }
742
743
709 744
710// if (elt instanceof SVGSVGElement) { 745// if (elt instanceof SVGSVGElement) {
711 if(elt.nodeName.toLowerCase() === "svg") { 746 if(elt.nodeName.toLowerCase() === "svg") {
@@ -745,21 +780,39 @@ exports.ViewUtils = Montage.create(Component, {
745 780
746 getElementOffset: { 781 getElementOffset: {
747 value: function( elt ) { 782 value: function( elt ) {
748 var xOff = elt.offsetLeft, yOff = elt.offsetTop; 783 var xOff, yOff, offset, parent, border, pS, bl, bt;
749 // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff;
750 // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff;
751 var offset = [xOff, yOff];
752 if(elt.offsetParent && (elt.offsetParent !== this._stageElement))
753 {
754 var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent);
755
756 var border = parseInt(pS.getPropertyValue("border"));
757 784
758 if(border) 785 if(elt.elementModel.getProperty("offsetCache")) {
759 { 786 xOff = elt.elementModel.getProperty("offsetLeft");
760 var bl = parseInt(pS.getPropertyValue("border-left-width")), 787 yOff = elt.elementModel.getProperty("offsetTop");
788 } else {
789 xOff = elt.offsetLeft;
790 yOff = elt.offsetTop;
791 elt.elementModel.setProperty("offsetLeft", xOff);
792 elt.elementModel.setProperty("offsetTop", yOff);
793 elt.elementModel.setProperty("offsetCache", true);
794 }
795 offset = [xOff, yOff];
796 parent = this.getOffsetParent(elt);
797 if(parent && (parent !== this._stageElement))
798 {
799 if(parent.elementModel.getProperty("border")) {
800 border = parent.elementModel.getProperty("border");
801 bl = parent.elementModel.getProperty("border-left-width");
802 bt = parent.elementModel.getProperty("border-top-width");
803 } else {
804 if(elt.ownerDocument.defaultView) {
805 pS = elt.ownerDocument.defaultView.getComputedStyle(parent, null);
806 border = parseInt(pS.getPropertyValue("border"));
807 bl = parseInt(pS.getPropertyValue("border-left-width"));
761 bt = parseInt(pS.getPropertyValue("border-top-width")); 808 bt = parseInt(pS.getPropertyValue("border-top-width"));
809 parent.elementModel.setProperty("border", border);
810 parent.elementModel.setProperty("border-left-width", bl);
811 parent.elementModel.setProperty("border-top-width", bt);
812 }
813 }
762 814
815 if(border) {
763 offset[0] += bl; 816 offset[0] += bl;
764 offset[1] += bt; 817 offset[1] += bt;
765 } 818 }
@@ -1072,7 +1125,7 @@ exports.ViewUtils = Montage.create(Component, {
1072 1125
1073 if (elt === this._stageElement) break; 1126 if (elt === this._stageElement) break;
1074 if (elt === this._rootElement) break; 1127 if (elt === this._rootElement) break;
1075 elt = elt.offsetParent; 1128 elt = this.getOffsetParent(elt);
1076 if (elt === this._rootElement) break; 1129 if (elt === this._rootElement) break;
1077 } 1130 }
1078 1131
@@ -1125,7 +1178,7 @@ exports.ViewUtils = Montage.create(Component, {
1125 //mat = offMat.multiply( mat ); 1178 //mat = offMat.multiply( mat );
1126 glmat4.multiply( offMat, mat, mat ); 1179 glmat4.multiply( offMat, mat, mat );
1127 1180
1128 elt = elt.offsetParent; 1181 elt = this.getOffsetParent(elt);
1129 } 1182 }
1130 1183
1131 return mat; 1184 return mat;