From db0fa4e454b76d8a2bd6ba47c6f10166761179e7 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 4 Apr 2012 14:06:38 -0700 Subject: Adding replaceElement routine and event so Timeline can avoid removing and adding layers and PI and SelectionController can avoid deselecting and reselecting the element. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 8 ++------ js/controllers/selection-controller.js | 7 +++++++ 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index c9164e3e..e792c646 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -73,12 +73,8 @@ exports.ShapesController = Montage.create(CanvasController, { canvas.width = el.width; canvas.height = el.height; canvas.elementModel = el.elementModel; - this.application.ninja.currentDocument.documentRoot.replaceChild(canvas, el); - NJevent("elementsRemoved", el); - el = canvas; - this.toggleWebGlMode(el, value); - el.elementModel.shapeModel.GLWorld.render(); - this.application.ninja.selectionController.selectElement(el); + this.toggleWebGlMode(canvas, value); + this.application.ninja.elementMediator.replaceElement(canvas, el); return; case "strokeMaterial": var sm = Object.create(MaterialsModel.getMaterial(value)); diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index dbb3f30d..5665b09c 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -45,6 +45,7 @@ exports.SelectionController = Montage.create(Component, { this.eventManager.addEventListener("openDocument", this, false); this.eventManager.addEventListener("elementAdded", this, false); this.eventManager.addEventListener("elementsRemoved", this, false); + this.eventManager.addEventListener("elementReplaced", this, false); this.eventManager.addEventListener("selectAll", this, false); this.eventManager.addEventListener("switchDocument", this, false); this.eventManager.addEventListener("closeDocument", this, false); @@ -103,6 +104,12 @@ exports.SelectionController = Montage.create(Component, { } }, + handleElementReplaced: { + value: function(event) { + this.application.ninja.selectedElements[this.application.ninja.selectedElements.indexOf(event.detail.data.oldChild)] = event.detail.data.newChild; + } + }, + handleSelectAll: { value: function(event) { var selected = [], childNodes = []; -- cgit v1.2.3