diff options
author | Valerio Virgillito | 2012-07-19 11:56:08 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-07-19 11:56:08 -0700 |
commit | c97f806fceb2a2e3c668b965e4f8e6fc047a3d9a (patch) | |
tree | 8e8d87b31fffb7163aff0634ba4128f08be66343 /js | |
parent | 6a49b632e0d7113ca7a6709e0a58097771512f20 (diff) | |
parent | fc13ef1e806116bb7ece5bb06604fa4f5714a6ed (diff) | |
download | ninja-c97f806fceb2a2e3c668b965e4f8e6fc047a3d9a.tar.gz |
Merge branch 'StageDrawingFixes' of https://github.com/mqg734/ninja into v0.7.1
Diffstat (limited to 'js')
-rwxr-xr-x | js/controllers/styles-controller.js | 51 | ||||
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 658 | ||||
-rwxr-xr-x | js/helper-classes/3D/snap-manager.js | 4 | ||||
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 99 | ||||
-rwxr-xr-x | js/panels/Materials/materials-library-panel.reel/materials-library-panel.js | 14 | ||||
-rwxr-xr-x | js/panels/Splitter.js | 2 | ||||
-rw-r--r-- | js/panels/css-panel/styles-view-delegate.js | 3 | ||||
-rwxr-xr-x | js/stage/layout.js | 58 | ||||
-rwxr-xr-x | js/stage/stage.reel/stage.js | 288 | ||||
-rwxr-xr-x | js/tools/Rotate3DToolBase.js | 1 | ||||
-rwxr-xr-x | js/tools/SelectionTool.js | 2 | ||||
-rwxr-xr-x | js/tools/Translate3DToolBase.js | 1 | ||||
-rwxr-xr-x | js/tools/modifier-tool-base.js | 3 |
13 files changed, 644 insertions, 540 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 89a389a4..b0db1b6a 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js | |||
@@ -1292,33 +1292,68 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
1292 | 1292 | ||
1293 | ///// Get Matrix From Element | 1293 | ///// Get Matrix From Element |
1294 | ///// Returns the matrix from an element's -webkit-transform | 1294 | ///// Returns the matrix from an element's -webkit-transform |
1295 | //// TODO - This routine should eventually check for other transform styles, i.e., rotateX, translateZ, etc. | ||
1296 | 1295 | ||
1297 | getMatrixFromElement : { | 1296 | getMatrixFromElement : { |
1298 | value: function(element, isStage) { | 1297 | value: function(element, isStage) { |
1299 | isStage = false; | 1298 | isStage = false; |
1300 | var xformStr = this.getElementStyle(element, "-webkit-transform", true, isStage), | 1299 | var xformStr = this.getElementStyle(element, "-webkit-transform", true, isStage), |
1301 | mat; | 1300 | mat, |
1301 | index1, | ||
1302 | index2, | ||
1303 | substr, | ||
1304 | numArray, | ||
1305 | nNums, | ||
1306 | i; | ||
1302 | 1307 | ||
1303 | if (xformStr) { | 1308 | if (xformStr) { |
1304 | var index1 = xformStr.indexOf( "matrix3d("); | 1309 | // Check for 3d matrix |
1310 | index1 = xformStr.indexOf( "matrix3d("); | ||
1311 | // If style does not contain 'matrix3d', try computed matrix/matrix3d from rotateY, translateZ, etc. | ||
1312 | if((index1 === -1) && element.ownerDocument.defaultView) { | ||
1313 | xformStr = element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue("-webkit-transform"); | ||
1314 | index1 = xformStr.indexOf( "matrix3d("); | ||
1315 | } | ||
1305 | if (index1 >= 0) { | 1316 | if (index1 >= 0) { |
1306 | index1 += 9; // do not include 'matrix3d(' | 1317 | index1 += 9; // do not include 'matrix3d(' |
1307 | var index2 = xformStr.indexOf( ")", index1 ); | 1318 | index2 = xformStr.indexOf( ")", index1 ); |
1308 | if (index2 >= 0) { | 1319 | if (index2 >= 0) { |
1309 | var substr = xformStr.substr( index1, (index2-index1)); | 1320 | substr = xformStr.substr( index1, (index2-index1)); |
1310 | if (substr && (substr.length > 0)) { | 1321 | if (substr && (substr.length > 0)) { |
1311 | var numArray = substr.split(','); | 1322 | numArray = substr.split(','); |
1312 | var nNums = numArray.length; | 1323 | nNums = numArray.length; |
1313 | if (nNums == 16) { | 1324 | if (nNums == 16) { |
1314 | // gl-matrix wants row order | 1325 | // gl-matrix wants row order |
1315 | mat = numArray; | 1326 | mat = numArray; |
1316 | for (var i=0; i<16; i++) { | 1327 | for (i=0; i<16; i++) { |
1317 | mat[i] = Number( mat[i] ); | 1328 | mat[i] = Number( mat[i] ); |
1318 | } | 1329 | } |
1319 | } | 1330 | } |
1320 | } | 1331 | } |
1321 | } | 1332 | } |
1333 | } else { | ||
1334 | // Check for 2d matrix | ||
1335 | index1 = xformStr.indexOf( "matrix("); | ||
1336 | if (index1 >= 0) { | ||
1337 | index1 += 7; // do not include 'matrix(' | ||
1338 | index2 = xformStr.indexOf( ")", index1 ); | ||
1339 | if (index2 >= 0) { | ||
1340 | substr = xformStr.substr( index1, (index2-index1)); | ||
1341 | if (substr && (substr.length > 0)) { | ||
1342 | numArray = substr.split(','); | ||
1343 | nNums = numArray.length; | ||
1344 | if (nNums === 6) { | ||
1345 | // gl-matrix wants row order | ||
1346 | mat = Matrix.I(4); | ||
1347 | mat[0] = Number(numArray[0]); | ||
1348 | mat[1] = Number(numArray[1]); | ||
1349 | mat[4] = Number(numArray[2]); | ||
1350 | mat[5] = Number(numArray[3]); | ||
1351 | mat[12] = Number(numArray[4]); | ||
1352 | mat[13] = Number(numArray[5]); | ||
1353 | } | ||
1354 | } | ||
1355 | } | ||
1356 | } | ||
1322 | } | 1357 | } |
1323 | } | 1358 | } |
1324 | return mat; | 1359 | return mat; |
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 869de213..b59bbf39 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js | |||
@@ -42,7 +42,6 @@ var StageLine = require("js/helper-classes/3D/StageLine").StageLine; | |||
42 | 42 | ||
43 | 43 | ||
44 | var DrawUtils = exports.DrawUtils = Montage.create(Component, { | 44 | var DrawUtils = exports.DrawUtils = Montage.create(Component, { |
45 | |||
46 | /////////////////////////////////////////////////////////////////////// | 45 | /////////////////////////////////////////////////////////////////////// |
47 | // Instance variables | 46 | // Instance variables |
48 | /////////////////////////////////////////////////////////////////////// | 47 | /////////////////////////////////////////////////////////////////////// |
@@ -97,7 +96,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
97 | _selectionCtr : {value: null, writable: true }, | 96 | _selectionCtr : {value: null, writable: true }, |
98 | 97 | ||
99 | // Properties that require element planes to be updated | 98 | // Properties that require element planes to be updated |
100 | _updatePlaneProps : {value: ["matrix", "left", "top", "width", "height"], writable: false }, | 99 | _updatePlaneProps : {value: ["matrix", "left", "top", "width", "height", "border", "border-width", "border-style", "-webkit-transform"], writable: false }, |
101 | _recalculateScrollOffsets : { value: false }, | 100 | _recalculateScrollOffsets : { value: false }, |
102 | 101 | ||
103 | /////////////////////////////////////////////////////////////////////// | 102 | /////////////////////////////////////////////////////////////////////// |
@@ -106,33 +105,33 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
106 | setDrawingSurfaceElement : { value: function( s ) { this._drawingSurfaceElt = s; if (s) this._drawingContext = s.getContext("2d"); }}, | 105 | setDrawingSurfaceElement : { value: function( s ) { this._drawingSurfaceElt = s; if (s) this._drawingContext = s.getContext("2d"); }}, |
107 | getDrawingSurfaceElement : { value: function() { return this._drawingSurfaceElt; }}, | 106 | getDrawingSurfaceElement : { value: function() { return this._drawingSurfaceElt; }}, |
108 | 107 | ||
109 | getDrawingContext : { value: function() { return this._drawingContext; }}, | 108 | getDrawingContext : { value: function() { return this._drawingContext; }}, |
110 | 109 | ||
111 | setSourceSpaceElement : { value: function(ss) { this._sourceSpaceElt = ss; }}, | 110 | setSourceSpaceElement : { value: function(ss) { this._sourceSpaceElt = ss; }}, |
112 | getSourceSpaceElement : { value: function() { return this._sourceSpaceElt; }}, | 111 | getSourceSpaceElement : { value: function() { return this._sourceSpaceElt; }}, |
113 | 112 | ||
114 | getWorkingPlane : { value: function() { return this._workingPlane; }}, | 113 | getWorkingPlane : { value: function() { return this._workingPlane; }}, |
115 | setWorkingPlane : { value: function (wp) { this._workingPlane = wp; }}, | 114 | setWorkingPlane : { value: function (wp) { this._workingPlane = wp; }}, |
116 | 115 | ||
117 | getGridHorizontalSpacing : { value: function() { return this._gridHorizontalSpacing; }}, | 116 | getGridHorizontalSpacing : { value: function() { return this._gridHorizontalSpacing; }}, |
118 | getGridVerticalSpacing : { value: function() { return this._gridVerticalSpacing; }}, | 117 | getGridVerticalSpacing : { value: function() { return this._gridVerticalSpacing; }}, |
119 | getGridHorizontalLineCount : { value: function() { return this._gridHorizontalLineCount; }}, | 118 | getGridHorizontalLineCount : { value: function() { return this._gridHorizontalLineCount; }}, |
120 | getGridVerticalLineCount : { value: function() { return this._gridVerticalLineCount; }}, | 119 | getGridVerticalLineCount : { value: function() { return this._gridVerticalLineCount; }}, |
121 | getGridOrigin : { value: function() { return this._gridOrigin.slice(0); }}, | 120 | getGridOrigin : { value: function() { return this._gridOrigin.slice(0); }}, |
122 | 121 | ||
123 | isDrawingGrid : { value: function() { return this.drawXY || this.drawYZ || this.drawXZ; }}, | 122 | isDrawingGrid : { value: function() { return this.drawXY || this.drawYZ || this.drawXZ; }}, |
124 | isDrawingElementNormal : { value: function() { return this.drawElementN }}, | 123 | isDrawingElementNormal : { value: function() { return this.drawElementN }}, |
125 | 124 | ||
126 | getLineColor : { value: function() { return this._lineColor; }}, | 125 | getLineColor : { value: function() { return this._lineColor; }}, |
127 | setLineColor : { value: function( color ) { this._lineColor = color; }}, | 126 | setLineColor : { value: function( color ) { this._lineColor = color; }}, |
128 | 127 | ||
129 | getLineWidth : { value: function() { return this._drawingContext.lineWidth; }}, | 128 | getLineWidth : { value: function() { return this._drawingContext.lineWidth; }}, |
130 | setLineWidth : { value: function( w ) { this._drawingContext.lineWidth = w; }}, | 129 | setLineWidth : { value: function( w ) { this._drawingContext.lineWidth = w; }}, |
131 | 130 | ||
132 | 131 | ||
133 | initialize: { | 132 | initialize: { |
134 | value: function() { | 133 | value: function() { |
135 | this._gridOrigin = [0,0]; // 2D plane space point | 134 | this._gridOrigin = [0,0]; // 2D plane space point |
136 | 135 | ||
137 | this.eventManager.addEventListener("elementAdded", this, false); | 136 | this.eventManager.addEventListener("elementAdded", this, false); |
138 | this.eventManager.addEventListener("elementsRemoved", this, false); | 137 | this.eventManager.addEventListener("elementsRemoved", this, false); |
@@ -212,7 +211,12 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
212 | this.addElement(elements); | 211 | this.addElement(elements); |
213 | } | 212 | } |
214 | 213 | ||
215 | this.drawWorkingPlane(); | 214 | // Redraw stage only once after all addition is completed |
215 | var stage = this.application.ninja.stage; | ||
216 | stage.drawLayout = true; | ||
217 | stage.updatePlanes = true; | ||
218 | stage.draw3DInfo = true; | ||
219 | stage.needsDrawSelection = true; | ||
216 | } | 220 | } |
217 | }, | 221 | }, |
218 | 222 | ||
@@ -229,7 +233,12 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
229 | this.removeElement(elements); | 233 | this.removeElement(elements); |
230 | } | 234 | } |
231 | 235 | ||
232 | this.drawWorkingPlane(); | 236 | // Redraw stage only once after all deletion is completed |
237 | var stage = this.application.ninja.stage; | ||
238 | stage.drawLayout = true; | ||
239 | stage.updatePlanes = true; | ||
240 | stage.draw3DInfo = true; | ||
241 |