2013-06-20 03:53:29 -07:00
|
|
|
#include "evas_common_private.h"
|
2012-10-08 18:58:41 -07:00
|
|
|
#include "evas_private.h"
|
2011-12-05 07:39:04 -08:00
|
|
|
#include <errno.h>
|
2011-05-18 00:04:32 -07:00
|
|
|
|
2014-06-02 06:47:59 -07:00
|
|
|
#define MY_CLASS EVAS_GRID_CLASS
|
2012-10-08 18:58:41 -07:00
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
typedef struct _Evas_Grid_Data Evas_Grid_Data;
|
2011-05-18 00:04:32 -07:00
|
|
|
typedef struct _Evas_Object_Grid_Option Evas_Object_Grid_Option;
|
|
|
|
typedef struct _Evas_Object_Grid_Iterator Evas_Object_Grid_Iterator;
|
|
|
|
typedef struct _Evas_Object_Grid_Accessor Evas_Object_Grid_Accessor;
|
|
|
|
|
|
|
|
struct _Evas_Object_Grid_Option
|
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
|
|
|
Eina_List *l;
|
|
|
|
int x, y, w, h;
|
|
|
|
};
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
struct _Evas_Grid_Data
|
2011-05-18 00:04:32 -07:00
|
|
|
{
|
|
|
|
Evas_Object_Smart_Clipped_Data base;
|
|
|
|
Eina_List *children;
|
|
|
|
struct {
|
|
|
|
int w, h;
|
|
|
|
} size;
|
|
|
|
Eina_Bool is_mirrored : 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _Evas_Object_Grid_Iterator
|
|
|
|
{
|
|
|
|
Eina_Iterator iterator;
|
|
|
|
|
|
|
|
Eina_Iterator *real_iterator;
|
|
|
|
const Evas_Object *grid;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _Evas_Object_Grid_Accessor
|
|
|
|
{
|
|
|
|
Eina_Accessor accessor;
|
|
|
|
|
|
|
|
Eina_Accessor *real_accessor;
|
|
|
|
const Evas_Object *grid;
|
|
|
|
};
|
|
|
|
|
2012-08-26 00:04:46 -07:00
|
|
|
#define EVAS_OBJECT_GRID_DATA_GET(o, ptr) \
|
2014-03-10 08:02:10 -07:00
|
|
|
Evas_Grid_Data *ptr = eo_data_scope_get(o, MY_CLASS)
|
2011-05-18 00:04:32 -07:00
|
|
|
|
2012-08-26 00:04:46 -07:00
|
|
|
#define EVAS_OBJECT_GRID_DATA_GET_OR_RETURN(o, ptr) \
|
|
|
|
EVAS_OBJECT_GRID_DATA_GET(o, ptr); \
|
|
|
|
if (!ptr) \
|
|
|
|
{ \
|
2013-12-25 19:22:05 -08:00
|
|
|
CRI("no widget data for object %p (%s)", \
|
2012-08-26 00:04:46 -07:00
|
|
|
o, evas_object_type_get(o)); \
|
|
|
|
abort(); \
|
|
|
|
return; \
|
2011-05-18 00:04:32 -07:00
|
|
|
}
|
|
|
|
|
2012-08-26 00:04:46 -07:00
|
|
|
#define EVAS_OBJECT_GRID_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
|
|
|
|
EVAS_OBJECT_GRID_DATA_GET(o, ptr); \
|
|
|
|
if (!ptr) \
|
|
|
|
{ \
|
2013-12-25 19:22:05 -08:00
|
|
|
CRI("No widget data for object %p (%s)", \
|
2012-08-26 00:04:46 -07:00
|
|
|
o, evas_object_type_get(o)); \
|
|
|
|
abort(); \
|
|
|
|
return val; \
|
2011-05-18 00:04:32 -07:00
|
|
|
}
|
|
|
|
|
2011-08-05 04:54:13 -07:00
|
|
|
static const char EVAS_OBJECT_GRID_OPTION_KEY[] = "|EvGd";
|
2011-05-18 00:04:32 -07:00
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_evas_object_grid_iterator_next(Evas_Object_Grid_Iterator *it, void **data)
|
|
|
|
{
|
|
|
|
Evas_Object_Grid_Option *opt;
|
|
|
|
|
|
|
|
if (!eina_iterator_next(it->real_iterator, (void **)&opt))
|
|
|
|
return EINA_FALSE;
|
|
|
|
if (data) *data = opt->obj;
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
_evas_object_grid_iterator_get_container(Evas_Object_Grid_Iterator *it)
|
|
|
|
{
|
|
|
|
return (Evas_Object *)it->grid;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evas_object_grid_iterator_free(Evas_Object_Grid_Iterator *it)
|
|
|
|
{
|
|
|
|
eina_iterator_free(it->real_iterator);
|
|
|
|
free(it);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2011-05-26 18:19:35 -07:00
|
|
|
_evas_object_grid_accessor_get_at(Evas_Object_Grid_Accessor *it, unsigned int idx, void **data)
|
2011-05-18 00:04:32 -07:00
|
|
|
{
|
|
|
|
Evas_Object_Grid_Option *opt = NULL;
|
|
|
|
|
2011-05-26 18:19:35 -07:00
|
|
|
if (!eina_accessor_data_get(it->real_accessor, idx, (void **)&opt))
|
2011-05-18 00:04:32 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
if (data) *data = opt->obj;
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object *
|
|
|
|
_evas_object_grid_accessor_get_container(Evas_Object_Grid_Accessor *it)
|
|
|
|
{
|
|
|
|
return (Evas_Object *)it->grid;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evas_object_grid_accessor_free(Evas_Object_Grid_Accessor *it)
|
|
|
|
{
|
|
|
|
eina_accessor_free(it->real_accessor);
|
|
|
|
free(it);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object_Grid_Option *
|
|
|
|
_evas_object_grid_option_get(Evas_Object *o)
|
|
|
|
{
|
|
|
|
return evas_object_data_get(o, EVAS_OBJECT_GRID_OPTION_KEY);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evas_object_grid_option_set(Evas_Object *o, const Evas_Object_Grid_Option *opt)
|
|
|
|
{
|
|
|
|
evas_object_data_set(o, EVAS_OBJECT_GRID_OPTION_KEY, opt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Evas_Object_Grid_Option *
|
|
|
|
_evas_object_grid_option_del(Evas_Object *o)
|
|
|
|
{
|
|
|
|
return evas_object_data_del(o, EVAS_OBJECT_GRID_OPTION_KEY);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-10-08 18:58:41 -07:00
|
|
|
_on_child_del(void *data, Evas *evas EINA_UNUSED, Evas_Object *child, void *einfo EINA_UNUSED)
|
2011-05-18 00:04:32 -07:00
|
|
|
{
|
|
|
|
Evas_Object *grid = data;
|
|
|
|
evas_object_grid_unpack(grid, child);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evas_object_grid_child_connect(Evas_Object *o, Evas_Object *child)
|
|
|
|
{
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(child, EVAS_CALLBACK_DEL, _on_child_del, o);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evas_object_grid_child_disconnect(Evas_Object *o, Evas_Object *child)
|
|
|
|
{
|
|
|
|
evas_object_event_callback_del_full
|
|
|
|
(child, EVAS_CALLBACK_DEL, _on_child_del, o);
|
|
|
|
}
|
|
|
|
|
|
|
|
EVAS_SMART_SUBCLASS_NEW("Evas_Object_Grid", _evas_object_grid,
|
2012-08-26 00:04:46 -07:00
|
|
|
Evas_Smart_Class, Evas_Smart_Class,
|
|
|
|
evas_object_smart_clipped_class_get, NULL)
|
2011-05-18 00:04:32 -07:00
|
|
|
|
|
|
|
static void
|
|
|
|
_evas_object_grid_smart_add(Evas_Object *o)
|
|
|
|
{
|
2014-03-10 08:02:10 -07:00
|
|
|
Evas_Grid_Data *priv;
|
2012-10-08 18:58:41 -07:00
|
|
|
|
|
|
|
priv = evas_object_smart_data_get(o);
|
|
|
|
if (!priv)
|
|
|
|
{
|
2013-05-02 00:47:16 -07:00
|
|
|
priv = eo_data_ref(o, MY_CLASS);
|
2012-10-08 18:58:41 -07:00
|
|
|
evas_object_smart_data_set(o, priv);
|
|
|
|
}
|
2011-05-18 00:04:32 -07:00
|
|
|
|
|
|
|
priv->size.w = 100;
|
|
|
|
priv->size.h = 100;
|
|
|
|
|
|
|
|
_evas_object_grid_parent_sc->add(o);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evas_object_grid_smart_del(Evas_Object *o)
|
|
|
|
{
|
|
|
|
EVAS_OBJECT_GRID_DATA_GET(o, priv);
|
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
l = priv->children;
|
|
|
|
while (l)
|
|
|
|
{
|
2012-08-26 00:04:46 -07:00
|
|
|
Evas_Object_Grid_Option *opt = l->data;
|
|
|
|
_evas_object_grid_child_disconnect(o, opt->obj);
|
|
|
|
_evas_object_grid_option_del(opt->obj);
|
|
|
|
free(opt);
|
|
|
|
l = eina_list_remove_list(l, l);
|
2011-05-18 00:04:32 -07:00
|
|
|
}
|
|
|
|
_evas_object_grid_parent_sc->del(o);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evas_object_grid_smart_resize(Evas_Object *o, Evas_Coord w, Evas_Coord h)
|
|
|
|
{
|
|
|
|
Evas_Coord ow, oh;
|
|
|
|
evas_object_geometry_get(o, NULL, NULL, &ow, &oh);
|
|
|
|
if ((ow == w) && (oh == h)) return;
|
|
|
|
evas_object_smart_changed(o);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evas_object_grid_smart_calculate(Evas_Object *o)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Evas_Object_Grid_Option *opt;
|
2014-09-06 06:10:02 -07:00
|
|
|
Evas *e;
|
2015-05-13 06:22:32 -07:00
|
|
|
Evas_Coord x, y, w, h;
|
|
|
|
long long xl, yl, wl, hl, vwl, vhl;
|
2011-05-18 00:04:32 -07:00
|
|
|
Eina_Bool mirror;
|
2014-09-06 06:10:02 -07:00
|
|
|
|
2011-05-18 00:04:32 -07:00
|
|
|
EVAS_OBJECT_GRID_DATA_GET_OR_RETURN(o, priv);
|
|
|
|
if (!priv->children) return;
|
2014-09-06 06:10:02 -07:00
|
|
|
|
|
|
|
e = evas_object_evas_get(o);
|
|
|
|
evas_event_freeze(e);
|
|
|
|
|
2011-05-18 00:04:32 -07:00
|
|
|
evas_object_geometry_get(o, &x, &y, &w, &h);
|
2015-05-13 06:22:32 -07:00
|
|
|
xl = x;
|
|
|
|
yl = y;
|
|
|
|
wl = w;
|
|
|
|
hl = h;
|
2011-05-18 00:04:32 -07:00
|
|
|
mirror = priv->is_mirrored;
|
2015-05-13 06:22:32 -07:00
|
|
|
vwl = priv->size.w;
|
|
|
|
vhl = priv->size.h;
|
2011-05-18 00:04:32 -07:00
|
|
|
EINA_LIST_FOREACH(priv->children, l, opt)
|
|
|
|
{
|
2015-05-13 06:22:32 -07:00
|
|
|
long long x1, y1, x2, y2;
|
2014-09-06 06:10:02 -07:00
|
|
|
|
2014-08-13 19:14:49 -07:00
|
|
|
if (!mirror)
|
|
|
|
{
|
2015-05-13 06:22:32 -07:00
|
|
|
x1 = xl + ((wl * (long long)opt->x) / vwl);
|
|
|
|
x2 = xl + ((wl * (long long)(opt->x + opt->w)) / vwl);
|
2014-08-13 19:14:49 -07:00
|
|
|
}
|
|
|
|
else
|
2011-05-18 00:04:32 -07:00
|
|
|
{
|
2015-05-13 06:22:32 -07:00
|
|
|
x1 = xl + ((wl * (vwl - (long long)(opt->x + opt->w))) / vwl);
|
|
|
|
x2 = xl + ((wl * (vwl - (long long)opt->x)) / vwl);
|
2011-05-18 00:04:32 -07:00
|
|
|
}
|
2015-05-13 06:22:32 -07:00
|
|
|
y1 = yl + ((hl * (long long)opt->y) / vhl);
|
|
|
|
y2 = yl + ((hl * (long long)(opt->y + opt->h)) / vhl);
|
2011-05-18 00:04:32 -07:00
|
|
|
evas_object_move(opt->obj, x1, y1);
|
|
|
|
evas_object_resize(opt->obj, x2 - x1, y2 - y1);
|
|
|
|
}
|
2014-09-06 06:10:02 -07:00
|
|
|
|
|
|
|
evas_event_thaw(e);
|
2011-05-18 00:04:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_evas_object_grid_smart_set_user(Evas_Smart_Class *sc)
|
|
|
|
{
|
|
|
|
sc->add = _evas_object_grid_smart_add;
|
|
|
|
sc->del = _evas_object_grid_smart_del;
|
|
|
|
sc->resize = _evas_object_grid_smart_resize;
|
|
|
|
sc->calculate = _evas_object_grid_smart_calculate;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Evas_Object *
|
|
|
|
evas_object_grid_add(Evas *evas)
|
|
|
|
{
|
2012-10-08 18:58:41 -07:00
|
|
|
Evas_Object *obj = eo_add(MY_CLASS, evas);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
EOLIAN static void
|
2014-03-18 07:01:24 -07:00
|
|
|
_evas_grid_eo_base_constructor(Eo *obj, Evas_Grid_Data *class_data EINA_UNUSED)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2013-03-18 08:33:54 -07:00
|
|
|
eo_do_super(obj, MY_CLASS, eo_constructor());
|
2012-10-08 18:58:41 -07:00
|
|
|
eo_do(obj, evas_obj_smart_attach(_evas_object_grid_smart_class_new()));
|
|
|
|
|
|
|
|
// return evas_object_smart_add(evas, _evas_object_grid_smart_class_new());
|
2011-05-18 00:04:32 -07:00
|
|
|
}
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
EOLIAN static Evas_Object*
|
|
|
|
_evas_grid_add_to(Eo *parent, Evas_Grid_Data *_pd EINA_UNUSED)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
|
|
|
Evas *evas;
|
2014-03-10 08:02:10 -07:00
|
|
|
Evas_Object *ret;
|
2011-05-18 00:04:32 -07:00
|
|
|
evas = evas_object_evas_get(parent);
|
2014-03-10 08:02:10 -07:00
|
|
|
ret = evas_object_grid_add(evas);
|
|
|
|
evas_object_smart_member_add(ret, parent);
|
2011-05-18 00:04:32 -07:00
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
return ret;
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_grid_size_set(Eo *o, Evas_Grid_Data *priv, int w, int h)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2011-05-18 00:04:32 -07:00
|
|
|
if ((priv->size.w == w) && (priv->size.h == h)) return;
|
|
|
|
priv->size.w = w;
|
|
|
|
priv->size.h = h;
|
|
|
|
evas_object_smart_changed(o);
|
|
|
|
}
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_grid_size_get(Eo *o EINA_UNUSED, Evas_Grid_Data *priv, int *w, int *h)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2011-08-29 04:39:43 -07:00
|
|
|
if (w) *w = priv->size.w;
|
|
|
|
if (h) *h = priv->size.h;
|
2011-05-18 00:04:32 -07:00
|
|
|
}
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_evas_grid_pack(Eo *o, Evas_Grid_Data *priv, Evas_Object *child, int x, int y, int w, int h)
|
2011-05-18 00:04:32 -07:00
|
|
|
{
|
|
|
|
Evas_Object_Grid_Option *opt;
|
|
|
|
Eina_Bool newobj = EINA_FALSE;
|
|
|
|
|
|
|
|
opt = _evas_object_grid_option_get(child);
|
|
|
|
if (!opt)
|
|
|
|
{
|
|
|
|
opt = malloc(sizeof(*opt));
|
|
|
|
if (!opt)
|
|
|
|
{
|
|
|
|
ERR("could not allocate grid option data.");
|
2014-03-10 08:02:10 -07:00
|
|
|
return EINA_FALSE;
|
2011-05-18 00:04:32 -07:00
|
|
|
}
|
|
|
|
newobj = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
opt->x = x;
|
|
|
|
opt->y = y;
|
|
|
|
opt->w = w;
|
|
|
|
opt->h = h;
|
|
|
|
|
|
|
|
if (newobj)
|
|
|
|
{
|
|
|
|
opt->obj = child;
|
|
|
|
priv->children = eina_list_append(priv->children, opt);
|
|
|
|
opt->l = eina_list_last(priv->children);
|
|
|
|
_evas_object_grid_option_set(child, opt);
|
|
|
|
evas_object_smart_member_add(child, o);
|
|
|
|
_evas_object_grid_child_connect(o, child);
|
|
|
|
}
|
|
|
|
// FIXME: we could keep a changed list
|
|
|
|
evas_object_smart_changed(o);
|
2014-03-10 08:02:10 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2011-05-18 00:04:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-03-10 08:02:10 -07:00
|
|
|
_evas_object_grid_remove_opt(Evas_Grid_Data *priv, Evas_Object_Grid_Option *opt)
|
2011-05-18 00:04:32 -07:00
|
|
|
{
|
|
|
|
priv->children = eina_list_remove_list(priv->children, opt->l);
|
|
|
|
opt->l = NULL;
|
|
|
|
}
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_evas_grid_unpack(Eo *o, Evas_Grid_Data *priv, Evas_Object *child)
|
2011-05-18 00:04:32 -07:00
|
|
|
{
|
|
|
|
Evas_Object_Grid_Option *opt;
|
|
|
|
|
|
|
|
if (o != evas_object_smart_parent_get(child))
|
|
|
|
{
|
2012-08-26 00:04:46 -07:00
|
|
|
ERR("cannot unpack child from incorrect grid!");
|
2014-03-10 08:02:10 -07:00
|
|
|
return EINA_FALSE;
|
2011-05-18 00:04:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
opt = _evas_object_grid_option_del(child);
|
|
|
|
if (!opt)
|
|
|
|
{
|
2012-08-26 00:04:46 -07:00
|
|
|
ERR("cannot unpack child with no packing option!");
|
2014-03-10 08:02:10 -07:00
|
|
|
return EINA_FALSE;
|
2011-05-18 00:04:32 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
_evas_object_grid_child_disconnect(o, child);
|
|
|
|
_evas_object_grid_remove_opt(priv, opt);
|
|
|
|
evas_object_smart_member_del(child);
|
|
|
|
free(opt);
|
2014-03-10 08:02:10 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_grid_clear(Eo *o, Evas_Grid_Data *priv, Eina_Bool clear)
|
2011-05-18 00:04:32 -07:00
|
|
|
{
|
|
|
|
Evas_Object_Grid_Option *opt;
|
|
|
|
|
|
|
|
EINA_LIST_FREE(priv->children, opt)
|
|
|
|
{
|
2012-08-26 00:04:46 -07:00
|
|
|
_evas_object_grid_child_disconnect(o, opt->obj);
|
|
|
|
_evas_object_grid_option_del(opt->obj);
|
|
|
|
evas_object_smart_member_del(opt->obj);
|
|
|
|
if (clear)
|
|
|
|
evas_object_del(opt->obj);
|
|
|
|
free(opt);
|
2011-05-18 00:04:32 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_evas_grid_pack_get(Eo *o EINA_UNUSED, Evas_Grid_Data *_pd EINA_UNUSED, Evas_Object *child, int *x, int *y, int *w, int *h)
|
2011-05-18 00:04:32 -07:00
|
|
|
{
|
|
|
|
Evas_Object_Grid_Option *opt;
|
|
|
|
|
2011-08-29 04:49:31 -07:00
|
|
|
if (x) *x = 0;
|
|
|
|
if (y) *y = 0;
|
|
|
|
if (w) *w = 0;
|
|
|
|
if (h) *h = 0;
|
2011-05-18 00:04:32 -07:00
|
|
|
opt = _evas_object_grid_option_get(child);
|
2014-03-10 08:02:10 -07:00
|
|
|
if (!opt) return 0;
|
2011-05-18 00:04:32 -07:00
|
|
|
if (x) *x = opt->x;
|
|
|
|
if (y) *y = opt->y;
|
|
|
|
if (w) *w = opt->w;
|
|
|
|
if (h) *h = opt->h;
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
return 1;
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
EOLIAN static Eina_Iterator*
|
|
|
|
_evas_grid_iterator_new(Eo *o, Evas_Grid_Data *priv)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2011-05-18 00:04:32 -07:00
|
|
|
Evas_Object_Grid_Iterator *it;
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
if (!priv->children) return NULL;
|
2011-05-18 00:04:32 -07:00
|
|
|
|
|
|
|
it = calloc(1, sizeof(Evas_Object_Grid_Iterator));
|
2014-03-10 08:02:10 -07:00
|
|
|
if (!it) return NULL;
|
2011-05-18 00:04:32 -07:00
|
|
|
|
|
|
|
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
|
|
|
|
|
|
|
|
it->real_iterator = eina_list_iterator_new(priv->children);
|
|
|
|
it->grid = o;
|
|
|
|
|
|
|
|
it->iterator.next = FUNC_ITERATOR_NEXT(_evas_object_grid_iterator_next);
|
|
|
|
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_evas_object_grid_iterator_get_container);
|
|
|
|
it->iterator.free = FUNC_ITERATOR_FREE(_evas_object_grid_iterator_free);
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
return &it->iterator;
|
2011-05-18 00:04:32 -07:00
|
|
|
}
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
EOLIAN static Eina_Accessor*
|
|
|
|
_evas_grid_accessor_new(Eo *o, Evas_Grid_Data *priv)
|
2011-05-18 00:04:32 -07:00
|
|
|
{
|
|
|
|
Evas_Object_Grid_Accessor *it;
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
if (!priv->children) return NULL;
|
2011-05-18 00:04:32 -07:00
|
|
|
|
|
|
|
it = calloc(1, sizeof(Evas_Object_Grid_Accessor));
|
2014-03-10 08:02:10 -07:00
|
|
|
if (!it) return NULL;
|
2011-05-18 00:04:32 -07:00
|
|
|
|
|
|
|
EINA_MAGIC_SET(&it->accessor, EINA_MAGIC_ACCESSOR);
|
|
|
|
|
|
|
|
it->real_accessor = eina_list_accessor_new(priv->children);
|
|
|
|
it->grid = o;
|
|
|
|
|
|
|
|
it->accessor.get_at = FUNC_ACCESSOR_GET_AT(_evas_object_grid_accessor_get_at);
|
|
|
|
it->accessor.get_container = FUNC_ACCESSOR_GET_CONTAINER(_evas_object_grid_accessor_get_container);
|
|
|
|
it->accessor.free = FUNC_ACCESSOR_FREE(_evas_object_grid_accessor_free);
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
return &it->accessor;
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
EOLIAN static Eina_List*
|
|
|
|
_evas_grid_children_get(Eo *o EINA_UNUSED, Evas_Grid_Data *priv)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2011-05-18 00:04:32 -07:00
|
|
|
Eina_List *new_list = NULL, *l;
|
|
|
|
Evas_Object_Grid_Option *opt;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(priv->children, l, opt)
|
|
|
|
new_list = eina_list_append(new_list, opt->obj);
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
return new_list;
|
2011-05-18 00:04:32 -07:00
|
|
|
}
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_evas_grid_mirrored_get(Eo *o EINA_UNUSED, Evas_Grid_Data *priv)
|
2011-05-18 00:04:32 -07:00
|
|
|
{
|
2014-03-10 08:02:10 -07:00
|
|
|
return priv->is_mirrored;
|
2012-10-08 18:58:41 -07:00
|
|
|
}
|
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_evas_grid_mirrored_set(Eo *o EINA_UNUSED, Evas_Grid_Data *priv, Eina_Bool mirrored)
|
2012-10-08 18:58:41 -07:00
|
|
|
{
|
2011-05-18 00:04:32 -07:00
|
|
|
mirrored = !!mirrored;
|
|
|
|
if (priv->is_mirrored != mirrored)
|
|
|
|
{
|
|
|
|
priv->is_mirrored = mirrored;
|
2012-10-08 18:58:41 -07:00
|
|
|
_evas_object_grid_smart_calculate(o);
|
2011-05-18 00:04:32 -07:00
|
|
|
}
|
|
|
|
}
|
2012-10-08 18:58:41 -07:00
|
|
|
|
2014-03-10 08:02:10 -07:00
|
|
|
#include "canvas/evas_grid.eo.c"
|