aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorValerio Virgillito2012-04-13 01:05:54 -0700
committerValerio Virgillito2012-04-13 01:05:54 -0700
commit0c17edd7cf21f26c4e25d78d3aa51d841dcf551f (patch)
treee89d4c0ffdec0c972860a6d4018dec5216c1aa9a /js
parentf91e64235eb03c889ff4f5577c3e3480cd0d787f (diff)
downloadninja-0c17edd7cf21f26c4e25d78d3aa51d841dcf551f.tar.gz
fixing the transform handles
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js')
-rwxr-xr-xjs/tools/SelectionTool.js126
1 files changed, 58 insertions, 68 deletions
diff --git a/js/tools/SelectionTool.js b/js/tools/SelectionTool.js
index d9327f33..7033ee3d 100755
--- a/js/tools/SelectionTool.js
+++ b/js/tools/SelectionTool.js
@@ -386,29 +386,6 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
386 } 386 }
387 }); 387 });
388 388
389 /*
390 this._targets.forEach(function(item) {
391 elt = item.elt;
392
393 if(self._use3DMode) {
394 curMat = item.mat;
395
396 curMat[12] += transMat[12];
397 curMat[13] += transMat[13];
398 curMat[14] += transMat[14];
399 viewUtils.setMatrixForElement( elt, curMat, true);
400 item.mat = curMat;
401
402 return NJevent("elementChanging", {type : "Changing", redraw: false});
403 } else {
404 var x = (parseInt(ElementsMediator.getProperty(elt, "left")) + transMat[12]) + "px";
405 var y = (parseInt(ElementsMediator.getProperty(elt, "top")) + transMat[13]) + "px";
406
407 targets.push({element:elt, properties:{left:x , top:y}});
408 }
409 });
410 */
411
412 if(this._use3DMode) { 389 if(this._use3DMode) {
413 return NJevent("elementChanging", {type : "Changing", redraw: false}); 390 return NJevent("elementChanging", {type : "Changing", redraw: false});
414 } else { 391 } else {
@@ -421,7 +398,7 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
421 //Routines to modify the selected objects 398 //Routines to modify the selected objects
422 modifyElements : { 399 modifyElements : {
423 value : function(data, event) { 400 value : function(data, event) {
424 var delta, deltaH, deltaW, deltaL, deltaT, modObject = []; 401 var delta, deltaH = [], deltaW = [], modObject = [];
425 402
426 if(this._handleMode !== null) { 403 if(this._handleMode !== null) {
427 // 0 7 6 404 // 0 7 6
@@ -431,76 +408,89 @@ var SelectionTool = exports.SelectionTool = Montage.create(ModifierToolBase, {
431 { 408 {
432 case 0: 409 case 0:
433 // Resize North-West 410 // Resize North-West
434 delta = ~~(data.pt1[0] - data.pt0[0]); 411 this.application.ninja.selectedElements.forEach(function(element) {
435 deltaW = this._undoArray.map(function(item) { return item._w - delta + "px"}); 412 delta = ~~(data.pt1[0] - data.pt0[0]);
436 deltaL = this._undoArray.map(function(item) { return item._x + delta + "px"}); 413 var width = parseInt(element.elementModel.getProperty("w")) - delta + "px";
437 delta = ~~(data.pt1[1] - data.pt0[1]); 414 var left = parseInt(element.elementModel.getProperty("x")) + delta + "px";
438 deltaH = this._undoArray.map(function(item) { return item._h - delta + "px"}); 415 delta = ~~(data.pt1[1] - data.pt0[1]);
439 deltaT = this._undoArray.map(function(item) { return item._y + delta + "px"}); 416 var height = parseInt(element.elementModel.getProperty("h")) - delta + "px";
440 ElementsMediator.setProperties(this.application.ninja.selectedElements, 417 var top = parseInt(element.elementModel.getProperty("y")) + delta + "px";
441 { "left": deltaL, "top": deltaT, "width": deltaW, "height": deltaH }, "Changing", "SelectionTool" ); 418 modObject.push({element:element, properties:{width: width, height: height, left: left, top: top}});
419 });
420 ElementsMediator.setProperties(modObject, "Changing", "SelectionTool" );
442 break; 421 break;
443 case 1: 422 case 1:
444 // Resize West 423 // Resize West
445 delta = ~~(data.pt1[0] - data.pt0[0]); 424 this.application.ninja.selectedElements.forEach(function(element) {
446 deltaW = this._undoArray.map(function(item) { return item._w - delta + "px"}); 425 delta = ~~(data.pt1[0] - data.pt0[0]);
447 deltaL = this._undoArray.map(function(item) { return item._x + delta + "px"}); 426 var width = parseInt(element.elementModel.getProperty("w")) - delta + "px";
448 ElementsMediator.setProperties(this.application.ninja.selectedElements, 427 var left = parseInt(element.elementModel.getProperty("x")) + delta + "px";
449 { "left": deltaL, "width": deltaW }, "Changing", "SelectionTool" ); 428 modObject.push({element:element, properties:{left: left, width: width}});
429 });
430 ElementsMediator.setProperties(modObject, "Changing", "SelectionTool");
450 break; 431 break;
451 case 2: 432 case 2:
452 // Resize South-West 433 // Resize South-West
453 delta = ~~(data.pt1[0] - data.pt0[0]); 434 this.application.ninja.selectedElements.forEach(function(element) {
454 deltaW = this._undoArray.map(function(item) { return item._w - delta + "px"}); 435 delta = ~~(data.pt1[0] - data.pt0[0]);
455 deltaL = this._undoArray.map(function(item) { return item._x + delta + "px"}); 436 var width = parseInt(element.elementModel.getProperty("w")) - delta + "px";
456 delta = ~~(data.pt1[1] - data.pt0[1]); 437 var left = parseInt(element.elementModel.getProperty("x")) + delta + "px";
457 deltaH = this._undoArray.map(function(item) { return item._h + delta + "px"}); 438 delta = ~~(data.pt1[1] - data.pt0[1]);
458 ElementsMediator.setProperties(this.application.ninja.selectedElements, 439 var height = parseInt(element.elementModel.getProperty("h")) + delta + "px";
459 { "left": deltaL, "width": deltaW, "height": deltaH }, "Changing", "SelectionTool" ); 440 modObject.push({element:element, properties:{width: width, height: height, left: left}});
441 });
442 ElementsMediator.setProperties(modObject, "Changing", "SelectionTool" );
460 break; 443 break;
461 case 3: 444 case 3:
462 // Resize South 445 // Resize South
463 delta = ~~(data.pt1[1] - data.pt0[1]); 446 this.application.ninja.selectedElements.forEach(function(element) {
464 deltaH = this._undoArray.map(function(item) { return item._h + delta + "px"}); 447 delta = ~~(data.pt1[1] - data.pt0[1]);
448 deltaH.push(parseInt(element.elementModel.getProperty("h")) + delta + "px");
449 // modObject.push({element:element, properties:{width: width, height: height}});
450 });
465 ElementsMediator.setProperty(this.application.ninja.selectedElements, "height", deltaH, "Changing", "SelectionTool" ); 451 ElementsMediator.setProperty(this.application.ninja.selectedElements, "height", deltaH, "Changing", "SelectionTool" );
466 break; 452 break;
467 case 4: 453 case 4:
468 // Resize South-East 454 // Resize South-East
469 delta = ~~(data.pt1[0] - data.pt0[0]);
470 deltaW = this._undoArray.map(function(item) { return item._w + delta + "px"});
471 delta = ~~(data.pt1[1] - data.pt0[1]);
472 deltaH = this._undoArray.map(function(item) { return item._h + delta + "px"});
473 /*
474 this.application.ninja.selectedElements.forEach(function(element) { 455 this.application.ninja.selectedElements.forEach(function(element) {
456 delta = ~~(data.pt1[0] - data.pt0[0]);
475 var width = parseInt(element.elementModel.getProperty("w")) + delta + "px"; 457 var width = parseInt(element.elementModel.getProperty("w")) + delta + "px";
476 modObject.push({element:element, properties:{width: width}}); 458 delta = ~~(data.pt1[1] - data.pt0[1]);
459 var height = parseInt(element.elementModel.getProperty("h")) + delta + "px";
460 modObject.push({element:element, properties:{width: width, height: height}});
477 }); 461 });
478 */ 462 ElementsMediator.setProperties(modObject, "Changing", "SelectionTool" );
479 ElementsMediator.setProperties(this.application.ninja.selectedElements, { "width": deltaW, "height": deltaH }, "Changing", "SelectionTool" );
480 break; 463 break;
481 case 5: 464 case 5:
482 // Resize East 465 // Resize East
483 delta = ~~(data.pt1[0] - data.pt0[0]); 466 this.application.ninja.selectedElements.forEach(function(element) {
484 deltaW = this._undoArray.map(function(item) { return item._w + delta + "px"}); 467 delta = ~~(data.pt1[0] - data.pt0[0]);
468 deltaW.push(parseInt(element.elementModel.getProperty("w")) + delta + "px");
469 // modObject.push({element:element, properties:{width: width, height: height}});
470 });
485 ElementsMediator.setProperty(this.application.ninja.selectedElements, "width", deltaW, "Changing", "SelectionTool" ); 471 ElementsMediator.setProperty(this.application.ninja.selectedElements, "width", deltaW, "Changing", "SelectionTool" );
486 break; 472 break;
487 case 6: 473 case 6:
488 // Resize North-East 474 // Resize North-East
489 delta = ~~(data.pt1[0] - data.pt0[0]); 475 this.application.ninja.selectedElements.forEach(function(element) {
490 deltaW = this._undoArray.map(function(item) { return item._w + delta + "px"}); 476 delta = ~~(data.pt1[0] - data.pt0[0]);
491 delta = ~~(data.pt1[1] - data.pt0[1]); 477 var width = parseInt(element.elementModel.getProperty("w")) + delta + "px";
492 deltaH = this._undoArray.map(function(item) { return item._h - delta + "px"}); 478 delta = ~~(data.pt1[1] - data.pt0[1]);
493 deltaT = this._undoArray.map(function(item) { return item._y + delta + "px"}); 479 var height = parseInt(element.elementModel.getProperty("h")) - delta + "px";
494 ElementsMediator.setProperties(this.application.ninja.selectedElements, 480 var top = parseInt(element.elementModel.getProperty("y")) + delta + "px";
495 { "top": deltaT, "width": deltaW, "height": deltaH }, "Changing", "SelectionTool" ); 481 modObject.push({element:element, properties:{width: width, height: height, top: top}});
482 });
483 ElementsMediator.setProperties(modObject, "Changing", "SelectionTool" );
496 break; 484 break;
497 case 7: 485 case 7:
498 // Resize North 486 // Resize North
499 delta = ~~(data.pt1[1] - data.pt0[1]); 487 this.application.ninja.selectedElements.forEach(function(element) {
500 deltaH = this._undoArray.map(function(item) { return item._h - delta + "px"}); 488 delta = ~~(data.pt1[1] - data.pt0[1]);
501 deltaT = this._undoArray.map(function(item) { return item._y + delta + "px"}); 489 var height = parseInt(element.elementModel.getProperty("h")) - delta + "px";
502 ElementsMediator.setProperties(this.application.ninja.selectedElements, 490 var top = parseInt(element.elementModel.getProperty("y")) + delta + "px";
503 { "top": deltaT, "height": deltaH }, "Changing", "SelectionTool" ); 491 modObject.push({element:element, properties:{height: height, top: top}});
492 });
493 ElementsMediator.setProperties(modObject, "Changing", "SelectionTool" );
504 break; 494 break;
505 default: 495 default:
506 break; 496 break;