forked from enlightenment/enlightenment
parent
822776146a
commit
1ee20d2068
|
@ -4,13 +4,13 @@ typedef struct _E_Widget_Data E_Widget_Data;
|
||||||
struct _E_Widget_Data
|
struct _E_Widget_Data
|
||||||
{
|
{
|
||||||
Evas_Object *obj;
|
Evas_Object *obj;
|
||||||
Eina_List *sliders;
|
Eina_List *sliders;
|
||||||
Eina_List *entries;
|
Eina_List *entries;
|
||||||
Evas_Object *spectrum, *vert, *well;
|
Evas_Object *spectrum, *vert, *well;
|
||||||
E_Color *cv;
|
E_Color *cv;
|
||||||
char **values;
|
char **values;
|
||||||
int mode;
|
int mode;
|
||||||
int changing;
|
int changing;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -57,53 +57,58 @@ _e_wid_cb_color_changed(void *data, Evas_Object *o)
|
||||||
/* entry changed */
|
/* entry changed */
|
||||||
EINA_LIST_FOREACH(wd->entries, l, eo)
|
EINA_LIST_FOREACH(wd->entries, l, eo)
|
||||||
{
|
{
|
||||||
if (o == eo)
|
if (o == eo)
|
||||||
{
|
{
|
||||||
changed = i;
|
changed = i;
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case E_COLOR_COMPONENT_R:
|
case E_COLOR_COMPONENT_R:
|
||||||
wd->cv->r = atoi(wd->values[i]);
|
wd->cv->r = atoi(wd->values[i]);
|
||||||
if (wd->cv->r > 255) wd->cv->r = 255;
|
if (wd->cv->r > 255) wd->cv->r = 255;
|
||||||
if (wd->cv->r < 0) wd->cv->r = 0;
|
if (wd->cv->r < 0) wd->cv->r = 0;
|
||||||
break;
|
break;
|
||||||
case E_COLOR_COMPONENT_G:
|
|
||||||
wd->cv->g = atoi(wd->values[i]);
|
case E_COLOR_COMPONENT_G:
|
||||||
if (wd->cv->g > 255) wd->cv->g = 255;
|
wd->cv->g = atoi(wd->values[i]);
|
||||||
if (wd->cv->g < 0) wd->cv->g = 0;
|
if (wd->cv->g > 255) wd->cv->g = 255;
|
||||||
break;
|
if (wd->cv->g < 0) wd->cv->g = 0;
|
||||||
case E_COLOR_COMPONENT_B:
|
break;
|
||||||
wd->cv->b = atoi(wd->values[i]);
|
|
||||||
if (wd->cv->b > 255) wd->cv->b = 255;
|
case E_COLOR_COMPONENT_B:
|
||||||
if (wd->cv->b < 0) wd->cv->b = 0;
|
wd->cv->b = atoi(wd->values[i]);
|
||||||
break;
|
if (wd->cv->b > 255) wd->cv->b = 255;
|
||||||
case E_COLOR_COMPONENT_H:
|
if (wd->cv->b < 0) wd->cv->b = 0;
|
||||||
wd->cv->h = atof(wd->values[i]);
|
break;
|
||||||
if (wd->cv->h > 360) wd->cv->h = 360;
|
|
||||||
if (wd->cv->h < 0) wd->cv->h = 0;
|
case E_COLOR_COMPONENT_H:
|
||||||
break;
|
wd->cv->h = atof(wd->values[i]);
|
||||||
case E_COLOR_COMPONENT_S:
|
if (wd->cv->h > 360) wd->cv->h = 360;
|
||||||
wd->cv->s = atof(wd->values[i]);
|
if (wd->cv->h < 0) wd->cv->h = 0;
|
||||||
if (wd->cv->s > 1) wd->cv->s = 1;
|
break;
|
||||||
if (wd->cv->s < 0) wd->cv->s = 0;
|
|
||||||
break;
|
case E_COLOR_COMPONENT_S:
|
||||||
case E_COLOR_COMPONENT_V:
|
wd->cv->s = atof(wd->values[i]);
|
||||||
wd->cv->v = atof(wd->values[i]);
|
if (wd->cv->s > 1) wd->cv->s = 1;
|
||||||
if (wd->cv->v > 1) wd->cv->v = 1;
|
if (wd->cv->s < 0) wd->cv->s = 0;
|
||||||
if (wd->cv->v < 0) wd->cv->v = 0;
|
break;
|
||||||
break;
|
|
||||||
}
|
case E_COLOR_COMPONENT_V:
|
||||||
break;
|
wd->cv->v = atof(wd->values[i]);
|
||||||
}
|
if (wd->cv->v > 1) wd->cv->v = 1;
|
||||||
i++;
|
if (wd->cv->v < 0) wd->cv->v = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed != -1)
|
if (changed != -1)
|
||||||
{
|
{
|
||||||
if (changed>= E_COLOR_COMPONENT_H)
|
if (changed >= E_COLOR_COMPONENT_H)
|
||||||
e_color_update_hsv(wd->cv);
|
e_color_update_hsv(wd->cv);
|
||||||
else if (changed >= E_COLOR_COMPONENT_R)
|
else if (changed >= E_COLOR_COMPONENT_R)
|
||||||
e_color_update_rgb(wd->cv);
|
e_color_update_rgb(wd->cv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o == wd->vert)
|
if (o == wd->vert)
|
||||||
|
@ -115,22 +120,22 @@ _e_wid_cb_color_changed(void *data, Evas_Object *o)
|
||||||
i = 0;
|
i = 0;
|
||||||
EINA_LIST_FOREACH(wd->sliders, l, so)
|
EINA_LIST_FOREACH(wd->sliders, l, so)
|
||||||
{
|
{
|
||||||
if (o != so)
|
if (o != so)
|
||||||
e_widget_cslider_update(so);
|
e_widget_cslider_update(so);
|
||||||
else
|
else
|
||||||
changed = i;
|
changed = i;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* update the spectrum */
|
/* update the spectrum */
|
||||||
if (o != wd->spectrum && changed != -1)
|
if (o != wd->spectrum && changed != -1)
|
||||||
{
|
{
|
||||||
if (wd->mode == changed ||
|
if (wd->mode == changed ||
|
||||||
(wd->mode >= E_COLOR_COMPONENT_H && changed <= E_COLOR_COMPONENT_B) ||
|
(wd->mode >= E_COLOR_COMPONENT_H && changed <= E_COLOR_COMPONENT_B) ||
|
||||||
(wd->mode <= E_COLOR_COMPONENT_B && changed >= E_COLOR_COMPONENT_H))
|
(wd->mode <= E_COLOR_COMPONENT_B && changed >= E_COLOR_COMPONENT_H))
|
||||||
e_widget_spectrum_update(wd->spectrum, 1);
|
e_widget_spectrum_update(wd->spectrum, 1);
|
||||||
else
|
else
|
||||||
e_widget_spectrum_update(wd->spectrum, 0);
|
e_widget_spectrum_update(wd->spectrum, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
e_widget_color_well_update(wd->well);
|
e_widget_color_well_update(wd->well);
|
||||||
|
@ -139,31 +144,36 @@ _e_wid_cb_color_changed(void *data, Evas_Object *o)
|
||||||
i = 0;
|
i = 0;
|
||||||
EINA_LIST_FOREACH(wd->entries, l, eo)
|
EINA_LIST_FOREACH(wd->entries, l, eo)
|
||||||
{
|
{
|
||||||
char buf[10];
|
char buf[10];
|
||||||
|
|
||||||
if (o == eo) continue;
|
if (o == eo) continue;
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case E_COLOR_COMPONENT_R:
|
case E_COLOR_COMPONENT_R:
|
||||||
snprintf(buf, 10, "%i", wd->cv->r);
|
snprintf(buf, 10, "%i", wd->cv->r);
|
||||||
break;
|
break;
|
||||||
case E_COLOR_COMPONENT_G:
|
|
||||||
snprintf(buf, 10, "%i", wd->cv->g);
|
case E_COLOR_COMPONENT_G:
|
||||||
break;
|
snprintf(buf, 10, "%i", wd->cv->g);
|
||||||
case E_COLOR_COMPONENT_B:
|
break;
|
||||||
snprintf(buf, 10, "%i", wd->cv->b);
|
|
||||||
break;
|
case E_COLOR_COMPONENT_B:
|
||||||
case E_COLOR_COMPONENT_H:
|
snprintf(buf, 10, "%i", wd->cv->b);
|
||||||
snprintf(buf, 10, "%.0f", wd->cv->h);
|
break;
|
||||||
break;
|
|
||||||
case E_COLOR_COMPONENT_S:
|
case E_COLOR_COMPONENT_H:
|
||||||
snprintf(buf, 10, "%.2f", wd->cv->s);
|
snprintf(buf, 10, "%.0f", wd->cv->h);
|
||||||
break;
|
break;
|
||||||
case E_COLOR_COMPONENT_V:
|
|
||||||
snprintf(buf, 10, "%.2f", wd->cv->v);
|
case E_COLOR_COMPONENT_S:
|
||||||
break;
|
snprintf(buf, 10, "%.2f", wd->cv->s);
|
||||||
}
|
break;
|
||||||
e_widget_entry_text_set(eo, buf);
|
|
||||||
|
case E_COLOR_COMPONENT_V:
|
||||||
|
snprintf(buf, 10, "%.2f", wd->cv->v);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
e_widget_entry_text_set(eo, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
wd->changing = 0;
|
wd->changing = 0;
|
||||||
|
@ -208,57 +218,62 @@ e_widget_csel_add(Evas *evas, E_Color *color, Eina_Bool alpha_enabled)
|
||||||
|
|
||||||
for (i = 0; i < E_COLOR_COMPONENT_MAX; i++)
|
for (i = 0; i < E_COLOR_COMPONENT_MAX; i++)
|
||||||
{
|
{
|
||||||
wd->values[i] = calloc(10, sizeof(char));
|
wd->values[i] = calloc(10, sizeof(char));
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case E_COLOR_COMPONENT_R:
|
case E_COLOR_COMPONENT_R:
|
||||||
snprintf(wd->values[i], 10, "%i", wd->cv->r);
|
snprintf(wd->values[i], 10, "%i", wd->cv->r);
|
||||||
break;
|
break;
|
||||||
case E_COLOR_COMPONENT_G:
|
|
||||||
snprintf(wd->values[i], 10, "%i", wd->cv->g);
|
|
||||||
break;
|
|
||||||
case E_COLOR_COMPONENT_B:
|
|
||||||
snprintf(wd->values[i], 10, "%i", wd->cv->b);
|
|
||||||
break;
|
|
||||||
case E_COLOR_COMPONENT_H:
|
|
||||||
snprintf(wd->values[i], 10, "%.0f", wd->cv->h);
|
|
||||||
break;
|
|
||||||
case E_COLOR_COMPONENT_S:
|
|
||||||
snprintf(wd->values[i], 10, "%.2f", wd->cv->s);
|
|
||||||
break;
|
|
||||||
case E_COLOR_COMPONENT_V:
|
|
||||||
snprintf(wd->values[i], 10, "%.2f", wd->cv->v);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
o = e_widget_radio_add(evas, labels[i], i, grp);
|
case E_COLOR_COMPONENT_G:
|
||||||
e_widget_sub_object_add(obj, o);
|
snprintf(wd->values[i], 10, "%i", wd->cv->g);
|
||||||
e_widget_on_change_hook_set(o, _e_wid_cb_radio_changed, wd);
|
break;
|
||||||
e_widget_table_object_append(frame, o, 0, i, 1, 1, 1, 1, 0, 0);
|
|
||||||
|
|
||||||
o = e_widget_cslider_add(evas, i, wd->cv, 0, 0);
|
case E_COLOR_COMPONENT_B:
|
||||||
e_widget_sub_object_add(obj, o);
|
snprintf(wd->values[i], 10, "%i", wd->cv->b);
|
||||||
evas_object_show(o);
|
break;
|
||||||
wd->sliders = eina_list_append(wd->sliders, o);
|
|
||||||
e_widget_on_change_hook_set(o, _e_wid_cb_color_changed, wd);
|
|
||||||
e_widget_table_object_append(frame, o, 1, i, 1, 1, 1, 1, 1, 0);
|
|
||||||
|
|
||||||
o = e_widget_entry_add(evas, &(wd->values[i]), NULL, NULL, NULL);
|
case E_COLOR_COMPONENT_H:
|
||||||
e_widget_sub_object_add(obj, o);
|
snprintf(wd->values[i], 10, "%.0f", wd->cv->h);
|
||||||
evas_object_show(o);
|
break;
|
||||||
wd->entries = eina_list_append(wd->entries, o);
|
|
||||||
e_widget_table_object_append(frame, o, 2, i, 1, 1, 1, 1, 1, 1);
|
case E_COLOR_COMPONENT_S:
|
||||||
e_widget_on_change_hook_set(o, _e_wid_cb_color_changed, wd);
|
snprintf(wd->values[i], 10, "%.2f", wd->cv->s);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case E_COLOR_COMPONENT_V:
|
||||||
|
snprintf(wd->values[i], 10, "%.2f", wd->cv->v);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
o = e_widget_radio_add(evas, labels[i], i, grp);
|
||||||
|
e_widget_sub_object_add(obj, o);
|
||||||
|
e_widget_on_change_hook_set(o, _e_wid_cb_radio_changed, wd);
|
||||||
|
e_widget_table_object_append(frame, o, 0, i, 1, 1, 1, 1, 0, 0);
|
||||||
|
|
||||||
|
o = e_widget_cslider_add(evas, i, wd->cv, 0, 0);
|
||||||
|
e_widget_sub_object_add(obj, o);
|
||||||
|
evas_object_show(o);
|
||||||
|
wd->sliders = eina_list_append(wd->sliders, o);
|
||||||
|
e_widget_on_change_hook_set(o, _e_wid_cb_color_changed, wd);
|
||||||
|
e_widget_table_object_append(frame, o, 1, i, 1, 1, 1, 1, 1, 0);
|
||||||
|
|
||||||
|
o = e_widget_entry_add(evas, &(wd->values[i]), NULL, NULL, NULL);
|
||||||
|
e_widget_sub_object_add(obj, o);
|
||||||
|
evas_object_show(o);
|
||||||
|
wd->entries = eina_list_append(wd->entries, o);
|
||||||
|
e_widget_table_object_append(frame, o, 2, i, 1, 1, 1, 1, 1, 1);
|
||||||
|
e_widget_on_change_hook_set(o, _e_wid_cb_color_changed, wd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alpha_enabled)
|
if (alpha_enabled)
|
||||||
{
|
{
|
||||||
o = e_widget_label_add(evas, "Alpha");
|
o = e_widget_label_add(evas, "Alpha");
|
||||||
e_widget_table_object_append(frame, o, 1, i, 1, 1, 1, 1, 0, 0);
|
e_widget_table_object_append(frame, o, 1, i, 1, 1, 1, 1, 0, 0);
|
||||||
o = e_widget_slider_add(evas, 1, 0, "%0.0f", 0, 255, 1, 0, NULL,
|
o = e_widget_slider_add(evas, 1, 0, "%0.0f", 0, 255, 1, 0, NULL,
|
||||||
&(wd->cv->a), 100);
|
&(wd->cv->a), 100);
|
||||||
e_widget_on_change_hook_set(o, _e_wid_cb_alpha_changed, wd);
|
e_widget_on_change_hook_set(o, _e_wid_cb_alpha_changed, wd);
|
||||||
e_widget_table_object_append(frame, o, 2, i, 1, 1, 1, 1, 0, 0);
|
e_widget_table_object_append(frame, o, 2, i, 1, 1, 1, 1, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
o = e_widget_spectrum_add(evas, wd->mode, wd->cv);
|
o = e_widget_spectrum_add(evas, wd->mode, wd->cv);
|
||||||
|
@ -287,3 +302,4 @@ e_widget_csel_add(Evas *evas, E_Color *color, Eina_Bool alpha_enabled)
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue