From: Mike Blumenkrantz Date: Sat, 7 Mar 2015 18:38:57 +0000 (-0500) Subject: edje color classes can now have text descriptions X-Git-Tag: v1.14.0-alpha1~285 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1cf630f2bdedfd6b50c88ee1024b9bb03c0d1c39;p=platform%2Fupstream%2Fefl.git edje color classes can now have text descriptions @feature --- diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c index 6d96fd2..303bd45 100644 --- a/src/bin/edje/edje_cc_handlers.c +++ b/src/bin/edje/edje_cc_handlers.c @@ -205,6 +205,7 @@ static void st_color_class_name(void); static void st_color_class_color(void); static void st_color_class_color2(void); static void st_color_class_color3(void); +static void st_color_class_desc(void); static void ob_collections(void); static void st_collections_base_scale(void); @@ -498,7 +499,8 @@ static void st_collections_group_nobroadcast(void); {PREFIX"color_classes.color_class.name", st_color_class_name}, /* dup */ \ {PREFIX"color_classes.color_class.color", st_color_class_color}, /* dup */ \ {PREFIX"color_classes.color_class.color2", st_color_class_color2}, /* dup */ \ - {PREFIX"color_classes.color_class.color3", st_color_class_color3}, /* dup */ + {PREFIX"color_classes.color_class.color3", st_color_class_color3}, /* dup */ \ + {PREFIX"color_classes.color_class.description", st_color_class_desc}, /* dup */ #define PROGRAM_SEQUENCE(PREFIX, NAME, FN) \ {PREFIX".program."NAME, FN}, /* dup */ \ @@ -2460,6 +2462,28 @@ st_color_class_color3(void) cc->a3 = parse_int_range(3, 0, 255); } +/** + @page edcref + @property + description + @parameters + [color class description] + @effect + Provides a descriptive name for the effect of the color class + @since 1.14 + @endproperty +*/ +static void +st_color_class_desc(void) +{ + Edje_Color_Class *cc; + + check_arg_count(1); + + cc = eina_list_data_get(eina_list_last(edje_file->color_classes)); + cc->desc = parse_str(0); +} + /** @edcsubsection{toplevel_styles, * Styles} */ diff --git a/src/lib/edje/Edje_Edit.h b/src/lib/edje/Edje_Edit.h index d43d434..249ed3c 100644 --- a/src/lib/edje/Edje_Edit.h +++ b/src/lib/edje/Edje_Edit.h @@ -813,6 +813,26 @@ EAPI Eina_Bool edje_edit_color_class_colors_set(Evas_Object *obj, const char *cl */ EAPI Eina_Bool edje_edit_color_class_name_set(Evas_Object *obj, const char *name, const char *newname); +/** Get the description of a color class. + * + * @param obj Object being edited. + * @param name Color class to get the description of. + * + * @return The description of the color class or @c NULL if not found + * @since 1.14 + */ +EAPI Eina_Stringshare *edje_edit_color_class_description_get(Evas_Object *obj, const char *class_name); + +/** Change the description of a color class. + * + * @param obj Object being edited. + * @param name Color class to edit. + * @param desc New description for the color class + * + * @return @c EINA_TRUE in case of success, @c EINA_FALSE otherwise. + * @since 1.14 + */ +EAPI Eina_Bool edje_edit_color_class_description_set(Evas_Object *obj, const char *class_name, const char *desc); //@} diff --git a/src/lib/edje/edje_data.c b/src/lib/edje/edje_data.c index 774d9c2..f18637e 100644 --- a/src/lib/edje/edje_data.c +++ b/src/lib/edje/edje_data.c @@ -418,6 +418,7 @@ _edje_edd_init(void) EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "g3", g3, EET_T_UCHAR); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "b3", b3, EET_T_UCHAR); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "a3", a3, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, "desc", desc, EET_T_STRING); /* the main file directory */ EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_File); diff --git a/src/lib/edje/edje_edit.c b/src/lib/edje/edje_edit.c index 5687e3e..faf5673 100644 --- a/src/lib/edje/edje_edit.c +++ b/src/lib/edje/edje_edit.c @@ -2519,6 +2519,43 @@ edje_edit_color_class_colors_set(Evas_Object *obj, const char *class_name, int r return EINA_FALSE; } +EAPI Eina_Stringshare * +edje_edit_color_class_description_get(Evas_Object *obj, const char *class_name) +{ + Eina_List *l; + Edje_Color_Class *cc; + + GET_ED_OR_RETURN(NULL); + EINA_SAFETY_ON_NULL_RETURN_VAL(class_name, NULL); + + if (!ed->file || !ed->file->color_classes) + return NULL; + EINA_LIST_FOREACH(ed->file->color_classes, l, cc) + if (eina_streq(cc->name, class_name)) + return cc->desc; + return NULL; +} + +EAPI Eina_Bool +edje_edit_color_class_description_set(Evas_Object *obj, const char *class_name, const char *desc) +{ + Eina_List *l; + Edje_Color_Class *cc; + + GET_ED_OR_RETURN(EINA_FALSE); + EINA_SAFETY_ON_NULL_RETURN_VAL(class_name, EINA_FALSE); + + if (!ed->file || !ed->file->color_classes) + return EINA_FALSE; + EINA_LIST_FOREACH(ed->file->color_classes, l, cc) + if (eina_streq(cc->name, class_name)) + { + eina_stringshare_replace(&cc->desc, desc); + return EINA_TRUE; + } + return EINA_FALSE; +} + EAPI Eina_Bool edje_edit_color_class_add(Evas_Object *obj, const char *name) { diff --git a/src/lib/edje/edje_load.c b/src/lib/edje/edje_load.c index 3124151..61b1de1 100644 --- a/src/lib/edje/edje_load.c +++ b/src/lib/edje/edje_load.c @@ -1545,6 +1545,7 @@ _edje_file_free(Edje_File *edf) EINA_LIST_FREE(edf->color_classes, ecc) { if (edf->free_strings && ecc->name) eina_stringshare_del(ecc->name); + if (edf->free_strings) eina_stringshare_del(ecc->desc); free(ecc); } diff --git a/src/lib/edje/edje_object.eo b/src/lib/edje/edje_object.eo index 6c80834..7e633be 100644 --- a/src/lib/edje/edje_object.eo +++ b/src/lib/edje/edje_object.eo @@ -2146,6 +2146,18 @@ class Edje.Object (Evas.Smart_Clipped, Efl.File) @out int a3; /*@ Shadow Alpha value */ } } + color_class_description_get @const { + /*@ + @brief Gets the description of an object color class. + + @return The description of the target color class or @c NULL if not found + + This function gets the description of a color class in use by an object. */ + return: const(char)*; + params { + @in const(char)* color_class; + } + } part_drag_step { /*@ @brief Steps the dragable x,y steps. diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h index 678421b..f76b655 100644 --- a/src/lib/edje/edje_private.h +++ b/src/lib/edje/edje_private.h @@ -1867,6 +1867,7 @@ struct _Edje_Color_Class unsigned char r, g, b, a; unsigned char r2, g2, b2, a2; unsigned char r3, g3, b3, a3; + Eina_Stringshare *desc; }; struct _Edje_Text_Class diff --git a/src/lib/edje/edje_smart.c b/src/lib/edje/edje_smart.c index 332b958..8af4cea 100644 --- a/src/lib/edje/edje_smart.c +++ b/src/lib/edje/edje_smart.c @@ -66,6 +66,7 @@ _edje_color_class_free(void *data) Edje_Color_Class *cc = data; if (cc->name) eina_stringshare_del(cc->name); + eina_stringshare_del(cc->desc); free(cc); } diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c index d0b71c6..5187027 100644 --- a/src/lib/edje/edje_util.c +++ b/src/lib/edje/edje_util.c @@ -774,6 +774,13 @@ _edje_object_color_class_get(Eo *obj EINA_UNUSED, Edje *ed, const char *color_cl return EINA_FALSE; } +EOLIAN Eina_Stringshare * +_edje_object_color_class_description_get(Eo *obj EINA_UNUSED, Edje *ed, const char *color_class) +{ + Edje_Color_Class *cc = _edje_color_class_find(ed, color_class); + return cc ? cc->desc : NULL; +} + void edje_object_color_class_del(Evas_Object *obj, const char *color_class) {