diff options
Diffstat (limited to 'js/helper-classes')
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 4 | ||||
-rwxr-xr-x | js/helper-classes/3D/snap-manager.js | 20 | ||||
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 62 |
3 files changed, 32 insertions, 54 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index a6d2d899..bf48a723 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js | |||
@@ -124,7 +124,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
124 | this._eltArray = []; | 124 | this._eltArray = []; |
125 | this._planesArray = []; | 125 | this._planesArray = []; |
126 | this.setDrawingSurfaceElement(stage.canvas); | 126 | this.setDrawingSurfaceElement(stage.canvas); |
127 | this.setSourceSpaceElement( stage.stageDeps.currentStage ); | 127 | this.setSourceSpaceElement( this.application.ninja.currentDocument.documentRoot); |
128 | this.setWorkingPlane( [0,0,1,0] ); | 128 | this.setWorkingPlane( [0,0,1,0] ); |
129 | 129 | ||
130 | //Loop through all the top-level children of the current document and call drawUtils.addElement on them | 130 | //Loop through all the top-level children of the current document and call drawUtils.addElement on them |
@@ -138,7 +138,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
138 | l, | 138 | l, |
139 | t, | 139 | t, |
140 | plane, | 140 | plane, |
141 | elt | 141 | elt; |
142 | for(i=0; i<len; i++) { | 142 | for(i=0; i<len; i++) { |
143 | elt = documentRootChildren[i]; | 143 | elt = documentRootChildren[i]; |
144 | plane = this.addElement(elt); | 144 | plane = this.addElement(elt); |
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 2e8020d3..e22ac3ad 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js | |||
@@ -21,7 +21,6 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
21 | /////////////////////////////////////////////////////////////////////// | 21 | /////////////////////////////////////////////////////////////////////// |
22 | // Instance variables | 22 | // Instance variables |
23 | /////////////////////////////////////////////////////////////////////// | 23 | /////////////////////////////////////////////////////////////////////// |
24 | currentStage: { value: null, writable: true }, | ||
25 | drawingCanvas: { value: null, writable: true}, | 24 | drawingCanvas: { value: null, writable: true}, |
26 | 25 | ||
27 | // we keep a stack of working planes to facilitate working on other planes temporarily | 26 | // we keep a stack of working planes to facilitate working on other planes temporarily |
@@ -84,14 +83,14 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
84 | popWorkingPlane : { value: function () { workingPlane = this._workingPlaneStack.pop(); return workingPlane; }}, | 83 | popWorkingPlane : { value: function () { workingPlane = this._workingPlaneStack.pop(); return workingPlane; }}, |
85 | 84 | ||
86 | getStageWidth : { value: function () { | 85 | getStageWidth : { value: function () { |
87 | return parseInt(this.currentStage.offsetWidth); | 86 | return parseInt(this.application.ninja.currentDocument.documentRoot.offsetWidth); |
88 | }}, | 87 | }}, |
89 | 88 | ||
90 | getStageHeight : { value: function () { | 89 | getStageHeight : { value: function () { |
91 | return parseInt(this.currentStage.offsetHeight); | 90 | return parseInt(this.application.ninja.currentDocument.documentRoot.offsetHeight); |
92 | }}, | 91 | }}, |
93 | 92 | ||
94 | getStage : { value: function() { return this.currentStage; }}, | 93 | getStage : { value: function() { return this.application.ninja.currentDocument.documentRoot; }}, |
95 | 94 | ||
96 | getGridVertexHitRad : { value: function() { return this._gridVertexHitRad; }}, | 95 | getGridVertexHitRad : { value: function() { return this._gridVertexHitRad; }}, |
97 | getGridEdgeHitRad : { value: function() { return this._gridEdgeHitRad; }}, | 96 | getGridEdgeHitRad : { value: function() { return this._gridEdgeHitRad; }}, |
@@ -185,12 +184,6 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
185 | } | 184 | } |
186 | }, | 185 | }, |
187 | 186 | ||
188 | setCurrentStage: { | ||
189 | value: function(stage) { | ||
190 | this.currentStage = stage; | ||
191 | } | ||
192 | }, | ||
193 | |||
194 | snap : { | 187 | snap : { |
195 | value: function (xScreen, yScreen, snap3D, quadPt) | 188 | value: function (xScreen, yScreen, snap3D, quadPt) |
196 | { | 189 | { |
@@ -463,6 +456,13 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
463 | } | 456 | } |
464 | }, | 457 | }, |
465 | 458 | ||
459 | reload2DCache: { | ||
460 | value: function() { | ||
461 | this.clear2DCache(); | ||
462 | this.load2DCache(workingPlane); | ||
463 | } | ||
464 | }, | ||
465 | |||
466 | clear2DCache : { | 466 | clear2DCache : { |
467 | value : function() { | 467 | value : function() { |
468 | // clear the 2D cache flags in the objects | 468 | // clear the 2D cache flags in the objects |
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index 8c338f84..75530af3 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js | |||
@@ -18,18 +18,14 @@ exports.ViewUtils = Montage.create(Component, { | |||
18 | // Instance variables | 18 | // Instance variables |
19 | /////////////////////////////////////////////////////////////////////// | 19 | /////////////////////////////////////////////////////////////////////// |
20 | 20 | ||
21 | m_viewportObj : { value: null, writable: true}, | 21 | m_viewportObj : { value: null}, |
22 | _perspectiveDist: { value: null, writable: true}, | 22 | _perspectiveDist: { value: null}, |
23 | 23 | ||
24 | // keep a stack of viewport objects | 24 | // keep a stack of viewport objects |
25 | _viewportObjStack: { value: [], writable: true }, | 25 | _viewportObjStack: { value: []}, |
26 | 26 | ||
27 | _currentDocument: { value: null , writable: true}, | 27 | _userContentLeft: { value: null}, |
28 | _userContentLeft: { value: null , writable: true}, | 28 | _userContentTop: { value: null}, |
29 | _userContentTop: { value: null , writable: true}, | ||
30 | |||
31 | _rootElement: { value: null, writable: true}, | ||
32 | _stageElement: { value: null, writable: true}, | ||
33 | 29 | ||
34 | /////////////////////////////////////////////////////////////////////// | 30 | /////////////////////////////////////////////////////////////////////// |
35 | // Property accessors | 31 | // Property accessors |
@@ -43,18 +39,9 @@ exports.ViewUtils = Montage.create(Component, { | |||
43 | }, | 39 | }, |
44 | getViewportObj: { value: function() { return this.m_viewportObj; } }, | 40 | getViewportObj: { value: function() { return this.m_viewportObj; } }, |
45 | 41 | ||
46 | setRootElement: { value: function( elt ) { this._rootElement = elt; } }, | ||
47 | getRootElement: { value: function () { return this._rootElement; } }, | ||
48 | |||
49 | setStageElement: { value: function( elt ) { this._stageElement = elt; } }, | ||
50 | getStageElement: { value: function () { return this._stageElement; } }, | ||
51 | |||
52 | setCurrentDocument: { value: function(value) { this._currentDocument = value; }}, | ||
53 | |||
54 | setUserContentLeft: { value: function(value) { this._userContentLeft = value; }}, | 42 | setUserContentLeft: { value: function(value) { this._userContentLeft = value; }}, |
55 | setUserContentTop: { value: function(value) { this._userContentTop = value; }}, | 43 | setUserContentTop: { value: function(value) { this._userContentTop = value; }}, |
56 | 44 | ||
57 | |||
58 | getPerspectiveDistance: { value: function () { return this._perspectiveDist; } }, | 45 | getPerspectiveDistance: { value: function () { return this._perspectiveDist; } }, |
59 | 46 | ||
60 | /////////////////////////////////////////////////////////////////////// | 47 | /////////////////////////////////////////////////////////////////////// |
@@ -302,7 +289,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
302 | // into stage world space. | 289 | // into stage world space. |
303 | postViewToStageWorld: { | 290 | postViewToStageWorld: { |
304 | value: function( localPt, elt ) { | 291 | value: function( localPt, elt ) { |
305 | if ((elt == null) || (elt === this._stageElement)) return localPt; | 292 | if ((elt == null) || (elt === this.application.ninja.currentDocument.documentRoot)) return localPt; |
306 | 293 | ||
307 | // get the 3D transformation and 2D offset from the element | 294 | // get the 3D transformation and 2D offset from the element |
308 | var pt = localPt.slice(0); | 295 | var pt = localPt.slice(0); |
@@ -329,7 +316,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
329 | this.popViewportObj(); | 316 | this.popViewportObj(); |
330 | 317 | ||
331 | // check if we are done | 318 | // check if we are done |
332 | if (parent === this._stageElement) break; | 319 | if (parent === this.application.ninja.currentDocument.documentRoot) break; |
333 | 320 | ||
334 | if (this.elementHas3D( parent )) | 321 | if (this.elementHas3D( parent )) |
335 | { | 322 | { |
@@ -358,13 +345,13 @@ exports.ViewUtils = Montage.create(Component, { | |||
358 | { | 345 | { |
359 | pt = this.childToParent( pt, child ); | 346 | pt = this.childToParent( pt, child ); |
360 | 347 | ||
361 | // if (child === this._stageElement) break; | 348 | // if (child === this.application.ninja.currentDocument.documentRoot) break; |
362 | // child = child.offsetParent; | 349 | // child = child.offsetParent; |
363 | 350 | ||
364 | if (child === this._stageElement) break; | 351 | if (child === this.application.ninja.currentDocument.documentRoot) break; |
365 | if (child === this._rootElement) break; | 352 | if (child === this.application.ninja.currentDocument.documentRoot.parentNode) break; |
366 | child = child.offsetParent; | 353 | child = child.offsetParent; |
367 | if (child === this._rootElement) break; | 354 | if (child === this.application.ninja.currentDocument.documentRoot.parentNode) break; |
368 | } | 355 | } |
369 | 356 | ||
370 | ///////////////////////////////////////////////////////// | 357 | ///////////////////////////////////////////////////////// |
@@ -414,7 +401,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
414 | { | 401 | { |
415 | // TODO - Commenting out flatten support until new perspective workflow is fully working | 402 | // TODO - Commenting out flatten support until new perspective workflow is fully working |
416 | // if (flatten) pt[2] = 0; | 403 | // if (flatten) pt[2] = 0; |
417 | // var flatten = (parent !== this._rootElement) && (ElementsMediator.getProperty(parent, "-webkit-transform-style") !== "preserve-3d"); | 404 | // var flatten = (parent !== this.application.ninja.currentDocument.documentRoot.parentNode) && (ElementsMediator.getProperty(parent, "-webkit-transform-style") !== "preserve-3d"); |
418 | // if(flatten) | 405 | // if(flatten) |
419 | // { | 406 | // { |
420 | // pt[2] = 0; | 407 | // pt[2] = 0; |
@@ -699,7 +686,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
699 | // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff; | 686 | // if (elt.__ninjaXOff) xOff = elt.__ninjaXOff; |
700 | // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff; | 687 | // if (elt.__ninjaYOff) yOff = elt.__ninjaYOff; |
701 | var offset = [xOff, yOff]; | 688 | var offset = [xOff, yOff]; |
702 | if(elt.offsetParent && (elt.offsetParent !== this._stageElement)) | 689 | if(elt.offsetParent && (elt.offsetParent !== this.application.ninja.currentDocument.documentRoot)) |
703 | { | 690 | { |
704 | var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent); | 691 | var pS = elt.ownerDocument.defaultView.getComputedStyle(elt.offsetParent); |
705 | 692 | ||
@@ -715,7 +702,7 @@ exports.ViewUtils = Montage.create(Component, { | |||
715 | } | 702 | } |
716 | } | 703 | } |
717 | 704 | ||
718 |