From 854a6d1be334782c8e232601e6d562a11296e55a Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 3 Feb 2012 14:06:26 -0800 Subject: Update grid and planes when elementChange event signifies the "matrix", "left", "top", "width" or "height" properties have changed. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'js/helper-classes') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index fd96af4d..fe617548 100644 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -71,6 +71,9 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { _selectionCtr : {value: null, writable: true }, + // Properties that require element planes to be updated + _updatePlaneProps : {value: ["matrix", "left", "top", "width", "height"], writable: false }, + /////////////////////////////////////////////////////////////////////// // Property accessors /////////////////////////////////////////////////////////////////////// @@ -124,11 +127,38 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { } }, + _shouldUpdatePlanes: { + value: function(props) { + if(!props) + { + return false; + } + else if (typeof props === "string") + { + return (this._updatePlaneProps.indexOf(props) !== -1); + } + + for (var p in props) + { + if(this._updatePlaneProps.indexOf(p) !== -1) + { + return true; + } + } + + return false; + } + }, + // TODO - Check why handleElementChange is being fired before handleAddElement handleElementChange: { value: function(event) { + if(!event.detail || !event.detail.data) + { + return; + } var els = event.detail.data.els; - if(els) + if(els && this._shouldUpdatePlanes(event.detail.data.prop)) { var len = els.length, i = 0, @@ -141,7 +171,9 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { el.elementModel.props3D.elementPlane.init(); } + this.application.ninja.stage.layout.draw(); this.drawWorkingPlane(); + this.draw3DCompass(); } } }, -- cgit v1.2.3 From 130c1d3bfeedfc50ab3481c7d8c2e83af224feac Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 3 Feb 2012 14:06:26 -0800 Subject: Update grid and planes when elementChange event signifies the "matrix", "left", "top", "width" or "height" properties have changed. Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'js/helper-classes') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index fe617548..08a27618 100644 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -168,7 +168,10 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { for(i=0; i < len; i++) { item = els[i]; el = item._element || item; - el.elementModel.props3D.elementPlane.init(); + if(el.elementModel.props3D.elementPlane) + { + el.elementModel.props3D.elementPlane.init(); + } } this.application.ninja.stage.layout.draw(); @@ -1097,7 +1100,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { var tmpCanvas = this.application.ninja.stage.canvas; var tmpStage = this.application.ninja.currentDocument.documentRoot; this.viewUtils.pushViewportObj( tmpCanvas ); - var tmpStage = this.application.ninja.currentDocument.documentRoot; // save the source space object and set to the target object var saveSource = this._sourceSpaceElt; -- cgit v1.2.3 From d7ad2659d7ef8d0fffbb1cba8218061ebd516dd0 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 3 Feb 2012 15:09:54 -0800 Subject: Handle delete of multiple objects. Also, have deletion go through the mediator so elementDeleted event is fired for SnapManager, DrawUtils, etc. to clean up after deleted element(s). Signed-off-by: Nivesh Rajbhandari --- js/helper-classes/3D/draw-utils.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'js/helper-classes') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 08a27618..c07391db 100644 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -110,6 +110,7 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { this.eventManager.addEventListener("elementAdded", this, false); this.eventManager.addEventListener("elementDeleted", this, false); + this.eventManager.addEventListener("deleteSelection", this, false); this.eventManager.addEventListener("elementChange", this, false); } }, @@ -127,6 +128,12 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { } }, + handleDeleteSelection: { + value: function(event) { + this.drawWorkingPlane(); + } + }, + _shouldUpdatePlanes: { value: function(props) { if(!props) -- cgit v1.2.3