From 1fde3bdcaeec81702d58e95607076603d61f946e Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 19 Jul 2012 11:54:27 -0700 Subject: Restrict materials popup to appear within our page. Signed-off-by: Nivesh Rajbhandari --- .../materials-library-panel.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js index 4b9044ae..c3c2a6de 100755 --- a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js +++ b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js @@ -217,15 +217,27 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { willPositionPopup: { value: function(popup, defaultPosition) { - var content = popup.content.element, + var left, + top, + content = popup.content.element, contentHt = parseFloat(content.style.height) || content.offsetHeight || 0, contentWd = parseFloat(content.style.width) || content.offsetWidth || 0, pt = webkitConvertPointFromNodeToPage(this.selectedMaterialNode, new WebKitPoint(0, 0)); - if(!pt) { + + if(!pt) { return defaultPosition; - } else { - return {top: pt.y - contentHt + 10, left: pt.x - contentWd + 10}; + } + + top = pt.y - contentHt + 10; + if(top < 0) { + top = 0; } + left = pt.x - contentWd + 10; + if(left < 0) { + left = 0; + } + + return {top:top, left:left}; } } }); -- cgit v1.2.3 From 71795a786342b3d84ef904dc448b4ce840a44810 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 19 Jul 2012 13:37:04 -0700 Subject: IKNINJA-1924 - Hovering over panel resizers after collapsing and expanding panel causes error. Canvas sizes were not updated when using the splitter to toggle collapse/expansion of panels. This was fixed by the StageDrawingFixes pull request. We should also guard agains null value in stage's getElement routine. Signed-off-by: Nivesh Rajbhandari --- js/stage/stage.reel/stage.js | 4 +++- js/tools/ShapeTool.js | 34 ---------------------------------- 2 files changed, 3 insertions(+), 35 deletions(-) diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 7ac64976..7c2fa903 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -894,7 +894,9 @@ exports.Stage = Montage.create(Component, { point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX - docView.iframe.contentWindow.pageXOffset + this.documentOffsetLeft, position.pageY - docView.iframe.contentWindow.pageYOffset + this.documentOffsetTop)); element = this.currentDocument.model.views.design.getElementFromPoint(point.x - this.userContentLeft,point.y - this.userContentTop); -// if(!element) debugger; + if(!element) { + return this.currentDocument.model.domContainer; + } // workaround Chrome 3d bug if(this.application.ninja.toolsData.selectedToolInstance._canSnap && this.currentDocument.inExclusion(element) !== -1) { point = webkitConvertPointFromPageToNode(this.canvas, new WebKitPoint(position.pageX, position.pageY)); diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 26ed9c6f..ecc0dca3 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -70,7 +70,6 @@ exports.ShapeTool = Montage.create(DrawingTool, { this.doDraw(event); } else { this.doSnap(event); - this._showFeedbackOnMouseMove(event); } this.drawLastSnap(); // Required cleanup for both Draw/Feedbacks @@ -159,39 +158,6 @@ exports.ShapeTool = Montage.create(DrawingTool, { } }, - /** Show a border when mousing - * over existing canvas elements to signal to the user that - * the drawing operation will act on the targeted canvas. - **/ - _showFeedbackOnMouseMove: { - value: function (event) { - // TODO - This call is causing the canvas to redraw 3 times per mouse move - var targetedObject = this.application.ninja.stage.getElement(event, true); - - if (targetedObject) { - if((targetedObject.nodeName === "CANVAS") && !ShapesController.isElementAShape(targetedObject)) - { - if (targetedObject !== this._targetedElement) { - if(this._targetedElement) - { - this._targetedElement.classList.remove("active-element-outline"); - } - this._targetedElement = targetedObject; - this._targetedElement.classList.add("active-element-outline"); - } - } - else if (this._targetedElement) { - this._targetedElement.classList.remove("active-element-outline"); - this._targetedElement = null; - } - } - else if (this._targetedElement) { - this._targetedElement.classList.remove("elem-red-outline"); - this._targetedElement = null; - } - } - }, - RenderShape: { value: function (w, h, planeMat, midPt) -- cgit v1.2.3 From 6db7685f40310683e1cb6c4e98895d2007e787dc Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 19 Jul 2012 16:24:17 -0700 Subject: IKNINJA-1899 - Fixed runtime error when undoing a delete shape action. Signed-off-by: Nivesh Rajbhandari --- js/mediators/element-mediator.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 4a4c9f88..f5b574fc 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -69,7 +69,7 @@ exports.ElementMediator = Montage.create(Component, { var undoLabel = "add element"; - document.application.undoManager.add(undoLabel, this.removeElements, this, elements, notify); + document.application.undoManager.add(undoLabel, this.removeElements, this, elements, notify, false); this.application.ninja.currentDocument.model.needsSave = true; @@ -80,9 +80,10 @@ exports.ElementMediator = Montage.create(Component, { }, removeElements:{ - value:function (elements, notify /* Used for the add undo */) { + value:function (elements, notify, callDeleteDelegate) { - if (this.deleteDelegate && (typeof this.deleteDelegate.handleDelete === 'function')) { + if ((callDeleteDelegate || (typeof callDeleteDelegate === "undefined")) + && this.deleteDelegate && (typeof this.deleteDelegate.handleDelete === 'function')) { return this.deleteDelegate.handleDelete(); // this.handleDelete.call(deleteDelegate); } @@ -98,7 +99,7 @@ exports.ElementMediator = Montage.create(Component, { var undoLabel = "add element"; - document.application.undoManager.add(undoLabel, this.addElements, this, elements, null, notify); + document.application.undoManager.add(undoLabel, this.addElements, this, elements, null, notify, false); this.application.ninja.currentDocument.model.needsSave = true; -- cgit v1.2.3 From 4648e2eda9aa8c8f9b0aed4d12fef8b1d00f1769 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 19 Jul 2012 16:26:03 -0700 Subject: IKNINJA-1780 - [Shape] Error when opening document that contains a shape with gradient color or no color. Signed-off-by: Nivesh Rajbhandari --- js/lib/geom/circle.js | 57 ++++++++++++++++-------------------------------- js/lib/geom/geom-obj.js | 20 +++++++++++++++++ js/lib/geom/line.js | 26 +++++++++------------- js/lib/geom/rectangle.js | 57 ++++++++++++++++-------------------------------- 4 files changed, 68 insertions(+), 92 deletions(-) diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js index ba47603b..4995c2cb 100755 --- a/js/lib/geom/circle.js +++ b/js/lib/geom/circle.js @@ -83,31 +83,13 @@ exports.Circle = Object.create(GeomObj, { if(strokeMaterial) { this._strokeMaterial = strokeMaterial.dup(); - } else { - this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); - } - - if(strokeColor) { - if(this._strokeMaterial.hasProperty("color")) { - this._strokeMaterial.setProperty( "color", this._strokeColor ); - } else if (this._strokeMaterial && (this._strokeMaterial.gradientType === this._strokeColor.gradientMode)) { - this._strokeMaterial.setGradientData(this._strokeColor.color); - } } if(fillMaterial) { this._fillMaterial = fillMaterial.dup(); - } else { - this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); } - if(fillColor) { - if(this._fillMaterial.hasProperty("color")) { - this._fillMaterial.setProperty( "color", this._fillColor ); - } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) { - this._fillMaterial.setGradientData(this._fillColor.color); - } - } + this.initColors(); } }, @@ -770,8 +752,8 @@ exports.Circle = Object.create(GeomObj, { 'fillColor' : this._fillColor, 'innerRadius' : this._innerRadius, 'strokeStyle' : this._strokeStyle, - 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : MaterialsModel.getDefaultMaterialName(), - 'fillMat' : this._fillMaterial ? this._fillMaterial.getName() : MaterialsModel.getDefaultMaterialName(), + 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : null, + 'fillMat' : this._fillMaterial ? this._fillMaterial.getName() : null, 'materials' : this.exportMaterialsJSON() }; @@ -790,27 +772,26 @@ exports.Circle = Object.create(GeomObj, { this._fillColor = jObj.fillColor; this._innerRadius = jObj.innerRadius; this._strokeStyle = jObj.strokeStyle; - var strokeMaterialName = jObj.strokeMat; - var fillMaterialName = jObj.fillMat; - var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ).dup(); - if (!strokeMat) { - console.log( "object material not found in library: " + strokeMaterialName ); - strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); + if(jObj.strokeMat) { + var strokeMat = MaterialsModel.getMaterial(jObj.strokeMat).dup(); + if (!strokeMat) { + console.log("object material not found in library: " + jObj.strokeMat); + } else { + this._strokeMaterial = strokeMat; + } } - this._strokeMaterial = strokeMat; - if (this._strokeMaterial.hasProperty( 'color' )) - this._strokeMaterial.setProperty( 'color', this._strokeColor ); - - var fillMat = MaterialsModel.getMaterial( fillMaterialName ).dup(); - if (!fillMat) { - console.log( "object material not found in library: " + fillMaterialName ); - fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); + + if(jObj.fillMat) { + var fillMat = MaterialsModel.getMaterial(jObj.fillMat).dup(); + if (!fillMat) { + console.log("object material not found in library: " + jObj.fillMat); + } else { + this._fillMaterial = fillMat; + } } - this._fillMaterial = fillMat; - if (this._fillMaterial.hasProperty( 'color' )) - this._fillMaterial.setProperty( 'color', this._fillColor ); + this.initColors(); this.importMaterialsJSON( jObj.materials ); } }, diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index 3cd3a89b..dd60cdec 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js @@ -205,6 +205,26 @@ exports.GeomObj = Object.create(Object.prototype, { /////////////////////////////////////////////////////////////////////// // Methods /////////////////////////////////////////////////////////////////////// + initColors: { + value: function() { + if(this._strokeColor && this._strokeMaterial) { + if(this._strokeMaterial.hasProperty("color")) { + this._strokeMaterial.setProperty( "color", this._strokeColor ); + } else if (this._strokeMaterial && (this._strokeMaterial.gradientType === this._strokeColor.gradientMode)) { + this._strokeMaterial.setGradientData(this._strokeColor.color); + } + } + + if(this._fillColor && this._fillMaterial) { + if(this._fillMaterial.hasProperty("color")) { + this._fillMaterial.setProperty( "color", this._fillColor ); + } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) { + this._fillMaterial.setGradientData(this._fillColor.color); + } + } + } + }, + setMaterialColor: { value: function(c, type) { var i = 0, diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js index c0322f46..eec4f6d9 100755 --- a/js/lib/geom/line.js +++ b/js/lib/geom/line.js @@ -89,17 +89,9 @@ exports.Line = Object.create(GeomObj, { if(strokeMaterial) { this._strokeMaterial = strokeMaterial.dup(); - } else { - this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); } - if(strokeColor) { - if(this._strokeMaterial.hasProperty("color")) { - this._strokeMaterial.setProperty( "color", this._strokeColor ); - } else if (this._strokeMaterial && (this._strokeMaterial.gradientType === this._strokeColor.gradientMode)) { - this._strokeMaterial.setGradientData(this._strokeColor.color); - } - } + this.initColors(); } }, @@ -245,7 +237,7 @@ exports.Line = Object.create(GeomObj, { 'strokeWidth' : this._strokeWidth, 'strokeColor' : this._strokeColor, 'strokeStyle' : this._strokeStyle, - 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : MaterialsModel.getDefaultMaterialName(), + 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : null, 'materials' : this.exportMaterialsJSON() }; @@ -265,15 +257,17 @@ exports.Line = Object.create(GeomObj, { this._slope = jObj.slope; this._strokeStyle = jObj.strokeStyle; this._strokeColor = jObj.strokeColor; - var strokeMaterialName = jObj.strokeMat; - var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); - if (!strokeMat) { - console.log( "object material not found in library: " + strokeMaterialName ); - strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); + if(jObj.strokeMat) { + var strokeMat = MaterialsModel.getMaterial(jObj.strokeMat).dup(); + if (!strokeMat) { + console.log("object material not found in library: " + jObj.strokeMat); + } else { + this._strokeMaterial = strokeMat; + } } - this._strokeMaterial = strokeMat; + this.initColors(); this.importMaterialsJSON( jObj.materials ); } }, diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index f1da4918..f3db92af 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js @@ -99,31 +99,13 @@ exports.Rectangle = Object.create(GeomObj, { if(strokeMaterial) { this._strokeMaterial = strokeMaterial.dup(); - } else { - this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); - } - - if(strokeColor) { - if(this._strokeMaterial.hasProperty("color")) { - this._strokeMaterial.setProperty( "color", this._strokeColor ); - } else if (this._strokeMaterial && (this._strokeMaterial.gradientType === this._strokeColor.gradientMode)) { - this._strokeMaterial.setGradientData(this._strokeColor.color); - } } if(fillMaterial) { this._fillMaterial = fillMaterial.dup(); - } else { - this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); } - if(fillColor) { - if(this._fillMaterial.hasProperty("color")) { - this._fillMaterial.setProperty( "color", this._fillColor ); - } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) { - this._fillMaterial.setGradientData(this._fillColor.color); - } - } + this.initColors(); } }, @@ -303,8 +285,8 @@ exports.Rectangle = Object.create(GeomObj, { 'brRadius' : this._brRadius, 'innerRadius' : this._innerRadius, 'strokeStyle' : this._strokeStyle, - 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : MaterialsModel.getDefaultMaterialName(), - 'fillMat' : this._fillMaterial ? this._fillMaterial.getName() : MaterialsModel.getDefaultMaterialName(), + 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : null, + 'fillMat' : this._fillMaterial ? this._fillMaterial.getName() : null, 'materials' : this.exportMaterialsJSON() }; @@ -327,27 +309,26 @@ exports.Rectangle = Object.create(GeomObj, { this._brRadius = jObj.brRadius; this._innerRadius = jObj.innerRadius; this._strokeStyle = jObj.strokeStyle; - var strokeMaterialName = jObj.strokeMat; - var fillMaterialName = jObj.fillMat; - var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ).dup(); - if (!strokeMat) { - console.log( "object material not found in library: " + strokeMaterialName ); - strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); + if(jObj.strokeMat) { + var strokeMat = MaterialsModel.getMaterial(jObj.strokeMat).dup(); + if (!strokeMat) { + console.log("object material not found in library: " + jObj.strokeMat); + } else { + this._strokeMaterial = strokeMat; + } } - this._strokeMaterial = strokeMat; - if (this._strokeMaterial.hasProperty( 'color' )) - this._strokeMaterial.setProperty( 'color', this._strokeColor ); - - var fillMat = MaterialsModel.getMaterial( fillMaterialName ).dup(); - if (!fillMat) { - console.log( "object material not found in library: " + fillMaterialName ); - fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); + + if(jObj.fillMat) { + var fillMat = MaterialsModel.getMaterial(jObj.fillMat).dup(); + if (!fillMat) { + console.log("object material not found in library: " + jObj.fillMat); + } else { + this._fillMaterial = fillMat; + } } - this._fillMaterial = fillMat; - if (this._fillMaterial.hasProperty( 'color' )) - this._fillMaterial.setProperty( 'color', this._fillColor ); + this.initColors(); this.importMaterialsJSON( jObj.materials ); } }, -- cgit v1.2.3 From d7f5d6ffb39d55f2d4f4f366421571826df1e8bb Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Fri, 20 Jul 2012 11:54:04 -0700 Subject: If no material was defined, use Flat material when switching from 2d to WebGL shape. Signed-off-by: Nivesh Rajbhandari --- js/controllers/elements/shapes-controller.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 1d945066..6dabff47 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -841,10 +841,10 @@ exports.ShapesController = Montage.create(CanvasController, { child.strokeMat = "Linear Gradient"; } } - else if( (child.strokeMat === "Radial Gradient") || + else if( !child.strokeMat || (child.strokeMat === "Radial Gradient") || (child.strokeMat === "Linear Gradient") ) { - // Set Flat Material for children geometry if color has been changed to solid + // Set Flat Material for children geometry if no material defined or color has been changed to solid child.strokeMat = "Flat"; } } @@ -863,10 +863,10 @@ exports.ShapesController = Montage.create(CanvasController, { child.fillMat = "Linear Gradient"; } } - else if( (child.fillMat === "Radial Gradient") || + else if( !child.fillMat || (child.fillMat === "Radial Gradient") || (child.fillMat === "Linear Gradient") ) { - // Set Flat Material for children geometry if color has been changed to solid + // Set Flat Material for children geometry if no material defined or color has been changed to solid child.fillMat = "Flat"; } } -- cgit v1.2.3 From 288b81e06db68b785524db5c7f7ae1ecbc3d83b1 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 20 Jul 2012 15:15:27 -0700 Subject: Binding view: fixed mouse move event outside the hud - Changing the variable event to 'e' Signed-off-by: Valerio Virgillito --- js/stage/binding-view.reel/binding-view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/stage/binding-view.reel/binding-view.js b/js/stage/binding-view.reel/binding-view.js index 3e83281e..b207cc3d 100755 --- a/js/stage/binding-view.reel/binding-view.js +++ b/js/stage/binding-view.reel/binding-view.js @@ -365,7 +365,7 @@ exports.BindingView = Montage.create(Component, { this.mouseOverHud = overHud; if(this._isDrawingConnection && !overHud) { //NOTE : Continue This content. mouse over select - var obj = this.application.ninja.stage.getElement(event, true); + var obj = this.application.ninja.stage.getElement(e, true); if (obj && obj !== this.selectedElement) { if (!obj.controller || obj === null) -- cgit v1.2.3