summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShilpa Singh <shilpa.singh@samsung.com>2015-11-09 12:23:46 -0800
committerCedric BAIL <cedric@osg.samsung.com>2015-11-09 12:37:09 -0800
commit8ee1ea87201464aa46d1af5bd5d8ea8417789823 (patch)
tree9666776fce0419d280bf6baa611d4e3b2121a91e
parentf5e0859fe2b347ed4119d606f5bdfaed75710a67 (diff)
colorselector: read color names instead of RGBA when accessibility is set
Summary: Issue: When accessibility is set, individual color item's RGBA values are read instead of actual color names. Solution: Read color names by matching the color RGBA from the array. Test Plan: enable accessibility run elementary test select colorselector demo click on individual color palette items Reviewers: cedric Reviewed By: cedric Differential Revision: https://phab.enlightenment.org/D3240 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/bin/test_colorselector.c30
-rw-r--r--src/lib/elm_colorselector.c180
-rw-r--r--src/lib/elm_widget_colorselector.h7
3 files changed, 202 insertions, 15 deletions
diff --git a/src/bin/test_colorselector.c b/src/bin/test_colorselector.c
index 2a86f744a..d1a6febeb 100644
--- a/src/bin/test_colorselector.c
+++ b/src/bin/test_colorselector.c
@@ -114,25 +114,29 @@ test_colorselector(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
114 evas_object_show(fr); 114 evas_object_show(fr);
115 115
116 cs = elm_colorselector_add(fr); 116 cs = elm_colorselector_add(fr);
117 item = elm_colorselector_palette_color_add(cs, 255, 90, 18, 128); 117 item = elm_colorselector_palette_color_add(cs, 0, 0, 0, 255);
118 elm_colorselector_palette_item_selected_set(item, EINA_TRUE); 118 elm_colorselector_palette_item_selected_set(item, EINA_TRUE);
119 119
120 elm_colorselector_palette_color_add(cs, 255, 213, 0, 255); 120 elm_colorselector_palette_color_add(cs, 255, 255, 255, 255);
121 elm_colorselector_palette_color_add(cs, 146, 255, 11, 255); 121 elm_colorselector_palette_color_add(cs, 255, 0, 0, 255);
122 elm_colorselector_palette_color_add(cs, 9, 186, 10, 255); 122 elm_colorselector_palette_color_add(cs, 0, 255, 0, 255);
123 elm_colorselector_palette_color_add(cs, 86, 201, 242, 255); 123 elm_colorselector_palette_color_add(cs, 0, 0, 255, 255);
124 elm_colorselector_palette_color_add(cs, 18, 83, 128, 255); 124 elm_colorselector_palette_color_add(cs, 255, 255, 0, 255);
125 elm_colorselector_palette_color_add(cs, 140, 53, 238, 255); 125 elm_colorselector_palette_color_add(cs, 0, 255, 255, 255);
126 elm_colorselector_palette_color_add(cs, 255, 145, 145, 255); 126 elm_colorselector_palette_color_add(cs, 255, 0, 255, 255);
127 elm_colorselector_palette_color_add(cs, 255, 59, 119, 255); 127 elm_colorselector_palette_color_add(cs, 192, 192, 192, 255);
128 elm_colorselector_palette_color_add(cs, 133, 100, 69, 255); 128 elm_colorselector_palette_color_add(cs, 128, 128, 128, 255);
129 elm_colorselector_palette_color_add(cs, 255, 255, 119, 255); 129 elm_colorselector_palette_color_add(cs, 128, 0, 0, 255);
130 elm_colorselector_palette_color_add(cs, 133, 100, 255, 255); 130 elm_colorselector_palette_color_add(cs, 128, 128, 0, 255);
131 elm_colorselector_palette_color_add(cs, 0, 128, 0, 255);
132 elm_colorselector_palette_color_add(cs, 128, 0, 128, 255);
133 elm_colorselector_palette_color_add(cs, 0, 128, 128, 255);
134 elm_colorselector_palette_color_add(cs, 0, 100, 128, 255);
131 135
132 item_list = elm_colorselector_palette_items_get(cs); 136 item_list = elm_colorselector_palette_items_get(cs);
133 last_item_list = eina_list_last(item_list); 137 last_item_list = eina_list_last(item_list);
134 color_item = eina_list_data_get(last_item_list); 138 color_item = eina_list_data_get(last_item_list);
135 elm_colorselector_palette_item_color_set(color_item, 255, 0, 0, 255); 139 elm_colorselector_palette_item_color_set(color_item, 0, 0, 128, 255);
136 140
137 a = 180; 141 a = 180;
138 r = 255; 142 r = 255;
diff --git a/src/lib/elm_colorselector.c b/src/lib/elm_colorselector.c
index b70544b68..d919e7ba1 100644
--- a/src/lib/elm_colorselector.c
+++ b/src/lib/elm_colorselector.c
@@ -39,6 +39,149 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] =
39 {NULL, NULL} 39 {NULL, NULL}
40}; 40};
41 41
42static const Elm_Color_Name _color_name[] = {
43 {{0, 0, 0, 255}, "black"},
44 {{0, 0, 128, 255}, "navy"},
45 {{0, 0, 139, 255}, "darkblue"},
46 {{0, 0, 205, 255}, "mediumblue"},
47 {{0, 0, 255, 255}, "blue"},
48 {{0, 100, 0, 255}, "darkgreen"},
49 {{0, 128, 0, 255}, "green"},
50 {{0, 128, 128, 255}, "teal"},
51 {{0, 139, 139, 255}, "darkcyan"},
52 {{0, 191, 255, 255}, "deepskyblue"},
53 {{0, 206, 209, 255}, "darkturquoise"},
54 {{0, 250, 154, 255}, "mediumspringgreen"},
55 {{0, 255, 0, 255}, "lime"},
56 {{0, 255, 127, 255}, "springgreen"},
57 {{0, 255, 255, 255}, "aqua"},
58 {{0, 255, 255, 255}, "cyan"},
59 {{25, 25, 112, 255}, "midnightblue"},
60 {{30, 144, 255, 255}, "dodgerblue"},
61 {{32, 178, 170, 255}, "lightseagreen"},
62 {{34, 139, 34, 255}, "forestgreen"},
63 {{46, 139, 87, 255}, "seagreen"},
64 {{47, 79, 79, 255}, "darkslategrey"},
65 {{50, 205, 50, 255}, "limegreen"},
66 {{60, 179, 113, 255}, "mediumseagreen"},
67 {{64, 224, 208, 255}, "turquoise"},
68 {{65, 105, 225, 255}, "royalblue"},
69 {{70, 130, 180, 255}, "steelblue"},
70 {{72, 61, 139, 255}, "darkslateblue"},
71 {{72, 209, 204, 255}, "mediumturquoise"},
72 {{75, 0, 130, 255}, "indigo"},
73 {{85, 107, 47, 255}, "darkolivegreen"},
74 {{95, 158, 160, 255}, "cadetblue"},
75 {{100, 149, 237, 255}, "cornflowerblue"},
76 {{102, 205, 170, 255}, "mediumaquamarine"},
77 {{105, 105, 105, 255}, "dimgrey"},
78 {{106, 90, 205, 255}, "slateblue"},
79 {{107, 142, 35, 255}, "olivedrab"},
80 {{112, 128, 144, 255}, "slategrey"},
81 {{119, 136, 153, 255}, "lightslategrey"},
82 {{123, 104, 238, 255}, "mediumslateblue"},
83 {{124, 252, 0, 255}, "lawngreen"},
84 {{127, 255, 0, 255}, "chartreuse"},
85 {{127, 255, 212, 255}, "aquamarine"},
86 {{128, 0, 0, 255}, "maroon"},
87 {{128, 0, 128, 255}, "purple"},
88 {{128, 128, 0, 255}, "olive"},
89 {{128, 128, 128, 255}, "grey"},
90 {{135, 206, 235, 255}, "skyblue"},
91 {{135, 206, 250, 255}, "lightskyblue"},
92 {{138, 43, 226, 255}, "blueviolet"},
93 {{139, 0, 0, 255}, "darkred"},
94 {{139, 0, 139, 255}, "darkmagenta"},
95 {{139, 69, 19, 255}, "saddlebrown"},
96 {{143, 188, 143, 255}, "darkseagreen"},
97 {{144, 238, 144, 255}, "lightgreen"},
98 {{147, 112, 219, 255}, "mediumpurple"},
99 {{148, 0, 211, 255}, "darkviolet"},
100 {{152, 251, 152, 255}, "palegreen"},
101 {{153, 50, 204, 255}, "darkorchid"},
102 {{154, 205, 50, 255}, "yellowgreen"},
103 {{160, 82, 45, 255}, "sienna"},
104 {{165, 42, 42, 255}, "brown"},
105 {{169, 169, 169, 255}, "darkgrey"},
106 {{173, 216, 230, 255}, "lightblue"},
107 {{173, 255, 47, 255}, "greenyellow"},
108 {{175, 238, 238, 255}, "paleturquoise"},
109 {{176, 196, 222, 255}, "lightsteelblue"},
110 {{176, 224, 230, 255}, "powderblue"},
111 {{178, 34, 34, 255}, "firebrick"},
112 {{184, 134, 11, 255}, "darkgoldenrod"},
113 {{186, 85, 211, 255}, "mediumorchid"},
114 {{188, 143, 143, 255}, "rosybrown"},
115 {{189, 183, 107, 255}, "darkkhaki"},
116 {{192, 192, 192, 255}, "silver"},
117 {{199, 21, 133, 255}, "mediumvioletred"},
118 {{205, 92, 92, 255}, "indianred"},
119 {{205, 133, 63, 255}, "peru"},
120 {{210, 105, 30, 255}, "chocolate"},
121 {{210, 180, 140, 255}, "tan"},
122 {{211, 211, 211, 255}, "lightgrey"},
123 {{216, 191, 216, 255}, "thistle"},
124 {{218, 112, 214, 255}, "orchid"},
125 {{218, 165, 32, 255}, "goldenrod"},
126 {{219, 112, 147, 255}, "palevioletred"},
127 {{220, 20, 60, 255}, "crimson"},
128 {{220, 220, 220, 255}, "gainsboro"},
129 {{221, 160, 221, 255}, "plum"},
130 {{222, 184, 135, 255}, "burlywood"},
131 {{224, 255, 255, 255}, "lightcyan"},
132 {{230, 230, 250, 255}, "lavender"},
133 {{233, 150, 122, 255}, "darksalmon"},
134 {{238, 130, 238, 255}, "violet"},
135 {{238, 232, 170, 255}, "palegoldenrod"},
136 {{240, 128, 128, 255}, "lightcoral"},
137 {{240, 230, 140, 255}, "khaki"},
138 {{240, 248, 255, 255}, "aliceblue"},
139 {{240, 255, 255, 255}, "azure"},
140 {{240, 255, 240, 255}, "honeydew"},
141 {{244, 164, 96, 255}, "sandybrown"},
142 {{245, 222, 179, 255}, "wheat"},
143 {{245, 245, 220, 255}, "beige"},
144 {{245, 245, 245, 255}, "whitesmoke"},
145 {{245, 255, 250, 255}, "mintcream"},
146 {{248, 248, 255, 255}, "ghostwhite"},
147 {{250, 235, 215, 255}, "antiquewhite"},
148 {{250, 128, 114, 255}, "salmon"},
149 {{250, 250, 210, 255}, "lightgoldenrodyellow"},
150 {{250, 240, 230, 255}, "linen"},
151 {{253, 245, 230, 255}, "oldlace"},
152 {{255, 0, 0, 255}, "red"},
153 {{255, 0, 255, 255}, "fuchsia"},
154 {{255, 0, 255, 255}, "magenta"},
155 {{255, 20, 147, 255}, "deeppink"},
156 {{255, 69, 0, 255}, "orangered"},
157 {{255, 99, 71, 255}, "tomato"},
158 {{255, 105, 180, 255}, "hotpink"},
159 {{255, 127, 80, 255}, "coral"},
160 {{255, 140, 0, 255}, "darkorange"},
161 {{255, 160, 122, 255}, "lightsalmon"},
162 {{255, 165, 0, 255}, "orange"},
163 {{255, 182, 193, 255}, "lightpink "},
164 {{255, 192, 203, 255}, "pink"},
165 {{255, 215, 0, 255}, "gold"},
166 {{255, 218, 185, 255}, "peachpuff"},
167 {{255, 222, 173, 255}, "navajowhite"},
168 {{255, 228, 181, 255}, "moccasin"},
169 {{255, 228, 196, 255}, "bisque"},
170 {{255, 228, 225, 255}, "mistyrose"},
171 {{255, 235, 205, 255}, "blanchedalmond"},
172 {{255, 239, 213, 255}, "papayawhip"},
173 {{255, 240, 245, 255}, "lavenderblush"},
174 {{255, 245, 238, 255}, "seashell"},
175 {{255, 248, 220, 255}, "cornsilk"},
176 {{255, 250, 205, 255}, "lemonchiffon"},
177 {{255, 250, 240, 255}, "floralwhite"},
178 {{255, 255, 0, 255}, "yellow"},
179 {{255, 255, 224, 255}, "lightyellow"},
180 {{255, 255, 240, 255}, "ivory"},
181 {{255, 250, 250, 255}, "snow"},
182 {{255, 255, 255, 255}, "white"}
183};
184
42static Eina_Bool _key_action_move(Evas_Object *obj, const char *params); 185static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
43 186
44static const Elm_Action key_actions[] = { 187static const Elm_Action key_actions[] = {
@@ -52,6 +195,34 @@ enum Palette_Box_Direction
52 PALETTE_BOX_DOWN 195 PALETTE_BOX_DOWN
53}; 196};
54 197
198static const char *
199_get_color_name (unsigned int R, unsigned int G, unsigned int B, unsigned int A)
200{
201 unsigned int low, mid, high;
202 unsigned int r, g, b;
203
204 if (A != 255) return NULL;
205 low = 0;
206 high = sizeof(_color_name)/ sizeof(_color_name[0]);
207 while (low <= high)
208 {
209 mid = (low + high) / 2;
210
211 r = _color_name[mid].color.r;
212 g = _color_name[mid].color.g;
213 b = _color_name[mid].color.b;
214
215 if (r == R && g == G && B == b)
216 return _color_name[mid].name;
217
218 if ((r < R) || ((r == R) && (g < G)) || ((r == R) && (g == G) && b < B))
219 low = mid + 1;
220 else
221 high = mid-1;
222 }
223 return NULL;
224}
225
55static void 226static void
56_items_del(Elm_Colorselector_Data *sd) 227_items_del(Elm_Colorselector_Data *sd)
57{ 228{
@@ -1461,7 +1632,8 @@ _access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
1461{ 1632{
1462 char *ret; 1633 char *ret;
1463 Eina_Strbuf *buf; 1634 Eina_Strbuf *buf;
1464 int r = 0, g = 0, b = 0 ,a = 0; 1635 const char *color_name = NULL;
1636 int r = 0, g = 0, b = 0, a = 0;
1465 1637
1466 Elm_Color_Item_Data *it = data; 1638 Elm_Color_Item_Data *it = data;
1467 ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it, NULL); 1639 ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it, NULL);
@@ -1469,7 +1641,11 @@ _access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
1469 elm_colorselector_palette_item_color_get(EO_OBJ(it), &r, &g, &b, &a); 1641 elm_colorselector_palette_item_color_get(EO_OBJ(it), &r, &g, &b, &a);
1470 1642
1471 buf = eina_strbuf_new(); 1643 buf = eina_strbuf_new();
1472 eina_strbuf_append_printf(buf, "red %d, green %d, blue %d, alpha %d", r, g, b, a); 1644 color_name = _get_color_name(r, g, b, a);
1645 if (color_name)
1646 eina_strbuf_append_printf(buf, "%s", color_name);
1647 else
1648 eina_strbuf_append_printf(buf, "red %d, green %d, blue %d, alpha %d", r, g, b, a);
1473 ret = eina_strbuf_string_steal(buf); 1649 ret = eina_strbuf_string_steal(buf);
1474 eina_strbuf_free(buf); 1650 eina_strbuf_free(buf);
1475 return ret; 1651 return ret;
diff --git a/src/lib/elm_widget_colorselector.h b/src/lib/elm_widget_colorselector.h
index ba4cc1051..cacb61ca4 100644
--- a/src/lib/elm_widget_colorselector.h
+++ b/src/lib/elm_widget_colorselector.h
@@ -100,6 +100,13 @@ struct _Elm_Color_Item_Data
100 Eina_Bool still_in : 1; 100 Eina_Bool still_in : 1;
101}; 101};
102 102
103typedef struct _Elm_Color_Name Elm_Color_Name;
104struct _Elm_Color_Name
105{
106 Elm_Color_RGBA color;
107 const char *name;
108};
109
103/** 110/**
104 * @} 111 * @}
105 */ 112 */