diff --git a/legacy/edje/src/lib/Edje.h b/legacy/edje/src/lib/Edje.h index 1733d0355f..149542bea6 100644 --- a/legacy/edje/src/lib/Edje.h +++ b/legacy/edje/src/lib/Edje.h @@ -25,11 +25,10 @@ extern "C" { void edje_object_part_geometry_get (Evas_Object *o, const char *part, double *x, double *y, double *w, double *h); void edje_object_part_text_set (Evas_Object *o, const char *part, const char *text); const char *edje_object_part_text_get (Evas_Object *o, const char *part); - -#if 0 - void edje_object_color_class_set (Evas_Object *o, const char *color_class, int r, int g, int b, int a); + int edje_object_freeze (Evas_Object *o); + int edje_object_thaw (Evas_Object *o); + void edje_object_color_class_set (Evas_Object *o, const char *color_class, int r, int g, int b, int a, int r2, int g2, int b2, int a2, int r3, int g3, int b3, int a3); void edje_object_text_class_set (Evas_Object *o, const char *text_class, const char *font, double size); -#endif #ifdef __cplusplus } diff --git a/legacy/edje/src/lib/edje_calc.c b/legacy/edje/src/lib/edje_calc.c index 223c4e43cf..270c4da716 100644 --- a/legacy/edje/src/lib/edje_calc.c +++ b/legacy/edje/src/lib/edje_calc.c @@ -35,7 +35,6 @@ _edje_part_pos_set(Edje *ed, Edje_Real_Part *ep, int mode, double pos) ep->description_pos = npos; ed->dirty = 1; - ep->dirty = 1; } void @@ -161,7 +160,6 @@ _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, char *d1, double v1, } ed->dirty = 1; - ep->dirty = 1; } void @@ -335,6 +333,16 @@ _edje_part_recalc_single(Edje *ed, text = chosen_desc->text.text; font = chosen_desc->text.font; size = chosen_desc->text.size; + + if ((ep->part->text_class) && (strlen(ep->part->text_class) > 0)) + { + Ejde_Text_Class *tc; + + tc = _edje_text_class_find(ed, ep->part->text_class); + if (tc->font) font = tc->font; + if (tc->size > 0) size = tc->size; + } + if (ep->text.text) text = ep->text.text; if (ep->text.font) font = ep->text.font; if (ep->text.size > 0) size = ep->text.size; @@ -558,6 +566,29 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep) } else p3 = p1; + + if ((ep->part->color_class) && (strlen(ep->part->color_class) > 0)) + { + Ejde_Color_Class *cc; + + cc = _edje_color_class_find(ed, ep->part->color_class); + if (cc) + { + p3.color.r = (((int)cc->r + 1) * p3.color.r) >> 8; + p3.color.g = (((int)cc->g + 1) * p3.color.g) >> 8; + p3.color.b = (((int)cc->b + 1) * p3.color.b) >> 8; + p3.color.a = (((int)cc->a + 1) * p3.color.a) >> 8; + p3.color2.r = (((int)cc->r2 + 1) * p3.color2.r) >> 8; + p3.color2.g = (((int)cc->g2 + 1) * p3.color2.g) >> 8; + p3.color2.b = (((int)cc->b2 + 1) * p3.color2.b) >> 8; + p3.color2.a = (((int)cc->a2 + 1) * p3.color2.a) >> 8; + p3.color3.r = (((int)cc->r3 + 1) * p3.color3.r) >> 8; + p3.color3.g = (((int)cc->g3 + 1) * p3.color3.g) >> 8; + p3.color3.b = (((int)cc->b3 + 1) * p3.color3.b) >> 8; + p3.color3.a = (((int)cc->a3 + 1) * p3.color3.a) >> 8; + } + } + if (ep->part->type == EDJE_PART_TYPE_RECTANGLE) { evas_object_move(ep->object, ed->x + p3.x, ed->y + p3.y); @@ -616,5 +647,4 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep) ep->h = p3.h; ep->calculated = 1; - ep->dirty = 0; } diff --git a/legacy/edje/src/lib/edje_main.c b/legacy/edje/src/lib/edje_main.c index 46dc870835..4e9422d8d1 100644 --- a/legacy/edje/src/lib/edje_main.c +++ b/legacy/edje/src/lib/edje_main.c @@ -48,6 +48,25 @@ _edje_del(Edje *ed) free(escb->source); free(escb); } + while (ed->color_classes) + { + Ejde_Color_Class *cc; + + cc = ed->color_classes->data; + ed->color_classes = evas_list_remove(ed->color_classes, cc); + if (cc->name) free(cc->name); + free(cc); + } + while (ed->text_classes) + { + Ejde_Text_Class *tc; + + tc = ed->text_classes->data; + ed->text_classes = evas_list_remove(ed->text_classes, tc); + if (tc->name) free(tc->name); + if (tc->font) free(tc->font); + free(tc); + } free(ed); } diff --git a/legacy/edje/src/lib/edje_private.h b/legacy/edje/src/lib/edje_private.h index 0e3f81dbff..2c61fc7391 100644 --- a/legacy/edje/src/lib/edje_private.h +++ b/legacy/edje/src/lib/edje_private.h @@ -25,14 +25,12 @@ * drag vals should be 0.0 -> 1.0 if drag is confined. "rest" pos = 0.0. * query dragable for its relative pos value * - * text and color classes need to work + * real part size and "before min/max limit" sizes need to be stored per part + * need to be able to calculate min & max size of a whole edje * * named parts need to be able to be "replaced" with new evas objects * part replacement with object callbacks should be possible * - * real part size and "before min/max limit" sizes need to be stored per part - * need to be able to calculate min & max size of a whole edje - * * need to be able to list collections in an eet file * * externally sourced images need to be supported in edje_cc and edje @@ -42,54 +40,12 @@ * need to detect clip_to part loops * need to detect confine_to part loops * - * edje_cc should be able to force lossy, lossless, min and max quality and compression of encoded images - * edje_cc needs to prune out unused images - * edje_cc might need an option for limiting number of tween images - * - * audit edje for corrupt/bad input files - * * ? reduce linked list walking and list_nth calls * ? add containering (hbox, vbox, table, wrapping multi-line hbox & vbox) * ? add numeric params to conditions for progs (ranges etc.) * ? key/value pair config values per colelction and per edje file */ - -/* HOW THIS ALL WORKS: - * ------------------- - * - * A part file contains: - * a list of images stored - * the images - * a list of part collections - * the part collections - * - * A part collection contains: - * a list of programs - * a list of actions - * a list of parts - * - * when a signal is emitted and matches the conditionals of a program a - * specific action is started. that action may affect one or more parts in - * a part collection and may operate over a period of time. it may also - * spawn another action when it is done (able to loop!) over a period of - * time. A part is set into a certain state and the calculated outputs of the - * staret and end state are mixed based on the kind of tweening and time. a - * tween time of 0.0 = do it right away. an image_id list for tweening is - * also able ot be provided and shoudl be run through over time during the - * tween to the new state. - * - * the signals that can be emitted are: - * "mouse,down" - * "mouse,up" - * "mouse,in" - * "mouse,out" - * "mouse,move" - * "drag,start" - * "drag" - * "drag,stop" - */ - typedef struct _Edje_File Edje_File; typedef struct _Edje_Image_Directory Edje_Image_Directory; typedef struct _Edje_Image_Directory_Entry Edje_Image_Directory_Entry; @@ -351,6 +307,8 @@ typedef struct _Edje_Calc_Params Edje_Calc_Params; typedef struct _Edje_Emission Edje_Emission; typedef struct _Edje_Pending_Program Edje_Pending_Program; typedef struct _Ejde_Text_Style Ejde_Text_Style; +typedef struct _Ejde_Color_Class Ejde_Color_Class; +typedef struct _Ejde_Text_Class Ejde_Text_Class; struct _Edje { @@ -377,6 +335,8 @@ struct _Edje Evas_List *actions; /* currently running actions */ Evas_List *callbacks; Evas_List *pending_actions; + Evas_List *color_classes; + Evas_List *text_classes; int freeze; int references; }; @@ -390,7 +350,6 @@ struct _Edje_Real_Part Evas_Object *object; Evas_List *extra_objects; unsigned char calculated : 1; - unsigned char dirty : 1; unsigned char still_in : 1; int clicked_button; Edje_Part *part; @@ -484,6 +443,21 @@ struct _Ejde_Text_Style } members[32]; }; +struct _Ejde_Color_Class +{ + char *name; + unsigned char r, g, b, a; + unsigned char r2, g2, b2, a2; + unsigned char r3, g3, b3, a3; +}; + +struct _Ejde_Text_Class +{ + char *name; + char *font; + double size; +}; + void _edje_part_pos_set(Edje *ed, Edje_Real_Part *ep, int mode, double pos); void _edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, char *d1, double v1, char *d2, double v2); void _edje_recalc(Edje *ed); @@ -522,10 +496,12 @@ void _edje_text_part_on_add_clippers(Edje *ed, Edje_Real_Part *ep); void _edje_text_part_on_del(Edje *ed, Edje_Real_Part *ep); void _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *params, Edje_Part_Description *chosen_desc); -Edje *_edje_fetch(Evas_Object *obj); -int _edje_glob_match(char *str, char *glob); -int _edje_freeze(Edje *ed); -int _edje_thaw(Edje *ed); +Ejde_Color_Class *_edje_color_class_find(Edje *ed, char *color_class); +Ejde_Text_Class *_edje_text_class_find(Edje *ed, char *text_class); +Edje *_edje_fetch(Evas_Object *obj); +int _edje_glob_match(char *str, char *glob); +int _edje_freeze(Edje *ed); +int _edje_thaw(Edje *ed); extern Eet_Data_Descriptor *_edje_edd_edje_file; diff --git a/legacy/edje/src/lib/edje_text.c b/legacy/edje/src/lib/edje_text.c index 1ac3b18057..e0f8d52eda 100644 --- a/legacy/edje/src/lib/edje_text.c +++ b/legacy/edje/src/lib/edje_text.c @@ -238,10 +238,20 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep, double tw, th; double ox, oy, sw, sh; char *buf = NULL; - + text = chosen_desc->text.text; font = chosen_desc->text.font; size = chosen_desc->text.size; + + if ((ep->part->text_class) && (strlen(ep->part->text_class) > 0)) + { + Ejde_Text_Class *tc; + + tc = _edje_text_class_find(ed, ep->part->text_class); + if (tc->font) font = tc->font; + if (tc->size > 0) size = tc->size; + } + if (ep->text.text) text = ep->text.text; if (ep->text.font) font = ep->text.font; if (ep->text.size > 0) size = ep->text.size; diff --git a/legacy/edje/src/lib/edje_util.c b/legacy/edje/src/lib/edje_util.c index f439ca939a..d6b937effa 100644 --- a/legacy/edje/src/lib/edje_util.c +++ b/legacy/edje/src/lib/edje_util.c @@ -79,7 +79,6 @@ edje_object_part_text_set(Evas_Object *obj, const char *part, const char *text) if (rp->text.text) free(rp->text.text); rp->text.text = strdup(text); ed->dirty = 1; - rp->dirty = 1; _edje_recalc(ed); } return; @@ -111,6 +110,174 @@ edje_object_part_text_get(Evas_Object *obj, const char *part) return NULL; } +int +edje_object_freeze(Evas_Object *obj) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if (!ed) return 0; + return _edje_freeze(ed); +} + +int +edje_object_thaw(Evas_Object *obj) +{ + Edje *ed; + + ed = _edje_fetch(obj); + if (!ed) return 0; + return _edje_thaw(ed); +} + +void +edje_object_color_class_set(Evas_Object *obj, const char *color_class, int r, int g, int b, int a, int r2, int g2, int b2, int a2, int r3, int g3, int b3, int a3) +{ + Edje *ed; + Evas_List *l; + Ejde_Color_Class *cc; + + ed = _edje_fetch(obj); + if ((!ed) || (!color_class)) return; + if (r < 0) r = 0; + if (r > 255) r = 255; + if (g < 0) g = 0; + if (g > 255) g = 255; + if (b < 0) b = 0; + if (b > 255) b = 255; + if (a < 0) a = 0; + if (a > 255) a = 255; + for (l = ed->color_classes; l; l = l->next) + { + cc = l->data; + if (!strcmp(cc->name, color_class)) + { + if ((cc->r == r) && (cc->g == g) && + (cc->b == b) && (cc->a == a) && + (cc->r2 == r2) && (cc->g2 == g2) && + (cc->b2 == b2) && (cc->a2 == a2) && + (cc->r3 == r3) && (cc->g3 == g3) && + (cc->b3 == b3) && (cc->a3 == a3)) + return; + cc->r = r; + cc->g = g; + cc->b = b; + cc->a = a; + cc->r2 = r2; + cc->g2 = g2; + cc->b2 = b2; + cc->a2 = a2; + cc->r3 = r3; + cc->g3 = g3; + cc->b3 = b3; + cc->a3 = a3; + ed->dirty = 1; + _edje_recalc(ed); + return; + } + } + cc = malloc(sizeof(Ejde_Color_Class)); + cc->name = strdup(color_class); + if (!cc->name) + { + free(cc); + return; + } + cc->r = r; + cc->g = g; + cc->b = b; + cc->a = a; + cc->r2 = r2; + cc->g2 = g2; + cc->b2 = b2; + cc->a2 = a2; + cc->r3 = r3; + cc->g3 = g3; + cc->b3 = b3; + cc->a3 = a3; + ed->color_classes = evas_list_append(ed->color_classes, cc); + ed->dirty = 1; + _edje_recalc(ed); +} + +void +edje_object_text_class_set(Evas_Object *obj, const char *text_class, const char *font, double size) +{ + Edje *ed; + Evas_List *l; + Ejde_Text_Class *tc; + + ed = _edje_fetch(obj); + if ((!ed) || (!text_class)) return; + if (size < 0.0) size = 0.0; + for (l = ed->text_classes; l; l = l->next) + { + tc = l->data; + if (!strcmp(tc->name, text_class)) + { + if ((tc->font) && (font) && + (!strcmp(tc->font, font)) && + (tc->size == size)) + return; + if ((!tc->font) && (!font) && + (tc->size == size)) + return; + if (tc->font) free(tc->font); + if (font) tc->font = strdup(font); + else tc->font = NULL; + tc->size = size; + ed->dirty = 1; + _edje_recalc(ed); + return; + } + } + tc = malloc(sizeof(Ejde_Text_Class)); + tc->name = strdup(text_class); + if (!tc->name) + { + free(tc); + return; + } + if (font) tc->font = strdup(font); + else tc->font = NULL; + tc->size = size; + ed->text_classes = evas_list_append(ed->text_classes, tc); + ed->dirty = 1; + _edje_recalc(ed); +} + +Ejde_Color_Class * +_edje_color_class_find(Edje *ed, char *color_class) +{ + Evas_List *l; + + if (!color_class) return NULL; + for (l = ed->color_classes; l; l = l->next) + { + Ejde_Color_Class *cc; + + cc = l->data; + if (!strcmp(color_class, cc->name)) return cc; + } + return NULL; +} + +Ejde_Text_Class * +_edje_text_class_find(Edje *ed, char *text_class) +{ + Evas_List *l; + + if (!text_class) return NULL; + for (l = ed->text_classes; l; l = l->next) + { + Ejde_Text_Class *tc; + + tc = l->data; + if (!strcmp(text_class, tc->name)) return tc; + } + return NULL; +} + Edje * _edje_fetch(Evas_Object *obj) {