static void st_collections_group_parts_part_dragable_confine(void);
static void st_collections_group_parts_part_dragable_events(void);
+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);
+static void st_collections_group_parts_part_box_items_item_source(void);
+static void st_collections_group_parts_part_box_items_item_min(void);
+static void st_collections_group_parts_part_box_items_item_prefer(void);
+static void st_collections_group_parts_part_box_items_item_max(void);
+static void st_collections_group_parts_part_box_items_item_padding(void);
+static void st_collections_group_parts_part_box_items_item_align(void);
+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);
+
static void ob_collections_group_parts_part_description(void);
static void st_collections_group_parts_part_description_inherit(void);
static void st_collections_group_parts_part_description_state(void);
static void st_collections_group_parts_part_description_gradient_rel1_offset(void);
static void st_collections_group_parts_part_description_gradient_rel2_relative(void);
static void st_collections_group_parts_part_description_gradient_rel2_offset(void);
+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 ob_collections_group_programs_program(void);
static void st_collections_group_programs_program_name(void);
{"collections.group.parts.part.color_classes.color_class.color", st_color_class_color}, /* dup */
{"collections.group.parts.part.color_classes.color_class.color2", st_color_class_color2}, /* dup */
{"collections.group.parts.part.color_classes.color_class.color3", st_color_class_color3}, /* dup */
+ {"collections.group.parts.part.box.items.item.type", st_collections_group_parts_part_box_items_item_type},
+ {"collections.group.parts.part.box.items.item.name", st_collections_group_parts_part_box_items_item_name},
+ {"collections.group.parts.part.box.items.item.source", st_collections_group_parts_part_box_items_item_source},
+ {"collections.group.parts.part.box.items.item.min", st_collections_group_parts_part_box_items_item_min},
+ {"collections.group.parts.part.box.items.item.prefer", st_collections_group_parts_part_box_items_item_prefer},
+ {"collections.group.parts.part.box.items.item.max", st_collections_group_parts_part_box_items_item_max},
+ {"collections.group.parts.part.box.items.item.padding", st_collections_group_parts_part_box_items_item_padding},
+ {"collections.group.parts.part.box.items.item.align", st_collections_group_parts_part_box_items_item_align},
+ {"collections.group.parts.part.box.items.item.weight", st_collections_group_parts_part_box_items_item_weight},
+ {"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.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},
{"collections.group.parts.part.description.gradient.rel2.relative", st_collections_group_parts_part_description_gradient_rel2_relative},
{"collections.group.parts.part.description.gradient.rel2.offset", st_collections_group_parts_part_description_gradient_rel2_offset},
{"collections.group.parts.part.description.gradient.spectrum", st_collections_group_parts_part_description_gradient_spectrum},
+ {"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.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 */
{"collections.group.parts.part.styles.style", ob_styles_style}, /* dup */
{"collections.group.parts.part.color_classes", NULL}, /* dup */
{"collections.group.parts.part.color_classes.color_class", ob_color_class}, /* dup */
+ {"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.description", ob_collections_group_parts_part_description},
{"collections.group.parts.part.description.rel1", NULL},
{"collections.group.parts.part.description.rel2", NULL},
{"collections.group.parts.part.description.gradient", NULL},
{"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.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 */
description { }
dragable { }
+ items { }
}
..
}
ep->clip_to_id = -1;
ep->dragable.confine_id = -1;
ep->dragable.events_id = -1;
+ ep->items = NULL;
}
/**
@li TEXTBLOCK
@li GRADIENT
@li GROUP
+ @li BOX
@endproperty
*/
static void
"TEXTBLOCK", EDJE_PART_TYPE_TEXTBLOCK,
"GRADIENT", EDJE_PART_TYPE_GRADIENT,
"GROUP", EDJE_PART_TYPE_GROUP,
+ "BOX", EDJE_PART_TYPE_BOX,
NULL);
}
/**
@page edcref
@block
+ items
+ @context
+ part {
+ ..
+ box {
+ items {
+ item {
+ type: TYPE;
+ source: "some source";
+ min: 1 1;
+ max: 100 100;
+ padding: 1 1 2 2;
+ }
+ item {
+ type: TYPE;
+ source: "some other source";
+ name: "some name";
+ align: 1.0 0.5;
+ }
+ ..
+ }
+ }
+ ..
+ }
+ @description
+ On a part of type BOX, this block can be used to set other groups
+ as elements of the box. These can be mixed with external objects set
+ by the application through the edje_object_part_box_* API.
+ @endblock
+*/
+static void ob_collections_group_parts_part_box_items_item(void)
+{
+ Edje_Part_Collection *pc;
+ Edje_Part *ep;
+ Edje_Pack_Element *item;
+
+ 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)
+ {
+ fprintf(stderr, "%s: Error. parse error %s:%i. "
+ "box attributes in non-BOX part.\n",
+ progname, file_in, line - 1);
+ exit(-1);
+ }
+
+ item = mem_alloc(SZ(Edje_Pack_Element));
+ ep->items = eina_list_append(ep->items, item);
+ item->type = EDJE_PART_TYPE_GROUP;
+ item->name = NULL;
+ item->source = NULL;
+ item->min.w = 0;
+ item->min.h = 0;
+ item->prefer.w = 0;
+ item->prefer.h = 0;
+ item->max.w = -1;
+ item->max.h = -1;
+ item->padding.l = 0;
+ item->padding.r = 0;
+ item->padding.t = 0;
+ item->padding.b = 0;
+ item->align.x = 0.5;
+ item->align.y = 0.5;
+ item->weight.x = 0.0;
+ item->weight.y = 0.0;
+ item->aspect.w = 0;
+ item->aspect.h = 0;
+ item->aspect.mode = EDJE_ASPECT_PREFER_NONE;
+ item->options = NULL;
+}
+
+/**
+ @page edcref
+ @property
+ type
+ @parameters
+ Only GROUP for now (defaults to it)
+ @effect
+ Sets the type of the object this item will hold.
+ @endproperty
+*/
+static void st_collections_group_parts_part_box_items_item_type(void)
+{
+ Edje_Part_Collection *pc;
+ Edje_Part *ep;
+ Edje_Pack_Element *item;
+
+ check_arg_count(1);
+
+ pc = eina_list_data_get(eina_list_last(edje_collections));
+ ep = eina_list_data_get(eina_list_last(pc->parts));
+
+ item = eina_list_data_get(eina_list_last(ep->items));
+
+ {
+ char *s;
+
+ s = parse_str(0);
+ if (strcmp(s, "GROUP"))
+ {
+ fprintf(stderr, "%s: Error. parse error %s:%i. "
+ "token %s not one of: GROUP.\n",
+ progname, file_in, line - 1, s);
+ exit(-1);
+ }
+ /* FIXME: handle the enum, once everything else is supported */
+ item->type = EDJE_PART_TYPE_GROUP;
+ }
+}
+
+/**
+ @page edcref
+ @property
+ name
+ @parameters
+ [name for the object]
+ @effect
+ Sets the name of the object via evas_object_name_set().
+ @endproperty
+*/
+static void st_collections_group_parts_part_box_items_item_name(void)
+{
+ Edje_Part_Collection *pc;
+ Edje_Part *ep;
+ Edje_Pack_Element *item;
+
+ check_arg_count(1);
+
+ pc = eina_list_data_get(eina_list_last(edje_collections));
+ ep = eina_list_data_get(eina_list_last(pc->parts));
+
+ item = eina_list_data_get(eina_list_last(ep->items));
+ item->name = parse_str(0);
+}
+
+/**
+ @page edcref
+ @property
+ source
+ @parameters
+ [another groups name]
+ @effect
+ Sets the group this object will be made from.
+ @endproperty
+*/
+static void st_collections_group_parts_part_box_items_item_source(void)
+{
+ Edje_Part_Collection *pc;
+ Edje_Part *ep;
+ Edje_Pack_Element *item;
+
+ check_arg_count(1);
+
+ pc = eina_list_data_get(eina_list_last(edje_collections));
+ ep = eina_list_data_get(eina_list_last(pc->parts));
+
+ item = eina_list_data_get(eina_list_last(ep->items));
+ item->source = parse_str(0);
+}
+
+/**
+ @page edcref
+ @property
+ min
+ @parameters
+ [width] [height]
+ @effect
+ Sets the minimum size hints for this object.
+ @endproperty
+*/
+static void st_collections_group_parts_part_box_items_item_min(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));
+
+ item = eina_list_data_get(eina_list_last(ep->items));
+ item->min.w = parse_int_range(0, 0, 0x7ffffff);
+ item->min.h = parse_int_range(1, 0, 0x7ffffff);
+}
+
+/**
+ @page edcref
+ @property
+ prefer
+ @parameters
+ [width] [height]
+ @effect
+ Sets the preferred size hints for this object.
+ @endproperty
+*/
+static void st_collections_group_parts_part_box_items_item_prefer(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));
+
+ item = eina_list_data_get(eina_list_last(ep->items));
+ item->prefer.w = parse_int_range(0, 0, 0x7ffffff);
+ item->prefer.h = parse_int_range(1, 0, 0x7ffffff);
+}
+/**
+ @page edcref
+ @property
+ max
+ @parameters
+ [width] [height]
+ @effect
+ Sets the maximum size hints for this object.
+ @endproperty
+*/
+static void st_collections_group_parts_part_box_items_item_max(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));
+
+ item = eina_list_data_get(eina_list_last(ep->items));
+ item->max.w = parse_int_range(0, 0, 0x7ffffff);
+ item->max.h = parse_int_range(1, 0, 0x7ffffff);
+}
+
+/**
+ @page edcref
+ @property
+ padding
+ @parameters
+ [left] [right] [top] [bottom]
+ @effect
+ Sets the padding hints for this object.
+ @endproperty
+*/
+static void st_collections_group_parts_part_box_items_item_padding(void)
+{
+ Edje_Part_Collection *pc;
+ Edje_Part *ep;
+ Edje_Pack_Element *item;
+
+ check_arg_count(4);
+
+ pc = eina_list_data_get(eina_list_last(edje_collections));
+ ep = eina_list_data_get(eina_list_last(pc->parts));
+
+ item = eina_list_data_get(eina_list_last(ep->items));
+ item->padding.l = parse_int_range(0, 0, 0x7ffffff);
+ item->padding.r = parse_int_range(1, 0, 0x7ffffff);
+ item->padding.t = parse_int_range(2, 0, 0x7ffffff);
+ item->padding.b = parse_int_range(3, 0, 0x7ffffff);
+}
+
+/**
+ @page edcref
+ @property
+ align
+ @parameters
+ [x] [y]
+ @effect
+ Sets the alignment hints for this object.
+ @endproperty
+*/
+static void st_collections_group_parts_part_box_items_item_align(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));
+
+ item = eina_list_data_get(eina_list_last(ep->items));
+ item->align.x = parse_float_range(0, -1.0, 1.0);
+ item->align.y = parse_float_range(1, -1.0, 1.0);
+}
+
+/**
+ @page edcref
+ @property
+ weight
+ @parameters
+ [x] [y]
+ @effect
+ Sets the weight hints for this object.
+ @endproperty
+*/
+static void st_collections_group_parts_part_box_items_item_weight(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));
+
+ item = eina_list_data_get(eina_list_last(ep->items));
+ item->weight.x = parse_float_range(0, 0.0, 99999.99);
+ item->weight.y = parse_float_range(1, 0.0, 99999.99);
+}
+
+/**
+ @page edcref
+ @property
+ aspect
+ @parameters
+ [w] [h]
+ @effect
+ Sets the aspect width and height hints for this object.
+ @endproperty
+*/
+static void st_collections_group_parts_part_box_items_item_aspect(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));
+
+ item = eina_list_data_get(eina_list_last(ep->items));
+ item->aspect.w = parse_int_range(0, 0, 0x7fffffff);
+ item->aspect.h = parse_int_range(1, 0, 0x7fffffff);
+}
+
+/**
+ @page edcref
+ @property
+ aspect_mode
+ @parameters
+ NONE, NEITHER, HORIZONTAL, VERTICAL, BOTH
+ @effect
+ Sets the aspect control hints for this object.
+ @endproperty
+*/
+static void st_collections_group_parts_part_box_items_item_aspect_mode(void)
+{
+ Edje_Part_Collection *pc;
+ Edje_Part *ep;
+ Edje_Pack_Element *item;
+
+ check_arg_count(1);
+
+ pc = eina_list_data_get(eina_list_last(edje_collections));
+ ep = eina_list_data_get(eina_list_last(pc->parts));
+
+ item = eina_list_data_get(eina_list_last(ep->items));
+ item->aspect.mode = parse_enum(0,
+ "NONE", EDJE_ASPECT_CONTROL_NONE,
+ "NEITHER", EDJE_ASPECT_CONTROL_NEITHER,
+ "HORIZONTAL", EDJE_ASPECT_CONTROL_HORIZONTAL,
+ "VERTICAL", EDJE_ASPECT_CONTROL_VERTICAL,
+ "BOTH", EDJE_ASPECT_CONTROL_BOTH,
+ NULL);
+}
+
+/**
+ @page edcref
+ @property
+ options
+ @parameters
+ [extra options]
+ @effect
+ Sets extra options for the object. Unused for now.
+ @endproperty
+*/
+static void st_collections_group_parts_part_box_items_item_options(void)
+{
+ Edje_Part_Collection *pc;
+ Edje_Part *ep;
+ Edje_Pack_Element *item;
+
+ check_arg_count(1);
+
+ pc = eina_list_data_get(eina_list_last(edje_collections));
+ ep = eina_list_data_get(eina_list_last(pc->parts));
+
+ item = eina_list_data_get(eina_list_last(ep->items));
+ item->options = parse_str(0);
+}
+
+/**
+ @page edcref
+ @block
description
@context
description {
ed->gradient.rel2.relative_y = 1;
ed->gradient.rel2.offset_x = -1;
ed->gradient.rel2.offset_y = -1;
+ ed->box.layout = NULL;
+ ed->box.alt_layout = NULL;
+ ed->box.align.x = 0.5;
+ ed->box.align.y = 0.5;
+ ed->box.padding.x = 0;
+ ed->box.padding.y = 0;
}
/**
/**
@page edcref
+
+ @block
+ box
+ @context
+ part {
+ description {
+ ..
+ box {
+ layout: "vertical";
+ padding: 0 2;
+ align: 0.5 0.5;
+ }
+ ..
+ }
+ }
+ @description
+ A box block can contain other objects and display them in different
+ layouts, any of the predefined set, or a custom one, set by the
+ application.
+ @endblock
+
+ @property
+ layout
+ @parameters
+ [primary layout] [fallback layout]
+ @effect
+ Sets the layout for the box:
+ @li horizontal (default)
+ @li vertical
+ @li horizontal_homogeneous
+ @li vertical_homogeneous
+ @li horizontal_max (homogeneous to the max sized child)
+ @li vertical_max
+ @li horizontal_flow
+ @li vertical_flow
+ @li stack
+ @li some_other_custom_layout_set_by_the_application
+ You could set a custom layout as fallback, it makes very
+ very little sense though, and if that one fails, it will
+ default to horizontal.
+ @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_box_layout(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_BOX)
+ {
+ fprintf(stderr, "%s: Error. parse error %s:%i. "
+ "box attributes in non-BOX 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->box.layout = parse_str(0);
+ if (is_param(1))
+ ed->box.alt_layout = parse_str(1);
+}
+
+static void st_collections_group_parts_part_description_box_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_BOX)
+ {
+ fprintf(stderr, "%s: Error. parse error %s:%i. "
+ "box attributes in non-BOX 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->box.align.x = parse_float_range(0, -1.0, 1.0);
+ ed->box.align.y = parse_float_range(1, -1.0, 1.0);
+}
+
+static void st_collections_group_parts_part_description_box_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_BOX)
+ {
+ fprintf(stderr, "%s: Error. parse error %s:%i. "
+ "box attributes in non-BOX 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->box.padding.x = parse_int_range(0, 0, 0x7fffffff);
+ ed->box.padding.y = parse_int_range(1, 0, 0x7fffffff);
+}
+
+/**
+ @page edcref
@block
program
@context
}
static void
+check_packed_items(Edje_Part_Collection *pc, Edje_Part *ep, Edje_File *ef)
+{
+ Eina_List *l;
+ Edje_Pack_Element *it;
+
+ EINA_LIST_FOREACH(ep->items, l, it)
+ {
+ if (it->type == EDJE_PART_TYPE_GROUP && !it->source)
+ error_and_abort(ef, "Collection %i: missing source on packed item "
+ "of type GROUP in part \"%s\"\n",
+ pc->id, ep->name);
+ }
+}
+
+static void
check_part (Edje_Part_Collection *pc, Edje_Part *ep, Eet_File *ef)
{
Edje_Part_Description *epd = ep->default_desc;
EINA_LIST_FOREACH(ep->other_desc, l, data)
check_image_part_desc (pc, ep, data, ef);
}
+ else if (ep->type == EDJE_PART_TYPE_BOX)
+ check_packed_items(pc, ep, ef);
}
static void
EAPI void edje_extern_object_min_size_set (Evas_Object *obj, Evas_Coord minw, Evas_Coord minh);
EAPI void edje_extern_object_max_size_set (Evas_Object *obj, Evas_Coord maxw, Evas_Coord maxh);
EAPI void edje_extern_object_aspect_set(Evas_Object *obj, Edje_Aspect_Control aspect, Evas_Coord aw, Evas_Coord ah);
+ EAPI void edje_box_layout_register(const char *name, Evas_Object_Box_Layout func, void *(*layout_data_get)(void *), void (*layout_data_free)(void *), void (*free_data)(void *), void *data);
/* edje_smart.c */
EAPI Evas_Object *edje_object_add (Evas *evas);
EAPI void edje_object_part_drag_page_get (const Evas_Object *obj, const char *part, double *dx, double *dy);
EAPI void edje_object_part_drag_step (Evas_Object *obj, const char *part, double dx, double dy);
EAPI void edje_object_part_drag_page (Evas_Object *obj, const char *part, double dx, double dy);
+ EAPI Evas_Bool edje_object_part_box_append (Evas_Object *obj, const char *part, Evas_Object *child);
+ EAPI Evas_Bool edje_object_part_box_prepend (Evas_Object *obj, const char *part, Evas_Object *child);
+ EAPI Evas_Bool edje_object_part_box_insert_before (Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference);
+ EAPI Evas_Bool edje_object_part_box_insert_at (Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos);
+ 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);
/* edje_message_queue.c */
EAPI void edje_object_message_send (Evas_Object *obj, Edje_Message_Type type, int id, void *msg);
}
static void
+_edje_box_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edje_Part_Description *chosen_desc)
+{
+ Evas_Object_Box_Layout layout;
+ void (*free_data)(void *data);
+ void *data;
+
+ if (!_edje_box_layout_find(chosen_desc->box.layout, &layout, &data, &free_data))
+ {
+ if ((!chosen_desc->box.alt_layout) ||
+ (!_edje_box_layout_find(chosen_desc->box.alt_layout, &layout, &data, &free_data)))
+ {
+ fprintf(stderr, "ERROR: box layout '%s' (fallback '%s') not available, using horizontal.\n",
+ chosen_desc->box.layout, chosen_desc->box.alt_layout);
+ layout = evas_object_box_layout_horizontal;
+ free_data = NULL;
+ data = NULL;
+ }
+ }
+
+ evas_object_box_layout_set(ep->object, layout, data, free_data);
+ evas_object_box_align_set(ep->object, chosen_desc->box.align.x, chosen_desc->box.align.y);
+ evas_object_box_padding_set(ep->object, chosen_desc->box.padding.x, chosen_desc->box.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;
case EDJE_PART_TYPE_IMAGE:
case EDJE_PART_TYPE_TEXTBLOCK:
case EDJE_PART_TYPE_GRADIENT:
+ case EDJE_PART_TYPE_BOX:
evas_object_color_set(ep->object,
(pf->color.r * pf->color.a) / 255,
(pf->color.g * pf->color.a) / 255,
case EDJE_PART_TYPE_GRADIENT:
_edje_gradient_recalc_apply(ed, ep, pf, chosen_desc);
break;
+ case EDJE_PART_TYPE_BOX:
+ _edje_box_recalc_apply(ed, ep, pf, chosen_desc);
+ break;
case EDJE_PART_TYPE_RECTANGLE:
case EDJE_PART_TYPE_SWALLOW:
case EDJE_PART_TYPE_GROUP:
EAPI Eet_Data_Descriptor *_edje_edd_edje_program_after = NULL;
EAPI Eet_Data_Descriptor *_edje_edd_edje_part_collection_directory = NULL;
EAPI Eet_Data_Descriptor *_edje_edd_edje_part_collection_directory_entry = NULL;
+EAPI Eet_Data_Descriptor *_edje_edd_edje_pack_element = NULL;
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;
FREED(_edje_edd_edje_program_after);
FREED(_edje_edd_edje_part_collection_directory);
FREED(_edje_edd_edje_part_collection_directory_entry);
+ FREED(_edje_edd_edje_pack_element);
FREED(_edje_edd_edje_part_collection);
FREED(_edje_edd_edje_part);
FREED(_edje_edd_edje_part_description);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "gradient.rel2.relative_y", gradient.rel2.relative_y, EET_T_DOUBLE);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "gradient.rel2.offset_x", gradient.rel2.offset_x, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "gradient.rel2.offset_y", gradient.rel2.offset_y, EET_T_INT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "box.layout", box.layout, EET_T_STRING);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "box.alt_layout", box.alt_layout, EET_T_STRING);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, Edje_Part_Description, "box.align.x", box.align.x, EET_T_DOUBLE);
+ 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);
+
+ NEWD("Edje_Pack_Element",
+ Edje_Pack_Element);
+ _edje_edd_edje_pack_element =
+ eet_data_descriptor3_new(&eddc);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "type", type, EET_T_UCHAR);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "name", name, EET_T_STRING);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "source", source, EET_T_STRING);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "min.w", min.w, EET_T_INT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "min.h", min.h, EET_T_INT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "prefer.w", prefer.w, EET_T_INT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "prefer.h", prefer.h, EET_T_INT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "max.w", max.w, EET_T_INT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "max.h", max.h, EET_T_INT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "padding.l", padding.l, EET_T_INT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "padding.r", padding.r, EET_T_INT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "padding.t", padding.t, EET_T_INT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "padding.b", padding.b, EET_T_INT);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "align.x", align.x, EET_T_DOUBLE);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "align.y", align.y, EET_T_DOUBLE);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "weight.x", weight.x, EET_T_DOUBLE);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "weight.y", weight.y, EET_T_DOUBLE);
+ EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "aspect.w", aspect.w, EET_T_INT);
+ 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);
NEWD("Edje_Part",
Edje_Part);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "source4", source4, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "source5", source5, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "source6", source6, EET_T_STRING);
+ EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_part, Edje_Part, "items", items, _edje_edd_edje_pack_element);
NEWD("Edje_Part_Collection",
Edje_Part_Collection);
static Evas_Bool _edje_collection_free_prog_cache_matches_free_cb(const Evas_Hash *hash, const char *key, void *data, void *fdata);
#endif
static int _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *group, Eina_List *group_path);
+static void _edje_object_pack_item_hints_set(Evas_Object *obj, Edje_Pack_Element *it);
static void _cb_signal_repeat(void *data, Evas_Object *obj, const char *signal, const char *source);
static Eina_List *_edje_swallows_collect(Edje *ed);
rp->object = evas_object_textblock_add(ed->evas);
else if (ep->type == EDJE_PART_TYPE_GRADIENT)
rp->object = evas_object_gradient_add(ed->evas);
+ else if (ep->type == EDJE_PART_TYPE_BOX)
+ {
+ rp->object = evas_object_box_add(ed->evas);
+ }
else
printf("EDJE ERROR: wrong part type %i!\n", ep->type);
if (rp->object)
for (i = 0; i < ed->table_parts_size; i++)
{
Edje_Real_Part *rp;
+ Eina_List *curr_item;
+ Edje_Pack_Element *pack_it;
+ const char *source = NULL;
rp = ed->table_parts[i];
- if (rp->part->type != EDJE_PART_TYPE_GROUP) continue;
- if (rp->part->source)
+ if (rp->part->type != EDJE_PART_TYPE_GROUP &&
+ rp->part->type != EDJE_PART_TYPE_BOX) continue;
+ if (rp->part->type == EDJE_PART_TYPE_GROUP)
+ source = rp->part->source;
+ else if (rp->part->type == EDJE_PART_TYPE_BOX)
+ {
+ if (rp->part->items)
+ {
+ curr_item = rp->part->items;
+ pack_it = curr_item->data;
+ source = pack_it->source;
+ }
+ }
+ while (source)
{
Eina_List *l;
Evas_Object *child_obj;
Edje *child_ed;
- const char *group_path_entry = eina_stringshare_add(rp->part->source);
+ const char *group_path_entry = eina_stringshare_add(source);
const char *data;
if (!group_path)
child_obj = edje_object_add(ed->evas);
group_path = eina_list_append(group_path, group_path_entry);
- if (!_edje_object_file_set_internal(child_obj, file, rp->part->source, group_path))
+ if (!_edje_object_file_set_internal(child_obj, file, source, group_path))
{
_edje_thaw(ed);
_edje_unblock(ed);
eina_stringshare_del(group_path_entry);
edje_object_signal_callback_add(child_obj, "*", "*", _cb_signal_repeat, obj);
- _edje_real_part_swallow(rp, child_obj);
+ if (rp->part->type == EDJE_PART_TYPE_GROUP)
+ {
+ _edje_real_part_swallow(rp, child_obj);
+ source = NULL;
+ }
+ else if (rp->part->type == EDJE_PART_TYPE_BOX)
+ {
+ _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);
+ rp->items = eina_list_append(rp->items, child_obj);
+ if (!(curr_item = curr_item->next))
+ source = NULL;
+ else
+ {
+ pack_it = curr_item->data;
+ source = pack_it->source;
+ }
+ }
}
}
rp->swallowed_object = NULL;
}
+ if (rp->items)
+ {
+ /* all internal, for now */
+ while (rp->items)
+ {
+ /* evas_box handles deletion of objects */
+ /*evas_object_del(rp->items->data);*/
+ rp->items = eina_list_remove_list(rp->items, rp->items);
+ }
+ }
if (rp->text.text) eina_stringshare_del(rp->text.text);
if (rp->text.font) eina_stringshare_del(rp->text.font);
if (rp->text.cache.in_str) eina_stringshare_del(rp->text.cache.in_str);
#endif
static void
+_edje_object_pack_item_hints_set(Evas_Object *obj, Edje_Pack_Element *it)
+{
+ Evas_Coord w = 0, h = 0, minw, minh;
+
+ minw = it->min.w;
+ minh = it->min.h;
+
+ if ((minw <= 0) && (minh <= 0))
+ {
+ edje_object_size_min_get(obj, &w, &h);
+ if ((w <= 0) && (h <= 0))
+ edje_object_size_min_calc(obj, &w, &h);
+ }
+ else
+ {
+ w = minw;
+ h = minh;
+ }
+ if (((minw <= 0) && (minh <= 0)) && ((w > 0) || (h > 0)))
+ evas_object_size_hint_min_set(obj, w, h);
+ else
+ evas_object_size_hint_min_set(obj, minw, minh);
+
+ evas_object_size_hint_request_set(obj, it->prefer.w, it->prefer.h);
+ evas_object_size_hint_max_set(obj, it->max.w, it->max.h);
+ evas_object_size_hint_padding_set(obj, it->padding.l, it->padding.r, it->padding.t, it->padding.b);
+ evas_object_size_hint_align_set(obj, it->align.x, it->align.y);
+ evas_object_size_hint_weight_set(obj, it->weight.x, it->weight.y);
+ evas_object_size_hint_aspect_set(obj, it->aspect.mode, it->aspect.w, it->aspect.h);
+
+ evas_object_resize(obj, w, h);
+}
+
+static void
_cb_signal_repeat(void *data, Evas_Object *obj, const char *signal, const char *source)
{
Evas_Object *parent;
srand(time(NULL));
_edje_edd_setup();
_edje_text_init();
+ _edje_box_init();
embryo_init();
eet_init();
}
_edje_color_class_hash_free();
_edje_text_class_members_free();
_edje_text_class_hash_free();
+ _edje_box_shutdown();
embryo_shutdown();
ecore_job_shutdown();
eet_shutdown();
typedef struct _Edje_Program_After Edje_Program_After;
typedef struct _Edje_Part_Collection_Directory Edje_Part_Collection_Directory;
typedef struct _Edje_Part_Collection_Directory_Entry Edje_Part_Collection_Directory_Entry;
+typedef struct _Edje_Pack_Element Edje_Pack_Element;
typedef struct _Edje_Part_Collection Edje_Part_Collection;
typedef struct _Edje_Part Edje_Part;
typedef struct _Edje_Part_Image_Id Edje_Part_Image_Id;
#define EDJE_PART_TYPE_TEXTBLOCK 5
#define EDJE_PART_TYPE_GRADIENT 6
#define EDJE_PART_TYPE_GROUP 7
-#define EDJE_PART_TYPE_LAST 8
+#define EDJE_PART_TYPE_BOX 8
+#define EDJE_PART_TYPE_LAST 9
#define EDJE_TEXT_EFFECT_NONE 0
#define EDJE_TEXT_EFFECT_PLAIN 1
/*----------*/
+/*----------*/
+
+struct _Edje_Pack_Element
+{
+ unsigned char type; /* only GROUP supported for now */
+ const char *name; /* if != NULL, will be set with evas_object_name_set */
+ const char *source; /* group name to use as source for this element */
+ Edje_Size min, prefer, max;
+ struct {
+ int l, r, t, b;
+ } padding;
+ Edje_Alignment align;
+ Edje_Alignment weight;
+ Edje_Aspect aspect;
+ const char *options; /* extra options for custom objects */
+};
+
+/*----------*/
+
struct _Edje_Part_Collection
{
Eina_List *programs; /* a list of Edje_Program */
signed char x; /* can u click & drag this bit in x dir */
signed char y; /* can u click & drag this bit in y dir */
} dragable;
+ Eina_List *items; /* packed items for box and table */
unsigned char type; /* what type (image, rect, text) */
unsigned char effect; /* 0 = plain... */
unsigned char mouse_events; /* it will affect/respond to mouse events */
} text;
+ struct {
+ char *layout, *alt_layout;
+ Edje_Alignment align;
+ struct {
+ int x, y;
+ } padding;
+ } box;
+
Edje_Color color, color2, color3; /* color for rect or text, shadow etc. */
unsigned char visible; /* is it shown */
Evas_Object *object;
Eina_List *extra_objects;
Evas_Object *swallowed_object;
+ Eina_List *items;
void *entry_data;
Evas_Object *cursorbg_object;
Evas_Object *cursorfg_object;
void _edje_block_violate(Edje *ed);
void _edje_object_part_swallow_free_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
void _edje_real_part_swallow(Edje_Real_Part *rp, Evas_Object *obj_swallow);
+void _edje_box_init(void);
+void _edje_box_shutdown(void);
+Evas_Bool _edje_box_layout_find(const char *name, Evas_Object_Box_Layout *cb, void **data, void (**free_data)(void *data));
+
+Evas_Bool _edje_real_part_box_append(Edje_Real_Part *rp, Evas_Object *child_obj);
+Evas_Bool _edje_real_part_box_prepend(Edje_Real_Part *rp, Evas_Object *child_obj);
+Evas_Bool _edje_real_part_box_insert_before(Edje_Real_Part *rp, Evas_Object *child_obj, const Evas_Object *ref);
+Evas_Bool _edje_real_part_box_insert_at(Edje_Real_Part *rp, Evas_Object *child_obj, unsigned int pos);
+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);
void _edje_embryo_script_init (Edje *ed);
void _edje_embryo_script_shutdown (Edje *ed);
#include "edje_private.h"
+
+struct _Edje_Box_Layout
+{
+ EINA_RBTREE;
+ Evas_Object_Box_Layout func;
+ void *(*layout_data_get)(void *);
+ void (*layout_data_free)(void *);
+ void *data;
+ void (*free_data)(void *);
+ char name[];
+};
+typedef struct _Edje_Box_Layout Edje_Box_Layout;
+
+
static Evas_Hash *_edje_color_class_hash = NULL;
static Evas_Hash *_edje_color_class_member_hash = NULL;
static Evas_Hash *_edje_text_class_hash = NULL;
static Evas_Hash *_edje_text_class_member_hash = NULL;
+static Eina_Rbtree *_edje_box_layout_registry = NULL;
+
char *_edje_fontset_append = NULL;
double _edje_scale = 1.0;
int _edje_freeze_val = 0;
}
}
+
+static const struct edje_box_layout_builtin {
+ const char *name;
+ Evas_Object_Box_Layout cb;
+} _edje_box_layout_builtin[] = {
+ /* KEEP SORTED AND UPDATE OFFSETS BELOW AT _edje_box_layout_builtin_find() */
+ {"horizontal", evas_object_box_layout_horizontal},
+ {"horizontal_flow", evas_object_box_layout_flow_horizontal},
+ {"horizontal_homogeneous", evas_object_box_layout_homogeneous_horizontal},
+ {"horizontal_max", evas_object_box_layout_homogeneous_max_size_horizontal},
+ {"stack", evas_object_box_layout_stack},
+ {"vertical", evas_object_box_layout_vertical},
+ {"vertical_flow", evas_object_box_layout_flow_vertical},
+ {"vertical_homogeneous", evas_object_box_layout_homogeneous_vertical},
+ {"vertical_max", evas_object_box_layout_homogeneous_max_size_vertical},
+ {NULL, NULL}
+};
+
+static Evas_Object_Box_Layout
+_edje_box_layout_builtin_find(const char *name)
+{
+ const struct edje_box_layout_builtin *base;
+
+ switch (name[0])
+ {
+ case 'h':
+ base = _edje_box_layout_builtin + 0;
+ break;
+ case 's':
+ base = _edje_box_layout_builtin + 4;
+ break;
+ case 'v':
+ base = _edje_box_layout_builtin + 5;
+ break;
+ default:
+ return NULL;
+ }
+
+ for (; (base->name != NULL) && (base->name[0] == name[0]); base++)
+ if (strcmp(base->name, name) == 0)
+ return base->cb;
+
+ return NULL;
+}
+
+static Eina_Rbtree_Direction
+_edje_box_layout_external_node_cmp(const Eina_Rbtree *left, const Eina_Rbtree *right, __UNUSED__ void *data)
+{
+ Edje_Box_Layout *l = (Edje_Box_Layout *)left;
+ Edje_Box_Layout *r = (Edje_Box_Layout *)right;
+
+ if (strcmp(l->name, r->name) < 0)
+ return EINA_RBTREE_LEFT;
+ else
+ return EINA_RBTREE_RIGHT;
+}
+
+static int
+_edje_box_layout_external_find_cmp(const Eina_Rbtree *node, const void *key, __UNUSED__ int length, __UNUSED__ void *data)
+{
+ Edje_Box_Layout *l = (Edje_Box_Layout *)node;
+ return strcmp(key, l->name);
+}
+
+static Edje_Box_Layout *
+_edje_box_layout_external_find(const char *name)
+{
+ return (Edje_Box_Layout *)eina_rbtree_inline_lookup
+ (_edje_box_layout_registry, name, 0, _edje_box_layout_external_find_cmp,
+ NULL);
+}
+
+Evas_Bool
+_edje_box_layout_find(const char *name, Evas_Object_Box_Layout *cb, void **data, void (**free_data)(void *data))
+{
+ const Edje_Box_Layout *l;
+
+ if (!name)
+ return 0;
+
+ *cb = _edje_box_layout_builtin_find(name);
+ if (*cb)
+ {
+ *free_data = NULL;
+ *data = NULL;
+ return 1;
+ }
+
+ l = _edje_box_layout_external_find(name);
+ if (!l)
+ return 0;
+
+ *cb = l->func;
+ *free_data = l->layout_data_free;
+ if (l->layout_data_get)
+ *data = l->layout_data_get(l->data);
+ else
+ *data = NULL;
+
+ return 1;
+}
+
+void
+_edje_box_layout_external_free(Eina_Rbtree *node, __UNUSED__ void *data)
+{
+ Edje_Box_Layout *l = (Edje_Box_Layout *)node;
+
+ if (l->data && l->free_data)
+ l->free_data(l->data);
+ free(l);
+}
+
+static Edje_Box_Layout *
+_edje_box_layout_external_new(const char *name, Evas_Object_Box_Layout func, void *(*layout_data_get)(void *), void (*layout_data_free)(void *), void (*free_data)(void *), void *data)
+{
+ Edje_Box_Layout *l;
+ int name_len;
+
+ name_len = strlen(name) + 1;
+ l = malloc(sizeof(Edje_Box_Layout) + name_len);
+ if (!l)
+ {
+ perror("malloc");
+ return NULL;
+ }
+
+ l->func = func;
+ l->layout_data_get = layout_data_get;
+ l->layout_data_free = layout_data_free;
+ l->free_data = free_data;
+ l->data = data;
+
+ memcpy(l->name, name, name_len);
+
+ return l;
+}
+
+/** Registers a custom layout to be used in edje boxes
+ * @param name The name of the layout
+ * @param func The function defining the layout
+ * @param layout_data_get This function gets the custom data pointer for func
+ * @param layout_data_free Passed to func to free its private data when needed
+ * @param free_data Frees data
+ * @param data Private pointer passed to layout_data_get
+ *
+ * This function registers custom layouts that can be referred from themes
+ * by the registered name.
+ * The Evas_Object_Box_Layout functions receive two pointers for internal
+ * use, one being private data, and the other the function to free that
+ * data when it's not longer needed. From Edje, this private data will be
+ * retrieved by calling layout_data_get, and layout_data_free will be the
+ * free function passed to func. layout_data_get will be called with data
+ * as its parameter, and this one will be freed by free_data whenever the
+ * layout is unregistered from Edje.
+ */
+EAPI void
+edje_box_layout_register(const char *name, Evas_Object_Box_Layout func, void *(*layout_data_get)(void *), void (*layout_data_free)(void *), void (*free_data)(void *), void *data)
+{
+ Edje_Box_Layout *l;
+
+ if (!name) return;
+
+ if (_edje_box_layout_builtin_find(name))
+ {
+ fprintf(stderr,
+ "ERROR: cannot register layout '%s': would override builtin!\n",
+ name);
+
+ if (data && free_data) free_data(data);
+ return;
+ }
+
+ l = _edje_box_layout_external_find(name);
+ if (!l)
+ {
+ if (!func)
+ {
+ if (data && free_data) free_data(data);
+ return;
+ }
+
+ l = _edje_box_layout_external_new
+ (name, func, layout_data_get, layout_data_free, free_data, data);
+ if (!l)
+ return;
+
+ _edje_box_layout_registry = eina_rbtree_inline_insert
+ (_edje_box_layout_registry, (Eina_Rbtree *)l,
+ _edje_box_layout_external_node_cmp, NULL);
+ }
+ else
+ {
+ if (func)
+ {
+ if (l->data && l->free_data) l->free_data(l->data);
+
+ l->func = func;
+ l->layout_data_get = layout_data_get;
+ l->layout_data_free = layout_data_free;
+ l->free_data = free_data;
+ l->data = data;
+ }
+ else
+ {
+ if (data && free_data) free_data(data);
+
+ _edje_box_layout_registry = eina_rbtree_inline_remove
+ (_edje_box_layout_registry, (Eina_Rbtree *)l,
+ _edje_box_layout_external_node_cmp, NULL);
+ _edje_box_layout_external_free((Eina_Rbtree *)l, NULL);
+ }
+ }
+}
+
/** Unswallow an object
* @param obj A valid Evas_Object handle
* @param obj_swallow The swallowed object
_edje_emit(rp->edje, "drag,page", rp->part->name);
}
+void
+_edje_box_init(void)
+{
+}
+
+void
+_edje_box_shutdown(void)
+{
+ if (!_edje_box_layout_registry)
+ return;
+
+ eina_rbtree_delete
+ (_edje_box_layout_registry, _edje_box_layout_external_free, NULL);
+ _edje_box_layout_registry = NULL;
+}
+
+/** Appends an object to the box
+ * @param obj A valid Evas_Object handle
+ * @param part The part name
+ * @param child The object to append
+ *
+ * @return 1: Successfully added.\n
+ * 0: An error occured.
+ *
+ * Appends child to the box indicated by part.\n
+ */
+EAPI Evas_Bool
+edje_object_part_box_append(Evas_Object *obj, const char *part, Evas_Object *child)
+{
+ Edje *ed;
+ Edje_Real_Part *rp;
+
+ ed = _edje_fetch(obj);
+ if ((!ed) || (!part) || (!child)) return 0;
+
+ rp = _edje_real_part_recursive_get(ed, part);
+ if (!rp) return 0;
+ if (rp->part->type != EDJE_PART_TYPE_BOX) return 0;
+
+ return _edje_real_part_box_append(rp, child);
+}
+
+/** Prepends an object to the box
+ * @param obj A valid Evas_Object handle
+ * @param part The part name
+ * @param child The object to prepend
+ *
+ * @return 1: Successfully added.\n
+ * 0: An error occured.
+ *
+ * Prepends child to the box indicated by part.\n
+ */
+EAPI Evas_Bool
+edje_object_part_box_prepend(Evas_Object *obj, const char *part, Evas_Object *child)
+{
+ 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_BOX) return 0;
+
+ return _edje_real_part_box_prepend(rp, child);
+}
+
+/** Adds an object to the box
+ * @param obj A valid Evas_Object handle
+ * @param part The part name
+ * @param child The object to insert
+ * @param reference The object to be used as reference
+ *
+ * @return 1: Successfully added.\n
+ * 0: An error occured.
+ *
+ * Inserts child in the box given by part, in the position marked by reference.\n
+ */
+EAPI Evas_Bool
+edje_object_part_box_insert_before(Evas_Object *obj, const char *part, Evas_Object *child, const Evas_Object *reference)
+{
+ 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_BOX) return 0;
+
+ return _edje_real_part_box_insert_before(rp, child, reference);
+}
+
+/** Inserts an object to the box
+ * @param obj A valid Evas_Object handle
+ * @param part The part name
+ * @param child The object to insert
+ * @param pos The position where to insert child
+ *
+ * @return 1: Successfully added.\n
+ * 0: An error occured.
+ *
+ * Adds child to the box indicated by part, in the position given by pos.\n
+ */
+EAPI Evas_Bool
+edje_object_part_box_insert_at(Evas_Object *obj, const char *part, Evas_Object *child, unsigned int pos)
+{
+ 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_BOX) return 0;
+
+ return _edje_real_part_box_insert_at(rp, child, pos);
+}
+
+/** Removes an object from the box
+ * @param obj A valid Evas_Object handle
+ * @param part The part name
+ * @param child The object to remove
+ *
+ * @return 1: Successfully removed.\n
+ * 0: An error occured.
+ *
+ * Removes child from the box indicated by part.\n
+ */
+EAPI Evas_Object *
+edje_object_part_box_remove(Evas_Object *obj, const char *part, Evas_Object *child)
+{
+ Edje *ed;
+ Edje_Real_Part *rp;
+
+ ed = _edje_fetch(obj);
+ if ((!ed) || (!part)) return NULL;
+
+ rp = _edje_real_part_recursive_get(ed, part);
+ if (!rp) return NULL;
+ if (rp->part->type != EDJE_PART_TYPE_BOX) return NULL;
+
+ return _edje_real_part_box_remove(rp, child);
+}
+
+/** Removes an object from the box
+ * @param obj A valid Evas_Object handle
+ * @param part The part name
+ * @param pos
+ *
+ * @return 1: Successfully removed.\n
+ * 0: An error occured.
+ *
+ * Removes from the box indicated by part, the object in the position pos.\n
+ */
+EAPI Evas_Object *
+edje_object_part_box_remove_at(Evas_Object *obj, const char *part, unsigned int pos)
+{
+ Edje *ed;
+ Edje_Real_Part *rp;
+
+ ed = _edje_fetch(obj);
+ if ((!ed) || (!part)) return NULL;
+
+ rp = _edje_real_part_recursive_get(ed, part);
+ if (!rp) return NULL;
+ if (rp->part->type != EDJE_PART_TYPE_BOX) return NULL;
+
+ return _edje_real_part_box_remove_at(rp, pos);
+}
+
+/** Removes all elements from the box
+ * @param obj A valid Evas_Object handle
+ * @param part The part name
+ * @param clear Delete objects on removal
+ *
+ * @return 1: Successfully cleared.\n
+ * 0: An error occured.
+ *
+ * Removes all the external objects from the box indicated by part.
+ * Elements created from the theme will not be removed.\n
+ */
+EAPI Evas_Bool
+edje_object_part_box_remove_all(Evas_Object *obj, const char *part, Evas_Bool clear)
+{
+ Edje *ed;
+ Edje_Real_Part *rp;
+
+ ed = _edje_fetch(obj);
+ if ((!ed) || (!part)) return NULL;
+
+ rp = _edje_real_part_recursive_get(ed, part);
+ if (!rp) return NULL;
+ if (rp->part->type != EDJE_PART_TYPE_BOX) return NULL;
+
+ return _edje_real_part_box_remove_all(rp, clear);
+
+}
+
+Evas_Bool
+_edje_real_part_box_append(Edje_Real_Part *rp, Evas_Object *child_obj)
+{
+ Evas_Object_Box_Option *opt;
+
+ opt = evas_object_box_append(rp->object, child_obj);
+ if (!opt) return 0;
+
+ return 1;
+}
+
+Evas_Bool
+_edje_real_part_box_prepend(Edje_Real_Part *rp, Evas_Object *child_obj)
+{
+ Evas_Object_Box_Option *opt;
+
+ opt = evas_object_box_prepend(rp->object, child_obj);
+ if (!opt) return 0;
+
+ return 1;
+}
+
+Evas_Bool
+_edje_real_part_box_insert_before(Edje_Real_Part *rp, Evas_Object *child_obj, const Evas_Object *ref)
+{
+ Evas_Object_Box_Option *opt;
+
+ opt = evas_object_box_insert_before(rp->object, child_obj, ref);
+ if (!opt) return 0;
+
+ return 1;
+}
+
+Evas_Bool
+_edje_real_part_box_insert_at(Edje_Real_Part *rp, Evas_Object *child_obj, unsigned int pos)
+{
+ Evas_Object_Box_Option *opt;
+
+ opt = evas_object_box_insert_at(rp->object, child_obj, pos);
+ if (!opt) return 0;
+
+ return 1;
+}
+
+Evas_Object *
+_edje_real_part_box_remove(Edje_Real_Part *rp, Evas_Object *child_obj)
+{
+ if (evas_object_data_get(child_obj, "\377 edje.box_item")) return NULL;
+ if (evas_object_box_remove(rp->object, child_obj))
+ return child_obj;
+ return NULL;
+}
+
+Evas_Object *
+_edje_real_part_box_remove_at(Edje_Real_Part *rp, unsigned int pos)
+{
+ Evas_Object_Box_Option *opt;
+ Evas_Object_Box_Data *priv;
+ Evas_Object *child_obj;
+
+ priv = evas_object_smart_data_get(rp->object);
+ opt = eina_list_nth(priv->children, pos);
+ if (!opt) return NULL;
+ child_obj = opt->obj;
+ if (evas_object_data_get(child_obj, "\377 edje.box_item")) return NULL;
+ if (evas_object_box_remove_at(rp->object, pos))
+ return child_obj;
+ return NULL;
+}
+
+Evas_Bool
+_edje_real_part_box_remove_all(Edje_Real_Part *rp, Evas_Bool clear)
+{
+ Evas_Object_Box_Option *opt;
+ Evas_Object_Box_Data *priv;
+ Eina_List *l;
+ 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(priv->children, l, opt)
+ {
+ Evas_Object *child_obj;
+ child_obj = opt->obj;
+ if (evas_object_data_get(child_obj, "\377 edje.box_item"))
+ {
+ i++;
+ continue;
+ }
+ if (!evas_object_box_remove_at(rp->object, i))
+ return 0;
+ if (clear)
+ evas_object_del(child_obj);
+ }
+ return 1;
+}
+
Edje_Real_Part *
_edje_real_part_recursive_get(Edje *ed, const char *part)
{