diff options
Diffstat (limited to 'js/tools/SelectionTool.js')
-rwxr-xr-x | js/tools/SelectionTool.js | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index aec5b6a3..94cc6b83 100755 --- a/js/tools/SelectionTool.js +++ b/js/tools/SelectionTool.js | |||
@@ -60,6 +60,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
60 | else | 60 | else |
61 | { | 61 | { |
62 | this._canSnap = true; | 62 | this._canSnap = true; |
63 | this._updateTargets(); | ||
63 | } | 64 | } |
64 | 65 | ||
65 | this.isDrawing = true; | 66 | this.isDrawing = true; |
@@ -223,7 +224,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
223 | HandleDoubleClick: { | 224 | HandleDoubleClick: { |
224 | value: function(event) { | 225 | value: function(event) { |
225 | if(this.application.ninja.selectedElements.length > 0) { | 226 | if(this.application.ninja.selectedElements.length > 0) { |
226 | this.application.ninja.currentSelectedContainer = this.application.ninja.selectedElements[0]._element; | 227 | this.application.ninja.currentSelectedContainer = this.application.ninja.selectedElements[0]; |
227 | } else { | 228 | } else { |
228 | this.application.ninja.currentSelectedContainer = this.application.ninja.currentDocument.documentRoot; | 229 | this.application.ninja.currentSelectedContainer = this.application.ninja.currentDocument.documentRoot; |
229 | } | 230 | } |
@@ -242,8 +243,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
242 | case Keyboard.LEFT: | 243 | case Keyboard.LEFT: |
243 | var newLeft = []; | 244 | var newLeft = []; |
244 | var leftArr = this.application.ninja.selectedElements.map(function(item) { | 245 | var leftArr = this.application.ninja.selectedElements.map(function(item) { |
245 | newLeft.push( (parseInt(ElementsMediator.getProperty(item._element, "left")) - inc) + "px" ); | 246 | newLeft.push( (parseInt(ElementsMediator.getProperty(item, "left")) - inc) + "px" ); |
246 | return ElementsMediator.getProperty(item._element, "left"); | 247 | return ElementsMediator.getProperty(item, "left"); |
247 | }); | 248 | }); |
248 | 249 | ||
249 | ElementsMediator.setProperty(this.application.ninja.selectedElements, "left", newLeft , "Change", "selectionTool", leftArr); | 250 | ElementsMediator.setProperty(this.application.ninja.selectedElements, "left", newLeft , "Change", "selectionTool", leftArr); |
@@ -251,8 +252,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
251 | case Keyboard.UP: | 252 | case Keyboard.UP: |
252 | var newTop = []; | 253 | var newTop = []; |
253 | var topArr = this.application.ninja.selectedElements.map(function(item) { | 254 | var topArr = this.application.ninja.selectedElements.map(function(item) { |
254 | newTop.push( (parseInt(ElementsMediator.getProperty(item._element, "top")) - inc) + "px" ); | 255 | newTop.push( (parseInt(ElementsMediator.getProperty(item, "top")) - inc) + "px" ); |
255 | return ElementsMediator.getProperty(item._element, "top"); | 256 | return ElementsMediator.getProperty(item, "top"); |
256 | }); | 257 | }); |
257 | 258 | ||
258 | ElementsMediator.setProperty(this.application.ninja.selectedElements, "top", newTop , "Change", "selectionTool", topArr); | 259 | ElementsMediator.setProperty(this.application.ninja.selectedElements, "top", newTop , "Change", "selectionTool", topArr); |
@@ -260,8 +261,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
260 | case Keyboard.RIGHT: | 261 | case Keyboard.RIGHT: |
261 | var newLeft = []; | 262 | var newLeft = []; |
262 | var leftArr = this.application.ninja.selectedElements.map(function(item) { | 263 | var leftArr = this.application.ninja.selectedElements.map(function(item) { |
263 | newLeft.push( (parseInt(ElementsMediator.getProperty(item._element, "left")) + inc) + "px" ); | 264 | newLeft.push( (parseInt(ElementsMediator.getProperty(item, "left")) + inc) + "px" ); |
264 | return ElementsMediator.getProperty(item._element, "left"); | 265 | return ElementsMediator.getProperty(item, "left"); |
265 | }); | 266 | }); |
266 | 267 | ||
267 | ElementsMediator.setProperty(this.application.ninja.selectedElements, "left", newLeft , "Change", "selectionTool", leftArr); | 268 | ElementsMediator.setProperty(this.application.ninja.selectedElements, "left", newLeft , "Change", "selectionTool", leftArr); |
@@ -269,8 +270,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
269 | case Keyboard.DOWN: | 270 | case Keyboard.DOWN: |
270 | var newTop = []; | 271 | var newTop = []; |
271 | var topArr = this.application.ninja.selectedElements.map(function(item) { | 272 | var topArr = this.application.ninja.selectedElements.map(function(item) { |
272 | newTop.push( (parseInt(ElementsMediator.getProperty(item._element, "top")) + inc) + "px" ); | 273 | newTop.push( (parseInt(ElementsMediator.getProperty(item, "top")) + inc) + "px" ); |
273 | return ElementsMediator.getProperty(item._element, "top"); | 274 | return ElementsMediator.getProperty(item, "top"); |
274 | }); | 275 | }); |
275 | 276 | ||
276 | ElementsMediator.setProperty(this.application.ninja.selectedElements, "top", newTop , "Change", "selectionTool", topArr); | 277 | ElementsMediator.setProperty(this.application.ninja.selectedElements, "top", newTop , "Change", "selectionTool", topArr); |
@@ -308,16 +309,14 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
308 | previousStyles = []; | 309 | previousStyles = []; |
309 | var len = this.application.ninja.selectedElements.length; | 310 | var len = this.application.ninja.selectedElements.length; |
310 | this._targets = []; | 311 | this._targets = []; |
311 | for(var i = 0; i < len; i++) | 312 | for(var i = 0; i < len; i++) { |
312 | { | 313 | var elt = this.application.ninja.selectedElements[i]; |
313 | var elt = this.application.ninja.selectedElements[i]._element; | ||
314 | 314 | ||
315 | var curMat = viewUtils.getMatrixFromElement(elt); | 315 | var curMat = viewUtils.getMatrixFromElement(elt); |
316 | var curMatInv = glmat4.inverse(curMat, []); | 316 | var curMatInv = glmat4.inverse(curMat, []); |
317 | 317 | ||
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 | { | ||
321 | var prevX, | 320 | var prevX, |
322 | prevY, | 321 | prevY, |
323 | prevW, | 322 | prevW, |
@@ -330,8 +329,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
330 | previousStyleStr, | 329 | previousStyleStr, |
331 | newStyleStr; | 330 | newStyleStr; |
332 | 331 | ||
333 | if(!this._use3DMode) | 332 | if(!this._use3DMode) { |
334 | { | ||
335 | prevX = this._undoArray[i]._x; | 333 | prevX = this._undoArray[i]._x; |
336 | prevY = this._undoArray[i]._y; | 334 | prevY = this._undoArray[i]._y; |
337 | prevW = this._undoArray[i]._w; | 335 | prevW = this._undoArray[i]._w; |
@@ -465,12 +463,6 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
465 | } | 463 | } |
466 | else | 464 | else |
467 | { | 465 | { |
468 | // curMat = item.mat.slice(0); | ||
469 | // glmat4.multiply(curMat, qMat, curMat); | ||
470 | // var previousMat = this._undoArray[i].mat.slice(0); | ||
471 | // var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + curMat[12] - previousMat[12]; | ||
472 | // var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + curMat[13] - previousMat[13]; | ||
473 | |||
474 | var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + transMat[12]; | 466 | var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + transMat[12]; |
475 | var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + transMat[13]; | 467 | var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + transMat[13]; |
476 | 468 | ||