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