diff options
author | hwc487 | 2012-06-29 15:22:53 -0700 |
---|---|---|
committer | hwc487 | 2012-06-29 15:22:53 -0700 |
commit | 9f5901c76442df4d6dfff261706a4ef11c2f1536 (patch) | |
tree | 650ba70f1856a47328d35c485a96e89240529149 | |
parent | 3df60279083f2cda60b3b871037c6d58454de5b2 (diff) | |
parent | ec69c8761f798eaf39c4a154997f8bc54b7e47f4 (diff) | |
download | ninja-9f5901c76442df4d6dfff261706a4ef11c2f1536.tar.gz |
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into GridFixes
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 79 | ||||
-rwxr-xr-x | js/controllers/styles-controller.js | 2 | ||||
-rwxr-xr-x | js/lib/rdge/materials/uber-material.js | 12 | ||||
-rwxr-xr-x | js/tools/FillTool.js | 5 | ||||
-rwxr-xr-x | js/tools/LineTool.js | 21 | ||||
-rwxr-xr-x | js/tools/OvalTool.js | 18 | ||||
-rwxr-xr-x | js/tools/RectTool.js | 20 | ||||
-rwxr-xr-x | js/tools/ShapeTool.js | 18 |
8 files changed, 121 insertions, 54 deletions
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 74353454..c3099459 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js | |||
@@ -138,6 +138,10 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
138 | this.application.ninja.elementMediator.replaceElement(canvas, el); | 138 | this.application.ninja.elementMediator.replaceElement(canvas, el); |
139 | break; | 139 | break; |
140 | case "strokeMaterial": | 140 | case "strokeMaterial": |
141 | // skip shape types that don't support WebGL | ||
142 | if(!el.elementModel.shapeModel.useWebGl) { | ||
143 | return; | ||
144 | } | ||
141 | m = Object.create(MaterialsModel.getMaterial(value)); | 145 | m = Object.create(MaterialsModel.getMaterial(value)); |
142 | if(m) | 146 | if(m) |
143 | { | 147 | { |
@@ -152,6 +156,10 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
152 | } | 156 | } |
153 | break; | 157 | break; |
154 | case "fillMaterial": | 158 | case "fillMaterial": |
159 | // skip shape types that don't support WebGL or fill color | ||
160 | if(!el.elementModel.shapeModel.GLGeomObj.canFill || !el.elementModel.shapeModel.useWebGl) { | ||
161 | return; | ||
162 | } | ||
155 | m = Object.create(MaterialsModel.getMaterial(value)); | 163 | m = Object.create(MaterialsModel.getMaterial(value)); |
156 | if(m) | 164 | if(m) |
157 | { | 165 | { |
@@ -445,17 +453,17 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
445 | 453 | ||
446 | if(gradientM) | 454 | if(gradientM) |
447 | { | 455 | { |
448 | if(isFill) | 456 | if(isFill) |
449 | { | 457 | { |
450 | el.elementModel.shapeModel.GLGeomObj.setFillMaterial(gradientM); | 458 | el.elementModel.shapeModel.GLGeomObj.setFillMaterial(gradientM); |
451 | } | 459 | } |
452 | else | 460 | else |
453 | { | 461 | { |
454 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(gradientM); | 462 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(gradientM); |
455 | } | 463 | } |
456 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); | 464 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); |
457 | } | 465 | } |
458 | } | 466 | } |
459 | }, | 467 | }, |
460 | 468 | ||
461 | _setFlatMaterial: { | 469 | _setFlatMaterial: { |
@@ -472,10 +480,13 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
472 | } | 480 | } |
473 | 481 | ||
474 | if(!m || ((m.getName() === "Linear Gradient") || m.getName() === "Radial Gradient") ) | 482 | if(!m || ((m.getName() === "Linear Gradient") || m.getName() === "Radial Gradient") ) |
475 | { | 483 | { |
484 | // Uber Material also supports solid colors, so don't change from Uber to Flat Material | ||
485 | if(m && (m.getName() === "Uber")) { return; } | ||
486 | |||
476 | flatM = Object.create(MaterialsModel.getMaterial("Flat")); | 487 | flatM = Object.create(MaterialsModel.getMaterial("Flat")); |
477 | if(flatM) | 488 | if(flatM) |
478 | { | 489 | { |
479 | if(isFill) | 490 | if(isFill) |
480 | { | 491 | { |
481 | el.elementModel.shapeModel.GLGeomObj.setFillMaterial(flatM); | 492 | el.elementModel.shapeModel.GLGeomObj.setFillMaterial(flatM); |
@@ -484,10 +495,10 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
484 | { | 495 | { |
485 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(flatM); | 496 | el.elementModel.shapeModel.GLGeomObj.setStrokeMaterial(flatM); |
486 | } | 497 | } |
487 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); | 498 | el.elementModel.shapeModel.GLGeomObj.buildBuffers(); |
488 | } | ||
489 | } | 499 | } |
490 | } | 500 | } |
501 | } | ||
491 | }, | 502 | }, |
492 | 503 | ||
493 | setColor: { | 504 | setColor: { |
@@ -597,14 +608,31 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
597 | 608 | ||
598 | setStroke: { | 609 | setStroke: { |
599 | value: function(el, stroke, eventType, source) { | 610 | value: function(el, stroke, eventType, source) { |
600 | if(stroke.colorInfo) { | ||
601 | this.setColor(el, stroke.colorInfo, false); | ||
602 | } | ||
603 | if(stroke.shapeInfo) { | 611 | if(stroke.shapeInfo) { |
604 | this.setProperty(el, "strokeSize", stroke.shapeInfo.strokeSize + " " + stroke.shapeInfo.strokeUnits, eventType, source); | 612 | this.setProperty(el, "strokeSize", stroke.shapeInfo.strokeSize + " " + stroke.shapeInfo.strokeUnits, eventType, source); |
605 | } | 613 | } |
614 | var m; | ||
606 | if(stroke.webGLInfo) { | 615 | if(stroke.webGLInfo) { |
607 | this.setProperty(el, "strokeMaterial", stroke.webGLInfo.material); | 616 | m = stroke.webGLInfo.material; |
617 | this.setProperty(el, "strokeMaterial", m); | ||
618 | if((m === "Linear Gradient") || (m === "Radial Gradient")) { | ||
619 | // Just use the default gradient material values | ||
620 | return; | ||
621 | } | ||
622 | } | ||
623 | if(stroke.colorInfo) { | ||
624 | if(el.elementModel.shapeModel.useWebGl) { | ||
625 | m = el.elementModel.shapeModel.GLGeomObj.getStrokeMaterial().getName(); | ||
626 | if( ((stroke.colorInfo.mode === "gradient") && (m !== "Linear Gradient") && (m !== "Radial Gradient")) || | ||
627 | ((stroke.colorInfo.mode !== "gradient") && ((m === "Linear Gradient") || (m === "Radial Gradient")))) | ||
628 | { | ||
629 | return; | ||
630 | } else { | ||
631 | this.setColor(el, stroke.colorInfo, false); | ||
632 | } | ||
633 | } else { | ||
634 | this.setColor(el, stroke.colorInfo, false); | ||
635 | } | ||
608 | } | 636 | } |
609 | } | 637 | } |
610 | }, | 638 | }, |
@@ -638,11 +666,28 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
638 | 666 | ||
639 | setFill: { | 667 | setFill: { |
640 | value: function(el, fill) { | 668 | value: function(el, fill) { |
641 | if(fill.colorInfo) { | 669 | var m; |
642 | this.setColor(el, fill.colorInfo, true); | ||
643 | } | ||
644 | if(fill.webGLInfo) { | 670 | if(fill.webGLInfo) { |
645 | this.setProperty(el, "fillMaterial", fill.webGLInfo.material); | 671 | m = fill.webGLInfo.material; |
672 | this.setProperty(el, "fillMaterial", m); | ||
673 | if((m === "Linear Gradient") || (m === "Radial Gradient")) { | ||
674 | // Just use the default gradient material values | ||
675 | return; | ||
676 | } | ||
677 | } | ||
678 | if(fill.colorInfo) { | ||
679 | if(el.elementModel.shapeModel.useWebGl) { | ||
680 | m = el.elementModel.shapeModel.GLGeomObj.getFillMaterial().getName(); | ||
681 | if( ((fill.colorInfo.mode === "gradient") && (m !== "Linear Gradient") && (m !== "Radial Gradient")) || | ||
682 | ((fill.colorInfo.mode !== "gradient") && ((m === "Linear Gradient") || (m === "Radial Gradient")))) | ||
683 | { | ||
684 | return; | ||
685 | } else { | ||
686 | this.setColor(el, fill.colorInfo, true); | ||
687 | } | ||
688 | } else { | ||
689 | this.setColor(el, fill.colorInfo, true); | ||
690 | } | ||
646 | } | 691 | } |
647 | } | 692 | } |
648 | }, | 693 | }, |
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js index e25ed20c..478fc1db 100755 --- a/js/controllers/styles-controller.js +++ b/js/controllers/styles-controller.js | |||
@@ -1440,11 +1440,11 @@ var stylesController = exports.StylesController = Montage.create(Component, { | |||
1440 | 1440 | ||
1441 | ///// Dispatch modified event | 1441 | ///// Dispatch modified event |
1442 | NJevent('styleSheetModified', eventData); | 1442 | NJevent('styleSheetModified', eventData); |
1443 | this.currentDocument.model.needsSave = true; | ||
1443 | 1444 | ||
1444 | ///// If the sheet doesn't already exist in the list of modified | 1445 | ///// If the sheet doesn't already exist in the list of modified |
1445 | ///// sheets, dispatch dirty event and add the sheet to the list | 1446 | ///// sheets, dispatch dirty event and add the sheet to the list |
1446 | if(sheetSearch.length === 0) { | 1447 | if(sheetSearch.length === 0) { |
1447 | this.currentDocument.model.needsSave = true; | ||
1448 | this.dirtyStyleSheets.push({ | 1448 | this.dirtyStyleSheets.push({ |
1449 | document : sheet.ownerNode.ownerDocument, | 1449 | document : sheet.ownerNode.ownerDocument, |
1450 | stylesheet : sheet | 1450 | stylesheet : sheet |
diff --git a/js/lib/rdge/materials/uber-material.js b/js/lib/rdge/materials/uber-material.js index 347e45d3..e1c6781d 100755 --- a/js/lib/rdge/materials/uber-material.js +++ b/js/lib/rdge/materials/uber-material.js | |||
@@ -99,6 +99,18 @@ var UberMaterial = function UberMaterial() { | |||
99 | } | 99 | } |
100 | } | 100 | } |
101 | }; | 101 | }; |
102 | |||
103 | this.hasProperty = function( prop ) | ||
104 | { | ||
105 | if(prop === "color") return true; | ||
106 | |||
107 | var propNames = [], dummy = []; | ||
108 | this.getAllProperties( propNames, dummy, dummy, dummy ) | ||
109 | for (var i=0; i<propNames.length; i++) | ||
110 | { | ||
111 | if (prop === propNames[i]) return true; | ||
112 | } | ||
113 | }; | ||
102 | /////////////////////////////////////////////////////////////////////// | 114 | /////////////////////////////////////////////////////////////////////// |
103 |