diff options
author | Jonathan Duran | 2012-07-17 09:30:22 -0700 |
---|---|---|
committer | Jonathan Duran | 2012-07-17 09:30:22 -0700 |
commit | 53051672a62208fbc96957719d8285fac6431ed6 (patch) | |
tree | 79d542ee811044e8af2ef84aa0d6662c6eb895c4 /js/tools/TranslateObject3DTool.js | |
parent | 7e2c2dbd040ed79a3f0678f91bd4b6db9cf69231 (diff) | |
parent | 5146f224258929415adf4a8022e492454b4e2476 (diff) | |
download | ninja-53051672a62208fbc96957719d8285fac6431ed6.tar.gz |
Merge branch 'refs/heads/NINJA-master' into TimelineUber
Conflicts:
js/panels/Timeline/DragDrop.js
js/panels/Timeline/Keyframe.reel/Keyframe.js
js/panels/Timeline/Layer.reel/Layer.js
js/panels/Timeline/PropertyTrack.reel/PropertyTrack.js
js/panels/Timeline/Span.reel/Span.js
js/panels/Timeline/Style.reel/Style.js
js/panels/Timeline/TimelinePanel.reel/TimelinePanel.js
js/panels/Timeline/TimelineTrack.reel/TimelineTrack.js
js/panels/Timeline/Track.reel/Track.html
js/panels/Timeline/Track.reel/Track.js
js/panels/Timeline/Track.reel/css/Track.css
js/panels/Timeline/TrackSpacer.reel/TrackSpacer.html
js/panels/Timeline/TrackSpacer.reel/TrackSpacer.js
js/panels/Timeline/TrackSpacer.reel/css/TrackSpacer.css
js/panels/Timeline/Tween.reel/Tween.js
Signed-off-by: Jonathan Duran <jduran@motorola.com>
Diffstat (limited to 'js/tools/TranslateObject3DTool.js')
-rwxr-xr-x | js/tools/TranslateObject3DTool.js | 107 |
1 files changed, 54 insertions, 53 deletions
diff --git a/js/tools/TranslateObject3DTool.js b/js/tools/TranslateObject3DTool.js index 421ace8f..284ba417 100755 --- a/js/tools/TranslateObject3DTool.js +++ b/js/tools/TranslateObject3DTool.js | |||
@@ -1,24 +1,25 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility LLC. |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | ||
5 | 4 | ||
6 | Redistribution and use in source and binary forms, with or without | 5 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 6 | modification, are permitted provided that the following conditions are met: |
8 | 7 | ||
9 | - Redistributions of source code must retain the above copyright notice, | 8 | * Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. | 9 | this list of conditions and the following disclaimer. |
11 | - Redistributions in binary form must reproduce the above copyright | 10 | |
12 | notice, this list of conditions and the following disclaimer in the | 11 | * Redistributions in binary form must reproduce the above copyright notice, |
13 | documentation and/or other materials provided with the distribution. | 12 | this list of conditions and the following disclaimer in the documentation |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 13 | and/or other materials provided with the distribution. |
15 | may be used to endorse or promote products derived from this software | 14 | |
16 | without specific prior written permission. | 15 | * Neither the name of Motorola Mobility LLC nor the names of its |
16 | contributors may be used to endorse or promote products derived from this | ||
17 | software without specific prior written permission. | ||
17 | 18 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
@@ -51,29 +52,29 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { | |||
51 | { | 52 | { |
52 | // console.log( "initializeSnapping" ); | 53 | // console.log( "initializeSnapping" ); |
53 | 54 | ||
54 | this._mouseDownHitRec = null; | 55 | this._mouseDownHitRec = null; |
55 | this._mouseUpHitRec = null; | 56 | this._mouseUpHitRec = null; |
56 | 57 | ||
57 | snapManager.clearAvoidList(); | 58 | snapManager.clearAvoidList(); |
58 | snapManager.clearDragPlane(); | 59 | snapManager.clearDragPlane(); |
59 | 60 | ||
60 | // the translate tool does snap align to the bounds of the object only. | 61 | // the translate tool does snap align to the bounds of the object only. |
61 | // turn off snap align to the cursor. This needs to be re-enabled in the mouse up method | 62 | // turn off snap align to the cursor. This needs to be re-enabled in the mouse up method |
62 | snapManager.enableSnapAlign( false ); | 63 | snapManager.enableSnapAlign( false ); |
63 | 64 | ||
64 | // snap to element and snap to grid are conditionally enabled based | 65 | // snap to element and snap to grid are conditionally enabled based |
65 | // on the snap results of the mouse down. enable everything for the first snap | 66 | // on the snap results of the mouse down. enable everything for the first snap |
66 | this._snapToElements = snapManager.elementSnapEnabledAppLevel(); | 67 | this._snapToElements = snapManager.elementSnapEnabledAppLevel(); |
67 | this._snapToGrid = snapManager.gridSnapEnabledAppLevel(); | 68 | this._snapToGrid = snapManager.gridSnapEnabledAppLevel(); |
68 | 69 | ||
69 | this._dragPlane = null; | 70 | this._dragPlane = null; |
70 | this._clickedOnStage = false; | 71 | this._clickedOnStage = false; |
71 | var do3DSnap = true; | 72 | var do3DSnap = true; |
72 | 73 | ||
73 | if(this._handleMode === null) | 74 | if(this._handleMode === null) |
74 | { | 75 | { |
75 | snapManager.enableElementSnap ( true ); | 76 | snapManager.enableElementSnap ( true ); |
76 | snapManager.enableGridSnap ( true ); | 77 | snapManager.enableGridSnap ( true ); |
77 | } | 78 | } |
78 | else | 79 | else |
79 | { | 80 | { |
@@ -81,21 +82,21 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { | |||
81 | //if(this._handleMode === 2) | 82 | //if(this._handleMode === 2) |
82 | { | 83 | { |
83 | this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target, this._handleMode, this._inLocalMode); | 84 | this._dragPlane = viewUtils.getNormalToUnprojectedElementPlane(this._target, this._handleMode, this._inLocalMode); |
84 | //console.log( "dragPlane: " + this._dragPlane ); | 85 | //console.log( "dragPlane: " + this._dragPlane ); |
85 | snapManager.setupDragPlaneFromPlane(this._dragPlane); | 86 | snapManager.setupDragPlaneFromPlane(this._dragPlane); |
86 | do3DSnap = false; | 87 | do3DSnap = false; |
87 | 88 | ||
88 | snapManager.enableElementSnap ( false ); | 89 | snapManager.enableElementSnap ( false ); |
89 | snapManager.enableGridSnap ( false ); | 90 | snapManager.enableGridSnap ( false ); |
90 | } | 91 | } |
91 | } | 92 | } |
92 | 93 | ||
93 | if(this.application.ninja.selectedElements.length) { | 94 | if(this.application.ninja.selectedElements.length) { |
94 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); | 95 | var point = webkitConvertPointFromPageToNode(this.application.ninja.stage.canvas, new WebKitPoint(event.pageX, event.pageY)); |
95 | 96 | ||
96 | // do the snap before setting up the avoid list to allow | 97 | // do the snap before setting up the avoid list to allow |
97 | // a snap on the mouse down | 98 | // a snap on the mouse down |
98 | var hitRec = snapManager.snap(point.x, point.y, do3DSnap); | 99 | var hitRec = snapManager.snap(point.x, point.y, do3DSnap); |
99 | 100 | ||
100 | if(this._handleMode === 2) | 101 | if(this._handleMode === 2) |
101 | { | 102 | { |
@@ -111,7 +112,7 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { | |||
111 | if(elt && (elt !== hitRec.getElement())) | 112 | if(elt && (elt !== hitRec.getElement())) |
112 | { | 113 | { |
113 | var otherSnap = snapManager.findHitRecordForElement(elt); | 114 | var otherSnap = snapManager.findHitRecordForElement(elt); |
114 | if (otherSnap) hitRec = otherSnap; | 115 | if (otherSnap) hitRec = otherSnap; |
115 | } | 116 | } |
116 | if(elt === this.application.ninja.currentDocument.model.domContainer) | 117 | if(elt === this.application.ninja.currentDocument.model.domContainer) |
117 | { | 118 | { |
@@ -124,18 +125,18 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { | |||
124 | snapManager.addToAvoidList(element); | 125 | snapManager.addToAvoidList(element); |
125 | }); | 126 | }); |
126 | 127 | ||
127 | if (hitRec) | 128 | if (hitRec) |
128 | { | 129 | { |
129 | // disable snap attributes | 130 | // disable snap attributes |
130 | if (hitRec.getType() == hitRec.SNAP_TYPE_ELEMENT) | 131 | if (hitRec.getType() == hitRec.SNAP_TYPE_ELEMENT) |
131 | { | 132 | { |
132 | this._snapToElements = false; | 133 | this._snapToElements = false; |
133 | this._snapToGrid = false; | 134 | this._snapToGrid = false; |
134 | } | 135 | } |
135 | else if (hitRec.getType() == hitRec.SNAP_TYPE_ELEMENT_CENTER) | 136 | else if (hitRec.getType() == hitRec.SNAP_TYPE_ELEMENT_CENTER) |
136 | { | 137 | { |
137 | snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); | 138 | snapManager.enableSnapAlign( snapManager.snapAlignEnabledAppLevel() ); |
138 | } | 139 | } |
139 | 140 | ||
140 | if(this._handleMode === 2) | 141 | if(this._handleMode === 2) |
141 | this.clickedObject = this._target; | 142 | this.clickedObject = this._target; |
@@ -158,23 +159,23 @@ exports.TranslateObject3DTool = Montage.create(Translate3DToolBase, { | |||
158 | } | 159 | } |
159 | 160 | ||
160 | // only do quadrant snapping if the 4 corners of the element are in the drag plane | 161 | // only do quadrant snapping if the 4 corners of the element are in the drag plane |
161 | 162 | ||
162 | var sign = MathUtils.fpSign( vecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); | 163 | var sign = MathUtils.fpSign( vecUtils.vecDot(3,this._dragPlane,[0,0,1]) + this._dragPlane[3] - 1.0); |
163 | this._shouldUseQuadPt = (sign == 0); | 164 | this._shouldUseQuadPt = (sign == 0); |
164 | 165 | ||
165 | var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); | 166 | var wpHitRec = hitRec.convertToWorkingPlane( this._dragPlane ); |
166 | this._mouseDownHitRec = wpHitRec; | 167 | this._mouseDownHitRec = wpHitRec; |
167 | this._mouseUpHitRec = null; | 168 | this._mouseUpHitRec = null; |
168 | 169 | ||
169 | var pt = hitRec.getScreenPoint(); | 170 | var pt = hitRec.getScreenPoint(); |
170 | this.downPoint.x = pt[0]; | 171 | this.downPoint.x = pt[0]; |
171 | this.downPoint.y = pt[1]; | 172 | this.downPoint.y = pt[1]; |
172 | 173 | ||
173 | // TODO - need to figure out snapManager dependency by drawUtils. | 174 | // TODO - need to figure out snapManager dependency by drawUtils. |
174 | // For now, bypassing by calling snapManager.drawLastHit(); | 175 | // For now, bypassing by calling snapManager.drawLastHit(); |
175 | // drawUtils.refreshDisplay(); | 176 | // drawUtils.refreshDisplay(); |
176 | snapManager.drawLastHit(); | 177 | snapManager.drawLastHit(); |
177 | } | 178 | } |
178 | } | 179 | } |
179 | else | 180 | else |
180 | { | 181 | { |