diff options
Diffstat (limited to 'js')
-rwxr-xr-x | js/controllers/elements/element-controller.js | 2 | ||||
-rwxr-xr-x | js/lib/NJUtils.js | 5 | ||||
-rwxr-xr-x | js/mediators/element-mediator.js | 9 | ||||
-rwxr-xr-x | js/tools/SelectionTool.js | 47 | ||||
-rwxr-xr-x | js/tools/TagTool.js | 15 | ||||
-rwxr-xr-x | js/tools/drawing-tool-base.js | 2 |
6 files changed, 45 insertions, 35 deletions
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 4f360bb9..9cba6d94 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js | |||
@@ -244,7 +244,7 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, | |||
244 | else | 244 | else |
245 | { | 245 | { |
246 | var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, false); | 246 | var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, false); |
247 | if(dist === null) { | 247 | if(dist == null) { |
248 | dist = 1400; | 248 | dist = 1400; |
249 | } | 249 | } |
250 | 250 | ||
diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index f611052b..cb877591 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js | |||
@@ -94,7 +94,10 @@ exports.NJUtils = Object.create(Object.prototype, { | |||
94 | ///// TODO: find a different place for this function | 94 | ///// TODO: find a different place for this function |
95 | makeElementModel: { | 95 | makeElementModel: { |
96 | value: function(el, selection, controller, isShape) { | 96 | value: function(el, selection, controller, isShape) { |
97 | var p3d = Montage.create(Properties3D).init(el, (selection === "Stage")); | 97 | var p3d = Montage.create(Properties3D); |
98 | if(selection === "Stage") { | ||
99 | p3d.init(el, true); | ||
100 | } | ||
98 | var shapeProps = null; | 101 | var shapeProps = null; |
99 | if(isShape) { | 102 | if(isShape) { |
100 | shapeProps = Montage.create(ShapeModel); | 103 | shapeProps = Montage.create(ShapeModel); |
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index d62fa1f8..eac0ca54 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js | |||
@@ -90,9 +90,12 @@ exports.ElementMediator = Montage.create(NJComponent, { | |||
90 | _addElement: { | 90 | _addElement: { |
91 | value: function(el, rules, noEvent) { | 91 | value: function(el, rules, noEvent) { |
92 | ElementController.addElement(el, rules); | 92 | ElementController.addElement(el, rules); |
93 | var p3d = this.get3DProperties(el); | 93 | // var p3d = this.get3DProperties(el); |
94 | if(p3d) { | 94 | // if(p3d) { |
95 | el.elementModel.controller["set3DProperties"](el, [p3d], 0, true); | 95 | // el.elementModel.controller["set3DProperties"](el, [p3d], 0, true); |
96 | // } | ||
97 | if(el.elementModel && el.elementModel.props3D) { | ||
98 | el.elementModel.props3D.init(el, false); | ||
96 | } | 99 | } |
97 | if(!noEvent) { | 100 | if(!noEvent) { |
98 | this.application.ninja.documentController.activeDocument.needsSave = true; | 101 | this.application.ninja.documentController.activeDocument.needsSave = true; |
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index f9411f48..e252e36b 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js | |||
@@ -318,18 +318,28 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
318 | this._targets.push({elt:elt, mat:curMat, matInv:curMatInv}); | 318 | this._targets.push({elt:elt, mat:curMat, matInv:curMatInv}); |
319 | if(addToUndoStack) | 319 | if(addToUndoStack) |
320 | { | 320 | { |
321 | var prevX, | ||
322 | prevY, | ||
323 | prevW, | ||
324 | prevH, | ||
325 | _x, | ||
326 | _y, | ||
327 | _w, | ||
328 | _h, | ||
329 | previousMat, | ||
330 | previousStyleStr, | ||
331 | newStyleStr; | ||
321 | 332 | ||
322 | if(!this._use3DMode) | 333 | if(!this._use3DMode) |
323 | { | 334 | { |
324 | var previousMat = this._undoArray[i].mat.slice(0); | 335 | prevX = this._undoArray[i]._x; |
325 | var prevX = this._undoArray[i]._x; | 336 | prevY = this._undoArray[i]._y; |
326 | var prevY = this._undoArray[i]._y; | 337 | prevW = this._undoArray[i]._w; |
327 | var prevW = this._undoArray[i]._w; | 338 | prevH = this._undoArray[i]._h; |
328 | var prevH = this._undoArray[i]._h; | 339 | _x = parseInt(ElementsMediator.getProperty(elt, "left")); |
329 | var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + curMat[12] - previousMat[12]; | 340 | _y = parseInt(ElementsMediator.getProperty(elt, "top")); |
330 | var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + curMat[13] - previousMat[13]; | 341 | _w = parseInt(ElementsMediator.getProperty(elt, "width")); |
331 | var _w = parseInt(ElementsMediator.getProperty(elt, "width")); | 342 | _h = parseInt(ElementsMediator.getProperty(elt, "height")); |
332 | var _h = parseInt(ElementsMediator.getProperty(elt, "height")); | ||
333 | 343 | ||
334 | previousLeft.push(prevX + "px"); | 344 | previousLeft.push(prevX + "px"); |
335 | previousTop.push(prevY + "px"); | 345 | previousTop.push(prevY + "px"); |
@@ -339,27 +349,22 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
339 | newTop.push(_y + "px"); | 349 | newTop.push(_y + "px"); |
340 | newWidth.push(_w + "px"); | 350 | newWidth.push(_w + "px"); |
341 | newHeight.push(_h + "px"); | 351 | newHeight.push(_h + "px"); |
342 | |||
343 | viewUtils.setMatrixForElement(elt, previousMat); | ||
344 | |||
345 | this._targets[i].mat = previousMat; | ||
346 | this._targets[i].matInv = glmat4.inverse(previousMat, []); | ||
347 | } | 352 | } |
348 | else | 353 | else |
349 | { | 354 | { |
350 | var previousMat = this._undoArray[i].mat.slice(0); | 355 | previousMat = this._undoArray[i].mat.slice(0); |
351 | var prevW = this._undoArray[i]._w; | 356 | prevW = this._undoArray[i]._w; |
352 | var prevH = this._undoArray[i]._h; | 357 | prevH = this._undoArray[i]._h; |
353 | var _w = parseInt(ElementsMediator.getProperty(elt, "width")); | 358 | _w = parseInt(ElementsMediator.getProperty(elt, "width")); |
354 | var _h = parseInt(ElementsMediator.getProperty(elt, "height")); | 359 | _h = parseInt(ElementsMediator.getProperty(elt, "height")); |
355 | previousWidth.push(prevW + "px"); | 360 | previousWidth.push(prevW + "px"); |
356 | previousHeight.push(prevH + "px"); | 361 | previousHeight.push(prevH + "px"); |
357 | newWidth.push(_w + "px"); | 362 | newWidth.push(_w + "px"); |
358 | newHeight.push(_h + "px"); | 363 | newHeight.push(_h + "px"); |
359 | 364 | ||
360 | var previousStyleStr = {dist:this._undoArray[i].dist, | 365 | previousStyleStr = {dist:this._undoArray[i].dist, |
361 | mat:MathUtils.scientificToDecimal(previousMat, 5)}; | 366 | mat:MathUtils.scientificToDecimal(previousMat, 5)}; |
362 | var newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), | 367 | newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), |
363 | mat:MathUtils.scientificToDecimal(curMat, 5)}; | 368 | mat:MathUtils.scientificToDecimal(curMat, 5)}; |
364 | previousStyles.push(previousStyleStr); | 369 | previousStyles.push(previousStyleStr); |
365 | newStyles.push(newStyleStr); | 370 | newStyles.push(newStyleStr); |
diff --git a/js/tools/TagTool.js b/js/tools/TagTool.js index e3f49bbe..6df49a7b 100755 --- a/js/tools/TagTool.js +++ b/js/tools/TagTool.js | |||
@@ -222,21 +222,20 @@ exports.TagTool = Montage.create(DrawingTool, { | |||
222 | 222 | ||
223 | makeElement: { | 223 | makeElement: { |
224 | value: function(w, h, planeMat, midPt,tag) { | 224 | value: function(w, h, planeMat, midPt,tag) { |
225 | var styles; | ||
226 | |||
227 | var left = Math.round(midPt[0] - 0.5 * w); | 225 | var left = Math.round(midPt[0] - 0.5 * w); |
228 | var top = Math.round(midPt[1] - 0.5 * h); | 226 | var top = Math.round(midPt[1] - 0.5 * h); |
229 | 227 | ||
230 | var matStr = DrawingToolBase.getElementMatrix(planeMat, midPt); | 228 | var styles = { |
231 | |||
232 | styles = { | ||
233 | 'position': 'absolute', | 229 | 'position': 'absolute', |
234 | 'top' : top + 'px', | 230 | 'top' : top + 'px', |
235 | 'left' : left + 'px', | 231 | 'left' : left + 'px' |
236 | '-webkit-transform-style' : 'preserve-3d', | ||
237 | '-webkit-transform' : matStr | ||
238 | }; | 232 | }; |
239 | 233 | ||
234 | if(!MathUtils.isIdentityMatrix(planeMat)) { | ||
235 | styles['-webkit-transform-style'] = 'preserve-3d'; | ||
236 | styles['-webkit-transform'] = DrawingToolBase.getElementMatrix(planeMat, midPt); | ||
237 | } | ||
238 | |||
240 | // TODO - for canvas, set both as style and attribute. | 239 | // TODO - for canvas, set both as style and attribute. |
241 | // Otherwise, we need to create a separate controller for canvas elements | 240 | // Otherwise, we need to create a separate controller for canvas elements |
242 | if(tag.tagName === "CANVAS") { | 241 | if(tag.tagName === "CANVAS") { |
diff --git a/js/tools/drawing-tool-base.js b/js/tools/drawing-tool-base.js index 8d87605c..84602186 100755 --- a/js/tools/drawing-tool-base.js +++ b/js/tools/drawing-tool-base.js | |||
@@ -442,7 +442,7 @@ exports.DrawingToolBase = Montage.create(Montage, { | |||
442 | flatMat = divMat; | 442 | flatMat = divMat; |
443 | flatMatSafe = MathUtils.scientificToDecimal(flatMat, 10); | 443 | flatMatSafe = MathUtils.scientificToDecimal(flatMat, 10); |
444 | 444 | ||
445 | return "perspective(" + 1400 + ") matrix3d( " + flatMatSafe + ")"; | 445 | return "perspective(" + 1400 + ") matrix3d(" + flatMatSafe + ")"; |
446 | } | 446 | } |
447 | }, | 447 | }, |
448 | 448 | ||