From: sachiel Date: Thu, 18 Dec 2008 02:43:20 +0000 (+0000) Subject: And finally, edje table goes in X-Git-Tag: 2.0_alpha~163^2~962 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=01f16cfa03b253cca9a9cbde4163579de675c1c6;p=framework%2Fuifw%2Fedje.git And finally, edje table goes in git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@38204 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/bin/edje_cc_handlers.c b/src/bin/edje_cc_handlers.c index 1aafa37..44a1d94 100644 --- a/src/bin/edje_cc_handlers.c +++ b/src/bin/edje_cc_handlers.c @@ -110,6 +110,7 @@ static void st_collections_group_parts_part_dragable_y(void); static void st_collections_group_parts_part_dragable_confine(void); static void st_collections_group_parts_part_dragable_events(void); +/* box and table items share these */ static void ob_collections_group_parts_part_box_items_item(void); static void st_collections_group_parts_part_box_items_item_type(void); static void st_collections_group_parts_part_box_items_item_name(void); @@ -123,6 +124,9 @@ static void st_collections_group_parts_part_box_items_item_weight(void); static void st_collections_group_parts_part_box_items_item_aspect(void); static void st_collections_group_parts_part_box_items_item_aspect_mode(void); static void st_collections_group_parts_part_box_items_item_options(void); +/* but these are only for table */ +static void st_collections_group_parts_part_table_items_item_position(void); +static void st_collections_group_parts_part_table_items_item_span(void); static void ob_collections_group_parts_part_description(void); static void st_collections_group_parts_part_description_inherit(void); @@ -183,6 +187,9 @@ static void st_collections_group_parts_part_description_gradient_rel2_offset(voi static void st_collections_group_parts_part_description_box_layout(void); static void st_collections_group_parts_part_description_box_align(void); static void st_collections_group_parts_part_description_box_padding(void); +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); static void ob_collections_group_programs_program(void); static void st_collections_group_programs_program_name(void); @@ -299,6 +306,20 @@ New_Statement_Handler statement_handlers[] = {"collections.group.parts.part.box.items.item.aspect", st_collections_group_parts_part_box_items_item_aspect}, {"collections.group.parts.part.box.items.item.aspect_mode", st_collections_group_parts_part_box_items_item_aspect_mode}, {"collections.group.parts.part.box.items.item.options", st_collections_group_parts_part_box_items_item_options}, + {"collections.group.parts.part.table.items.item.type", st_collections_group_parts_part_box_items_item_type}, /* dup */ + {"collections.group.parts.part.table.items.item.name", st_collections_group_parts_part_box_items_item_name}, /* dup */ + {"collections.group.parts.part.table.items.item.source", st_collections_group_parts_part_box_items_item_source}, /* dup */ + {"collections.group.parts.part.table.items.item.min", st_collections_group_parts_part_box_items_item_min}, /* dup */ + {"collections.group.parts.part.table.items.item.prefer", st_collections_group_parts_part_box_items_item_prefer}, /* dup */ + {"collections.group.parts.part.table.items.item.max", st_collections_group_parts_part_box_items_item_max}, /* dup */ + {"collections.group.parts.part.table.items.item.padding", st_collections_group_parts_part_box_items_item_padding}, /* dup */ + {"collections.group.parts.part.table.items.item.align", st_collections_group_parts_part_box_items_item_align}, /* dup */ + {"collections.group.parts.part.table.items.item.weight", st_collections_group_parts_part_box_items_item_weight}, /* dup */ + {"collections.group.parts.part.table.items.item.aspect", st_collections_group_parts_part_box_items_item_aspect}, /* dup */ + {"collections.group.parts.part.table.items.item.aspect_mode", st_collections_group_parts_part_box_items_item_aspect_mode}, /* dup */ + {"collections.group.parts.part.table.items.item.options", st_collections_group_parts_part_box_items_item_options}, /* dup */ + {"collections.group.parts.part.table.items.item.position", st_collections_group_parts_part_table_items_item_position}, + {"collections.group.parts.part.table.items.item.span", st_collections_group_parts_part_table_items_item_span}, {"collections.group.parts.part.description.inherit", st_collections_group_parts_part_description_inherit}, {"collections.group.parts.part.description.state", st_collections_group_parts_part_description_state}, {"collections.group.parts.part.description.visible", st_collections_group_parts_part_description_visible}, @@ -361,6 +382,9 @@ New_Statement_Handler statement_handlers[] = {"collections.group.parts.part.description.box.layout", st_collections_group_parts_part_description_box_layout}, {"collections.group.parts.part.description.box.align", st_collections_group_parts_part_description_box_align}, {"collections.group.parts.part.description.box.padding", st_collections_group_parts_part_description_box_padding}, + {"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.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 */ @@ -498,6 +522,9 @@ New_Object_Handler object_handlers[] = {"collections.group.parts.part.box", NULL}, {"collections.group.parts.part.box.items", NULL}, {"collections.group.parts.part.box.items.item", ob_collections_group_parts_part_box_items_item}, + {"collections.group.parts.part.table", NULL}, + {"collections.group.parts.part.table.items", NULL}, + {"collections.group.parts.part.table.items.item", ob_collections_group_parts_part_box_items_item}, /* dup */ {"collections.group.parts.part.description", ob_collections_group_parts_part_description}, {"collections.group.parts.part.description.rel1", NULL}, {"collections.group.parts.part.description.rel2", NULL}, @@ -516,6 +543,7 @@ New_Object_Handler object_handlers[] = {"collections.group.parts.part.description.gradient.rel1", NULL}, {"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.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 */ @@ -1593,6 +1621,7 @@ st_collections_group_parts_part_name(void) @li GRADIENT @li GROUP @li BOX + @li TABLE @endproperty */ static void @@ -1615,6 +1644,7 @@ st_collections_group_parts_part_type(void) "GRADIENT", EDJE_PART_TYPE_GRADIENT, "GROUP", EDJE_PART_TYPE_GROUP, "BOX", EDJE_PART_TYPE_BOX, + "TABLE", EDJE_PART_TYPE_TABLE, NULL); } @@ -2294,10 +2324,10 @@ static void ob_collections_group_parts_part_box_items_item(void) 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_BOX) + if ((ep->type != EDJE_PART_TYPE_BOX) && (ep->type != EDJE_PART_TYPE_TABLE)) { fprintf(stderr, "%s: Error. parse error %s:%i. " - "box attributes in non-BOX part.\n", + "box attributes in non-BOX or TABLE part.\n", progname, file_in, line - 1); exit(-1); } @@ -2325,6 +2355,10 @@ static void ob_collections_group_parts_part_box_items_item(void) item->aspect.h = 0; item->aspect.mode = EDJE_ASPECT_PREFER_NONE; item->options = NULL; + item->col = -1; + item->row = -1; + item->colspan = 1; + item->rowspan = 1; } /** @@ -2657,6 +2691,76 @@ static void st_collections_group_parts_part_box_items_item_options(void) /** @page edcref + @property + position + @parameters + [col] [row] + @effect + Sets the position this item will have in the table. + This is required for parts of type TABLE. + @endproperty +*/ +static void st_collections_group_parts_part_table_items_item_position(void) +{ + Edje_Part_Collection *pc; + Edje_Part *ep; + Edje_Pack_Element *item; + + 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_TABLE) + { + fprintf(stderr, "%s: Error. parse error %s:%i. " + "table attributes in non-TABLE part.\n", + progname, file_in, line - 1); + exit(-1); + } + + item = eina_list_data_get(eina_list_last(ep->items)); + item->col = parse_int_range(0, 0, 0xffff); + item->row = parse_int_range(1, 0, 0xffff); +} + +/** + @page edcref + @property + span + @parameters + [col] [row] + @effect + Sets how many columns/rows this item will use. + Defaults to 1 1. + @endproperty +*/ +static void st_collections_group_parts_part_table_items_item_span(void) +{ + Edje_Part_Collection *pc; + Edje_Part *ep; + Edje_Pack_Element *item; + + 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_TABLE) + { + fprintf(stderr, "%s: Error. parse error %s:%i. " + "table attributes in non-TABLE part.\n", + progname, file_in, line - 1); + exit(-1); + } + + item = eina_list_data_get(eina_list_last(ep->items)); + item->colspan = parse_int_range(0, 1, 0xffff); + item->rowspan = parse_int_range(1, 1, 0xffff); +} + +/** + @page edcref @block description @context @@ -2764,6 +2868,11 @@ ob_collections_group_parts_part_description(void) ed->box.align.y = 0.5; ed->box.padding.x = 0; ed->box.padding.y = 0; + ed->table.homogeneous = EDJE_OBJECT_TABLE_HOMOGENEOUS_NONE; + ed->table.align.x = 0.5; + ed->table.align.y = 0.5; + ed->table.padding.x = 0; + ed->table.padding.y = 0; } /** @@ -5058,6 +5167,135 @@ static void st_collections_group_parts_part_description_box_padding(void) /** @page edcref + + @block + table + @context + part { + description { + .. + table { + homogeneous: TABLE; + padding: 0 2; + align: 0.5 0.5; + } + .. + } + } + @description + A table block can contain other objects packed in multiple columns + and rows, and each item can span across more than one column and/or + row. + @endblock + + @property + homogeneous + @parameters + [homogeneous mode] + @effect + Sets the homogeneous mode for the table: + @li NONE (default) + @li TABLE + @li ITEM + @endproperty + + @property + align + @parameters + [horizontal] [vertical] + @effect + Change the position of the point of balance inside the container. The + default value is 0.5 0.5. + @endproperty + + @property + padding + @parameters + [horizontal] [vertical] + @effect + Sets the space between cells in pixels. Defaults to 0 0. + @endproperty +*/ +static void st_collections_group_parts_part_description_table_homogeneous(void) +{ + Edje_Part_Collection *pc; + Edje_Part *ep; + Edje_Part_Description *ed; + + check_min_arg_count(1); + + 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_TABLE) + { + fprintf(stderr, "%s: Error. parse error %s:%i. " + "table attributes in non-TABLE 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)); + ed->table.homogeneous = parse_enum(0, + "NONE", EDJE_OBJECT_TABLE_HOMOGENEOUS_NONE, + "TABLE", EDJE_OBJECT_TABLE_HOMOGENEOUS_TABLE, + "ITEM", EDJE_OBJECT_TABLE_HOMOGENEOUS_ITEM, + NULL); +} + +static void st_collections_group_parts_part_description_table_align(void) +{ + Edje_Part_Collection *pc; + Edje_Part *ep; + Edje_Part_Description *ed; + + 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_TABLE) + { + fprintf(stderr, "%s: Error. parse error %s:%i. " + "table attributes in non-TABLE 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)); + ed->table.align.x = parse_float_range(0, -1.0, 1.0); + ed->table.align.y = parse_float_range(1, -1.0, 1.0); +} + +static void st_collections_group_parts_part_description_table_padding(void) +{ + Edje_Part_Collection *pc; + Edje_Part *ep; + Edje_Part_Description *ed; + + 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_TABLE) + { + fprintf(stderr, "%s: Error. parse error %s:%i. " + "table attributes in non-TABLE 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)); + ed->table.padding.x = parse_int_range(0, 0, 0x7fffffff); + ed->table.padding.y = parse_int_range(1, 0, 0x7fffffff); +} + +/** + @page edcref @block program @context diff --git a/src/bin/edje_cc_out.c b/src/bin/edje_cc_out.c index 819a4f5..347bef1 100644 --- a/src/bin/edje_cc_out.c +++ b/src/bin/edje_cc_out.c @@ -162,6 +162,10 @@ check_packed_items(Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) error_and_abort(ef, "Collection %i: missing source on packed item " "of type GROUP in part \"%s\"\n", pc->id, ep->name); + if (ep->type == EDJE_PART_TYPE_TABLE && (it->col < 0 || it->row < 0)) + error_and_abort(ef, "Collection %i: missing col/row on packed item " + "for part \"%s\" of type TABLE\n", + pc->id, ep->name); } } @@ -183,7 +187,8 @@ check_part (Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef) EINA_LIST_FOREACH(ep->other_desc, l, data) check_image_part_desc (pc, ep, data, ef); } - else if (ep->type == EDJE_PART_TYPE_BOX) + else if ((ep->type == EDJE_PART_TYPE_BOX) || + (ep->type == EDJE_PART_TYPE_TABLE)) check_packed_items(pc, ep, ef); } diff --git a/src/lib/Edje.h b/src/lib/Edje.h index a4410a1..f1b63f4 100644 --- a/src/lib/Edje.h +++ b/src/lib/Edje.h @@ -62,6 +62,14 @@ enum _Edje_Aspect_Control }; typedef enum _Edje_Aspect_Control Edje_Aspect_Control; +enum _Edje_Object_Table_Homogeneous_Mode +{ + EDJE_OBJECT_TABLE_HOMOGENEOUS_NONE = 0, + EDJE_OBJECT_TABLE_HOMOGENEOUS_TABLE = 1, + EDJE_OBJECT_TABLE_HOMOGENEOUS_ITEM = 2 +}; +typedef enum _Edje_Object_Table_Homogeneous_Mode Edje_Object_Table_Homogeneous_Mode; + typedef struct _Edje_Message_String Edje_Message_String; typedef struct _Edje_Message_Int Edje_Message_Int; typedef struct _Edje_Message_Float Edje_Message_Float; @@ -267,6 +275,10 @@ extern "C" { EAPI Evas_Object *edje_object_part_box_remove (Evas_Object *obj, const char *part, Evas_Object *child); EAPI Evas_Object *edje_object_part_box_remove_at (Evas_Object *obj, const char *part, unsigned int pos); EAPI Evas_Bool edje_object_part_box_remove_all (Evas_Object *obj, const char *part, Evas_Bool clear); + EAPI Evas_Bool edje_object_part_table_pack (Evas_Object *obj, const char *part, Evas_Object *child_obj, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan); + EAPI Evas_Bool edje_object_part_table_unpack (Evas_Object *obj, const char *part, Evas_Object *child_obj); + EAPI void edje_object_part_table_col_row_size_get (const Evas_Object *obj, const char *part, int *cols, int *rows); + EAPI void edje_object_part_table_clear (Evas_Object *obj, const char *part, Evas_Bool clear); /* edje_message_queue.c */ EAPI void edje_object_message_send (Evas_Object *obj, Edje_Message_Type type, int id, void *msg); diff --git a/src/lib/edje_calc.c b/src/lib/edje_calc.c index 3396449..997cebb 100644 --- a/src/lib/edje_calc.c +++ b/src/lib/edje_calc.c @@ -1220,6 +1220,14 @@ _edje_box_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_ } static void +_edje_table_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description *chosen_desc) +{ + evas_object_table_homogeneous_set(ep->object, chosen_desc->table.homogeneous); + evas_object_table_align_set(ep->object, chosen_desc->table.align.x, chosen_desc->table.align.y); + evas_object_table_padding_set(ep->object, chosen_desc->table.padding.x, chosen_desc->table.padding.y); +} + +static void _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description *chosen_desc, double pos) { int image_id; @@ -1507,6 +1515,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags) case EDJE_PART_TYPE_TEXTBLOCK: case EDJE_PART_TYPE_GRADIENT: case EDJE_PART_TYPE_BOX: + case EDJE_PART_TYPE_TABLE: evas_object_color_set(ep->object, (pf->color.r * pf->color.a) / 255, (pf->color.g * pf->color.a) / 255, @@ -1547,6 +1556,9 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags) case EDJE_PART_TYPE_BOX: _edje_box_recalc_apply(ed, ep, pf, chosen_desc); break; + case EDJE_PART_TYPE_TABLE: + _edje_table_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 cdd0a2c..e238f10 100644 --- a/src/lib/edje_data.c +++ b/src/lib/edje_data.c @@ -369,6 +369,11 @@ _edje_edd_setup(void) EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "box.align.y", box.align.y, EET_T_DOUBLE); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "box.padding.x", box.padding.x, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "box.padding.y", box.padding.y, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "table.homogeneous", table.homogeneous, EET_T_UCHAR); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "table.align.x", table.align.x, EET_T_DOUBLE); + 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); NEWD("Edje_Pack_Element", Edje_Pack_Element); @@ -395,6 +400,10 @@ _edje_edd_setup(void) EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "aspect.h", aspect.h, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "aspect.mode", aspect.mode, EET_T_UCHAR); EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "options", options, EET_T_STRING); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "col", col, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "row", row, EET_T_INT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "colspan", colspan, EET_T_USHORT); + EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "rowspan", rowspan, EET_T_USHORT); NEWD("Edje_Part", Edje_Part); diff --git a/src/lib/edje_load.c b/src/lib/edje_load.c index 7586dd3..d7d9f5c 100644 --- a/src/lib/edje_load.c +++ b/src/lib/edje_load.c @@ -349,6 +349,8 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g { rp->object = evas_object_box_add(ed->evas); } + else if (ep->type == EDJE_PART_TYPE_TABLE) + rp->object = evas_object_table_add(ed->evas); else printf("EDJE ERROR: wrong part type %i!\n", ep->type); if (rp->object) @@ -502,10 +504,12 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g rp = ed->table_parts[i]; if (rp->part->type != EDJE_PART_TYPE_GROUP && - rp->part->type != EDJE_PART_TYPE_BOX) continue; + rp->part->type != EDJE_PART_TYPE_BOX && + rp->part->type != EDJE_PART_TYPE_TABLE) continue; if (rp->part->type == EDJE_PART_TYPE_GROUP) source = rp->part->source; - else if (rp->part->type == EDJE_PART_TYPE_BOX) + else if (rp->part->type == EDJE_PART_TYPE_BOX || + rp->part->type == EDJE_PART_TYPE_TABLE) { if (rp->part->items) { @@ -579,15 +583,22 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g _edje_real_part_swallow(rp, child_obj); source = NULL; } - else if (rp->part->type == EDJE_PART_TYPE_BOX) + else { _edje_object_pack_item_hints_set(child_obj, pack_it); evas_object_show(child_obj); - - _edje_real_part_box_append(rp, child_obj); - evas_object_data_set(child_obj, "\377 edje.box_item", curr_item->data); if (pack_it->name) evas_object_name_set(child_obj, pack_it->name); + if (rp->part->type == EDJE_PART_TYPE_BOX) + { + _edje_real_part_box_append(rp, child_obj); + evas_object_data_set(child_obj, "\377 edje.box_item", pack_it); + } + else if(rp->part->type == EDJE_PART_TYPE_TABLE) + { + _edje_real_part_table_pack(rp, child_obj, pack_it->col, pack_it->row, pack_it->colspan, pack_it->rowspan); + evas_object_data_set(child_obj, "\377 edje.table_item", pack_it); + } rp->items = eina_list_append(rp->items, child_obj); if (!(curr_item = curr_item->next)) source = NULL; @@ -756,7 +767,7 @@ _edje_file_del(Edje *ed) /* all internal, for now */ while (rp->items) { - /* evas_box handles deletion of objects */ + /* evas_box/table handles deletion of objects */ /*evas_object_del(rp->items->data);*/ rp->items = eina_list_remove_list(rp->items, rp->items); } diff --git a/src/lib/edje_private.h b/src/lib/edje_private.h index 854905f..5fc4a81 100644 --- a/src/lib/edje_private.h +++ b/src/lib/edje_private.h @@ -153,7 +153,8 @@ typedef struct _Edje_Patterns Edje_Patterns; #define EDJE_PART_TYPE_GRADIENT 6 #define EDJE_PART_TYPE_GROUP 7 #define EDJE_PART_TYPE_BOX 8 -#define EDJE_PART_TYPE_LAST 9 +#define EDJE_PART_TYPE_TABLE 9 +#define EDJE_PART_TYPE_LAST 10 #define EDJE_TEXT_EFFECT_NONE 0 #define EDJE_TEXT_EFFECT_PLAIN 1 @@ -414,6 +415,9 @@ struct _Edje_Pack_Element Edje_Alignment weight; Edje_Aspect aspect; const char *options; /* extra options for custom objects */ + /* table specific follows */ + int col, row; + unsigned short colspan, rowspan; }; /*----------*/ @@ -583,6 +587,13 @@ struct _Edje_Part_Description int x, y; } padding; } box; + struct { + unsigned char homogeneous; + Edje_Alignment align; + struct { + int x, y; + } padding; + } table; Edje_Color color, color2, color3; /* color for rect or text, shadow etc. */ @@ -1129,6 +1140,9 @@ Evas_Bool _edje_real_part_box_insert_at(Edje_Real_Part *rp, Evas_Object Evas_Object *_edje_real_part_box_remove(Edje_Real_Part *rp, Evas_Object *child_obj); Evas_Object *_edje_real_part_box_remove_at(Edje_Real_Part *rp, unsigned int pos); Evas_Bool _edje_real_part_box_remove_all(Edje_Real_Part *rp, Evas_Bool clear); +Evas_Bool _edje_real_part_table_pack(Edje_Real_Part *rp, Evas_Object *child_obj, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan); +Evas_Bool _edje_real_part_table_unpack(Edje_Real_Part *rp, Evas_Object *child_obj); +void _edje_real_part_table_clear(Edje_Real_Part *rp, Evas_Bool clear); void _edje_embryo_script_init (Edje *ed); void _edje_embryo_script_shutdown (Edje *ed); diff --git a/src/lib/edje_util.c b/src/lib/edje_util.c index 5a94016..cf768fd 100644 --- a/src/lib/edje_util.c +++ b/src/lib/edje_util.c @@ -2402,32 +2402,170 @@ _edje_real_part_box_remove_at(Edje_Real_Part *rp, unsigned int pos) Evas_Bool _edje_real_part_box_remove_all(Edje_Real_Part *rp, Evas_Bool clear) { - Evas_Object_Box_Data *priv; - Evas_Object_Box_Option *opt; - Eina_List *l, *l_next; + Eina_List *children; int i; if (eina_list_count(rp->items) == 0) return evas_object_box_remove_all(rp->object, clear); - priv = evas_object_smart_data_get(rp->object); i = 0; - EINA_LIST_FOREACH_SAFE(priv->children, l, l_next, opt) + children = evas_object_box_children_get(rp->object); + while (children) { - Evas_Object *child_obj; - child_obj = opt->obj; + Evas_Object *child_obj = children->data; if (evas_object_data_get(child_obj, "\377 edje.box_item")) + i++; + else { - i++; - continue; + if (!evas_object_box_remove_at(rp->object, i)) + return 0; + if (clear) + evas_object_del(child_obj); } - if (!evas_object_box_remove_at(rp->object, i)) - return 0; - if (clear) - evas_object_del(child_obj); + children = eina_list_remove_list(children, children); } return 1; } +/** Packs an object into the table + * @param obj A valid Evas_Object handle + * @param part The part name + * @param child The object to pack in + * @param col The column to place it in + * @param row The row to place it in + * @param colspan Columns the child will take + * @param rowspan Rows the child will take + * + * @return 1: Successfully added.\n + * 0: An error occured. + * + * Packs an object into the table indicated by part.\n + */ +EAPI Evas_Bool +edje_object_part_table_pack(Evas_Object *obj, const char *part, Evas_Object *child_obj, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return 0; + + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return 0; + if (rp->part->type != EDJE_PART_TYPE_TABLE) return 0; + + return _edje_real_part_table_pack(rp, child_obj, col, row, colspan, rowspan); +} + +/** Removes an object from the table + * @param obj A valid Evas_Object handle + * @param part The part name + * @param child The object to pack in + * + * @return 1: Successfully removed.\n + * 0: An error occured. + * + * Removes an object from the table indicated by part.\n + */ +EAPI Evas_Bool +edje_object_part_table_unpack(Evas_Object *obj, const char *part, Evas_Object *child_obj) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return 0; + + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return 0; + if (rp->part->type != EDJE_PART_TYPE_TABLE) return 0; + + return _edje_real_part_table_unpack(rp, child_obj); +} + +/** Gets the number of columns and rows the table has + * @param obj A valid Evas_Object handle + * @param part The part name + * @param cols Pointer where to store number of columns (can be NULL) + * @param rows Pointer where to store number of rows (can be NULL) + * + * Retrieves the size of the table in number of columns and rows.\n + */ +EAPI void +edje_object_part_table_col_row_size_get(const Evas_Object *obj, const char *part, int *cols, int *rows) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return; + if (rp->part->type != EDJE_PART_TYPE_TABLE) return; + + return evas_object_table_col_row_size_get(rp->object, cols, rows); +} + +/** Removes all object from the table + * @param obj A valid Evas_Object handle + * @param part The part name + * @param clear If set, will delete subobjs on remove + * + * Removes all object from the table indicated by part, except + * the internal ones set from the theme.\n + */ +EAPI void +edje_object_part_table_clear(Evas_Object *obj, const char *part, Evas_Bool clear) +{ + Edje *ed; + Edje_Real_Part *rp; + + ed = _edje_fetch(obj); + if ((!ed) || (!part)) return; + + rp = _edje_real_part_recursive_get(ed, part); + if (!rp) return; + if (rp->part->type != EDJE_PART_TYPE_TABLE) return; + + return _edje_real_part_table_clear(rp, clear); +} + +Evas_Bool +_edje_real_part_table_pack(Edje_Real_Part *rp, Evas_Object *child_obj, unsigned short col, unsigned short row, unsigned short colspan, unsigned short rowspan) +{ + return evas_object_table_pack(rp->object, child_obj, col, row, colspan, rowspan); +} + +Evas_Bool +_edje_real_part_table_unpack(Edje_Real_Part *rp, Evas_Object *child_obj) +{ + return evas_object_table_unpack(rp->object, child_obj); +} + +void +_edje_real_part_table_clear(Edje_Real_Part *rp, Evas_Bool clear) +{ + Eina_List *children; + + if (eina_list_count(rp->items) == 0) + { + evas_object_table_clear(rp->object, clear); + return; + } + children = evas_object_table_children_get(rp->object); + while (children) + { + Evas_Object *child_obj = children->data; + if (!evas_object_data_get(child_obj, "\377 edje.table_item")) + { + evas_object_table_unpack(rp->object, child_obj); + if (clear) + evas_object_del(child_obj); + } + children = eina_list_remove_list(children, children); + } +} + Edje_Real_Part * _edje_real_part_recursive_get(Edje *ed, const char *part) {