2016-06-09 21:29:33 -07:00
|
|
|
#include "efl_ui_grid_private.h"
|
|
|
|
|
|
|
|
#define MY_CLASS EFL_UI_GRID_STATIC_CLASS
|
2017-08-17 03:36:17 -07:00
|
|
|
#define MY_CLASS_NAME "Efl.Ui.Grid_Static"
|
2016-07-12 02:03:54 -07:00
|
|
|
#define MY_CLASS_NAME_LEGACY "elm_grid"
|
2016-06-09 21:29:33 -07:00
|
|
|
|
|
|
|
EOLIAN static Eo *
|
2016-08-10 07:23:04 -07:00
|
|
|
_efl_ui_grid_static_efl_object_constructor(Eo *obj, void *pd EINA_UNUSED)
|
2016-06-09 21:29:33 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Grid_Data *gd;
|
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
obj = efl_constructor(efl_super(obj, MY_CLASS));
|
2016-06-20 21:26:15 -07:00
|
|
|
efl_canvas_object_type_set(obj, MY_CLASS_NAME);
|
2016-06-09 21:29:33 -07:00
|
|
|
elm_interface_atspi_accessible_role_set(obj, ELM_ATSPI_ROLE_FILLER);
|
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
gd = efl_data_scope_get(obj, EFL_UI_GRID_CLASS);
|
2016-06-09 21:29:33 -07:00
|
|
|
gd->req_cols = 100;
|
|
|
|
gd->req_rows = 100;
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2017-04-16 21:41:29 -07:00
|
|
|
_efl_ui_grid_static_efl_pack_layout_layout_update(Eo *obj, void *_pd EINA_UNUSED)
|
2016-06-09 21:29:33 -07:00
|
|
|
{
|
|
|
|
Efl_Ui_Grid_Data *gd;
|
|
|
|
Grid_Item *gi;
|
|
|
|
Evas *e;
|
|
|
|
long long xl, yl, wl, hl, vwl, vhl;
|
|
|
|
Eina_Bool mirror;
|
2017-09-14 20:14:32 -07:00
|
|
|
Eina_Rect r;
|
2016-06-09 21:29:33 -07:00
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
gd = efl_data_scope_get(obj, EFL_UI_GRID_CLASS);
|
2016-06-09 21:29:33 -07:00
|
|
|
if (!gd->items) return;
|
|
|
|
|
2016-06-20 23:45:31 -07:00
|
|
|
e = evas_object_evas_get(obj);
|
2016-08-10 07:23:04 -07:00
|
|
|
efl_event_freeze(e);
|
2016-06-09 21:29:33 -07:00
|
|
|
|
2017-09-14 20:14:32 -07:00
|
|
|
r = efl_gfx_geometry_get(obj);
|
|
|
|
xl = r.x;
|
|
|
|
yl = r.y;
|
|
|
|
wl = r.w;
|
|
|
|
hl = r.h;
|
2017-06-13 03:41:15 -07:00
|
|
|
mirror = efl_ui_mirrored_get(obj);
|
2016-06-09 23:01:00 -07:00
|
|
|
|
|
|
|
if (!gd->req_cols || !gd->req_rows)
|
|
|
|
{
|
2017-08-17 03:36:17 -07:00
|
|
|
WRN("Grid_Static size must be set before using! Default to 100x100.");
|
2016-06-09 23:01:00 -07:00
|
|
|
efl_pack_grid_size_set(obj, 100, 100);
|
2017-07-23 03:42:06 -07:00
|
|
|
if (!gd->req_cols || !gd->req_rows) goto err;
|
2016-06-09 23:01:00 -07:00
|
|
|
}
|
2016-06-09 21:29:33 -07:00
|
|
|
vwl = gd->req_cols;
|
|
|
|
vhl = gd->req_rows;
|
|
|
|
|
|
|
|
EINA_INLIST_FOREACH(gd->items, gi)
|
|
|
|
{
|
|
|
|
long long x1, y1, x2, y2;
|
|
|
|
|
|
|
|
if (!mirror)
|
|
|
|
{
|
|
|
|
x1 = xl + ((wl * (long long)gi->col) / vwl);
|
|
|
|
x2 = xl + ((wl * (long long)(gi->col + gi->col_span)) / vwl);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x1 = xl + ((wl * (vwl - (long long)(gi->col + gi->col_span))) / vwl);
|
|
|
|
x2 = xl + ((wl * (vwl - (long long)gi->col)) / vwl);
|
|
|
|
}
|
|
|
|
y1 = yl + ((hl * (long long)gi->row) / vhl);
|
|
|
|
y2 = yl + ((hl * (long long)(gi->row + gi->row_span)) / vhl);
|
2017-09-14 20:14:32 -07:00
|
|
|
efl_gfx_geometry_set(gi->object, EINA_RECT(x1, y1, x2 - x1, y2 - y1));
|
2016-06-09 21:29:33 -07:00
|
|
|
}
|
2017-07-23 03:42:06 -07:00
|
|
|
err:
|
2016-08-10 07:23:04 -07:00
|
|
|
efl_event_thaw(e);
|
2016-06-09 21:29:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "efl_ui_grid_static.eo.c"
|