|
|
|
@ -6,6 +6,8 @@ |
|
|
|
|
#define SAT_STEP 128.0 |
|
|
|
|
#define LIG_STEP 256.0 |
|
|
|
|
#define ALP_STEP 256.0 |
|
|
|
|
#define DEFAULT_HOR_PAD 10 |
|
|
|
|
#define DEFAULT_VER_PAD 10 |
|
|
|
|
|
|
|
|
|
typedef enum _Color_Type |
|
|
|
|
{ |
|
|
|
@ -30,16 +32,32 @@ struct _Colorselector_Data |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
typedef struct _Widget_Data Widget_Data; |
|
|
|
|
typedef struct _Elm_Color_Item Elm_Color_Item; |
|
|
|
|
struct _Widget_Data |
|
|
|
|
{ |
|
|
|
|
Evas_Object *sel; |
|
|
|
|
Evas_Object *base; |
|
|
|
|
Evas_Object *box; |
|
|
|
|
Eina_List *items; |
|
|
|
|
Colorselector_Data *cp[4]; |
|
|
|
|
Ecore_Timer *longpress_timer; |
|
|
|
|
const char *palette_name; |
|
|
|
|
Evas_Coord _x, _y, _w, _h; |
|
|
|
|
int r, g, b, a; |
|
|
|
|
int er, eg, eb; |
|
|
|
|
int sr, sg, sb; |
|
|
|
|
int lr, lg, lb; |
|
|
|
|
double h, s, l; |
|
|
|
|
Elm_Colorselector_Mode mode; |
|
|
|
|
Eina_Bool longpressed : 1; |
|
|
|
|
Eina_Bool config_load: 1; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct _Elm_Color_Item |
|
|
|
|
{ |
|
|
|
|
ELM_WIDGET_ITEM; |
|
|
|
|
Evas_Object *color_obj; |
|
|
|
|
Elm_Color_RGBA *color; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static const char *widtype = NULL; |
|
|
|
@ -47,6 +65,7 @@ static const char *widtype = NULL; |
|
|
|
|
static void _del_hook(Evas_Object *obj); |
|
|
|
|
static void _theme_hook(Evas_Object *obj); |
|
|
|
|
static void _sizing_eval(Evas_Object *obj); |
|
|
|
|
static void _resize_cb(void *data, Evas *a, Evas_Object *obj, void *event_info); |
|
|
|
|
static void _rgb_to_hsl(void *data); |
|
|
|
|
static void _hsl_to_rgb(void *data); |
|
|
|
|
static void _color_with_saturation(void *data); |
|
|
|
@ -66,13 +85,26 @@ static void _right_button_repeat_cb(void *data, Evas_Object * obj, |
|
|
|
|
void *event_info); |
|
|
|
|
static void _add_colorbar(Evas_Object *obj); |
|
|
|
|
static void _set_color(Evas_Object *obj, int r, int g, int b, int a); |
|
|
|
|
static Elm_Color_Item *_item_new(Evas_Object *obj); |
|
|
|
|
static void _item_sizing_eval(Elm_Color_Item *item); |
|
|
|
|
static void _item_highlight(void *data, Evas *e, Evas_Object *obj, void *event_info); |
|
|
|
|
static void _item_unhighlight(void *data, Evas *e, Evas_Object *obj, void *event_info); |
|
|
|
|
static Eina_Bool _long_press(void *data); |
|
|
|
|
static void _remove_items(Widget_Data *wd); |
|
|
|
|
static void _colors_remove(Evas_Object *obj); |
|
|
|
|
static void _colors_save(Evas_Object *obj); |
|
|
|
|
static void _colors_load_apply(Evas_Object *obj); |
|
|
|
|
|
|
|
|
|
static const char SIG_CHANGED[] = "changed"; |
|
|
|
|
static const char SIG_COLOR_ITEM_SELECTED[] = "color,item,selected"; |
|
|
|
|
static const char SIG_COLOR_ITEM_LONGPRESSED[] = "color,item,longpressed"; |
|
|
|
|
|
|
|
|
|
static const Evas_Smart_Cb_Description _signals[] = |
|
|
|
|
{ |
|
|
|
|
{SIG_CHANGED, ""}, |
|
|
|
|
{NULL, NULL} |
|
|
|
|
{SIG_COLOR_ITEM_SELECTED, ""}, |
|
|
|
|
{SIG_COLOR_ITEM_LONGPRESSED, ""}, |
|
|
|
|
{SIG_CHANGED, ""}, |
|
|
|
|
{NULL, NULL} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
@ -82,6 +114,9 @@ _del_hook(Evas_Object *obj) |
|
|
|
|
int i = 0; |
|
|
|
|
|
|
|
|
|
if (!wd) return; |
|
|
|
|
if (wd->longpress_timer) ecore_timer_del(wd->longpress_timer); |
|
|
|
|
if (wd->palette_name) eina_stringshare_del(wd->palette_name); |
|
|
|
|
_remove_items(wd); |
|
|
|
|
for (i = 0; i < 4; i++) free(wd->cp[i]); |
|
|
|
|
free(wd); |
|
|
|
|
} |
|
|
|
@ -90,13 +125,21 @@ static void |
|
|
|
|
_theme_hook(Evas_Object *obj) |
|
|
|
|
{ |
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj); |
|
|
|
|
Eina_List *elist; |
|
|
|
|
Elm_Color_Item *item; |
|
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
if ((!wd) || (!wd->base)) return; |
|
|
|
|
if ((!wd) || (!wd->sel)) return; |
|
|
|
|
|
|
|
|
|
_elm_theme_object_set(obj, wd->base, "colorselector", "bg", |
|
|
|
|
_elm_theme_object_set(obj, wd->base, "colorselector", "palette", |
|
|
|
|
elm_widget_style_get(obj)); |
|
|
|
|
|
|
|
|
|
_elm_theme_object_set(obj, wd->sel, "colorselector", "bg", |
|
|
|
|
elm_widget_style_get(obj)); |
|
|
|
|
EINA_LIST_FOREACH(wd->items, elist, item) |
|
|
|
|
{ |
|
|
|
|
elm_layout_theme_set(VIEW(item), "colorselector", "item", elm_widget_style_get(obj)); |
|
|
|
|
_elm_theme_object_set(obj, item->color_obj, "colorselector", "item/color", elm_widget_style_get(obj)); |
|
|
|
|
} |
|
|
|
|
for (i = 0; i < 4; i++) |
|
|
|
|
{ |
|
|
|
|
evas_object_del(wd->cp[i]->colorbar); |
|
|
|
@ -136,10 +179,52 @@ _colorselector_set_size_hints(Evas_Object *obj, int timesw, int timesh) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
_sizing_eval(Evas_Object *obj) |
|
|
|
|
_item_sizing_eval(Elm_Color_Item *item) |
|
|
|
|
{ |
|
|
|
|
Evas_Coord minw = -1, minh = -1; |
|
|
|
|
|
|
|
|
|
if (!item) return; |
|
|
|
|
|
|
|
|
|
elm_coords_finger_size_adjust(1, &minw, 1, &minh); |
|
|
|
|
edje_object_size_min_restricted_calc(VIEW(item), &minw, &minh, minw, |
|
|
|
|
minh); |
|
|
|
|
evas_object_size_hint_min_set(VIEW(item), minw, minh); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void _resize_cb(void *data, Evas *a __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) |
|
|
|
|
{ |
|
|
|
|
_sizing_eval(data); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
_sizing_eval_palette(Evas_Object *obj) |
|
|
|
|
{ |
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj); |
|
|
|
|
Eina_List *elist; |
|
|
|
|
Elm_Color_Item *item; |
|
|
|
|
Evas_Coord bw = 0, bh = 0; |
|
|
|
|
Evas_Coord w = 0, h = 0; |
|
|
|
|
if (!wd) return; |
|
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(wd->items, elist, item) |
|
|
|
|
{ |
|
|
|
|
_item_sizing_eval(item); |
|
|
|
|
} |
|
|
|
|
evas_object_size_hint_min_get(wd->box, &bw, &bh); |
|
|
|
|
evas_object_size_hint_min_set(obj, bw, bh); |
|
|
|
|
evas_object_size_hint_max_set(obj, -1, -1); |
|
|
|
|
evas_object_geometry_get(obj, NULL, NULL, &w, &h); |
|
|
|
|
if (w < bw) w = bw; |
|
|
|
|
if (h < bh) h = bh; |
|
|
|
|
evas_object_resize(obj, w, h); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
_sizing_eval_selector(Evas_Object *obj) |
|
|
|
|
{ |
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj); |
|
|
|
|
Evas_Coord minw = -1, minh = -1; |
|
|
|
|
Evas_Coord w = 0, h = 0; |
|
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
if (!wd) return; |
|
|
|
@ -156,9 +241,211 @@ _sizing_eval(Evas_Object *obj) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
elm_coords_finger_size_adjust(4, &minw, 4, &minh); |
|
|
|
|
edje_object_size_min_restricted_calc(wd->base, &minw, &minh, minw, minh); |
|
|
|
|
edje_object_size_min_restricted_calc(wd->sel, &minw, &minh, minw, minh); |
|
|
|
|
evas_object_size_hint_min_set(obj, minw, minh); |
|
|
|
|
evas_object_size_hint_max_set(obj, -1, -1); |
|
|
|
|
evas_object_geometry_get(obj, NULL, NULL, &w, &h); |
|
|
|
|
if (w < minw) w = minw; |
|
|
|
|
if (h < minh) h = minh; |
|
|
|
|
evas_object_resize(obj, w, h); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void |
|
|
|
|
_sizing_eval_palette_selector(Evas_Object *obj) |
|
|
|
|
{ |
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj); |
|
|
|
|
Evas_Coord minw = -1, minh = -1; |
|
|
|
|
Evas_Coord bw = 0, bh = 0; |
|
|
|
|
Evas_Coord w = 0, h = 0; |
|
|
|
|
int i; |
|
|
|
|
if (!wd) return; |
|
|
|
|
elm_coords_finger_size_adjust(1, &minw, 1, &minh); |
|
|
|
|
for (i = 0; i < 4; i++) |
|
|
|
|
{ |
|
|
|
|
if (wd->cp[i]->bg_rect) |
|
|
|
|
_colorselector_set_size_hints(wd- |