edje: add spread.{w,h}.

This is particularly useful when using table and replicating the
same group all over the place. At least for many games I have in mind
this will save a lot of lines !
This commit is contained in:
Cedric BAIL 2013-03-22 15:29:33 +09:00
parent d1112534a1
commit 8222bf4650
6 changed files with 160 additions and 75 deletions

View File

@ -1,3 +1,7 @@
2013-03-22 Cedric Bail
* Edje: Add spread width and height in TABLE part.
2013-03-20 Jérémy Zurcher (jeyzu) 2013-03-20 Jérémy Zurcher (jeyzu)
* Eina: Add eina_list_shuffle * Eina: Add eina_list_shuffle
@ -68,7 +72,6 @@
creating on-demand. resource surface/contexts are used for creating creating on-demand. resource surface/contexts are used for creating
GL resources for Evas_GL. GL resources for Evas_GL.
2013-02-28 Tom Hacohen (TAsn) 2013-02-28 Tom Hacohen (TAsn)
* Evas textblock: Added proper size adjustments for * Evas textblock: Added proper size adjustments for

4
NEWS
View File

@ -72,7 +72,9 @@ Additions:
* Add eio_eet_sync symbols. * Add eio_eet_sync symbols.
* Add infrastructure to handle buggy touchscreen in Ecore_Input_Evas. * Add infrastructure to handle buggy touchscreen in Ecore_Input_Evas.
* Add infrastructure to handle message between ecore and parent ecore in Ecore_Evas. * Add infrastructure to handle message between ecore and parent ecore in Ecore_Evas.
* Edje textblock: Added support for size_range. * Edje:
- textblock: Added support for size_range.
- table: Added spread.{w,h} to repeat and automatically name an item in a TABLE part.
* Ecore_x: Add atom related with indicator type. * Ecore_x: Add atom related with indicator type.
* Ecore_x: Add manual render code before deiconify * Ecore_x: Add manual render code before deiconify
* Eeze: Add a dummy libmount replacement for when libmount is not there. * Eeze: Add a dummy libmount replacement for when libmount is not there.

View File

@ -239,6 +239,7 @@ 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_name(void);
static void st_collections_group_parts_part_box_items_item_source(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_min(void);
static void st_collections_group_parts_part_box_items_item_spread(void);
static void st_collections_group_parts_part_box_items_item_prefer(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_max(void);
static void st_collections_group_parts_part_box_items_item_padding(void); static void st_collections_group_parts_part_box_items_item_padding(void);
@ -528,6 +529,7 @@ New_Statement_Handler statement_handlers[] =
{"collections.group.parts.part.box.items.item.name", st_collections_group_parts_part_box_items_item_name}, {"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.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.min", st_collections_group_parts_part_box_items_item_min},
{"collections.group.parts.part.box.items.item.spread", st_collections_group_parts_part_box_items_item_spread},
{"collections.group.parts.part.box.items.item.prefer", st_collections_group_parts_part_box_items_item_prefer}, {"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.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.padding", st_collections_group_parts_part_box_items_item_padding},
@ -540,6 +542,7 @@ New_Statement_Handler statement_handlers[] =
{"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.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.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.min", st_collections_group_parts_part_box_items_item_min}, /* dup */
{"collections.group.parts.part.table.items.item.spread", st_collections_group_parts_part_box_items_item_spread}, /* 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.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.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.padding", st_collections_group_parts_part_box_items_item_padding}, /* dup */
@ -4309,6 +4312,8 @@ static void ob_collections_group_parts_part_box_items_item(void)
item->row = -1; item->row = -1;
item->colspan = 1; item->colspan = 1;
item->rowspan = 1; item->rowspan = 1;
item->spread.w = 1;
item->spread.h = 1;
pitem = (Edje_Pack_Element_Parser *)item; pitem = (Edje_Pack_Element_Parser *)item;
pitem->can_override = EINA_FALSE; pitem->can_override = EINA_FALSE;
} }
@ -4428,6 +4433,27 @@ static void st_collections_group_parts_part_box_items_item_min(void)
current_item->min.h = parse_int_range(1, 0, 0x7ffffff); current_item->min.h = parse_int_range(1, 0, 0x7ffffff);
} }
/**
@page edcref
@property
spread
@parameters
[width] [height]
@effect
Will replicate the item in a rectangle of size width x height
box starting from the defined position of this item.
default value will be 1 1;
@endproperty
*/
static void st_collections_group_parts_part_box_items_item_spread(void)
{
check_arg_count(2);
current_item->spread.w = parse_int_range(0, 0, 0x7ffffff);
current_item->spread.h = parse_int_range(1, 0, 0x7ffffff);
}
/** /**
@page edcref @page edcref
@property @property

View File

@ -883,6 +883,8 @@ _edje_edd_init(void)
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, "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.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, "min.h", min.h, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "spread.w", spread.w, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_pack_element, Edje_Pack_Element, "spread.h", spread.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.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, "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.w", max.w, EET_T_INT);

View File

@ -827,6 +827,7 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
{ {
Eina_List *l; Eina_List *l;
Evas_Object *child_obj; Evas_Object *child_obj;
Edje_Pack_Element pack_it_copy;
const char *group_path_entry = eina_stringshare_add(source); const char *group_path_entry = eina_stringshare_add(source);
const char *data; const char *data;
@ -848,6 +849,18 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
} }
} }
if (pack_it)
{
pack_it_copy = *pack_it;
}
else
{
pack_it_copy.spread.w = 0;
pack_it_copy.spread.h = 0;
}
do
{
child_obj = edje_object_add(ed->base->evas); child_obj = edje_object_add(ed->base->evas);
group_path = eina_list_append(group_path, group_path_entry); group_path = eina_list_append(group_path, group_path_entry);
if (rp->part->type == EDJE_PART_TYPE_GROUP) if (rp->part->type == EDJE_PART_TYPE_GROUP)
@ -866,7 +879,6 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
} }
group_path = eina_list_remove(group_path, group_path_entry); group_path = eina_list_remove(group_path, group_path_entry);
eina_stringshare_del(group_path_entry);
edje_object_propagate_callback_add(child_obj, edje_object_propagate_callback_add(child_obj,
_cb_signal_repeat, _cb_signal_repeat,
@ -883,11 +895,24 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
if ((rp->type == EDJE_RP_TYPE_CONTAINER) && if ((rp->type == EDJE_RP_TYPE_CONTAINER) &&
(rp->typedata.container)) (rp->typedata.container))
{ {
Eina_Strbuf *buf = NULL;
const char *name = pack_it_copy.name;
pack_it->parent = rp; pack_it->parent = rp;
_edje_object_pack_item_hints_set(child_obj, pack_it); _edje_object_pack_item_hints_set(child_obj, &pack_it_copy);
if (pack_it->name)
evas_object_name_set(child_obj, pack_it->name); if (pack_it_copy.spread.h >= 1 && pack_it_copy.spread.w > 1)
{
buf = eina_strbuf_new();
if (name)
eina_strbuf_append_printf(buf, "%s{%i,%i}", name, pack_it_copy.col, pack_it_copy.row);
else
eina_strbuf_append_printf(buf, "%i,%i", pack_it_copy.col, pack_it_copy.row);
name = eina_strbuf_string_get(buf);
}
if (name) evas_object_name_set(child_obj, name);
if (buf) eina_strbuf_free(buf);
if (rp->part->type == EDJE_PART_TYPE_BOX) if (rp->part->type == EDJE_PART_TYPE_BOX)
{ {
@ -896,13 +921,34 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
} }
else if (rp->part->type == EDJE_PART_TYPE_TABLE) 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); _edje_real_part_table_pack(rp, child_obj,
pack_it_copy.col, pack_it_copy.row,
pack_it_copy.colspan, pack_it_copy.rowspan);
evas_object_data_set(child_obj, "\377 edje.table_item", pack_it); evas_object_data_set(child_obj, "\377 edje.table_item", pack_it);
} }
_edje_subobj_register(ed, child_obj); _edje_subobj_register(ed, child_obj);
evas_object_show(child_obj); evas_object_show(child_obj);
rp->typedata.container->items = eina_list_append(rp->typedata.container->items, child_obj); rp->typedata.container->items = eina_list_append(rp->typedata.container->items, child_obj);
}
}
pack_it_copy.spread.w--;
pack_it_copy.col++;
if (pack_it_copy.spread.w < 1 && pack_it)
{
pack_it_copy.col = pack_it->col;
pack_it_copy.row++;
pack_it_copy.spread.h--;
pack_it_copy.spread.w = pack_it->spread.w;
}
}
while (pack_it_copy.spread.h > 0);
eina_stringshare_del(group_path_entry);
if ((rp->type == EDJE_RP_TYPE_CONTAINER) &&
(rp->typedata.container))
{
if (item_count > 0) if (item_count > 0)
{ {
pack_it = *curr_item; pack_it = *curr_item;
@ -919,7 +965,6 @@ _edje_object_file_set_internal(Evas_Object *obj, const char *file, const char *g
} }
} }
} }
}
if (group_path_started) if (group_path_started)
{ {
@ -1746,6 +1791,7 @@ _cb_signal_repeat(void *data, Evas_Object *obj, const char *sig, const char *sou
size_t length_source; size_t length_source;
int i = 0; int i = 0;
const char *alias = NULL; const char *alias = NULL;
const char *name = NULL;
Edje_Message_Signal emsg; Edje_Message_Signal emsg;
parent = data; parent = data;
@ -1754,9 +1800,12 @@ _cb_signal_repeat(void *data, Evas_Object *obj, const char *sig, const char *sou
pack_it = evas_object_data_get(obj, "\377 edje.box_item"); pack_it = evas_object_data_get(obj, "\377 edje.box_item");
if (!pack_it) pack_it = evas_object_data_get(obj, "\377 edje.table_item"); if (!pack_it) pack_it = evas_object_data_get(obj, "\377 edje.table_item");
name = evas_object_name_get(obj);
if (pack_it) if (pack_it)
{ {
if (!pack_it->name) if (!name) name = pack_it->name;
if (!name)
{ {
Eina_List *child = NULL; Eina_List *child = NULL;
Evas_Object *o; Evas_Object *o;
@ -1782,7 +1831,7 @@ _cb_signal_repeat(void *data, Evas_Object *obj, const char *sig, const char *sou
} }
else else
{ {
length_index = strlen(pack_it->name) + 2; length_index = strlen(name) + 2;
} }
} }
@ -1802,7 +1851,7 @@ _cb_signal_repeat(void *data, Evas_Object *obj, const char *sig, const char *sou
length_parent += eina_convert_itoa(i, new_src + length_parent); length_parent += eina_convert_itoa(i, new_src + length_parent);
else else
{ {
memcpy(new_src + length_parent, pack_it->name, length_index); memcpy(new_src + length_parent, name, length_index);
length_parent += length_index - 2; length_parent += length_index - 2;
} }
new_src[length_parent++] = EDJE_PART_PATH_SEPARATOR_INDEXR; new_src[length_parent++] = EDJE_PART_PATH_SEPARATOR_INDEXR;

View File

@ -164,7 +164,7 @@ EAPI extern int _edje_default_log_dom ;
/* increment this when you add new feature to edje file format without /* increment this when you add new feature to edje file format without
* breaking backward compatibility. * breaking backward compatibility.
*/ */
#define EDJE_FILE_MINOR 4 #define EDJE_FILE_MINOR 5
/* FIXME: /* FIXME:
* *
@ -725,6 +725,9 @@ struct _Edje_Pack_Element
struct { struct {
int l, r, t, b; int l, r, t, b;
} padding; } padding;
struct {
int w, h;
} spread;
Edje_Alignment align; Edje_Alignment align;
Edje_Alignment weight; Edje_Alignment weight;
Edje_Aspect aspect; Edje_Aspect aspect;