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, 36 insertions, 26 deletions
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js
index f9411f48..aec5b6a3 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);
@@ -460,11 +465,14 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
460 } 465 }
461 else 466 else
462 { 467 {
463 curMat = item.mat.slice(0); 468// curMat = item.mat.slice(0);
464 glmat4.multiply(curMat, qMat, curMat); 469// glmat4.multiply(curMat, qMat, curMat);
465 var previousMat = this._undoArray[i].mat.slice(0); 470// var previousMat = this._undoArray[i].mat.slice(0);
466 var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + curMat[12] - previousMat[12]; 471// var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + curMat[12] - previousMat[12];
467 var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + curMat[13] - previousMat[13]; 472// var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + curMat[13] - previousMat[13];
473
474 var _x = parseInt(ElementsMediator.getProperty(elt, "left")) + transMat[12];
475 var _y = parseInt(ElementsMediator.getProperty(elt, "top")) + transMat[13];
468 476
469 newLeft.push(_x + "px"); 477 newLeft.push(_x + "px");
470 newTop.push(_y + "px"); 478 newTop.push(_y + "px");
@@ -577,6 +585,8 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
577 { 585 {
578 // form the translation vector and post translate the matrix by it. 586 // form the translation vector and post translate the matrix by it.
579 delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 ); 587 delta = vecUtils.vecSubtract( 3, data.pt1, data.pt0 );
588 delta[0] = ~~delta[0];
589 delta[1] = ~~delta[1];
580 delta[2] = 0; 590 delta[2] = 0;
581 var transMat = Matrix.Translation( delta ); 591 var transMat = Matrix.Translation( delta );
582 this._moveElements(transMat); 592 this._moveElements(transMat);