diff options
author | Nivesh Rajbhandari | 2012-03-12 12:00:07 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-03-12 12:00:07 -0700 |
commit | 2c6339a9191033c937c2bac3e181c2bc380f4c48 (patch) | |
tree | f5b6b66c578d77f3db3373ff9521519d107fc33a /js | |
parent | e44238821c6b19a4b2259d26e14847b9995338f2 (diff) | |
download | ninja-2c6339a9191033c937c2bac3e181c2bc380f4c48.tar.gz |
Fixed element mediator, PI, and eye-dropper to handle different borders sides and gradients.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js')
-rwxr-xr-x | js/controllers/elements/element-controller.js | 32 | ||||
-rwxr-xr-x | js/mediators/element-mediator.js | 15 | ||||
-rwxr-xr-x | js/models/color-model.js | 3 | ||||
-rwxr-xr-x | js/panels/properties.reel/properties.js | 4 | ||||
-rwxr-xr-x | js/tools/EyedropperTool.js | 17 |
5 files changed, 41 insertions, 30 deletions
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, | |||
74 | 74 | ||
75 | //-------------------------------------------------------------------------------------------------------- | 75 | //-------------------------------------------------------------------------------------------------------- |
76 | // Routines to get/set color properties | 76 | // Routines to get/set color properties |
77 | // borderSide : "top", "right", "bottom", or "left" | ||
77 | getColor: { | 78 | getColor: { |
78 | value: function(el, isFill) { | 79 | value: function(el, isFill, borderSide) { |
79 | var colorObj, | 80 | var colorObj, |
80 | color, | 81 | color, |
81 | image; | 82 | image; |
@@ -87,22 +88,29 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, | |||
87 | { | 88 | { |
88 | return el.elementModel.fill; | 89 | return el.elementModel.fill; |
89 | } | 90 | } |
90 | // return this.application.ninja.stylesController.getElementStyle(el, "background-color"); | ||
91 | //TODO: Once logic for color and gradient is established, this needs to be revised | 91 | //TODO: Once logic for color and gradient is established, this needs to be revised |
92 | color = this.getProperty(el, "background-color"); | 92 | color = this.getProperty(el, "background-color"); |
93 | image = this.getProperty(el, "background-image"); | 93 | image = this.getProperty(el, "background-image"); |
94 | } | 94 | } |
95 | else | 95 | else |
96 | { | 96 | { |
97 | // TODO - Need to figure out which border side user wants | 97 | // Try getting border color from specific side first |
98 | if(el.elementModel.stroke) | 98 | if(borderSide) |
99 | { | 99 | { |
100 | return el.elementModel.stroke; | 100 | color = this.getProperty(el, "border-" + borderSide + "-color"); |
101 | image = this.getProperty(el, "border-" + borderSide + "-image"); | ||
102 | } | ||
103 | |||
104 | // If no color was found, look up the shared border color | ||
105 | if(!color && !image) | ||
106 | { | ||
107 | if(el.elementModel.stroke) | ||
108 | { | ||
109 | return el.elementModel.stroke; | ||
110 | } | ||
111 | color = this.getProperty(el, "border-color"); | ||
112 | image = this.getProperty(el, "border-image"); | ||
101 | } | 113 | } |
102 | // TODO - Need to figure out which border side user wants | ||
103 | // return this.application.ninja.stylesController.getElementStyle(el, "border-color"); | ||
104 | color = this.getProperty(el, "border-color"); | ||
105 | image = this.getProperty(el, "border-image"); | ||
106 | } | 114 | } |
107 | 115 | ||
108 | if(color || image) { | 116 | if(color || image) { |
@@ -120,11 +128,15 @@ var ElementController = exports.ElementController = Montage.create(NJComponent, | |||
120 | { | 128 | { |
121 | el.elementModel.fill = colorObj; | 129 | el.elementModel.fill = colorObj; |
122 | } | 130 | } |
123 | else | 131 | else if(!borderSide) |
124 | { | 132 | { |
125 | // TODO - Need to update border style and width also | 133 | // TODO - Need to update border style and width also |
126 | el.elementModel.stroke = colorObj; | 134 | el.elementModel.stroke = colorObj; |
127 | } | 135 | } |
136 | else | ||
137 | { | ||
138 | // TODO - Should update specific border sides too | ||
139 | } | ||
128 | 140 | ||
129 | return colorObj; | 141 | return colorObj; |
130 | } | 142 | } |
diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 127f73e1..d62fa1f8 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js | |||
@@ -459,13 +459,12 @@ exports.ElementMediator = Montage.create(NJComponent, { | |||
459 | 459 | ||
460 | //-------------------------------------------------------------------------------------------------------- | 460 | //-------------------------------------------------------------------------------------------------------- |
461 | // Routines to get/set color | 461 | // Routines to get/set color |
462 | // for now just return the bg/fill color | ||
463 | getColor: { | 462 | getColor: { |
464 | value: function(el, isFill) { | 463 | value: function(el, isFill, borderSide) { |
465 | if(!el.elementModel) { | 464 | if(!el.elementModel) { |
466 | NJUtils.makeModelFromElement(el); | 465 | NJUtils.makeModelFromElement(el); |
467 | } | 466 | } |
468 | return el.elementModel.controller["getColor"](el, isFill); | 467 | return el.elementModel.controller["getColor"](el, isFill, borderSide); |
469 | } | 468 | } |
470 | }, | 469 | }, |
471 | 470 | ||
@@ -621,16 +620,6 @@ exports.ElementMediator = Montage.create(NJComponent, { | |||
621 | } | 620 | } |
622 | }, | 621 | }, |
623 | 622 | ||
624 | getColor2: { | ||
625 | value: function(el, prop, mutator) { | ||
626 | if(!el.elementModel) { | ||
627 | NJUtils.makeModelFromElement(el); | ||
628 | } | ||
629 | |||
630 | return this.getColor(el, (prop === "background")); | ||
631 | } | ||
632 | }, | ||
633 | |||
634 | //-------------------------------------------------------------------------------------------------------- | 623 | //-------------------------------------------------------------------------------------------------------- |
635 | // Routines to get/set 3D properties | 624 | // Routines to get/set 3D properties |
636 | get3DProperty: { | 625 | get3DProperty: { |
diff --git a/js/models/color-model.js b/js/models/color-model.js index 2c86422f..4189fbef 100755 --- a/js/models/color-model.js +++ b/js/models/color-model.js | |||
@@ -574,6 +574,9 @@ exports.ColorModel = Montage.create(Component, { | |||
574 | temp = this.hslToRgb(color.h/360, color.s/100, color.l/100); | 574 | temp = this.hslToRgb(color.h/360, color.s/100, color.l/100); |
575 | } else if (color.r !== undefined) { | 575 | } else if (color.r !== undefined) { |
576 | temp = color; | 576 | temp = color; |
577 | } else if (color.gradientMode) { | ||
578 | // TODO - Need to handle gradients at some point | ||
579 | return null; | ||
577 | } | 580 | } |
578 | temp.a = color.a; | 581 | temp.a = color.a; |
579 | } | 582 | } |
diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js index eb9faa8b..947d7937 100755 --- a/js/panels/properties.reel/properties.js +++ b/js/panels/properties.reel/properties.js | |||
@@ -302,13 +302,15 @@ exports.Properties = Montage.create(Component, { | |||
302 | } | 302 | } |
303 | else | 303 | else |
304 | { | 304 | { |
305 | currentValue = ElementsMediator.getColor2(el, control.prop, control.valueMutator); | ||
306 | if(control.prop === "border") | 305 | if(control.prop === "border") |
307 | { | 306 | { |
307 | // TODO - For now, always return the top border if multiple border sides | ||
308 | currentValue = ElementsMediator.getColor(el, false, "top"); | ||
308 | this.application.ninja.colorController.colorModel.input = "stroke"; | 309 | this.application.ninja.colorController.colorModel.input = "stroke"; |
309 | } | 310 | } |
310 | else if(control.prop === "background") | 311 | else if(control.prop === "background") |
311 | { | 312 | { |
313 | currentValue = ElementsMediator.getColor(el, true); | ||
312 | this.application.ninja.colorController.colorModel.input = "fill"; | 314 | this.application.ninja.colorController.colorModel.input = "fill"; |
313 | } | 315 | } |
314 | 316 | ||
diff --git a/js/tools/EyedropperTool.js b/js/tools/EyedropperTool.js index 6e71c693..927b86cf 100755 --- a/js/tools/EyedropperTool.js +++ b/js/tools/EyedropperTool.js | |||
@@ -152,10 +152,14 @@ exports.EyedropperTool = Montage.create(toolBase, { | |||
152 | { | 152 | { |
153 | color = this.application.ninja.colorController.getColorObjFromCss(c); | 153 | color = this.application.ninja.colorController.getColorObjFromCss(c); |
154 | } | 154 | } |
155 | else | 155 | else if(c.mode !== "gradient") |
156 | { | 156 | { |
157 | color = this.application.ninja.colorController.getColorObjFromCss(c.color.css); | 157 | color = this.application.ninja.colorController.getColorObjFromCss(c.color.css); |
158 | } | 158 | } |
159 | else | ||
160 | { | ||
161 | color = c; | ||
162 | } | ||
159 | } | 163 | } |
160 | 164 | ||
161 | this._updateColor(color, false); | 165 | this._updateColor(color, false); |
@@ -175,7 +179,8 @@ exports.EyedropperTool = Montage.create(toolBase, { | |||
175 | if(updateColorToolBar) | 179 | if(updateColorToolBar) |
176 | { | 180 | { |
177 | eventType = "change"; | 181 | eventType = "change"; |
178 | if (color && color.value) | 182 | // TODO - Color chips in toolbar doesn't support gradients yet |
183 | if (color && color.value && (color.mode !== "gradient")) | ||
179 | { | 184 | { |
180 | var input = this.application.ninja.colorController.colorModel.input; | 185 | var input = this.application.ninja.colorController.colorModel.input; |
181 | 186 | ||
@@ -295,10 +300,10 @@ exports.EyedropperTool = Montage.create(toolBase, { | |||
295 | x = tmpPt[0]; | 300 | x = tmpPt[0]; |
296 | y = tmpPt[1]; | 301 | y = tmpPt[1]; |
297 | 302 | ||
298 | if(x < innerBounds[0][0]) return ElementsMediator.getProperty(elt, "border-left-color"); | 303 | if(x < innerBounds[0][0]) return ElementsMediator.getColor(elt, false, "left"); |
299 | if(x > innerBounds[2][0]) return ElementsMediator.getProperty(elt, "border-right-color"); | 304 | if(x > innerBounds[2][0]) return ElementsMediator.getColor(elt, false, "right"); |
300 | if(y < innerBounds[0][1]) return ElementsMediator.getProperty(elt, "border-top-color"); | 305 | if(y < innerBounds[0][1]) return ElementsMediator.getColor(elt, false, "top"); |
301 | if(y > innerBounds[1][1]) return ElementsMediator.getProperty(elt, "border-bottom-color"); | 306 | if(y > innerBounds[1][1]) return ElementsMediator.getColor(elt, false, "bottom"); |
302 | } |