From: sachiel Date: Tue, 27 Oct 2009 01:08:19 +0000 (+0000) Subject: and bring external back now that the file was added X-Git-Tag: 2.0_alpha~163^2~782 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d247c29699a08f12901549b532035d097bd74494;p=framework%2Fuifw%2Fedje.git and bring external back now that the file was added git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@43306 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/bin/edje_cc_handlers.c b/src/bin/edje_cc_handlers.c index 168a768..216c63e 100644 --- a/src/bin/edje_cc_handlers.c +++ b/src/bin/edje_cc_handlers.c @@ -200,10 +200,15 @@ static void st_collections_group_parts_part_description_table_homogeneous(void); static void st_collections_group_parts_part_description_table_align(void); static void st_collections_group_parts_part_description_table_padding(void); +/* external part parameters */ +static void st_collections_group_parts_part_description_params_int(void); static void ob_collections_group_programs_program(void); +static void st_collections_group_parts_part_description_params_double(void); + static void st_collections_group_programs_program_name(void); +static void st_collections_group_parts_part_description_params_string(void); static void st_collections_group_programs_program_signal(void); -static void st_collections_group_programs_program_source(void); + static void st_collections_group_programs_program_source(void); static void st_collections_group_programs_program_in(void); static void st_collections_group_programs_program_action(void); static void st_collections_group_programs_program_transition(void); @@ -399,6 +404,9 @@ New_Statement_Handler statement_handlers[] = {"collections.group.parts.part.description.table.homogeneous", st_collections_group_parts_part_description_table_homogeneous}, {"collections.group.parts.part.description.table.align", st_collections_group_parts_part_description_table_align}, {"collections.group.parts.part.description.table.padding", st_collections_group_parts_part_description_table_padding}, + {"collections.group.parts.part.description.params.int", st_collections_group_parts_part_description_params_int}, + {"collections.group.parts.part.description.params.double", st_collections_group_parts_part_description_params_double}, + {"collections.group.parts.part.description.params.string", st_collections_group_parts_part_description_params_string}, {"collections.group.parts.part.description.images.image", st_images_image}, /* dup */ {"collections.group.parts.part.description.font", st_fonts_font}, /* dup */ {"collections.group.parts.part.description.fonts.font", st_fonts_font}, /* dup */ @@ -559,6 +567,7 @@ New_Object_Handler object_handlers[] = {"collections.group.parts.part.description.gradient.rel2", NULL}, {"collections.group.parts.part.description.box", NULL}, {"collections.group.parts.part.description.table", NULL}, + {"collections.group.parts.part.description.params", NULL}, {"collections.group.parts.part.description.color_classes", NULL}, /* dup */ {"collections.group.parts.part.description.color_classes.color_class", ob_color_class}, /* dup */ {"collections.group.parts.part.description.program", ob_collections_group_programs_program}, /* dup */ @@ -1693,6 +1702,7 @@ st_collections_group_parts_part_name(void) @li GROUP @li BOX @li TABLE + @li EXTERNAL @endproperty */ static void @@ -1716,6 +1726,7 @@ st_collections_group_parts_part_type(void) "GROUP", EDJE_PART_TYPE_GROUP, "BOX", EDJE_PART_TYPE_BOX, "TABLE", EDJE_PART_TYPE_TABLE, + "EXTERNAL", EDJE_PART_TYPE_EXTERNAL, NULL); } @@ -2975,6 +2986,7 @@ ob_collections_group_parts_part_description(void) ed->table.align.y = 0.5; ed->table.padding.x = 0; ed->table.padding.y = 0; + ed->external_params = NULL; } /** @@ -3109,6 +3121,20 @@ st_collections_group_parts_part_description_inherit(void) data_queue_part_slave_lookup(&(parent->text.id_source), &(ed->text.id_source)); data_queue_part_slave_lookup(&(parent->text.id_text_source), &(ed->text.id_text_source)); + + if (parent->external_params) + { + Eina_List *l; + Edje_External_Param *param, *new_param; + + ed->external_params = NULL; + EINA_LIST_FOREACH(parent->external_params, l, param) + { + new_param = mem_alloc(SZ(Edje_External_Param)); + *new_param = *param; + ed->external_params = eina_list_append(ed->external_params, new_param); + } + } } /** @@ -5480,6 +5506,121 @@ static void st_collections_group_parts_part_description_table_padding(void) ed->table.padding.y = parse_int_range(1, 0, 0x7fffffff); } +static void +_st_collections_group_parts_part_description_params(Edje_External_Param_Type type) +{ + Edje_Part_Collection *pc; + Edje_Part *ep; + Edje_Part_Description *ed; + Edje_External_Param *param; + Eina_List *l; + const char *name; + int found = 0; + + check_arg_count(2); + + pc = eina_list_data_get(eina_list_last(edje_collections)); + ep = eina_list_data_get(eina_list_last(pc->parts)); + + if (ep->type != EDJE_PART_TYPE_EXTERNAL) + { + fprintf(stderr, "%s: Error. parse error %s:%i. " + "params in non-EXTERNAL part.\n", + progname, file_in, line - 1); + exit(-1); + } + + ed = ep->default_desc; + if (ep->other_desc) ed = eina_list_data_get(eina_list_last(ep->other_desc)); + + name = parse_str(0); + + /* if a param with this name already exists, overwrite it */ + EINA_LIST_FOREACH(ed->external_params, l, param) + { + if (!strcmp(param->name, name)) + { + found = 1; + break; + } + } + + if (!found) + { + param = mem_alloc(SZ(Edje_External_Param)); + param->name = name; + } + + param->type = type; + param->i = 0; + param->d = 0; + param->s = NULL; + + switch (type) + { + case EDJE_EXTERNAL_PARAM_TYPE_INT: + param->i = parse_int(1); + break; + case EDJE_EXTERNAL_PARAM_TYPE_DOUBLE: + param->d = parse_float(1); + break; + case EDJE_EXTERNAL_PARAM_TYPE_STRING: + param->s = parse_str(1); + break; + } + + if (!found) + ed->external_params = eina_list_append(ed->external_params, param); +} + +/** + @page edcref + @property + inherit + @parameters + [param_name] [int_value] + @effect + Adds an integer parameter for an external object + @endproperty +*/ +static void +st_collections_group_parts_part_description_params_int(void) +{ + _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_INT); +} + +/** + @page edcref + @property + inherit + @parameters + [param_name] [double_value] + @effect + Adds a double parameter for an external object + @endproperty +*/ +static void +st_collections_group_parts_part_description_params_double(void) +{ + _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_DOUBLE); +} + +/** + @page edcref + @property + inherit + @parameters + [param_name] [string_value] + @effect + Adds a string parameter for an external object + @endproperty +*/ +static void +st_collections_group_parts_part_description_params_string(void) +{ + _st_collections_group_parts_part_description_params(EDJE_EXTERNAL_PARAM_TYPE_STRING); +} + /** @page edcref @block diff --git a/src/lib/Edje.h b/src/lib/Edje.h index 7eb0bf2..b6f9fc1 100644 --- a/src/lib/Edje.h +++ b/src/lib/Edje.h @@ -90,7 +90,8 @@ typedef enum _Edje_Part_Type EDJE_PART_TYPE_GROUP = 7, EDJE_PART_TYPE_BOX = 8, EDJE_PART_TYPE_TABLE = 9, - EDJE_PART_TYPE_LAST = 10 + EDJE_PART_TYPE_EXTERNAL = 10, + EDJE_PART_TYPE_LAST = 11 } Edje_Part_Type; typedef enum _Edje_Text_Effect @@ -226,6 +227,37 @@ enum EDJE_LOAD_ERROR_RECURSIVE_REFERENCE = 9 }; +enum _Edje_External_Param_Type +{ + EDJE_EXTERNAL_PARAM_TYPE_INT, + EDJE_EXTERNAL_PARAM_TYPE_DOUBLE, + EDJE_EXTERNAL_PARAM_TYPE_STRING, + EDJE_EXTERNAL_PARAM_TYPE_MAX +}; +typedef enum _Edje_External_Param_Type Edje_External_Param_Type; + +struct _Edje_External_Param +{ + const char *name; + Edje_External_Param_Type type; + // XXX these could be in a union, but eet doesn't support them (or does it?) + int i; + double d; + const char *s; +}; +typedef struct _Edje_External_Param Edje_External_Param; + +struct _Edje_External_Type +{ + Evas_Object *(*add) (void *data, Evas *evas, Evas_Object *parent, const Eina_List *params); + void (*state_set) (void *data, Evas_Object *obj, const Eina_List *from_params, const Eina_List *to_params, float pos); + void (*signal_emit) (void *data, Evas_Object *obj, const char *emission, const char *source); + + void *data; +}; +typedef struct _Edje_External_Type Edje_External_Type; + + typedef void (*Edje_Signal_Cb) (void *data, Evas_Object *obj, const char *emission, const char *source); typedef void (*Edje_Text_Change_Cb) (void *data, Evas_Object *obj, const char *part); typedef void (*Edje_Message_Handler_Cb) (void *data, Evas_Object *obj, Edje_Message_Type type, int id, void *msg); @@ -365,6 +397,11 @@ extern "C" { EAPI void edje_message_signal_process (void); + /* edje_external.c */ + EAPI Eina_Bool edje_external_type_register(const char *type_name, Edje_External_Type *type_info); + EAPI Eina_Bool edje_external_type_unregister(const char *type_name); + EAPI Edje_External_Param *edje_external_param_find(const Eina_List *params, const char *key); + #ifdef __cplusplus } #endif diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 6a4c7d5..62a5bd7 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -42,7 +42,8 @@ edje_textblock_styles.c \ edje_edit.c \ edje_script_only.c \ edje_lua_script_only.c \ -edje_entry.c +edje_entry.c \ +edje_external.c libedje_la_LIBADD = @EDJE_LIBS@ @ECORE_IMF_LIBS@ -lm libedje_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@ diff --git a/src/lib/edje_calc.c b/src/lib/edje_calc.c index 2d2cc86..c4b447f 100644 --- a/src/lib/edje_calc.c +++ b/src/lib/edje_calc.c @@ -1874,6 +1874,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags) /* move and resize are needed for all previous object => no break here. */ case EDJE_PART_TYPE_SWALLOW: case EDJE_PART_TYPE_GROUP: + case EDJE_PART_TYPE_EXTERNAL: /* visibility and color have no meaning on SWALLOW and GROUP part. */ evas_object_move(ep->object, ed->x + pf->x, ed->y + pf->y); evas_object_resize(ep->object, pf->w, pf->h); @@ -1903,6 +1904,9 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags) case EDJE_PART_TYPE_TABLE: _edje_table_recalc_apply(ed, ep, pf, chosen_desc); break; + case EDJE_PART_TYPE_EXTERNAL: + _edje_external_recalc_apply(ed, ep, pf, chosen_desc); + break; case EDJE_PART_TYPE_RECTANGLE: case EDJE_PART_TYPE_SWALLOW: case EDJE_PART_TYPE_GROUP: diff --git a/src/lib/edje_data.c b/src/lib/edje_data.c index c913d60..c33c0b4 100644 --- a/src/lib/edje_data.c +++ b/src/lib/edje_data.c @@ -26,6 +26,7 @@ EAPI Eet_Data_Descriptor *_edje_edd_edje_part_collection = NULL; EAPI Eet_Data_Descriptor *_edje_edd_edje_part = NULL; EAPI Eet_Data_Descriptor *_edje_edd_edje_part_description = NULL; EAPI Eet_Data_Descriptor *_edje_edd_edje_part_image_id = NULL; +EAPI Eet_Data_Descriptor *_edje_edd_edje_external_param = NULL; #define FREED(eed) \ if (eed) \ @@ -59,6 +60,7 @@ _edje_edd_shutdown(void) FREED(_edje_edd_edje_part); FREED(_edje_edd_edje_part_description); FREED(_edje_edd_edje_part_image_id); + FREED(_edje_edd_edje_external_param); } void @@ -213,6 +215,15 @@ _edje_edd_init(void) eet_data_descriptor_file_new(&eddc); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_image_id, Edje_Part_Image_Id, "id", id, EET_T_INT); + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_External_Param); + _edje_edd_edje_external_param = + eet_data_descriptor_file_new(&eddc); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "name", name, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "type", type, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "i", i, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "d", d, EET_T_DOUBLE); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_external_param, Edje_External_Param, "s", s, EET_T_STRING); + EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description); _edje_edd_edje_part_description = eet_data_descriptor_file_new(&eddc); @@ -318,6 +329,7 @@ _edje_edd_init(void) EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "table.align.y", table.align.y, EET_T_DOUBLE); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "table.padding.x", table.padding.x, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "table.padding.y", table.padding.y, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_part_description, Edje_Part_Description, "external_params", external_params, _edje_edd_edje_external_param); EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Pack_Element); _edje_edd_edje_pack_element = diff --git a/src/lib/edje_load.c b/src/lib/edje_load.c index 53e7a23..4f0a08b 100644 --- a/src/lib/edje_load.c +++ b/src/lib/edje_load.c @@ -399,6 +399,7 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g break; case EDJE_PART_TYPE_SWALLOW: case EDJE_PART_TYPE_GROUP: + case EDJE_PART_TYPE_EXTERNAL: rp->object = evas_object_rectangle_add(ed->evas); evas_object_color_set(rp->object, 0, 0, 0, 0); evas_object_pass_events_set(rp->object, 1); @@ -595,6 +596,13 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g source = pack_it->source; } break; + case EDJE_PART_TYPE_EXTERNAL: + { + Evas_Object *child_obj; + child_obj = _edje_external_type_add(rp->part->source, evas_object_evas_get(ed->obj), ed->obj, rp->part->default_desc->external_params); + if (child_obj) _edje_real_part_swallow(rp, child_obj); + } + continue; default: continue; } @@ -839,7 +847,7 @@ _edje_file_del(Edje *ed) /* Objects swallowed by the app do not get deleted, but those internally swallowed (GROUP type) do. */ - if (rp->part->type == EDJE_PART_TYPE_GROUP) + if (rp->part->type == EDJE_PART_TYPE_GROUP || rp->part->type == EDJE_PART_TYPE_EXTERNAL) evas_object_del(rp->swallowed_object); rp->swallowed_object = NULL; @@ -1138,6 +1146,8 @@ _edje_collection_free_part_description_free(Edje_Part_Description *desc, unsigne EINA_LIST_FREE(desc->image.tween_list, pi) free(pi); + if (desc->external_params) + _edje_external_params_free(desc->external_params, free_strings); if (free_strings) { if (desc->color_class) eina_stringshare_del(desc->color_class); diff --git a/src/lib/edje_main.c b/src/lib/edje_main.c index aeeffef..33faf50 100644 --- a/src/lib/edje_main.c +++ b/src/lib/edje_main.c @@ -96,6 +96,7 @@ edje_init(void) _edje_edd_init(); _edje_text_init(); _edje_box_init(); + _edje_external_init(); _edje_lua_init(); _edje_message_init(); @@ -126,6 +127,7 @@ edje_init(void) _edje_real_part_mp = NULL; _edje_message_shutdown(); _edje_lua_shutdown(); + _edje_external_shutdown(); _edje_box_shutdown(); _edje_text_class_members_free(); _edje_text_class_hash_free(); @@ -183,6 +185,7 @@ edje_shutdown(void) _edje_message_shutdown(); _edje_lua_shutdown(); + _edje_external_shutdown(); _edje_box_shutdown(); _edje_text_class_members_free(); _edje_text_class_hash_free(); diff --git a/src/lib/edje_private.h b/src/lib/edje_private.h index 9892068..4643300 100644 --- a/src/lib/edje_private.h +++ b/src/lib/edje_private.h @@ -567,6 +567,7 @@ struct _Edje_Part_Description } table; Edje_Color color, color2, color3; /* color for rect or text, shadow etc. */ + Eina_List *external_params; /* parameters for external objects */ unsigned char visible; /* is it shown */ }; @@ -1338,4 +1339,11 @@ void _edje_entry_cursor_geometry_get(Edje_Real_Part *rp, Evas_Coord *cx, Evas_Co void _edje_entry_select_allow_set(Edje_Real_Part *rp, Eina_Bool allow); void _edje_entry_select_abort(Edje_Real_Part *rp); +void _edje_external_init(); +void _edje_external_shutdown(); +Evas_Object *_edje_external_type_add(const char *type_name, Evas *evas, Evas_Object *parent, const Eina_List *params); +void _edje_external_signal_emit(Evas_Object *obj, const char *emission, const char *source); +void _edje_external_params_free(Eina_List *params, unsigned int free_strings); +void _edje_external_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *params, Edje_Part_Description *chosen_desc); + #endif diff --git a/src/lib/edje_program.c b/src/lib/edje_program.c index b804992..066603e 100644 --- a/src/lib/edje_program.c +++ b/src/lib/edje_program.c @@ -944,8 +944,8 @@ _edje_emit(Edje *ed, const char *sig, const char *src) { size_t length; char *part; - /* the signal contains a colon, split the signal into "group:signal", - * and deliver it to "group" + /* the signal contains a colon, split the signal into "part:signal", + * and deliver it to "part" (if there is a GROUP or EXTERNAL part named "part") */ length = strlen(sig) + 1; part = alloca(length); @@ -962,17 +962,25 @@ _edje_emit(Edje *ed, const char *sig, const char *src) for (i = 0; i < ed->table_parts_size; i++) { Edje_Real_Part *rp = ed->table_parts[i]; - if ((rp->part->type == EDJE_PART_TYPE_GROUP) && + if ((rp->part->type == EDJE_PART_TYPE_GROUP || rp->part->type == EDJE_PART_TYPE_EXTERNAL) && (rp->swallowed_object) && (rp->part) && (rp->part->name) && (strcmp(rp->part->name, part) == 0)) { - Edje *ed2 = _edje_fetch(rp->swallowed_object); - if (ed2) _edje_emit(ed2, newsig, src); - return; /* stop processing. - * XXX maybe let signal be processed anyway? - * XXX in this case, just comment this line - */ + if (rp->part->type == EDJE_PART_TYPE_GROUP) + { + Edje *ed2 = _edje_fetch(rp->swallowed_object); + if (ed2) _edje_emit(ed2, newsig, src); + return; /* stop processing. + * XXX maybe let signal be processed anyway? + * XXX in this case, just comment this line + */ + } + else if (rp->part->type == EDJE_PART_TYPE_EXTERNAL) + { + _edje_external_signal_emit(rp->swallowed_object, newsig, src); + return; + } } } }