forked from enlightenment/efl
make colorselector set colors correctly (premul argb) and not mess entries
This commit is contained in:
parent
508786cfb2
commit
b2ee9057a0
|
@ -50,9 +50,7 @@ _palette_cb(void *data, Evas_Object *obj __UNUSED__,
|
|||
void *event_info __UNUSED__)
|
||||
{
|
||||
Evas_Object *cs = data;
|
||||
Evas_Object *win = evas_object_data_get(cs, "win");
|
||||
elm_colorselector_mode_set(cs, ELM_COLORSELECTOR_PALETTE);
|
||||
evas_object_resize(win, 320, 300);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -60,27 +58,28 @@ _components_cb(void *data, Evas_Object *obj __UNUSED__,
|
|||
void *event_info __UNUSED__)
|
||||
{
|
||||
Evas_Object *cs = data;
|
||||
Evas_Object *win = evas_object_data_get(cs, "win");
|
||||
elm_colorselector_mode_set(cs, ELM_COLORSELECTOR_COMPONENTS);
|
||||
evas_object_resize(win, 320, 455);
|
||||
}
|
||||
|
||||
static void
|
||||
_both_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
Evas_Object *cs = data;
|
||||
Evas_Object *win = evas_object_data_get(cs, "win");
|
||||
elm_colorselector_mode_set(cs, ELM_COLORSELECTOR_BOTH);
|
||||
evas_object_resize(win, 320, 550);
|
||||
}
|
||||
|
||||
static void
|
||||
_picker_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
Evas_Object *cs = data;
|
||||
Evas_Object *win = evas_object_data_get(cs, "win");
|
||||
elm_colorselector_mode_set(cs, ELM_COLORSELECTOR_PICKER);
|
||||
evas_object_resize(win, 320, 430);
|
||||
}
|
||||
|
||||
static void
|
||||
_all_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
Evas_Object *cs = data;
|
||||
elm_colorselector_mode_set(cs, ELM_COLORSELECTOR_ALL);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -118,7 +117,7 @@ test_colorselector(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
|
|||
evas_object_show(fr);
|
||||
|
||||
cs = elm_colorselector_add(fr);
|
||||
elm_colorselector_palette_color_add(cs, 255, 90, 18, 255);
|
||||
elm_colorselector_palette_color_add(cs, 255, 90, 18, 128);
|
||||
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);
|
||||
|
@ -194,7 +193,14 @@ test_colorselector(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
|
|||
evas_object_show(bt);
|
||||
elm_box_pack_end(bx2, bt);
|
||||
|
||||
evas_object_resize(win, 320, 550);
|
||||
bt = elm_button_add(bx2);
|
||||
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_smart_callback_add(bt, "clicked", _all_cb, cs);
|
||||
elm_object_text_set(bt, "All");
|
||||
evas_object_show(bt);
|
||||
elm_box_pack_end(bx2, bt);
|
||||
|
||||
evas_object_show(win);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -107,21 +107,33 @@ _color_picker_init(Elm_Colorselector_Smart_Data *sd)
|
|||
int color;
|
||||
int x, y, w, h;
|
||||
|
||||
snprintf(buf, 12, "%i", sd->r);
|
||||
elm_object_text_set(sd->entries[0], buf);
|
||||
if (!evas_object_data_get(sd->entries[0], "_changed"))
|
||||
{
|
||||
snprintf(buf, 12, "%i", sd->r);
|
||||
elm_object_text_set(sd->entries[0], buf);
|
||||
}
|
||||
if (!evas_object_data_get(sd->entries[1], "_changed"))
|
||||
{
|
||||
snprintf(buf, 12, "%i", sd->g);
|
||||
elm_object_text_set(sd->entries[1], buf);
|
||||
}
|
||||
if (!evas_object_data_get(sd->entries[2], "_changed"))
|
||||
{
|
||||
snprintf(buf, 12, "%i", sd->b);
|
||||
elm_object_text_set(sd->entries[2], buf);
|
||||
}
|
||||
if (!evas_object_data_get(sd->entries[3], "_changed"))
|
||||
{
|
||||
snprintf(buf, 12, "%i", sd->a);
|
||||
elm_object_text_set(sd->entries[3], buf);
|
||||
}
|
||||
|
||||
snprintf(buf, 12, "%i", sd->g);
|
||||
elm_object_text_set(sd->entries[1], buf);
|
||||
color = (sd->a << 24) |
|
||||
(((sd->r * sd->a) / 255) << 16) |
|
||||
(((sd->g * sd->a) / 255) << 8) |
|
||||
(((sd->b * sd->a) / 255));
|
||||
|
||||
snprintf(buf, 12, "%i", sd->b);
|
||||
elm_object_text_set(sd->entries[2], buf);
|
||||
|
||||
snprintf(buf, 12, "%i", sd->a);
|
||||
elm_object_text_set(sd->entries[3], buf);
|
||||
|
||||
color = (sd->a << 24) + (sd->r << 16) + (sd->g << 8) + sd->b;
|
||||
|
||||
if (sd->b == 255)
|
||||
if (sd->a == 255)
|
||||
evas_object_image_alpha_set(sd->picker_display, EINA_FALSE);
|
||||
else
|
||||
evas_object_image_alpha_set(sd->picker_display, EINA_TRUE);
|
||||
|
@ -129,10 +141,12 @@ _color_picker_init(Elm_Colorselector_Smart_Data *sd)
|
|||
pixels = evas_object_image_data_get(sd->picker_display, EINA_TRUE);
|
||||
copy = pixels;
|
||||
for (y = 0; y < 17; y++)
|
||||
for (x = 0; x < 17; x++)
|
||||
{
|
||||
*(pixels++) = color;
|
||||
}
|
||||
{
|
||||
for (x = 0; x < 17; x++)
|
||||
{
|
||||
*(pixels++) = color;
|
||||
}
|
||||
}
|
||||
evas_object_image_data_set(sd->picker_display, copy);
|
||||
evas_object_geometry_get(sd->picker_display, NULL, NULL, &w, &h);
|
||||
evas_object_image_data_update_add(sd->picker_display, 0, 0, w, h);
|
||||
|
@ -444,17 +458,16 @@ _entry_changed_cb(void *data,
|
|||
Elm_Colorselector_Smart_Data *sd = data;
|
||||
Evas_Object *parent;
|
||||
const char *text;
|
||||
int i;
|
||||
int v;
|
||||
int i, v;
|
||||
|
||||
for (i = 0; i < 4 && sd->entries[i] != obj; i++)
|
||||
;
|
||||
for (i = 0; i < 4 && sd->entries[i] != obj; i++);
|
||||
|
||||
parent = evas_object_data_get(obj, "parent");
|
||||
text = elm_object_text_get(obj);
|
||||
v = atoi(text);
|
||||
if (v > 255) v = 255;
|
||||
else if (v < 0) v = 0;
|
||||
evas_object_data_set(obj, "_changed", obj);
|
||||
|
||||
switch (i)
|
||||
{
|
||||
|
@ -471,6 +484,7 @@ _entry_changed_cb(void *data,
|
|||
_colors_set(parent, sd->r, sd->g, sd->b, v);
|
||||
break;
|
||||
}
|
||||
evas_object_data_del(obj, "_changed");
|
||||
}
|
||||
|
||||
#ifdef HAVE_ELEMENTARY_X
|
||||
|
@ -1457,9 +1471,11 @@ _palette_colors_load(Evas_Object *obj)
|
|||
item->color->a = color->a;
|
||||
|
||||
elm_box_pack_end(sd->palette_box, VIEW(item));
|
||||
evas_object_color_set
|
||||
(item->color_obj, item->color->r, item->color->g, item->color->b,
|
||||
item->color->a);
|
||||
evas_object_color_set(item->color_obj,
|
||||
(item->color->r * item->color->a) / 255,
|
||||
(item->color->g * item->color->a) / 255,
|
||||
(item->color->b * item->color->a) / 255,
|
||||
item->color->a);
|
||||
|
||||
sd->items = eina_list_append(sd->items, item);
|
||||
}
|
||||
|
@ -1517,6 +1533,8 @@ _elm_colorselector_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
|
|||
elm_widget_style_get(obj));
|
||||
elm_layout_content_set(obj, "selector", priv->col_bars_area);
|
||||
|
||||
elm_layout_signal_emit(obj, "elm,state,both", "elm");
|
||||
|
||||
/* setup the color picker */
|
||||
priv->picker = elm_box_add(obj);
|
||||
elm_box_horizontal_set(priv->picker, EINA_TRUE);
|
||||
|
@ -2028,10 +2046,11 @@ elm_colorselector_palette_item_color_set(Elm_Object_Item *it,
|
|||
item->color->g = g;
|
||||
item->color->b = b;
|
||||
item->color->a = a;
|
||||
evas_object_color_set
|
||||
(item->color_obj, item->color->r, item->color->g, item->color->b,
|
||||
item->color->a);
|
||||
|
||||
evas_object_color_set(item->color_obj,
|
||||
(item->color->r * item->color->a) / 255,
|
||||
(item->color->g * item->color->a) / 255,
|
||||
(item->color->b * item->color->a) / 255,
|
||||
item->color->a);
|
||||
_colors_save(WIDGET(it));
|
||||
}
|
||||
|
||||
|
@ -2082,9 +2101,11 @@ _palette_color_add(Eo *obj, void *_pd, va_list *list)
|
|||
item->color->a);
|
||||
|
||||
elm_box_pack_end(sd->palette_box, VIEW(item));
|
||||
evas_object_color_set
|
||||
(item->color_obj, item->color->r, item->color->g, item->color->b,
|
||||
item->color->a);
|
||||
evas_object_color_set(item->color_obj,
|
||||
(item->color->r * item->color->a) / 255,
|
||||
(item->color->g * item->color->a) / 255,
|
||||
(item->color->b * item->color->a) / 255,
|
||||
item->color->a);
|
||||
|
||||
sd->items = eina_list_append(sd->items, item);
|
||||
|
||||
|
|
Loading…
Reference in New Issue