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>
This commit is contained in:
Shilpa Singh 2015-11-09 12:23:46 -08:00 committed by Cedric BAIL
parent 8ffd8d190d
commit 8f3e250418
3 changed files with 202 additions and 15 deletions

View File

@ -114,25 +114,29 @@ test_colorselector(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
evas_object_show(fr);
cs = elm_colorselector_add(fr);
item = elm_colorselector_palette_color_add(cs, 255, 90, 18, 128);
item = elm_colorselector_palette_color_add(cs, 0, 0, 0, 255);
elm_colorselector_palette_item_selected_set(item, EINA_TRUE);
elm_colorselector_palette_color_add(cs, 255, 213, 0, 255);
elm_colorselector_palette_color_add(cs, 146, 255, 11, 255);
elm_colorselector_palette_color_add(cs, 9, 186, 10, 255);
elm_colorselector_palette_color_add(cs, 86, 201, 242, 255);
elm_colorselector_palette_color_add(cs, 18, 83, 128, 255);
elm_colorselector_palette_color_add(cs, 140, 53, 238, 255);
elm_colorselector_palette_color_add(cs, 255, 145, 145, 255);
elm_colorselector_palette_color_add(cs, 255, 59, 119, 255);
elm_colorselector_palette_color_add(cs, 133, 100, 69, 255);
elm_colorselector_palette_color_add(cs, 255, 255, 119, 255);
elm_colorselector_palette_color_add(cs, 133, 100, 255, 255);
elm_colorselector_palette_color_add(cs, 255, 255, 255, 255);
elm_colorselector_palette_color_add(cs, 255, 0, 0, 255);
elm_colorselector_palette_color_add(cs, 0, 255, 0, 255);
elm_colorselector_palette_color_add(cs, 0, 0, 255, 255);
elm_colorselector_palette_color_add(cs, 255, 255, 0, 255);
elm_colorselector_palette_color_add(cs, 0, 255, 255, 255);
elm_colorselector_palette_color_add(cs, 255, 0, 255, 255);
elm_colorselector_palette_color_add(cs, 192, 192, 192, 255);
elm_colorselector_palette_color_add(cs, 128, 128, 128, 255);
elm_colorselector_palette_color_add(cs, 128, 0, 0, 255);
elm_colorselector_palette_color_add(cs, 128, 128, 0, 255);
elm_colorselector_palette_color_add(cs, 0, 128, 0, 255);
elm_colorselector_palette_color_add(cs, 128, 0, 128, 255);
elm_colorselector_palette_color_add(cs, 0, 128, 128, 255);
elm_colorselector_palette_color_add(cs, 0, 100, 128, 255);
item_list = elm_colorselector_palette_items_get(cs);
last_item_list = eina_list_last(item_list);
color_item = eina_list_data_get(last_item_list);
elm_colorselector_palette_item_color_set(color_item, 255, 0, 0, 255);
elm_colorselector_palette_item_color_set(color_item, 0, 0, 128, 255);
a = 180;
r = 255;

View File

@ -39,6 +39,149 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] =
{NULL, NULL}
};
static const Elm_Color_Name _color_name[] = {
{{0, 0, 0, 255}, "black"},
{{0, 0, 128, 255}, "navy"},
{{0, 0, 139, 255}, "darkblue"},
{{0, 0, 205, 255}, "mediumblue"},
{{0, 0, 255, 255}, "blue"},
{{0, 100, 0, 255}, "darkgreen"},
{{0, 128, 0, 255}, "green"},
{{0, 128, 128, 255}, "teal"},
{{0, 139, 139, 255}, "darkcyan"},
{{0, 191, 255, 255}, "deepskyblue"},
{{0, 206, 209, 255}, "darkturquoise"},
{{0, 250, 154, 255}, "mediumspringgreen"},
{{0, 255, 0, 255}, "lime"},
{{0, 255, 127, 255}, "springgreen"},
{{0, 255, 255, 255}, "aqua"},
{{0, 255, 255, 255}, "cyan"},
{{25, 25, 112, 255}, "midnightblue"},
{{30, 144, 255, 255}, "dodgerblue"},
{{32, 178, 170, 255}, "lightseagreen"},
{{34, 139, 34, 255}, "forestgreen"},
{{46, 139, 87, 255}, "seagreen"},
{{47, 79, 79, 255}, "darkslategrey"},
{{50, 205, 50, 255}, "limegreen"},
{{60, 179, 113, 255}, "mediumseagreen"},
{{64, 224, 208, 255}, "turquoise"},
{{65, 105, 225, 255}, "royalblue"},
{{70, 130, 180, 255}, "steelblue"},
{{72, 61, 139, 255}, "darkslateblue"},
{{72, 209, 204, 255}, "mediumturquoise"},
{{75, 0, 130, 255}, "indigo"},
{{85, 107, 47, 255}, "darkolivegreen"},
{{95, 158, 160, 255}, "cadetblue"},
{{100, 149, 237, 255}, "cornflowerblue"},
{{102, 205, 170, 255}, "mediumaquamarine"},
{{105, 105, 105, 255}, "dimgrey"},
{{106, 90, 205, 255}, "slateblue"},
{{107, 142, 35, 255}, "olivedrab"},
{{112, 128, 144, 255}, "slategrey"},
{{119, 136, 153, 255}, "lightslategrey"},
{{123, 104, 238, 255}, "mediumslateblue"},
{{124, 252, 0, 255}, "lawngreen"},
{{127, 255, 0, 255}, "chartreuse"},
{{127, 255, 212, 255}, "aquamarine"},
{{128, 0, 0, 255}, "maroon"},
{{128, 0, 128, 255}, "purple"},
{{128, 128, 0, 255}, "olive"},
{{128, 128, 128, 255}, "grey"},
{{135, 206, 235, 255}, "skyblue"},
{{135, 206, 250, 255}, "lightskyblue"},
{{138, 43, 226, 255}, "blueviolet"},
{{139, 0, 0, 255}, "darkred"},
{{139, 0, 139, 255}, "darkmagenta"},
{{139, 69, 19, 255}, "saddlebrown"},
{{143, 188, 143, 255}, "darkseagreen"},
{{144, 238, 144, 255}, "lightgreen"},
{{147, 112, 219, 255}, "mediumpurple"},
{{148, 0, 211, 255}, "darkviolet"},
{{152, 251, 152, 255}, "palegreen"},
{{153, 50, 204, 255}, "darkorchid"},
{{154, 205, 50, 255}, "yellowgreen"},
{{160, 82, 45, 255}, "sienna"},
{{165, 42, 42, 255}, "brown"},
{{169, 169, 169, 255}, "darkgrey"},
{{173, 216, 230, 255}, "lightblue"},
{{173, 255, 47, 255}, "greenyellow"},
{{175, 238, 238, 255}, "paleturquoise"},
{{176, 196, 222, 255}, "lightsteelblue"},
{{176, 224, 230, 255}, "powderblue"},
{{178, 34, 34, 255}, "firebrick"},
{{184, 134, 11, 255}, "darkgoldenrod"},
{{186, 85, 211, 255}, "mediumorchid"},
{{188, 143, 143, 255}, "rosybrown"},
{{189, 183, 107, 255}, "darkkhaki"},
{{192, 192, 192, 255}, "silver"},
{{199, 21, 133, 255}, "mediumvioletred"},
{{205, 92, 92, 255}, "indianred"},
{{205, 133, 63, 255}, "peru"},
{{210, 105, 30, 255}, "chocolate"},
{{210, 180, 140, 255}, "tan"},
{{211, 211, 211, 255}, "lightgrey"},
{{216, 191, 216, 255}, "thistle"},
{{218, 112, 214, 255}, "orchid"},
{{218, 165, 32, 255}, "goldenrod"},
{{219, 112, 147, 255}, "palevioletred"},
{{220, 20, 60, 255}, "crimson"},
{{220, 220, 220, 255}, "gainsboro"},
{{221, 160, 221, 255}, "plum"},
{{222, 184, 135, 255}, "burlywood"},
{{224, 255, 255, 255}, "lightcyan"},
{{230, 230, 250, 255}, "lavender"},
{{233, 150, 122, 255}, "darksalmon"},
{{238, 130, 238, 255}, "violet"},
{{238, 232, 170, 255}, "palegoldenrod"},
{{240, 128, 128, 255}, "lightcoral"},
{{240, 230, 140, 255}, "khaki"},
{{240, 248, 255, 255}, "aliceblue"},
{{240, 255, 255, 255}, "azure"},
{{240, 255, 240, 255}, "honeydew"},
{{244, 164, 96, 255}, "sandybrown"},
{{245, 222, 179, 255}, "wheat"},
{{245, 245, 220, 255}, "beige"},
{{245, 245, 245, 255}, "whitesmoke"},
{{245, 255, 250, 255}, "mintcream"},
{{248, 248, 255, 255}, "ghostwhite"},
{{250, 235, 215, 255}, "antiquewhite"},
{{250, 128, 114, 255}, "salmon"},
{{250, 250, 210, 255}, "lightgoldenrodyellow"},
{{250, 240, 230, 255}, "linen"},
{{253, 245, 230, 255}, "oldlace"},
{{255, 0, 0, 255}, "red"},
{{255, 0, 255, 255}, "fuchsia"},
{{255, 0, 255, 255}, "magenta"},
{{255, 20, 147, 255}, "deeppink"},
{{255, 69, 0, 255}, "orangered"},
{{255, 99, 71, 255}, "tomato"},
{{255, 105, 180, 255}, "hotpink"},
{{255, 127, 80, 255}, "coral"},
{{255, 140, 0, 255}, "darkorange"},
{{255, 160, 122, 255}, "lightsalmon"},
{{255, 165, 0, 255}, "orange"},
{{255, 182, 193, 255}, "lightpink "},
{{255, 192, 203, 255}, "pink"},
{{255, 215, 0, 255}, "gold"},
{{255, 218, 185, 255}, "peachpuff"},
{{255, 222, 173, 255}, "navajowhite"},
{{255, 228, 181, 255}, "moccasin"},
{{255, 228, 196, 255}, "bisque"},
{{255, 228, 225, 255}, "mistyrose"},
{{255, 235, 205, 255}, "blanchedalmond"},
{{255, 239, 213, 255}, "papayawhip"},
{{255, 240, 245, 255}, "lavenderblush"},
{{255, 245, 238, 255}, "seashell"},
{{255, 248, 220, 255}, "cornsilk"},
{{255, 250, 205, 255}, "lemonchiffon"},
{{255, 250, 240, 255}, "floralwhite"},
{{255, 255, 0, 255}, "yellow"},
{{255, 255, 224, 255}, "lightyellow"},
{{255, 255, 240, 255}, "ivory"},
{{255, 250, 250, 255}, "snow"},
{{255, 255, 255, 255}, "white"}
};
static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
static const Elm_Action key_actions[] = {
@ -52,6 +195,34 @@ enum Palette_Box_Direction
PALETTE_BOX_DOWN
};
static const char *
_get_color_name (unsigned int R, unsigned int G, unsigned int B, unsigned int A)
{
unsigned int low, mid, high;
unsigned int r, g, b;
if (A != 255) return NULL;
low = 0;
high = sizeof(_color_name)/ sizeof(_color_name[0]);
while (low <= high)
{
mid = (low + high) / 2;
r = _color_name[mid].color.r;
g = _color_name[mid].color.g;
b = _color_name[mid].color.b;
if (r == R && g == G && B == b)
return _color_name[mid].name;
if ((r < R) || ((r == R) && (g < G)) || ((r == R) && (g == G) && b < B))
low = mid + 1;
else
high = mid-1;
}
return NULL;
}
static void
_items_del(Elm_Colorselector_Data *sd)
{
@ -1461,7 +1632,8 @@ _access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
{
char *ret;
Eina_Strbuf *buf;
int r = 0, g = 0, b = 0 ,a = 0;
const char *color_name = NULL;
int r = 0, g = 0, b = 0, a = 0;
Elm_Color_Item_Data *it = data;
ELM_COLORSELECTOR_ITEM_CHECK_OR_RETURN(it, NULL);
@ -1469,7 +1641,11 @@ _access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
elm_colorselector_palette_item_color_get(EO_OBJ(it), &r, &g, &b, &a);
buf = eina_strbuf_new();
eina_strbuf_append_printf(buf, "red %d, green %d, blue %d, alpha %d", r, g, b, a);
color_name = _get_color_name(r, g, b, a);
if (color_name)
eina_strbuf_append_printf(buf, "%s", color_name);
else
eina_strbuf_append_printf(buf, "red %d, green %d, blue %d, alpha %d", r, g, b, a);
ret = eina_strbuf_string_steal(buf);
eina_strbuf_free(buf);
return ret;

View File

@ -100,6 +100,13 @@ struct _Elm_Color_Item_Data
Eina_Bool still_in : 1;
};
typedef struct _Elm_Color_Name Elm_Color_Name;
struct _Elm_Color_Name
{
Elm_Color_RGBA color;
const char *name;
};
/**
* @}
*/