From 2364c671ffc2953e3ee8dfdf037244de8fab3920 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 6 Mar 2012 16:30:33 -0800 Subject: IKNINJA-1238 fix and fixing other js errors on switching and closing documents Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 21 ++++++++++++++++++++- js/controllers/selection-controller.js | 18 ++++++++++-------- 2 files changed, 30 insertions(+), 9 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 194496a6..1f8c58b0 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -61,7 +61,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.eventManager.addEventListener("executeSaveAs", this, false); this.eventManager.addEventListener("executeSaveAll", this, false); - this.eventManager.addEventListener("recordStyleChanged", this, false); + this.eventManager.addEventListener("styleSheetDirty", this, false); } }, @@ -168,6 +168,10 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function (result) { if(result.status === 204){ this.activeDocument.needsSave = false; + if(this.application.ninja.currentDocument !== null){ + //clear Dirty StyleSheets for the saved document + this.application.ninja.stylesController.clearDirtyStyleSheets(this.application.ninja.currentDocument); + } } } }, @@ -249,6 +253,15 @@ var DocumentController = exports.DocumentController = Montage.create(Component, }, //////////////////////////////////////////////////////////////////// // + saveAsCallback:{ + value:function(){ + //close current document + + //create a new file + } + }, + + //////////////////////////////////////////////////////////////////// openDocument: { value: function(doc) { @@ -506,5 +519,11 @@ var DocumentController = exports.DocumentController = Montage.create(Component, value: function() { return "userDocument_" + (this._iframeCounter++); } + }, + + handleStyleSheetDirty:{ + value:function(){ + this.activeDocument.needsSave = true; } + } }); diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 08eb018f..3f9d8514 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -91,15 +91,17 @@ exports.SelectionController = Montage.create(Component, { handleSwitchDocument: { value: function() { - this._selectedItems = this.application.ninja.selectedElements.slice(0); - if(this._selectedItems.length === 0 ){ - this._isDocument = true; - }else{ - this._isDocument = false; - } - NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); + if(this.application.ninja.documentController.activeDocument.currentView === "design"){ + this._selectedItems = this.application.ninja.selectedElements.slice(0); + if(this._selectedItems.length === 0 ){ + this._isDocument = true; + }else{ + this._isDocument = false; + } + NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); - this._selectionContainer = this.application.ninja.currentSelectedContainer; + this._selectionContainer = this.application.ninja.currentSelectedContainer; + } } }, -- cgit v1.2.3 From 92c311c527b864f35aa98dba950da677746d4708 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 6 Mar 2012 16:42:10 -0800 Subject: - detect document style edit [with Eric's input for styles-controller.js] - integrated save as Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 26 ++++++++++++++++++++------ js/controllers/styles-controller.js | 10 ++++++++-- 2 files changed, 28 insertions(+), 8 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index 1f8c58b0..e29148c9 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -157,7 +157,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ saveAsSettings.fileName = this.activeDocument.name; saveAsSettings.folderUri = this.activeDocument.uri.substring(0, this.activeDocument.uri.lastIndexOf("/")); - //add callback + saveAsSettings.callback = this.saveAsCallback.bind(this); this.application.ninja.newFileController.showSaveAsDialog(saveAsSettings); } } @@ -166,7 +166,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, // fileSaveResult: { value: function (result) { - if(result.status === 204){ + if((result.status === 204) || (result.status === 404)){//204=>existing file || 404=>new file... saved this.activeDocument.needsSave = false; if(this.application.ninja.currentDocument !== null){ //clear Dirty StyleSheets for the saved document @@ -254,10 +254,24 @@ var DocumentController = exports.DocumentController = Montage.create(Component, //////////////////////////////////////////////////////////////////// // saveAsCallback:{ - value:function(){ - //close current document - - //create a new file + value:function(saveAsDetails){ + var fileUri = null, filename = saveAsDetails.filename, destination = saveAsDetails.destination; + //update document metadata + this.activeDocument.name = ""+filename; + //prepare new file uri + if(destination && (destination.charAt(destination.length -1) !== "/")){ + destination = destination + "/"; + } + fileUri = destination+filename; + + this.activeDocument.uri = fileUri; + //save a new file + //use the ioMediator.fileSaveAll when implemented + this.activeDocument._userDocument.name=filename; + this.activeDocument._userDocument.root=destination; + this.activeDocument._userDocument.uri=fileUri; + this.application.ninja.ioMediator.fileSave(this.activeDocument.save(), this.fileSaveResult.bind(this)); + // } }, diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index 662816f5..addfc24e 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js @@ -1236,11 +1236,17 @@ var stylesController = exports.StylesController = Montage.create(Component, { clearDirtyStyleSheets : { value: function(doc) { - if(!doc) { + this.dirtyStyleSheets.length = 0; + + if(doc) { + var stillDirty = this.dirtyStyleSheets.filter(function(sheet) { + return sheet.document !== doc; + }); this.dirtyStyleSheets = null; - this.dirtyStyleSheets = []; + this.dirtyStyleSheets = stillDirty; } + } }, -- cgit v1.2.3 From 9e4ee2470726e3334eb47d904a6f4079d4ed7aef Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 6 Mar 2012 17:01:39 -0800 Subject: IKNINJA-1270: fixed browser crashing when you close a document while playing a video then wait for a while Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 9 +++++++++ js/controllers/selection-controller.js | 13 +++++++++++++ 2 files changed, 22 insertions(+) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index e29148c9..de080167 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -363,14 +363,23 @@ var DocumentController = exports.DocumentController = Montage.create(Component, nextDocumentIndex = closeDocumentIndex - 1; } this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); + doc.stopVideos(); this._removeDocumentView(doc.container); }else if(this._documents.length === 0){ + if(typeof this.activeDocument.pauseVideos !== "undefined"){ + this.activeDocument.pauseVideos(true); + } this.activeDocument = null; this._removeDocumentView(doc.container); this.application.ninja.stage.stageView.hideRulers(); document.getElementById("iframeContainer").style.display="block"; this.application.ninja.stage.hideCanvas(true); + }else{//closing inactive document tab - just clear DOM + if(typeof doc.pauseVideos !== "undefined"){ + doc.pauseVideos(true); + } + this._removeDocumentView(doc.container); } NJevent("closeDocument", doc.uri); diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index 3f9d8514..49bf42b6 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -48,6 +48,7 @@ exports.SelectionController = Montage.create(Component, { this.eventManager.addEventListener("selectAll", this, false); this.eventManager.addEventListener("deleteSelection", this, false); this.eventManager.addEventListener("switchDocument", this, false); + this.eventManager.addEventListener("closeDocument", this, false); // defaultEventManager.addEventListener( "undo", this, false); // defaultEventManager.addEventListener( "redo", this, false); } @@ -105,6 +106,18 @@ exports.SelectionController = Montage.create(Component, { } }, + handleCloseDocument:{ + value: function() { + //clear selections if all documents are closed + if(this.application.ninja.documentController._documents.length === 0){ + this._selectedItems.length =0; + this.application.ninja.selectedElements.length =0; + this._isDocument = true; + NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); + } + } + }, + handleElementAdded: { value: function(event) { this.executeSelectElement(event.detail); -- cgit v1.2.3 From 8020dc6e99e3bf0aad605f66a175bc2245da534b Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 6 Mar 2012 23:53:21 -0800 Subject: added close file menu item Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index de080167..ca3cd585 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -60,6 +60,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.eventManager.addEventListener("executeSave", this, false); this.eventManager.addEventListener("executeSaveAs", this, false); this.eventManager.addEventListener("executeSaveAll", this, false); + this.eventManager.addEventListener("executeFileClose", this, false); this.eventManager.addEventListener("styleSheetDirty", this, false); @@ -162,7 +163,15 @@ var DocumentController = exports.DocumentController = Montage.create(Component, } } }, - + //////////////////////////////////////////////////////////////////// + handleExecuteFileClose:{ + value: function(event) { + if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ + this.closeDocument(this.activeDocument.uuid); + } + } + }, + //////////////////////////////////////////////////////////////////// // fileSaveResult: { value: function (result) { -- cgit v1.2.3 From 2a8a41711052bb557271c27f82faba8dd13fd880 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 7 Mar 2012 06:12:34 -0800 Subject: preliminary support for setting gradients on webgl shapes. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 125 ++++++++++++++++++++++++--- 1 file changed, 114 insertions(+), 11 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 3423a5a7..7079fc7f 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -259,24 +259,70 @@ exports.ShapesController = Montage.create(CanvasController, { } }, - setColor: { - value: function(el, color, isFill) { - var webGl = color.webGlColor || color.color.webGlColor; - if(!webGl) + _setGradientMaterial: { + value: function(el, gradientMode, isFill) { + var m = "LinearGradientMaterial"; + if(gradientMode === "radial") { - webGl = this.application.ninja.colorController.colorModel.colorToWebGl(color.color); + m = "RadialGradientMaterial"; } + + if(el.elementModel.shapeModel.fillMaterial.getName() !== m) + { + var fm = Object.create(MaterialsModel.getMaterial(m)); + if(fm) + { + if(isFill) + { + el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm); + el.elementModel.shapeModel.fillMaterial = fm; + } + else + { + el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(fm); + el.elementModel.shapeModel.strokeMaterial = fm; + } + el.elementModel.shapeModel.GLGeomObj.buildBuffers(); + } + } + } + }, + + setColor: { + value: function(el, color, isFill) { + var mode = color.mode, + webGl; if(isFill) { - el.elementModel.shapeModel.GLGeomObj.setFillColor(webGl); - this.setShapeProperty(el, "fill", webGl); - this.setShapeProperty(el, "background", color); + if(mode) + { + switch (mode) { + case 'nocolor': + el.elementModel.shapeModel.GLGeomObj.setFillColor(null); + this.setShapeProperty(el, "fill", null); + this.setShapeProperty(el, "background", color); +// el.elementModel.fill = null; + return; + case 'gradient': + this._setGradientMaterial(el, color.color.gradientMode, isFill); + el.elementModel.shapeModel.GLGeomObj.setFillColor({gradientMode:color.color.gradientMode, color:color.color.stops}); + el.elementModel.shapeModel.GLWorld.render(); + this.setShapeProperty(el, "fill", color.color.css); + this.setShapeProperty(el, "background", color); +// el.elementModel.fill = color; + break; + default: + webGl = this.application.ninja.colorController.colorModel.colorToWebGl(color.color); + el.elementModel.shapeModel.GLGeomObj.setFillColor(webGl); + this.setShapeProperty(el, "fill", webGl); + this.setShapeProperty(el, "background", color); +// el.elementModel.fill = color; + } + } } else { - el.elementModel.shapeModel.GLGeomObj.setStrokeColor(webGl); - this.setShapeProperty(el, "stroke", webGl); - this.setShapeProperty(el, "border", color); + // Support for ink-bottle tool if(color.strokeInfo) { var strokeWidth = this.GetValueInPixels(color.strokeInfo.strokeSize, @@ -285,7 +331,64 @@ exports.ShapesController = Montage.create(CanvasController, { this.setShapeProperty(el, "strokeSize", color.strokeInfo.strokeSize + " " + color.strokeInfo.strokeUnits); } + + if(mode) + { + switch (mode) { + case 'nocolor': + el.elementModel.shapeModel.GLGeomObj.setStrokeColor(null); + this.setShapeProperty(el, "stroke", null); + this.setShapeProperty(el, "border", color); +// el.elementModel.fill = null; + return; + case 'gradient': + this._setGradientMaterial(el, color.color.gradientMode, isFill); + el.elementModel.shapeModel.GLGeomObj.setStrokeColor({gradientMode:color.color.gradientMode, color:color.color.stops}); + el.elementModel.shapeModel.GLWorld.render(); + this.setShapeProperty(el, "stroke", color.color.css); + this.setShapeProperty(el, "border", color); +// el.elementModel.fill = color; + break; + default: + webGl = this.application.ninja.colorController.colorModel.colorToWebGl(color.color); + el.elementModel.shapeModel.GLGeomObj.setStrokeColor(webGl); + this.setShapeProperty(el, "stroke", webGl); + this.setShapeProperty(el, "border", color); +// el.elementModel.fill = color; + } + } } + + + + + + +// var webGl = color.webGlColor || color.color.webGlColor; +// if(!webGl) +// { +// webGl = this.application.ninja.colorController.colorModel.colorToWebGl(color.color); +// } +// if(isFill) +// { +// el.elementModel.shapeModel.GLGeomObj.setFillColor(webGl); +// this.setShapeProperty(el, "fill", webGl); +// this.setShapeProperty(el, "background", color); +// } +// else +// { +// el.elementModel.shapeModel.GLGeomObj.setStrokeColor(webGl); +// this.setShapeProperty(el, "stroke", webGl); +// this.setShapeProperty(el, "border", color); +// if(color.strokeInfo) +// { +// var strokeWidth = this.GetValueInPixels(color.strokeInfo.strokeSize, +// color.strokeInfo.strokeUnits); +// el.elementModel.shapeModel.GLGeomObj.setStrokeWidth(strokeWidth); +// this.setShapeProperty(el, "strokeSize", color.strokeInfo.strokeSize + " " +// + color.strokeInfo.strokeUnits); +// } +// } el.elementModel.shapeModel.GLWorld.render(); } }, -- cgit v1.2.3 From fc567223aded95c35982b1d1239f6d28a957a199 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 7 Mar 2012 11:42:46 -0800 Subject: Gradient support for canvas-2d rectangle. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 7079fc7f..b6d97b14 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -301,22 +301,25 @@ exports.ShapesController = Montage.create(CanvasController, { el.elementModel.shapeModel.GLGeomObj.setFillColor(null); this.setShapeProperty(el, "fill", null); this.setShapeProperty(el, "background", color); -// el.elementModel.fill = null; + el.elementModel.fill = null; return; case 'gradient': - this._setGradientMaterial(el, color.color.gradientMode, isFill); + if(el.elementModel.shapeModel.useWebGl) + { + this._setGradientMaterial(el, color.color.gradientMode, isFill); + } el.elementModel.shapeModel.GLGeomObj.setFillColor({gradientMode:color.color.gradientMode, color:color.color.stops}); el.elementModel.shapeModel.GLWorld.render(); this.setShapeProperty(el, "fill", color.color.css); this.setShapeProperty(el, "background", color); -// el.elementModel.fill = color; + el.elementModel.fill = color; break; default: webGl = this.application.ninja.colorController.colorModel.colorToWebGl(color.color); el.elementModel.shapeModel.GLGeomObj.setFillColor(webGl); this.setShapeProperty(el, "fill", webGl); this.setShapeProperty(el, "background", color); -// el.elementModel.fill = color; + el.elementModel.fill = color; } } } @@ -339,22 +342,25 @@ exports.ShapesController = Montage.create(CanvasController, { el.elementModel.shapeModel.GLGeomObj.setStrokeColor(null); this.setShapeProperty(el, "stroke", null); this.setShapeProperty(el, "border", color); -// el.elementModel.fill = null; + el.elementModel.fill = null; return; case 'gradient': - this._setGradientMaterial(el, color.color.gradientMode, isFill); + if(el.elementModel.shapeModel.useWebGl) + { + this._setGradientMaterial(el, color.color.gradientMode, isFill); + } el.elementModel.shapeModel.GLGeomObj.setStrokeColor({gradientMode:color.color.gradientMode, color:color.color.stops}); el.elementModel.shapeModel.GLWorld.render(); this.setShapeProperty(el, "stroke", color.color.css); this.setShapeProperty(el, "border", color); -// el.elementModel.fill = color; + el.elementModel.fill = color; break; default: webGl = this.application.ninja.colorController.colorModel.colorToWebGl(color.color); el.elementModel.shapeModel.GLGeomObj.setStrokeColor(webGl); this.setShapeProperty(el, "stroke", webGl); this.setShapeProperty(el, "border", color); -// el.elementModel.fill = color; + el.elementModel.fill = color; } } } -- cgit v1.2.3 From 250420d8c6154172b27fe53aff30e78c227e8a67 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 7 Mar 2012 14:26:37 -0800 Subject: minor fixes Signed-off-by: Ananya Sen --- js/controllers/document-controller.js | 12 ++++++------ js/controllers/selection-controller.js | 14 -------------- 2 files changed, 6 insertions(+), 20 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index ca3cd585..87e93465 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -166,7 +166,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, //////////////////////////////////////////////////////////////////// handleExecuteFileClose:{ value: function(event) { - if((typeof this.activeDocument !== "undefined") && this.application.ninja.coreIoApi.cloudAvailable()){ + if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ this.closeDocument(this.activeDocument.uuid); } } @@ -372,11 +372,11 @@ var DocumentController = exports.DocumentController = Montage.create(Component, nextDocumentIndex = closeDocumentIndex - 1; } this.application.ninja.stage.stageView.switchDocument(this._documents[nextDocumentIndex]); - doc.stopVideos(); + if(typeof this.activeDocument.stopVideos !== "undefined"){doc.stopVideos();} this._removeDocumentView(doc.container); }else if(this._documents.length === 0){ - if(typeof this.activeDocument.pauseVideos !== "undefined"){ - this.activeDocument.pauseVideos(true); + if(typeof this.activeDocument.pauseAndStopVideos !== "undefined"){ + this.activeDocument.pauseAndStopVideos(); } this.activeDocument = null; this._removeDocumentView(doc.container); @@ -385,8 +385,8 @@ var DocumentController = exports.DocumentController = Montage.create(Component, this.application.ninja.stage.hideCanvas(true); }else{//closing inactive document tab - just clear DOM - if(typeof doc.pauseVideos !== "undefined"){ - doc.pauseVideos(true); + if(typeof doc.pauseAndStopVideos !== "undefined"){ + doc.pauseAndStopVideos(); } this._removeDocumentView(doc.container); } diff --git a/js/controllers/selection-controller.js b/js/controllers/selection-controller.js index eff9c91a..c713b6e5 100755 --- a/js/controllers/selection-controller.js +++ b/js/controllers/selection-controller.js @@ -100,20 +100,6 @@ exports.SelectionController = Montage.create(Component, { this._isDocument = false; } NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); - - this._selectionContainer = this.application.ninja.currentSelectedContainer; - } - } - }, - - handleCloseDocument:{ - value: function() { - //clear selections if all documents are closed - if(this.application.ninja.documentController._documents.length === 0){ - this._selectedItems.length =0; - this.application.ninja.selectedElements.length =0; - this._isDocument = true; - NJevent("selectionChange", {"elements": this.application.ninja.selectedElements, "isDocument": this._isDocument} ); } } }, -- cgit v1.2.3 From b6288e1ffe4ffe29a595bb1e146feb388503e2c4 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 7 Mar 2012 15:31:20 -0800 Subject: gradient support for canvas-2d shapes. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index b6d97b14..d72d9c14 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -261,28 +261,37 @@ exports.ShapesController = Montage.create(CanvasController, { _setGradientMaterial: { value: function(el, gradientMode, isFill) { - var m = "LinearGradientMaterial"; + var m = "LinearGradientMaterial", + fm; if(gradientMode === "radial") { m = "RadialGradientMaterial"; } - if(el.elementModel.shapeModel.fillMaterial.getName() !== m) + if(isFill) { - var fm = Object.create(MaterialsModel.getMaterial(m)); - if(fm) + if(el.elementModel.shapeModel.fillMaterial.getName() !== m) { - if(isFill) + fm = Object.create(MaterialsModel.getMaterial(m)); + if(fm) { el.elementModel.shapeModel.GLGeomObj.setFillMaterial(fm); el.elementModel.shapeModel.fillMaterial = fm; + el.elementModel.shapeModel.GLGeomObj.buildBuffers(); } - else + } + } + else + { + if(el.elementModel.shapeModel.strokeMaterial.getName() !== m) + { + fm = Object.create(MaterialsModel.getMaterial(m)); + if(fm) { el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(fm); el.elementModel.shapeModel.strokeMaterial = fm; + el.elementModel.shapeModel.GLGeomObj.buildBuffers(); } - el.elementModel.shapeModel.GLGeomObj.buildBuffers(); } } } -- cgit v1.2.3 From 2c6339a9191033c937c2bac3e181c2bc380f4c48 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Mon, 12 Mar 2012 12:00:07 -0700 Subject: Fixed element mediator, PI, and eye-dropper to handle different borders sides and gradients. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/element-controller.js | 32 ++++++++++++++++++--------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'js/controllers') diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index ec0335b4..9f00604f 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -74,8 +74,9 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, //-------------------------------------------------------------------------------------------------------- // Routines to get/set color properties + // borderSide : "top", "right", "bottom", or "left" getColor: { - value: function(el, isFill) { + value: function(el, isFill, borderSide) { var colorObj, color, image; @@ -87,22 +88,29 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, { return el.elementModel.fill; } -// return this.application.ninja.stylesController.getElementStyle(el, "background-color"); //TODO: Once logic for color and gradient is established, this needs to be revised color = this.getProperty(el, "background-color"); image = this.getProperty(el, "background-image"); } else { - // TODO - Need to figure out which border side user wants - if(el.elementModel.stroke) + // Try getting border color from specific side first + if(borderSide) { - return el.elementModel.stroke; + color = this.getProperty(el, "border-" + borderSide + "-color"); + image = this.getProperty(el, "border-" + borderSide + "-image"); + } + + // If no color was found, look up the shared border color + if(!color && !image) + { + if(el.elementModel.stroke) + { + return el.elementModel.stroke; + } + color = this.getProperty(el, "border-color"); + image = this.getProperty(el, "border-image"); } - // TODO - Need to figure out which border side user wants -// return this.application.ninja.stylesController.getElementStyle(el, "border-color"); - color = this.getProperty(el, "border-color"); - image = this.getProperty(el, "border-image"); } if(color || image) { @@ -120,11 +128,15 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, { el.elementModel.fill = colorObj; } - else + else if(!borderSide) { // TODO - Need to update border style and width also el.elementModel.stroke = colorObj; } + else + { + // TODO - Should update specific border sides too + } return colorObj; } -- cgit v1.2.3