Efl.Ui.Grid: Fix new API behaviour

This fixes the linear API usage with a table.
TODO:
- remove internal table (as it doesn't support layout funcs)
- implement multiple layout functions (regular, homogenous, ...)
This commit is contained in:
Jean-Philippe Andre 2016-04-14 16:41:57 +09:00
parent 86a59a3a24
commit 101cb7fe2a
5 changed files with 340 additions and 147 deletions

View File

@ -90,6 +90,39 @@ btnmargins_slider_cb(void *data, const Eo_Event *event)
return EO_CALLBACK_CONTINUE;
}
static Eina_Bool
layout_updated_cb(void *data, const Eo_Event *event)
{
Elm_Label *o = data;
char buf[64];
int rows, cols, count;
efl_pack_grid_size_get(event->obj, &cols, &rows);
count = efl_pack_contents_count(event->obj);
sprintf(buf, "%d items (%dx%d)", count, cols, rows);
elm_object_text_set(o, buf);
return EO_CALLBACK_CONTINUE;
}
static Eina_Bool
child_evt_cb(void *data, const Eo_Event *event)
{
Elm_Label *o = data;
Efl_Pack_Item *it = event->info;
int col, row, colspan, rowspan;
char buf[64];
efl_pack_child_position_get(event->obj, it, &col, &row, &colspan, &rowspan);
if (event->desc == EFL_PACK_EVENT_CHILD_ADDED)
sprintf(buf, "pack %d,%d %dx%d", col, row, colspan, rowspan);
else
sprintf(buf, "unpack %d,%d %dx%d", col, row, colspan, rowspan);
elm_object_text_set(o, buf);
return EO_CALLBACK_CONTINUE;
}
void
test_ui_grid(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
@ -289,6 +322,33 @@ test_ui_grid(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_i
efl_gfx_visible_set(o, 1);
/* ro info */
bx = eo_add(EFL_UI_BOX_CLASS, win,
efl_pack_direction_set(eo_self, EFL_ORIENT_DOWN));
evas_object_size_hint_align_set(bx, 0, -1);
evas_object_size_hint_weight_set(bx, 1, 1);
efl_pack(hbox, bx);
efl_gfx_visible_set(bx, 1);
o = elm_label_add(win);
elm_object_text_set(o, "<b>Properties</>");
efl_pack(bx, o);
efl_gfx_visible_set(o, 1);
o = elm_label_add(win);
eo_event_callback_add(grid, EFL_PACK_EVENT_LAYOUT_UPDATED, layout_updated_cb, o);
efl_pack(bx, o);
efl_gfx_visible_set(o, 1);
o = elm_label_add(win);
eo_event_callback_add(grid, EFL_PACK_EVENT_CHILD_ADDED, child_evt_cb, o);
eo_event_callback_add(grid, EFL_PACK_EVENT_CHILD_REMOVED, child_evt_cb, o);
evas_object_size_hint_align_set(o, 0.5, 0);
evas_object_size_hint_weight_set(o, 1, 1);
efl_pack(bx, o);
efl_gfx_visible_set(o, 1);
/* contents */
f = elm_frame_add(win);
elm_object_text_set(f, "Contents");
@ -366,7 +426,8 @@ btn_text(const char *str)
static void
remove_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
eo_unref(obj);
//efl_pack_unpack(data, obj);
eo_del(obj);
}
static void
@ -381,19 +442,6 @@ append_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED
efl_gfx_visible_set(o, 1);
}
static void
rmrand_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Eo *grid = data, *o;
int cols, rows;
efl_pack_grid_size_get(o, &cols, &rows);
if (!cols || !rows) return;
o = efl_pack_grid_child_at(grid, rand() % cols, rand() % rows);
eo_unref(o);
}
static void
clear_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
@ -405,7 +453,7 @@ void
test_ui_grid_linear(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Evas_Object *win, *o, *vbox, *f, *hbox, *grid, *ico;
Evas_Object *win, *o, *vbox, *f, *hbox, *grid, *ico, *bx;
win = elm_win_util_standard_add("ui-grid-linear", "Efl.Ui.Grid Linear APIs");
elm_win_autodel_set(win, EINA_TRUE);
@ -446,15 +494,6 @@ test_ui_grid_linear(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
efl_pack(hbox, o);
efl_gfx_visible_set(o, 1);
ico = elm_icon_add(win);
elm_icon_standard_set(ico, "edit-delete");
o = elm_button_add(win);
elm_object_content_set(o, ico);
elm_object_text_set(o, "Remove random");
evas_object_smart_callback_add(o, "clicked", rmrand_cb, grid);
efl_pack(hbox, o);
efl_gfx_visible_set(o, 1);
ico = elm_icon_add(win);
elm_icon_standard_set(ico, "edit-clear-all");
o = elm_button_add(win);
@ -465,6 +504,33 @@ test_ui_grid_linear(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
efl_gfx_visible_set(o, 1);
/* ro info */
bx = eo_add(EFL_UI_BOX_CLASS, win,
efl_pack_direction_set(eo_self, EFL_ORIENT_DOWN));
evas_object_size_hint_align_set(bx, 0, -1);
evas_object_size_hint_weight_set(bx, 1, 1);
efl_pack(hbox, bx);
efl_gfx_visible_set(bx, 1);
o = elm_label_add(win);
elm_object_text_set(o, "<b>Properties</>");
efl_pack(bx, o);
efl_gfx_visible_set(o, 1);
o = elm_label_add(win);
eo_event_callback_add(grid, EFL_PACK_EVENT_LAYOUT_UPDATED, layout_updated_cb, o);
efl_pack(bx, o);
efl_gfx_visible_set(o, 1);
o = elm_label_add(win);
eo_event_callback_add(grid, EFL_PACK_EVENT_CHILD_ADDED, child_evt_cb, o);
eo_event_callback_add(grid, EFL_PACK_EVENT_CHILD_REMOVED, child_evt_cb, o);
evas_object_size_hint_align_set(o, 0.5, 0);
evas_object_size_hint_weight_set(o, 1, 1);
efl_pack(bx, o);
efl_gfx_visible_set(o, 1);
/* contents */
f = elm_frame_add(win);
elm_object_text_set(f, "Contents");
@ -473,7 +539,7 @@ test_ui_grid_linear(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
efl_pack(vbox, f);
efl_gfx_visible_set(f, 1);
efl_pack_max_span_set(grid, 4);
efl_pack_columns_set(grid, 4);
efl_pack_directions_set(grid, EFL_ORIENT_RIGHT, EFL_ORIENT_DOWN);
evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_content_set(f, grid);

View File

@ -84,8 +84,8 @@ interface Efl.Pack (Efl.Pack_Item)
}
}
events {
child,added;
child,removed;
layout,updated; [[sent after the layout was updated]]
child,added: Efl.Pack_Item*; [[sent after a new item was added]]
child,removed: Efl.Pack_Item*; [[sent after an item was removed, may happen after unref]]
layout,updated; [[sent after the layout was updated]]
}
}

View File

@ -11,11 +11,11 @@ interface Efl.Pack_Grid (Efl.Pack_Linear)
subobj: Efl.Pack_Item *;
col: int;
row: int;
colspan: int @optional; [[0 means 1, -1 means @.max_span]]
rowspan: int @optional; [[0 means 1, -1 means @.max_span]]
colspan: int @optional; [[0 means 1, -1 means @.columns]]
rowspan: int @optional; [[0 means 1, -1 means @.rows]]
}
}
grid_children_at {
pack_children_at {
[[grids can have overlapping children - returns a list because
we expect only few items per cell
]]
@ -25,15 +25,15 @@ interface Efl.Pack_Grid (Efl.Pack_Linear)
@in row: int;
}
}
grid_child_at {
[[returns the top child at position. see also grid_children_at]]
pack_child_at {
[[returns the top child at position. see also @.pack_children_at]]
return: Efl.Pack_Item*;
params {
@in col: int;
@in row: int;
}
}
@property grid_child_position {
@property pack_child_position {
[[position and span of the $subobj in this container, may be modified to move the $subobj]]
set { [[same as grid_pack]] }
get {}
@ -58,29 +58,19 @@ interface Efl.Pack_Grid (Efl.Pack_Linear)
}
}
@property columns {
set {}
set { [[specifies limit for linear adds - if direction is horizontal]] }
get {}
values {
cols: int;
}
}
@property rows {
set {}
set { [[specifies limit for linear adds - if direction is vertical]] }
get {}
values {
rows: int;
}
}
@property max_span {
[[Max column or row when used with linear apis. Default is 0 (no limit)
only valid if direction is horizontal
]]
set {}
get {}
values {
maxx: int;
}
}
@property directions {
[[primary and secondary up/left/right/down orientation for linear apis. default is right and down
overrides @Efl.Pack_Linear.direction

View File

@ -16,12 +16,17 @@ typedef struct _Efl_Ui_Grid_Data Efl_Ui_Grid_Data;
typedef struct _Grid_Item_Iterator Grid_Item_Iterator;
typedef struct _Grid_Item Grid_Item;
static Eina_Bool _subobj_del_cb(void *data, const Eo_Event *event);
static void _item_remove(Efl_Ui_Grid *obj, Efl_Ui_Grid_Data *pd, Efl_Pack_Item *subobj);
#define GRID_ITEM_KEY "__grid_item"
struct _Grid_Item
{
EINA_INLIST;
Efl_Pack_Item *object;
int colspan, rowspan;
int col_span, row_span;
int col, row;
Eina_Bool linear : 1;
@ -30,11 +35,11 @@ struct _Grid_Item
struct _Efl_Ui_Grid_Data
{
Grid_Item *items;
int count;
int cols, rows; // requested
int max_span;
int lastcol, lastrow;
Efl_Orient dir1, dir2;
int req_cols, req_rows; // requested - 0 means infinite
int last_col, last_row; // only used by linear apis
Efl_Orient dir1, dir2; // must be orthogonal (H,V or V,H)
struct {
double h, v;
Eina_Bool scalable: 1;
@ -50,6 +55,11 @@ struct _Grid_Item_Iterator
Efl_Ui_Grid *object;
};
static const Eo_Callback_Array_Item subobj_callbacks [] = {
{ EO_BASE_EVENT_DEL, _subobj_del_cb },
{ NULL, NULL }
};
static inline Eina_Bool
_horiz(Efl_Orient dir)
{
@ -160,6 +170,13 @@ _efl_ui_grid_elm_widget_theme_apply(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED)
return EINA_TRUE;
}
static void
_layout_updated_emit(Efl_Ui_Grid *obj)
{
/* FIXME: can't be called properly since there is no smart calc event */
eo_event_callback_call(obj, EFL_PACK_EVENT_LAYOUT_UPDATED, NULL);
}
static void
_sizing_eval(Evas_Object *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED)
{
@ -180,13 +197,13 @@ _sizing_eval(Evas_Object *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED)
if ((maxw >= 0) && (w > maxw)) w = maxw;
if ((maxh >= 0) && (h > maxh)) h = maxh;
evas_object_resize(obj, w, h);
_layout_updated_emit(obj);
}
static void
_on_size_hints_changed(void *data,
Evas *e EINA_UNUSED,
Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
_table_size_hints_changed(void *data, Evas *e EINA_UNUSED,
Evas_Object *table EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Efl_Ui_Grid_Data *pd = eo_data_scope_get(data, MY_CLASS);
@ -201,10 +218,11 @@ _efl_ui_grid_evas_object_smart_add(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED)
elm_widget_sub_object_parent_add(obj);
table = evas_object_table_add(evas_object_evas_get(obj));
evas_object_table_homogeneous_set(table, EVAS_OBJECT_TABLE_HOMOGENEOUS_TABLE);
elm_widget_resize_object_set(obj, table, EINA_TRUE);
evas_object_event_callback_add
(table, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _on_size_hints_changed, obj);
(table, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _table_size_hints_changed, obj);
evas_obj_smart_add(eo_super(obj, MY_CLASS));
@ -224,7 +242,7 @@ _efl_ui_grid_evas_object_smart_del(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED)
evas_object_event_callback_del_full
(wd->resize_obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_on_size_hints_changed, obj);
_table_size_hints_changed, obj);
/* let's make our table object the *last* to be processed, since it
* may (smart) parent other sub objects here */
@ -250,8 +268,10 @@ _efl_ui_grid_eo_base_constructor(Eo *obj, Efl_Ui_Grid_Data *pd)
pd->dir1 = EFL_ORIENT_RIGHT;
pd->dir2 = EFL_ORIENT_DOWN;
pd->lastcol = -1;
pd->lastrow = -1;
pd->last_col = -1;
pd->last_row = -1;
pd->req_cols = 0;
pd->req_rows = 0;
return obj;
}
@ -285,81 +305,213 @@ _efl_ui_grid_efl_pack_padding_get(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, dou
if (v) *v = pd->pad.v;
}
EOLIAN static void
_efl_ui_grid_efl_pack_grid_pack_grid(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Pack_Item *subobj, int col, int row, int colspan, int rowspan)
static Eina_Bool
_subobj_del_cb(void *data, const Eo_Event *event)
{
Efl_Ui_Grid *obj = data;
Efl_Ui_Grid_Data *pd = eo_data_scope_get(obj, EFL_UI_GRID_CLASS);
eo_event_callback_array_del(event->obj, subobj_callbacks, data);
_item_remove(obj, pd, event->obj);
if (!elm_widget_sub_object_del(obj, event->obj))
WRN("failed to remove child from its parent");
return EO_CALLBACK_CONTINUE;
}
static void
_pack_at(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Pack_Item *subobj,
int col, int row, int colspan, int rowspan, Eina_Bool linear)
{
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
Grid_Item *gi = NULL;
if (col < 0) col = 0;
if (row < 0) row = 0;
// note: we could have colspan = -1 mean "full width" if req_cols is set?
if (colspan < 1) colspan = 1;
if (rowspan < 1) rowspan = 1;
if ((0xffff - col) < colspan)
if (((int64_t) col + (int64_t) colspan) > (int64_t) INT_MAX)
colspan = INT_MAX - col;
if (((int64_t) row + (int64_t) rowspan) > (int64_t) INT_MAX)
rowspan = INT_MAX - row;
if ((pd->req_cols && ((col + colspan) > pd->req_cols)) ||
(pd->req_rows && ((row + rowspan) > pd->req_rows)))
{
ERR("col + colspan > 0xffff. adjusted");
colspan = 0xffff - col;
}
if ((0xffff - row) < rowspan)
{
ERR("row + rowspan > 0xffff, adjusted");
rowspan = 0xffff - row;
ERR("grid requested size exceeded! packing in extra cell at "
"%d,%d %dx%d (grid: %dx%d)",
col, row, colspan, rowspan, pd->req_cols, pd->req_rows);
}
if ((col + colspan) >= 0x7ffff)
WRN("col + colspan getting rather large (>32767)");
if ((row + rowspan) >= 0x7ffff)
WRN("row + rowspan getting rather large (>32767)");
if ((pd->lastcol < (col + colspan - 1)) ||
(pd->lastrow < (row + rowspan - 1)))
if (obj == elm_widget_parent_widget_get(subobj))
{
pd->lastcol = col + colspan - 1;
pd->lastrow = row + rowspan - 1;
gi = eo_key_data_get(subobj, GRID_ITEM_KEY);
if (gi)
{
gi->col = col;
gi->row = row;
gi->col_span = colspan;
gi->row_span = rowspan;
gi->linear = EINA_FALSE;
}
else ERR("object is a child but internal data was not found!");
}
if (!gi)
{
gi = calloc(1, sizeof(*gi));
gi->col = col;
gi->row = row;
gi->col_span = colspan;
gi->row_span = rowspan;
gi->linear = !!linear;
gi->object = subobj; // xref(, obj);
pd->count++;
pd->items = (Grid_Item *)
eina_inlist_append(EINA_INLIST_GET(pd->items), EINA_INLIST_GET(gi));
eo_key_data_set(subobj, GRID_ITEM_KEY, gi);
elm_widget_sub_object_add(obj, subobj);
eo_event_callback_call(obj, EFL_PACK_EVENT_CHILD_ADDED, subobj);
eo_event_callback_array_add(subobj, subobj_callbacks, obj);
}
elm_widget_sub_object_add(obj, subobj);
evas_object_table_pack(wd->resize_obj, subobj, col, row, colspan, rowspan);
}
EOLIAN static void
_efl_ui_grid_efl_pack_grid_grid_child_position_set(Eo *obj, Efl_Ui_Grid_Data *pd, Evas_Object *subobj, int col, int row, int colspan, int rowspan)
_efl_ui_grid_efl_pack_grid_pack_grid(Eo *obj, Efl_Ui_Grid_Data *pd,
Efl_Pack_Item *subobj,
int col, int row, int colspan, int rowspan)
{
_efl_ui_grid_efl_pack_grid_pack_grid(obj, pd, subobj, col, row, colspan, rowspan);
EINA_SAFETY_ON_NULL_RETURN(subobj);
_pack_at(obj, pd, subobj, col, row, colspan, rowspan, EINA_FALSE);
}
EOLIAN static void
_efl_ui_grid_efl_pack_grid_grid_child_position_get(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, Evas_Object *subobj, int *col, int *row, int *colspan, int *rowspan)
_efl_ui_grid_efl_pack_grid_pack_child_position_set(Eo *obj, Efl_Ui_Grid_Data *pd, Evas_Object *subobj, int col, int row, int colspan, int rowspan)
{
unsigned short icol, irow, icolspan, irowspan;
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
EINA_SAFETY_ON_NULL_RETURN(subobj);
evas_object_table_pack_get
(wd->resize_obj, subobj, &icol, &irow, &icolspan, &irowspan);
if (col) *col = icol;
if (row) *row = irow;
if (colspan) *colspan = icolspan;
if (rowspan) *rowspan = irowspan;
if (obj != elm_widget_parent_widget_get(subobj))
{
ERR("object %p is not a child of %p", subobj, obj);
return;
}
_pack_at(obj, pd, subobj, col, row, colspan, rowspan, EINA_FALSE);
}
EOLIAN static void
_efl_ui_grid_efl_pack_grid_pack_child_position_get(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, Evas_Object *subobj, int *col, int *row, int *colspan, int *rowspan)
{
int c = -1, r = -1, cs = 0, rs = 0;
Grid_Item *gi;
if (obj != elm_widget_parent_widget_get(subobj))
{
ERR("%p is not a child of %p", subobj, obj);
goto end;
}
gi = eo_key_data_get(subobj, GRID_ITEM_KEY);
if (gi)
{
c = gi->col;
r = gi->row;
cs = gi->col_span;
rs = gi->row_span;
}
end:
if (col) *col = c;
if (row) *row = r;
if (colspan) *colspan = cs;
if (rowspan) *rowspan = rs;
}
EOLIAN static Efl_Pack_Item *
_efl_ui_grid_efl_pack_grid_grid_child_at(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, int col, int row)
_efl_ui_grid_efl_pack_grid_pack_child_at(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, int col, int row)
{
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
return evas_object_table_child_get(wd->resize_obj, col, row);
}
static void
_item_remove(Efl_Ui_Grid *obj, Efl_Ui_Grid_Data *pd, Efl_Pack_Item *subobj)
{
Grid_Item *gi = eo_key_data_get(subobj, GRID_ITEM_KEY);
Grid_Item *gi2, *last = NULL;
if (!gi)
{
WRN("item %p has no grid internal data", subobj);
EINA_INLIST_FOREACH(EINA_INLIST_GET(pd->items), gi)
if (gi->object == subobj)
break;
if (!gi)
{
ERR("item %p was not found in this grid", subobj);
return;
}
}
if (!gi->linear)
goto end;
EINA_INLIST_REVERSE_FOREACH(EINA_INLIST_GET(pd->items), gi2)
{
if (gi2 == gi) continue;
if (!gi2->linear) continue;
last = gi2;
break;
}
if (last)
{
if (_horiz(pd->dir1))
{
pd->last_col = last->col + last->col_span - 1;
pd->last_row = last->row;
}
else
{
pd->last_row = last->row + last->row_span - 1;
pd->last_col = last->col;
}
}
else
{
pd->last_col = -1;
pd->last_row = -1;
}
end:
eo_event_callback_call(obj, EFL_PACK_EVENT_CHILD_REMOVED, subobj);
pd->items = (Grid_Item *)
eina_inlist_remove(EINA_INLIST_GET(pd->items), EINA_INLIST_GET(gi));
pd->count--;
eo_key_data_del(subobj, GRID_ITEM_KEY);
free(gi);
}
EOLIAN static Eina_Bool
_efl_ui_grid_efl_pack_unpack(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, Efl_Pack_Item *subobj)
_efl_ui_grid_efl_pack_unpack(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Pack_Item *subobj)
{
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
_item_remove(obj, pd, subobj);
if (evas_object_table_unpack(wd->resize_obj, subobj))
{
if (elm_widget_sub_object_del(obj, subobj))
return EINA_TRUE;
return EINA_FALSE;
return EINA_FALSE; // oops - unlikely
}
return EINA_FALSE;
@ -390,9 +542,10 @@ _efl_ui_grid_evas_object_smart_calculate(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUS
}
EOLIAN void
_efl_ui_grid_efl_pack_layout_update(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED)
_efl_ui_grid_efl_pack_layout_update(Eo *obj, Efl_Ui_Grid_Data *pd)
{
_sizing_eval(obj, pd);
_layout_updated_emit(obj);
}
EOLIAN void
@ -451,23 +604,13 @@ _efl_ui_grid_efl_pack_contents_iterate(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED
}
EOLIAN static int
_efl_ui_grid_efl_pack_contents_count(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED)
_efl_ui_grid_efl_pack_contents_count(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd)
{
Eina_List *li;
int count;
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, 0);
/* FIXME */
li = evas_object_table_children_get(wd->resize_obj);
count = eina_list_count(li);
eina_list_free(li);
return count;
return pd->count;
}
EOLIAN static Eina_List *
_efl_ui_grid_efl_pack_grid_grid_children_at(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, int col, int row)
_efl_ui_grid_efl_pack_grid_pack_children_at(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, int col, int row)
{
Eina_List *l = NULL;
@ -541,13 +684,13 @@ _efl_ui_grid_efl_pack_grid_directions_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data
EOLIAN static void
_efl_ui_grid_efl_pack_grid_grid_size_set(Eo *obj, Efl_Ui_Grid_Data *pd EINA_UNUSED, int cols, int rows)
{
/* FIXME: what's the behaviour if items were packed OUTSIDE this box? */
if (cols < 0) cols = 0;
if (rows < 0) rows = 0;
efl_pack_columns_set(obj, cols);
efl_pack_rows_set(obj, rows);
pd->req_cols = cols;
pd->req_rows = rows;
efl_pack_layout_request(obj);
}
EOLIAN static void
@ -557,28 +700,10 @@ _efl_ui_grid_efl_pack_grid_grid_size_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *
if (rows) *rows = efl_pack_rows_get(obj);
}
EOLIAN static void
_efl_ui_grid_efl_pack_grid_max_span_set(Eo *obj, Efl_Ui_Grid_Data *pd, int maxx)
{
/* FIXME: what's the behaviour if items were packed OUTSIDE this range? */
if (maxx < 0) maxx = 0;
pd->max_span = maxx;
efl_pack_layout_request(obj);
}
EOLIAN static int
_efl_ui_grid_efl_pack_grid_max_span_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd)
{
return pd->max_span;
}
EOLIAN static void
_efl_ui_grid_efl_pack_grid_columns_set(Eo *obj, Efl_Ui_Grid_Data *pd, int columns)
{
/* FIXME: what's the behaviour if items were packed OUTSIDE this range? */
pd->cols = columns;
pd->req_cols = columns;
efl_pack_layout_request(obj);
}
@ -586,14 +711,20 @@ _efl_ui_grid_efl_pack_grid_columns_set(Eo *obj, Efl_Ui_Grid_Data *pd, int column
EOLIAN static int
_efl_ui_grid_efl_pack_grid_columns_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd)
{
return pd->cols;
if (!pd->req_cols)
{
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, 0);
int cols;
evas_object_table_col_row_size_get(wd->resize_obj, &cols, NULL);
return cols;
}
return pd->req_cols;
}
EOLIAN static void
_efl_ui_grid_efl_pack_grid_rows_set(Eo *obj, Efl_Ui_Grid_Data *pd, int rows)
{
/* FIXME: what's the behaviour if items were packed OUTSIDE this range? */
pd->rows = rows;
pd->req_rows = rows;
efl_pack_layout_request(obj);
}
@ -601,7 +732,14 @@ _efl_ui_grid_efl_pack_grid_rows_set(Eo *obj, Efl_Ui_Grid_Data *pd, int rows)
EOLIAN static int
_efl_ui_grid_efl_pack_grid_rows_get(Eo *obj EINA_UNUSED, Efl_Ui_Grid_Data *pd)
{
return pd->rows;
if (!pd->req_rows)
{
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, 0);
int rows;
evas_object_table_col_row_size_get(wd->resize_obj, &rows, NULL);
return rows;
}
return pd->req_rows;
}
EOLIAN static void
@ -616,13 +754,13 @@ _efl_ui_grid_efl_pack_linear_pack_end(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Pack_It
{
EINA_SAFETY_ON_NULL_RETURN(subobj);
int col = pd->lastcol;
int row = pd->lastrow;
int col = pd->last_col;
int row = pd->last_row;
if (_horiz(pd->dir1))
{
col++;
if (pd->max_span && (col >= pd->max_span))
if (pd->req_cols && (col >= pd->req_cols))
{
col = 0;
row++;
@ -632,7 +770,7 @@ _efl_ui_grid_efl_pack_linear_pack_end(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Pack_It
else
{
row++;
if (pd->max_span && (row >= pd->max_span))
if (pd->req_rows && (row >= pd->req_rows))
{
row = 0;
col++;
@ -640,10 +778,11 @@ _efl_ui_grid_efl_pack_linear_pack_end(Eo *obj, Efl_Ui_Grid_Data *pd, Efl_Pack_It
if (col < 0) col = 0;
}
pd->last_col = col;
pd->last_row = row;
DBG("packing new obj at %d,%d", col, row);
pd->lastcol = col;
pd->lastrow = row;
efl_pack_grid(obj, subobj, col, row, 1, 1);
_pack_at(obj, pd, subobj, col, row, 1, 1, EINA_TRUE);
}
#include "efl_ui_grid.eo.c"

View File

@ -26,14 +26,12 @@ class Efl.Ui.Grid (Elm.Widget, Efl.Pack_Grid)
Efl.Pack.layout_update;
Efl.Pack.layout_request;
Efl.Pack_Grid.pack_grid;
Efl.Pack_Grid.grid_children_at;
Efl.Pack_Grid.grid_child_at;
Efl.Pack_Grid.grid_child_position.set;
Efl.Pack_Grid.grid_child_position.get;
Efl.Pack_Grid.pack_children_at;
Efl.Pack_Grid.pack_child_at;
Efl.Pack_Grid.pack_child_position.set;
Efl.Pack_Grid.pack_child_position.get;
Efl.Pack_Grid.grid_size.set;
Efl.Pack_Grid.grid_size.get;
Efl.Pack_Grid.max_span.set;
Efl.Pack_Grid.max_span.get;
Efl.Pack_Grid.columns.set;
Efl.Pack_Grid.columns.get;
Efl.Pack_Grid.rows.set;