aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/elements
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/elements')
-rw-r--r--js/controllers/elements/element-controller.js92
-rw-r--r--js/controllers/elements/shapes-controller.js60
2 files changed, 112 insertions, 40 deletions
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js
index f2b54014..65c24b46 100644
--- a/js/controllers/elements/element-controller.js
+++ b/js/controllers/elements/element-controller.js
@@ -69,27 +69,111 @@ var ElementController = exports.ElementController = Montage.create(NJComponent,
69 // Routines to get/set color properties 69 // Routines to get/set color properties
70 getColor: { 70 getColor: {
71 value: function(el, isFill) { 71 value: function(el, isFill) {
72 var colorObj,
73 color,
74 image;
75
76 // Return cached value if one exists
72 if(isFill) 77 if(isFill)
73 { 78 {
74 return this.application.ninja.stylesController.getElementStyle(el, "background-color"); 79 if(el.elementModel.fill)
80 {
81 return el.elementModel.fill;
82 }
83// return this.application.ninja.stylesController.getElementStyle(el, "background-color");
84 //TODO: Once logic for color and gradient is established, this needs to be revised
85 color = this.getProperty(el, "background-color");
86 image = this.getProperty(el, "background-image");
75 } 87 }
76 else 88 else
77 { 89 {
78 // TODO - Need to figure out which border side user wants 90 // TODO - Need to figure out which border side user wants
79 return this.application.ninja.stylesController.getElementStyle(el, "border-color"); 91 if(el.elementModel.stroke)
92 {
93 return el.elementModel.stroke;
94 }
95 // TODO - Need to figure out which border side user wants
96// return this.application.ninja.stylesController.getElementStyle(el, "border-color");
97 color = this.getProperty(el, "border-color");
98 image = this.getProperty(el, "border-image");
99 }
100
101 if(color || image) {
102 if (image && image !== 'none' && image.indexOf('-webkit') >= 0) {
103 //Gradient
104 colorObj = this.application.ninja.colorController.getColorObjFromCss(image);
105 } else {
106 //Solid
107 colorObj = this.application.ninja.colorController.getColorObjFromCss(color);
108 }
80 } 109 }
110
111 // Update cache
112 if(isFill)
113 {
114 el.elementModel.fill = colorObj;
115 }
116 else
117 {
118 el.elementModel.stroke = colorObj;
119 }
120
121 return colorObj;
81 } 122 }
82 }, 123 },
83 124
84 setColor: { 125 setColor: {
85 value: function(el, color, isFill) { 126 value: function(el, color, isFill) {
127 var mode = color.mode;
86 if(isFill) 128 if(isFill)
87 { 129 {
88 this.application.ninja.stylesController.setElementStyle(el, "background-color", color.color.css); 130 if(mode)
131 {
132 switch (mode) {
133 case 'nocolor':
134 this.setProperty(el, "background-image", "none");
135 this.setProperty(el, "background-color", "none");
136 el.elementModel.fill = null;
137 return;
138 case 'gradient':
139 this.setProperty(el, "background-image", color.color.css);
140 this.setProperty(el, "background-color", "none");
141 break;
142 default:
143 this.setProperty(el, "background-image", "none");
144 this.setProperty(el, "background-color", color.color.css);
145 }
146 }
147 else
148 {
149 this.application.ninja.stylesController.setElementStyle(el, "background-color", color.color.css);
150 }
151 el.elementModel.fill = color;
89 } 152 }
90 else 153 else
91 { 154 {
92 this.application.ninja.stylesController.setElementStyle(el, "border-color", color.color.css); 155 if(mode)
156 {
157 switch (mode) {
158 case 'nocolor':
159 this.setProperty(el, "border-image", "none");
160 this.setProperty(el, "border-color", "none");
161 el.elementModel.stroke = null;
162 return;
163 case 'gradient':
164 this.setProperty(el, "border-image", color.color.css);
165 this.setProperty(el, "border-color", "none");
166 break;
167 default:
168 this.setProperty(el, "border-image", "none");
169 this.setProperty(el, "border-color", color.color.css);
170 }
171 }
172 else
173 {
174 this.application.ninja.stylesController.setElementStyle(el, "border-color", color.color.css);
175 }
176 el.elementModel.stroke = color;
93 } 177 }
94 } 178 }
95 }, 179 },
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js
index c5f22138..1717db94 100644
--- a/js/controllers/elements/shapes-controller.js
+++ b/js/controllers/elements/shapes-controller.js
@@ -24,26 +24,6 @@ exports.ShapesController = Montage.create(CanvasController, {
24 el.elementModel.shapeModel.GLGeomObj.setInnerRadius(val/100); 24 el.elementModel.shapeModel.GLGeomObj.setInnerRadius(val/100);
25 el.elementModel.shapeModel.GLGeomObj.buildBuffers(); 25 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
26 break; 26 break;
27 case "tlRadius":
28 this.setShapeProperty(el, "tlRadius", value);
29 el.elementModel.shapeModel.GLGeomObj.setTLRadius(val);
30 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
31 break;
32 case "trRadius":
33 this.setShapeProperty(el, "trRadius", value);
34 el.elementModel.shapeModel.GLGeomObj.setTRRadius(val);
35 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
36 break;
37 case "blRadius":
38 this.setShapeProperty(el, "blRadius", value);
39 el.elementModel.shapeModel.GLGeomObj.setBLRadius(val);
40 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
41 break;
42 case "brRadius":
43 this.setShapeProperty(el, "brRadius", value);
44 el.elementModel.shapeModel.GLGeomObj.setBRRadius(val);
45 el.elementModel.shapeModel.GLGeomObj.buildBuffers();
46 break;
47 case "width": 27 case "width":
48 el.elementModel.shapeModel.GLGeomObj.setWidth(val); 28 el.elementModel.shapeModel.GLGeomObj.setWidth(val);
49 CanvasController.setProperty(el, p, value); 29 CanvasController.setProperty(el, p, value);
@@ -66,16 +46,10 @@ exports.ShapesController = Montage.create(CanvasController, {
66 getProperty: { 46 getProperty: {
67 value: function(el, p) { 47 value: function(el, p) {
68 switch(p) { 48 switch(p) {
69 case "stroke":
70 case "fill":
71 case "strokeSize": 49 case "strokeSize":
72 case "innerRadius": 50 case "innerRadius":
73 case "tlRadius": 51 case "border":
74 case "trRadius": 52 case "background":
75 case "blRadius":
76 case "brRadius":
77 case "strokeMaterial":
78 case "fillMaterial":
79 return this.getShapeProperty(el, p); 53 return this.getShapeProperty(el, p);
80 default: 54 default:
81 return CanvasController.getProperty(el, p); 55 return CanvasController.getProperty(el, p);
@@ -182,30 +156,44 @@ exports.ShapesController = Montage.create(CanvasController, {
182 // Routines to get/set color properties 156 // Routines to get/set color properties
183 getColor: { 157 getColor: {
184 value: function(el, isFill) { 158 value: function(el, isFill) {
159 var color,
160 css;
185 if(isFill) 161 if(isFill)
186 { 162 {
187 return this.getShapeProperty(el, "fill"); 163 if(el.elementModel.shapeModel.background)
164 {
165 return el.elementModel.shapeModel.background;
166 }
167 color = this.getShapeProperty(el, "fill");
188 } 168 }
189 else 169 else
190 { 170 {
191 return this.getShapeProperty(el, "stroke"); 171 if(el.elementModel.shapeModel.border)
172 {
173 return el.elementModel.shapeModel.border;
174 }
175 color = this.getShapeProperty(el, "stroke");
192 } 176 }
177
178 css = this.application.ninja.colorController.colorModel.webGlToCss(color);
179 return this.application.ninja.colorController.getColorObjFromCss(css);
193 } 180 }
194 }, 181 },
195 182
196 setColor: {