diff options
Diffstat (limited to 'js/tools/SelectionTool.js')
-rwxr-xr-x | js/tools/SelectionTool.js | 62 |
1 files changed, 35 insertions, 27 deletions
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js index 7120e18f..eb5341de 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; |
@@ -318,16 +319,27 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
318 | 319 | ||
319 | this._targets.push({elt:elt, mat:curMat, matInv:curMatInv}); | 320 | this._targets.push({elt:elt, mat:curMat, matInv:curMatInv}); |
320 | if(addToUndoStack) { | 321 | if(addToUndoStack) { |
322 | var prevX, | ||
323 | prevY, | ||
324 | prevW, | ||
325 | prevH, | ||
326 | _x, | ||
327 | _y, | ||
328 | _w, | ||
329 | _h, | ||
330 | previousMat, | ||
331 | previousStyleStr, | ||
332 | newStyleStr; | ||
333 | |||
321 | if(!this._use3DMode) { | 334 | if(!this._use3DMode) { |
322 | var previousMat = this._undoArray[i].mat.slice(0); | 335 | prevX = this._undoArray[i]._x; |
323 | var prevX = this._undoArray[i]._x; | 336 | prevY = this._undoArray[i]._y; |
324 | var prevY = this._undoArray[i]._y; | 337 | prevW = this._undoArray[i]._w; |
325 | var prevW = this._undoArray[i]._w; | 338 | prevH = this._undoArray[i]._h; |
326 | var prevH = this._undoArray[i]._h; | 339 | _x = parseInt(ElementsMediator.getProperty(elt, "left")); |
327 | var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + curMat[12] - previousMat[12]; | 340 | _y = parseInt(ElementsMediator.getProperty(elt, "top")); |
328 | var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + curMat[13] - previousMat[13]; | 341 | _w = parseInt(ElementsMediator.getProperty(elt, "width")); |
329 | var _w = parseInt(ElementsMediator.getProperty(elt, "width")); | 342 | _h = parseInt(ElementsMediator.getProperty(elt, "height")); |
330 | var _h = parseInt(ElementsMediator.getProperty(elt, "height")); | ||
331 | 343 | ||
332 | previousLeft.push(prevX + "px"); | 344 | previousLeft.push(prevX + "px"); |
333 | previousTop.push(prevY + "px"); | 345 | previousTop.push(prevY + "px"); |
@@ -337,25 +349,22 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
337 | newTop.push(_y + "px"); | 349 | newTop.push(_y + "px"); |
338 | newWidth.push(_w + "px"); | 350 | newWidth.push(_w + "px"); |
339 | newHeight.push(_h + "px"); | 351 | newHeight.push(_h + "px"); |
340 | 352 | } | |
341 | viewUtils.setMatrixForElement(elt, previousMat); | 353 | else |
342 | 354 | { | |
343 | this._targets[i].mat = previousMat; | 355 | previousMat = this._undoArray[i].mat.slice(0); |
344 | this._targets[i].matInv = glmat4.inverse(previousMat, []); | 356 | prevW = this._undoArray[i]._w; |
345 | } else { | 357 | prevH = this._undoArray[i]._h; |
346 | var previousMat = this._undoArray[i].mat.slice(0); | 358 | _w = parseInt(ElementsMediator.getProperty(elt, "width")); |
347 | var prevW = this._undoArray[i]._w; | 359 | _h = parseInt(ElementsMediator.getProperty(elt, "height")); |
348 | var prevH = this._undoArray[i]._h; | ||
349 | var _w = parseInt(ElementsMediator.getProperty(elt, "width")); | ||
350 | var _h = parseInt(ElementsMediator.getProperty(elt, "height")); | ||
351 | previousWidth.push(prevW + "px"); | 360 | previousWidth.push(prevW + "px"); |
352 | previousHeight.push(prevH + "px"); | 361 | previousHeight.push(prevH + "px"); |
353 | newWidth.push(_w + "px"); | 362 | newWidth.push(_w + "px"); |
354 | newHeight.push(_h + "px"); | 363 | newHeight.push(_h + "px"); |
355 | 364 | ||
356 | var previousStyleStr = {dist:this._undoArray[i].dist, | 365 | previousStyleStr = {dist:this._undoArray[i].dist, |
357 | mat:MathUtils.scientificToDecimal(previousMat, 5)}; | 366 | mat:MathUtils.scientificToDecimal(previousMat, 5)}; |
358 | var newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), | 367 | newStyleStr = {dist:viewUtils.getPerspectiveDistFromElement(elt), |
359 | mat:MathUtils.scientificToDecimal(curMat, 5)}; | 368 | mat:MathUtils.scientificToDecimal(curMat, 5)}; |
360 | previousStyles.push(previousStyleStr); | 369 | previousStyles.push(previousStyleStr); |
361 | newStyles.push(newStyleStr); | 370 | newStyles.push(newStyleStr); |
@@ -456,11 +465,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
456 | } | 465 | } |
457 | else | 466 | else |
458 | { | 467 | { |
459 | curMat = item.mat.slice(0); | 468 | var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + transMat[12]; |
460 | glmat4.multiply(curMat, qMat, curMat); | 469 | var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + transMat[13]; |
461 | var previousMat = this._undoArray[i].mat.slice(0); | ||
462 | var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + curMat[12] - previousMat[12]; | ||
463 | var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + curMat[13] - previousMat[13]; | ||
464 | 470 | ||
465 | newLeft.push(_x + "px"); | 471 | newLeft.push(_x + "px"); |
466 | newTop.push(_y + "px"); | 472 | newTop.push(_y + "px"); |
@@ -573,6 +579,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, { | |||
573 | { | 579 | { |
574 | // form the translation vector and post translate the matrix by it. | 580 | // form the translation vector and post translate the matrix by it. |
575 | delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); | 581 | delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); |
582 | delta[0] = ~~delta[0]; | ||
583 | delta[1] = ~~delta[1]; | ||
576 | delta[2] = 0; | 584 | delta[2] = 0; |
577 | var transMat = Matrix.Translation( delta ); | 585 | var transMat = Matrix.Translation( delta ); |
578 | this._moveElements(transMat); | 586 | this._moveElements(transMat); |