diff options
author | Valerio Virgillito | 2012-02-06 11:02:14 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-06 11:02:14 -0800 |
commit | 671a27069db6a121507c2b342653aede685cff67 (patch) | |
tree | 77e9f1499c400229273f880c9d365115b411b227 /js/mediators | |
parent | e58204970e398ce3a36a52bbf72d120c7ffdc167 (diff) | |
parent | 1b0c5c0e7ebf9dda95a624da546aaece268631ad (diff) | |
download | ninja-671a27069db6a121507c2b342653aede685cff67.tar.gz |
Merge pull request #15 from mqg734/ToolFixes
Adding, deleting and modifying elements now keep the element planes and PI in sync.
Diffstat (limited to 'js/mediators')
-rw-r--r-- | js/mediators/element-mediator.js | 33 | ||||
-rw-r--r-- | js/mediators/keyboard-mediator.js | 6 |
2 files changed, 29 insertions, 10 deletions
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index a6f31703..c44e1cb5 100644 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js | |||
@@ -44,12 +44,16 @@ exports.ElementMediator = Montage.create(NJComponent, { | |||
44 | this.deleteDelegate.handleDelete(); | 44 | this.deleteDelegate.handleDelete(); |
45 | } else { | 45 | } else { |
46 | // Add the Undo/Redo | 46 | // Add the Undo/Redo |
47 | var els = []; | 47 | var els = [], |
48 | len = this.application.ninja.selectedElements.length; | ||
48 | 49 | ||
49 | if(this.application.ninja.selectedElements.length > 0) { | 50 | if(len) { |
50 | for(var i=0, item; item = this.application.ninja.selectedElements[i]; i++) { | 51 | for(var i = 0; i<len; i++) { |
51 | ElementController.removeElement(item._element); | 52 | els.push(this.application.ninja.selectedElements[i]); |
52 | els.push(item._element); | 53 | } |
54 | |||
55 | for(i=0; i<len; i++) { | ||
56 | this._removeElement(els[i]._element); | ||
53 | } | 57 | } |
54 | 58 | ||
55 | NJevent( "deleteSelection", els ); | 59 | NJevent( "deleteSelection", els ); |
@@ -425,7 +429,7 @@ exports.ElementMediator = Montage.create(NJComponent, { | |||
425 | el.elementModel.controller["set3DProperties"](el, props, i, update3DModel); | 429 | el.elementModel.controller["set3DProperties"](el, props, i, update3DModel); |
426 | } | 430 | } |
427 | 431 | ||
428 | NJevent("element" + eventType, {type : "set3DProperties", source: source, data: {"els": els, "prop": props, "value": props}, redraw: null}); | 432 | NJevent("element" + eventType, {type : "set3DProperties", source: source, data: {"els": els, "prop": "matrix", "value": props}, redraw: null}); |
429 | } | 433 | } |
430 | }, | 434 | }, |
431 | 435 | ||
@@ -436,7 +440,7 @@ exports.ElementMediator = Montage.create(NJComponent, { | |||
436 | getColor: { | 440 | getColor: { |
437 | value: function(el, isFill) { | 441 | value: function(el, isFill) { |
438 | if(!el.elementModel) { | 442 | if(!el.elementModel) { |
439 | NJUtils.makeElementModel(el, "Div", "block"); | 443 | NJUtils.makeElementModel2(el); |
440 | } | 444 | } |
441 | return el.elementModel.controller["getColor"](el, isFill); | 445 | return el.elementModel.controller["getColor"](el, isFill); |
442 | } | 446 | } |
@@ -462,7 +466,7 @@ exports.ElementMediator = Montage.create(NJComponent, { | |||
462 | if(!currentValue) { | 466 | if(!currentValue) { |
463 | var that = this; | 467 | var that = this; |
464 | currentValue = els.map(function(item) { | 468 | currentValue = els.map(function(item) { |
465 | return that.getColor(item._element); | 469 | return that.getColor(item._element, isFill); |
466 | }); | 470 | }); |
467 | } | 471 | } |
468 | 472 | ||
@@ -594,6 +598,15 @@ exports.ElementMediator = Montage.create(NJComponent, { | |||
594 | } | 598 | } |
595 | }, | 599 | }, |
596 | 600 | ||
601 | getColor2: { | ||
602 | value: function(el, prop, mutator) { | ||
603 | if(!el.elementModel) { | ||
604 | NJUtils.makeElementModel2(el); | ||
605 | } | ||
606 | |||
607 | return this.getColor(el, (prop === "background")); | ||
608 | } | ||
609 | }, | ||
597 | 610 | ||
598 | //-------------------------------------------------------------------------------------------------------- | 611 | //-------------------------------------------------------------------------------------------------------- |
599 | // Routines to get/set 3D properties | 612 | // Routines to get/set 3D properties |
@@ -651,11 +664,11 @@ exports.ElementMediator = Montage.create(NJComponent, { | |||
651 | 664 | ||
652 | if(isChanging) | 665 | if(isChanging) |
653 | { | 666 | { |
654 | NJevent("elementChanging", {type : "setMatrix", source: null, data: {"el": el, "prop": "matrix", "value": mat}, redraw: null}); | 667 | NJevent("elementChanging", {type : "setMatrix", source: null, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null}); |
655 | } | 668 | } |
656 | else | 669 | else |
657 | { | 670 | { |
658 | NJevent("elementChange", {type : "setMatrix", source: null, data: {"el": el, "prop": "matrix", "value": mat}, redraw: null}); | 671 | NJevent("elementChange", {type : "setMatrix", source: null, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null}); |
659 | } | 672 | } |
660 | } | 673 | } |
661 | }, | 674 | }, |
diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index 144932c0..a1fdead3 100644 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js | |||
@@ -178,6 +178,12 @@ exports.KeyboardMediator = Montage.create(Component, { | |||
178 | return; | 178 | return; |
179 | } | 179 | } |
180 | 180 | ||
181 | if(evt.keyCode === Keyboard.H ) { | ||
182 | evt.preventDefault(); | ||
183 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[15]}); | ||
184 | return; | ||
185 | } | ||
186 | |||
181 | if(evt.keyCode === Keyboard.Z ) { | 187 | if(evt.keyCode === Keyboard.Z ) { |
182 | evt.preventDefault(); | 188 | evt.preventDefault(); |
183 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[16]}); | 189 | this.application.ninja.handleSelectTool({"detail": this.application.ninja.toolsData.defaultToolsData[16]}); |