[Elm] Box ported to new class schema.

SVN revision: 70745
This commit is contained in:
Gustavo Lima Chaves 2012-05-03 22:44:41 +00:00
parent 6391d192df
commit bc06e63aa7
2 changed files with 394 additions and 289 deletions

View File

@ -189,7 +189,7 @@ _del_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
elm_box_unpack(data, obj);
evas_object_move(obj, 0, 0);
evas_object_color_set(obj, 128, 64, 0, 128);
// evas_object_del(obj);
evas_object_del(obj);
}
void

View File

@ -2,22 +2,17 @@
#include "elm_priv.h"
#include "els_box.h"
static const char SIG_CHILD_ADDED[] = "child,added";
static const char SIG_CHILD_REMOVED[] = "child,removed";
static const char BOX_SMART_NAME[] = "elm_box";
static const Evas_Smart_Cb_Description _signals[] = {
{SIG_CHILD_ADDED, ""},
{SIG_CHILD_REMOVED, ""},
{NULL, NULL}
};
typedef struct _Widget_Data Widget_Data;
typedef struct _Elm_Box_Smart_Data Elm_Box_Smart_Data;
typedef struct _Transition_Animation_Data Transition_Animation_Data;
struct _Widget_Data
struct _Elm_Box_Smart_Data
{
Evas_Object *box;
Elm_Widget_Smart_Data base; /* base widget smart data as
* first member obligatory, as
* we're inheriting from it */
Eina_Bool horizontal : 1;
Eina_Bool homogeneous : 1;
Eina_Bool recalc : 1;
@ -27,8 +22,6 @@ struct _Elm_Box_Transition
{
double initial_time;
double duration;
Eina_Bool animation_ended:1;
Eina_Bool recalculate:1;
Ecore_Animator *animator;
struct
@ -43,6 +36,9 @@ struct _Elm_Box_Transition
void (*transition_end_free_data)(void *data);
Eina_List *objs;
Evas_Object *box;
Eina_Bool animation_ended : 1;
Eina_Bool recalculate : 1;
};
struct _Transition_Animation_Data
@ -54,30 +50,43 @@ struct _Transition_Animation_Data
} start, end;
};
static const char *widtype = NULL;
static void _del_hook(Evas_Object *obj);
static void _sizing_eval(Evas_Object *obj);
static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _sub_del(void *data, Evas_Object *obj, void *event_info);
#define ELM_BOX_DATA_GET(o, sd) \
Elm_Box_Smart_Data * sd = evas_object_smart_data_get(o)
static void
_del_pre_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
evas_object_event_callback_del_full
(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
evas_object_box_remove_all(wd->box, EINA_FALSE);
#define ELM_BOX_DATA_GET_OR_RETURN(o, ptr) \
ELM_BOX_DATA_GET(o, ptr); \
if (!ptr) \
{ \
CRITICAL("No widget data for object %p (%s)", \
o, evas_object_type_get(o)); \
return; \
}
static void
_del_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
free(wd);
#define ELM_BOX_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
ELM_BOX_DATA_GET(o, ptr); \
if (!ptr) \
{ \
CRITICAL("No widget data for object %p (%s)", \
o, evas_object_type_get(o)); \
return val; \
}
#define ELM_BOX_CHECK(obj) \
if (!obj || !elm_widget_type_check((obj), BOX_SMART_NAME, __func__)) \
return
EVAS_SMART_SUBCLASS_NEW
(BOX_SMART_NAME, _elm_box, Elm_Widget_Smart_Class,
Elm_Widget_Smart_Class, elm_widget_smart_class_get, NULL);
static const char SIG_CHILD_ADDED[] = "child,added";
static const char SIG_CHILD_REMOVED[] = "child,removed";
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
{SIG_CHILD_ADDED, ""},
{SIG_CHILD_REMOVED, ""},
{NULL, NULL}
};
static void *
_elm_box_list_data_get(const Eina_List *list)
{
@ -86,7 +95,9 @@ _elm_box_list_data_get(const Eina_List *list)
}
static void
_cb_proxy_child_added(void *data, Evas_Object *o __UNUSED__, void *event_info)
_child_added_cb_proxy(void *data,
Evas_Object *o __UNUSED__,
void *event_info)
{
Evas_Object *box = data;
Evas_Object_Box_Option *opt = event_info;
@ -94,7 +105,9 @@ _cb_proxy_child_added(void *data, Evas_Object *o __UNUSED__, void *event_info)
}
static void
_cb_proxy_child_removed(void *data, Evas_Object *o __UNUSED__, void *event_info)
_child_removed_cb_proxy(void *data,
Evas_Object *o __UNUSED__,
void *event_info)
{
Evas_Object *box = data;
Evas_Object *child = event_info;
@ -102,14 +115,14 @@ _cb_proxy_child_removed(void *data, Evas_Object *o __UNUSED__, void *event_info)
}
static Eina_Bool
_elm_box_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
_elm_box_smart_focus_next(const Evas_Object *obj,
Elm_Focus_Direction dir,
Evas_Object **next)
{
Widget_Data *wd = elm_widget_data_get(obj);
const Eina_List *items;
void *(*list_data_get)(const Eina_List *list);
if ((!wd) || (!wd->box))
return EINA_FALSE;
ELM_BOX_DATA_GET(obj, sd);
/* Focus chain */
/* TODO: Change this to use other chain */
@ -117,7 +130,9 @@ _elm_box_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_O
list_data_get = eina_list_data_get;
else
{
Evas_Object_Box_Data *bd = evas_object_smart_data_get(wd->box);
Evas_Object_Box_Data *bd =
evas_object_smart_data_get(ELM_WIDGET_DATA(sd)->resize_obj);
items = bd->children;
list_data_get = _elm_box_list_data_get;
@ -128,89 +143,103 @@ _elm_box_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_O
}
static Eina_Bool
_elm_box_focus_direction_hook(const Evas_Object *obj, const Evas_Object *base, double degree,
Evas_Object **direction, double *weight)
_elm_box_smart_focus_direction(const Evas_Object *obj,
const Evas_Object *base,
double degree,
Evas_Object **direction,
double *weight)
{
Widget_Data *wd = elm_widget_data_get(obj);
const Eina_List *items;
void *(*list_data_get)(const Eina_List *list);
if ((!wd) || (!wd->box))
return EINA_FALSE;
ELM_BOX_DATA_GET(obj, sd);
if ((items = elm_widget_focus_custom_chain_get(obj)))
list_data_get = eina_list_data_get;
else
{
Evas_Object_Box_Data *bd = evas_object_smart_data_get(wd->box);
Evas_Object_Box_Data *bd =
evas_object_smart_data_get(ELM_WIDGET_DATA(sd)->resize_obj);
items = bd->children;
list_data_get = _elm_box_list_data_get;
if (!items) return EINA_FALSE;
}
return elm_widget_focus_list_direction_get(obj, base, items, list_data_get, degree,
direction, weight);
return elm_widget_focus_list_direction_get
(obj, base, items, list_data_get, degree, direction, weight);
}
static void
_theme_hook(Evas_Object *obj)
static Eina_Bool
_elm_box_smart_theme(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
_elm_widget_mirrored_reload(obj);
evas_object_smart_calculate(wd->box);
ELM_BOX_DATA_GET(obj, sd);
if (!_elm_box_parent_sc->theme(obj)) return EINA_FALSE;
evas_object_smart_calculate(ELM_WIDGET_DATA(sd)->resize_obj);
return EINA_TRUE;
}
static void
_sizing_eval(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
Evas_Coord w, h;
if (!wd) return;
evas_object_size_hint_min_get(wd->box, &minw, &minh);
evas_object_size_hint_max_get(wd->box, &maxw, &maxh);
ELM_BOX_DATA_GET(obj, sd);
evas_object_size_hint_min_get
(ELM_WIDGET_DATA(sd)->resize_obj, &minw, &minh);
evas_object_size_hint_max_get
(ELM_WIDGET_DATA(sd)->resize_obj, &maxw, &maxh);
evas_object_size_hint_min_set(obj, minw, minh);
evas_object_size_hint_max_set(obj, maxw, maxh);
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
if (w < minw) w = minw;
if (h < minh) h = minh;
if ((maxw >= 0) && (w > maxw)) w = maxw;
if ((maxh >= 0) && (h > maxh)) h = maxh;
evas_object_resize(obj, w, h);
}
static void
_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
_on_size_hints_changed(void *data,
Evas *e __UNUSED__,
Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
_sizing_eval(data);
}
static void
_sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
static Eina_Bool
_elm_box_smart_sub_object_del(Evas_Object *obj,
Evas_Object *child)
{
if (!_elm_box_parent_sc->sub_object_del(obj, child)) return EINA_FALSE;
_sizing_eval(obj);
return EINA_TRUE;
}
static void
_layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
_elm_box_custom_layout(Evas_Object *o,
Evas_Object_Box_Data *priv,
void *data)
{
Evas_Object *obj = (Evas_Object *) data;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
_els_box_layout(o, priv, wd->horizontal, wd->homogeneous,
elm_widget_mirrored_get(obj));
ELM_BOX_DATA_GET(data, sd);
_els_box_layout(o, priv, sd->horizontal, sd->homogeneous,
elm_widget_mirrored_get(data));
}
static Eina_Bool
_transition_animation(void *data)
{
evas_object_smart_changed(data);
return ECORE_CALLBACK_RENEW;
}
static void
_transition_layout_child_added(void *data, Evas_Object *obj __UNUSED__, void *event_info)
_transition_layout_child_added(void *data,
Evas_Object *obj __UNUSED__,
void *event_info)
{
Transition_Animation_Data *tad;
Evas_Object_Box_Option *opt = event_info;
@ -218,13 +247,16 @@ _transition_layout_child_added(void *data, Evas_Object *obj __UNUSED__, void *ev
tad = calloc(1, sizeof(Transition_Animation_Data));
if (!tad) return;
tad->obj = opt->obj;
layout_data->objs = eina_list_append(layout_data->objs, tad);
layout_data->recalculate = EINA_TRUE;
}
static void
_transition_layout_child_removed(void *data, Evas_Object *obj __UNUSED__, void *event_info)
_transition_layout_child_removed(void *data,
Evas_Object *obj __UNUSED__,
void *event_info)
{
Eina_List *l;
Transition_Animation_Data *tad;
@ -243,19 +275,24 @@ _transition_layout_child_removed(void *data, Evas_Object *obj __UNUSED__, void *
}
static void
_transition_layout_obj_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
_transition_layout_obj_resize_cb(void *data,
Evas *e __UNUSED__,
Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
Elm_Box_Transition *layout_data = data;
layout_data->recalculate = EINA_TRUE;
}
static void
_transition_layout_calculate_coords(Evas_Object *obj, Evas_Object_Box_Data *priv,
_transition_layout_calculate_coords(Evas_Object *obj,
Evas_Object_Box_Data *priv,
Elm_Box_Transition *layout_data)
{
Eina_List *l;
Transition_Animation_Data *tad;
Evas_Coord x, y, w, h;
Transition_Animation_Data *tad;
const double curtime = ecore_loop_time_get();
layout_data->duration =
@ -308,8 +345,11 @@ _transition_layout_load_children_list(Evas_Object_Box_Data *priv,
}
static Eina_Bool
_transition_layout_animation_start(Evas_Object *obj, Evas_Object_Box_Data *priv,
Elm_Box_Transition *layout_data, Eina_Bool(*transition_animation_cb)(void *data))
_transition_layout_animation_start(Evas_Object *obj,
Evas_Object_Box_Data *priv,
Elm_Box_Transition *layout_data,
Eina_Bool (*transition_animation_cb)
(void *data))
{
layout_data->start.layout(obj, priv, layout_data->start.data);
layout_data->box = obj;
@ -317,17 +357,22 @@ _transition_layout_animation_start(Evas_Object *obj, Evas_Object_Box_Data *priv,
if (!_transition_layout_load_children_list(priv, layout_data))
return EINA_FALSE;
_transition_layout_calculate_coords(obj, priv, layout_data);
evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
_transition_layout_obj_resize_cb, layout_data);
evas_object_smart_callback_add(obj, SIG_CHILD_ADDED,
_transition_layout_child_added, layout_data);
evas_object_smart_callback_add(obj, SIG_CHILD_REMOVED,
_transition_layout_child_removed, layout_data);
evas_object_event_callback_add
(obj, EVAS_CALLBACK_RESIZE, _transition_layout_obj_resize_cb,
layout_data);
evas_object_smart_callback_add
(obj, SIG_CHILD_ADDED, _transition_layout_child_added, layout_data);
evas_object_smart_callback_add
(obj, SIG_CHILD_REMOVED, _transition_layout_child_removed, layout_data);
if (!layout_data->animator)
layout_data->animator = ecore_animator_add(transition_animation_cb, obj);
layout_data->animation_ended = EINA_FALSE;
return EINA_TRUE;
}
@ -335,6 +380,7 @@ static void
_transition_layout_animation_stop(Elm_Box_Transition *layout_data)
{
layout_data->animation_ended = EINA_TRUE;
if (layout_data->animator)
{
ecore_animator_del(layout_data->animator);
@ -346,14 +392,16 @@ _transition_layout_animation_stop(Elm_Box_Transition *layout_data)
}
static void
_transition_layout_animation_exec(Evas_Object *obj, Evas_Object_Box_Data *priv __UNUSED__,
Elm_Box_Transition *layout_data, const double curtime)
_transition_layout_animation_exec(Evas_Object *obj,
Evas_Object_Box_Data *priv __UNUSED__,
Elm_Box_Transition *layout_data,
const double curtime)
{
Eina_List *l;
Transition_Animation_Data *tad;
Evas_Coord x, y, w, h;
Evas_Coord cur_x, cur_y, cur_w, cur_h;
double progress = 0.0;
Evas_Coord x, y, w, h;
Transition_Animation_Data *tad;
Evas_Coord cur_x, cur_y, cur_w, cur_h;
progress = (curtime - layout_data->initial_time) / layout_data->duration;
evas_object_geometry_get(obj, &x, &y, &w, &h);
@ -369,203 +417,238 @@ _transition_layout_animation_exec(Evas_Object *obj, Evas_Object_Box_Data *priv _
}
}
static void
_elm_box_smart_add(Evas_Object *obj)
{
EVAS_SMART_DATA_ALLOC(obj, Elm_Box_Smart_Data);
ELM_WIDGET_DATA(priv)->resize_obj =
evas_object_box_add(evas_object_evas_get(obj));
evas_object_box_layout_set
(ELM_WIDGET_DATA(priv)->resize_obj, _elm_box_custom_layout, obj, NULL);
evas_object_event_callback_add
(ELM_WIDGET_DATA(priv)->resize_obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_on_size_hints_changed, obj);
_elm_box_parent_sc->base.add(obj);
evas_object_smart_callback_add
(ELM_WIDGET_DATA(priv)->resize_obj, SIG_CHILD_ADDED,
_child_added_cb_proxy, obj);
evas_object_smart_callback_add
(ELM_WIDGET_DATA(priv)->resize_obj, SIG_CHILD_REMOVED,
_child_removed_cb_proxy, obj);
elm_widget_can_focus_set(obj, EINA_FALSE);
elm_widget_highlight_ignore_set(obj, EINA_TRUE);
}
static void
_elm_box_smart_del(Evas_Object *obj)
{
Eina_List *l;
Evas_Object *child;
ELM_BOX_DATA_GET(obj, sd);
evas_object_event_callback_del_full
(ELM_WIDGET_DATA(sd)->resize_obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_on_size_hints_changed, obj);
/* let's make our box object the *last* to be processed, since it
* may (smart) parent other sub objects here */
EINA_LIST_FOREACH (ELM_WIDGET_DATA(sd)->subobjs, l, child)
{
if (child == ELM_WIDGET_DATA(sd)->resize_obj)
{
ELM_WIDGET_DATA(sd)->subobjs =
eina_list_demote_list(ELM_WIDGET_DATA(sd)->subobjs, l);
break;
}
}
_elm_box_parent_sc->base.del(obj);
}
static void
_elm_box_smart_set_user(Elm_Widget_Smart_Class *sc)
{
sc->base.add = _elm_box_smart_add;
sc->base.del = _elm_box_smart_del;
sc->sub_object_del = _elm_box_smart_sub_object_del;
sc->theme = _elm_box_smart_theme;
sc->focus_next = _elm_box_smart_focus_next;
sc->focus_direction = _elm_box_smart_focus_direction;
}
EAPI Evas_Object *
elm_box_add(Evas_Object *parent)
{
Evas_Object *obj;
Evas *e;
Widget_Data *wd;
Evas_Object *obj;
ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
ELM_SET_WIDTYPE(widtype, "box");
elm_widget_type_set(obj, "box");
elm_widget_sub_object_add(parent, obj);
elm_widget_data_set(obj, wd);
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_del_pre_hook_set(obj, _del_pre_hook);
elm_widget_focus_next_hook_set(obj, _elm_box_focus_next_hook);
elm_widget_focus_direction_hook_set(obj, _elm_box_focus_direction_hook);
elm_widget_can_focus_set(obj, EINA_FALSE);
elm_widget_highlight_ignore_set(obj, EINA_TRUE);
elm_widget_theme_hook_set(obj, _theme_hook);
e = evas_object_evas_get(parent);
if (!e) return NULL;
wd->box = evas_object_box_add(e);
/*evas_object_box_layout_set(wd->box, evas_object_box_layout_vertical,
NULL, NULL);*/
evas_object_box_layout_set(wd->box, _layout, obj, NULL);
obj = evas_object_smart_add(e, _elm_box_smart_class_new());
evas_object_event_callback_add(wd->box, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
_changed_size_hints, obj);
elm_widget_resize_object_set(obj, wd->box);
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
evas_object_smart_callbacks_descriptions_set(obj, _signals);
evas_object_smart_callback_add
(wd->box, SIG_CHILD_ADDED, _cb_proxy_child_added, obj);
evas_object_smart_callback_add
(wd->box, SIG_CHILD_REMOVED, _cb_proxy_child_removed, obj);
if (!elm_widget_sub_object_add(parent, obj))
ERR("could not add %p as sub object of %p", obj, parent);
return obj;
}
EAPI void
elm_box_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
elm_box_horizontal_set(Evas_Object *obj,
Eina_Bool horizontal)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
wd->horizontal = !!horizontal;
evas_object_smart_calculate(wd->box);
/*if (wd->horizontal)
{
if (wd->homogeneous)
evas_object_box_layout_set(wd->box,
evas_object_box_layout_homogeneous_horizontal, NULL, NULL);
else
evas_object_box_layout_set(wd->box, evas_object_box_layout_horizontal,
NULL, NULL);
}
else
{
if (wd->homogeneous)
evas_object_box_layout_set(wd->box,
evas_object_box_layout_homogeneous_vertical, NULL, NULL);
else
evas_object_box_layout_set(wd->box, evas_object_box_layout_horizontal,
NULL, NULL);
} */
ELM_BOX_CHECK(obj);
ELM_BOX_DATA_GET(obj, sd);
sd->horizontal = !!horizontal;
evas_object_smart_calculate(ELM_WIDGET_DATA(sd)->resize_obj);
}
EAPI Eina_Bool
elm_box_horizontal_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return EINA_FALSE;
return wd->horizontal;
ELM_BOX_CHECK(obj) EINA_FALSE;
ELM_BOX_DATA_GET(obj, sd);
return sd->horizontal;
}
EAPI void
elm_box_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
elm_box_homogeneous_set(Evas_Object *obj,
Eina_Bool homogeneous)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
wd->homogeneous = !!homogeneous;
evas_object_smart_calculate(wd->box);
/*if (wd->horizontal)
{
if (wd->homogeneous)
evas_object_box_layout_set(wd->box,
evas_object_box_layout_homogeneous_horizontal, NULL, NULL);
else
evas_object_box_layout_set(wd->box, evas_object_box_layout_horizontal,
NULL, NULL);
}
else
{
if (wd->homogeneous)
evas_object_box_layout_set(wd->box,
evas_object_box_layout_homogeneous_vertical, NULL, NULL);
else
evas_object_box_layout_set(wd->box, evas_object_box_layout_horizontal,
NULL, NULL);
} */
ELM_BOX_CHECK(obj);
ELM_BOX_DATA_GET(obj, sd);
sd->homogeneous = !!homogeneous;
evas_object_smart_calculate(ELM_WIDGET_DATA(sd)->resize_obj);
}
EAPI Eina_Bool
elm_box_homogeneous_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return EINA_FALSE;
return wd->homogeneous;
ELM_BOX_CHECK(obj) EINA_FALSE;
ELM_BOX_DATA_GET(obj, sd);
return sd->homogeneous;
}
EAPI void
elm_box_pack_start(Evas_Object *obj, Evas_Object *subobj)
elm_box_pack_start(Evas_Object *obj,
Evas_Object *subobj)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
ELM_BOX_CHECK(obj);
ELM_BOX_DATA_GET(obj, sd);
elm_widget_sub_object_add(obj, subobj);
evas_object_box_prepend(wd->box, subobj);
evas_object_box_prepend(ELM_WIDGET_DATA(sd)->resize_obj, subobj);
}
EAPI void
elm_box_pack_end(Evas_Object *obj, Evas_Object *subobj)
elm_box_pack_end(Evas_Object *obj,
Evas_Object *subobj)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
ELM_BOX_CHECK(obj);
ELM_BOX_DATA_GET(obj, sd);
elm_widget_sub_object_add(obj, subobj);
evas_object_box_append(wd->box, subobj);
evas_object_box_append(ELM_WIDGET_DATA(sd)->resize_obj, subobj);
}
EAPI void
elm_box_pack_before(Evas_Object *obj, Evas_Object *subobj, Evas_Object *before)
elm_box_pack_before(Evas_Object *obj,
Evas_Object *subobj,
Evas_Object *before)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
ELM_BOX_CHECK(obj);
ELM_BOX_DATA_GET(obj, sd);
elm_widget_sub_object_add(obj, subobj);
evas_object_box_insert_before(wd->box, subobj, before);
evas_object_box_insert_before
(ELM_WIDGET_DATA(sd)->resize_obj, subobj, before);
}
EAPI void
elm_box_pack_after(Evas_Object *obj, Evas_Object *subobj, Evas_Object *after)
elm_box_pack_after(Evas_Object *obj,
Evas_Object *subobj,
Evas_Object *after)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
ELM_BOX_CHECK(obj);
ELM_BOX_DATA_GET(obj, sd);
elm_widget_sub_object_add(obj, subobj);
evas_object_box_insert_after(wd->box, subobj, after);
evas_object_box_insert_after
(ELM_WIDGET_DATA(sd)->resize_obj, subobj, after);
}
EAPI void
elm_box_clear(Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
evas_object_box_remove_all(wd->box, EINA_TRUE);
ELM_BOX_CHECK(obj);
ELM_BOX_DATA_GET(obj, sd);
/* EINA_TRUE means to delete objects as well */
evas_object_box_remove_all(ELM_WIDGET_DATA(sd)->resize_obj, EINA_TRUE);
}
EAPI void
elm_box_unpack(Evas_Object *obj, Evas_Object *subobj)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
evas_object_box_remove(wd->box, subobj);
ELM_BOX_CHECK(obj);
ELM_BOX_DATA_GET(obj, sd);
elm_widget_sub_object_del(obj, subobj);
evas_object_box_remove(ELM_WIDGET_DATA(sd)->resize_obj, subobj);
}
EAPI void
elm_box_unpack_all(Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
evas_object_box_remove_all(wd->box, EINA_FALSE);
Evas_Object_Box_Data *bd;
Evas_Object_Box_Option *opt;
Eina_List *l;
ELM_BOX_CHECK(obj);
ELM_BOX_DATA_GET(obj, sd);
bd = evas_object_smart_data_get(ELM_WIDGET_DATA(sd)->resize_obj);
EINA_LIST_FOREACH (bd->children, l, opt)
elm_widget_sub_object_del(obj, opt->obj);
/* EINA_FALSE means to delete objects as well */
evas_object_box_remove_all(ELM_WIDGET_DATA(sd)->resize_obj, EINA_FALSE);
}
EAPI void
elm_box_layout_set(Evas_Object *obj, Evas_Object_Box_Layout cb, const void *data, Ecore_Cb free_data)
elm_box_layout_set(Evas_Object *obj,
Evas_Object_Box_Layout cb,
const void *data,
Ecore_Cb free_data)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
ELM_BOX_CHECK(obj);
ELM_BOX_DATA_GET(obj, sd);
if (cb)
evas_object_box_layout_set(wd->box, cb, data, free_data);
evas_object_box_layout_set
(ELM_WIDGET_DATA(sd)->resize_obj, cb, data, free_data);
else
evas_object_box_layout_set(wd->box, _layout, obj, NULL);
evas_object_box_layout_set
(ELM_WIDGET_DATA(sd)->resize_obj, _elm_box_custom_layout, obj, NULL);
}
EAPI void
elm_box_layout_transition(Evas_Object *obj, Evas_Object_Box_Data *priv, void *data)
elm_box_layout_transition(Evas_Object *obj,
Evas_Object_Box_Data *priv,
void *data)
{
Elm_Box_Transition *box_data = data;
const double curtime = ecore_loop_time_get();
@ -599,9 +682,11 @@ elm_box_layout_transition(Evas_Object *obj, Evas_Object_Box_Data *priv, void *da
EAPI Elm_Box_Transition *
elm_box_transition_new(const double duration,
Evas_Object_Box_Layout start_layout, void *start_layout_data,
Evas_Object_Box_Layout start_layout,
void *start_layout_data,
Ecore_Cb start_layout_free_data,
Evas_Object_Box_Layout end_layout, void *end_layout_data,
Evas_Object_Box_Layout end_layout,
void *end_layout_data,
Ecore_Cb end_layout_free_data,
Ecore_Cb transition_end_cb,
void *transition_end_data)
@ -612,8 +697,7 @@ elm_box_transition_new(const double duration,
EINA_SAFETY_ON_NULL_RETURN_VAL(end_layout, NULL);
box_data = calloc(1, sizeof(Elm_Box_Transition));
if (!box_data)
return NULL;
if (!box_data) return NULL;
box_data->start.layout = start_layout;
box_data->start.data = start_layout_data;
@ -624,6 +708,7 @@ elm_box_transition_new(const double duration,
box_data->duration = duration;
box_data->transition_end_cb = transition_end_cb;
box_data->transition_end_data = transition_end_data;
return box_data;
}
@ -640,70 +725,90 @@ elm_box_transition_free(void *data)
box_data->end.free_data(box_data->end.data);
EINA_LIST_FREE (box_data->objs, tad)
free(tad);
evas_object_event_callback_del(box_data->box, EVAS_CALLBACK_RESIZE, _transition_layout_obj_resize_cb);
evas_object_smart_callback_del(box_data->box, SIG_CHILD_ADDED, _transition_layout_child_added);
evas_object_smart_callback_del(box_data->box, SIG_CHILD_REMOVED, _transition_layout_child_removed);
evas_object_event_callback_del
(box_data->box, EVAS_CALLBACK_RESIZE, _transition_layout_obj_resize_cb);
evas_object_smart_callback_del
(box_data->box, SIG_CHILD_ADDED, _transition_layout_child_added);
evas_object_smart_callback_del
(box_data->box, SIG_CHILD_REMOVED, _transition_layout_child_removed);
if (box_data->animator)
{
ecore_animator_del(box_data->animator);
box_data->animator = NULL;
}
free(data);
}
EAPI Eina_List *
elm_box_children_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
return evas_object_box_children_get(wd->box);
ELM_BOX_CHECK(obj) NULL;
ELM_BOX_DATA_GET(obj, sd);
return evas_object_box_children_get(ELM_WIDGET_DATA(sd)->resize_obj);
}
EAPI void
elm_box_padding_set(Evas_Object *obj, Evas_Coord horizontal, Evas_Coord vertical)
elm_box_padding_set(Evas_Object *obj,
Evas_Coord horizontal,
Evas_Coord vertical)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
evas_object_box_padding_set(wd->box, horizontal, vertical);
ELM_BOX_CHECK(obj);
ELM_BOX_DATA_GET(obj, sd);
evas_object_box_padding_set
(ELM_WIDGET_DATA(sd)->resize_obj, horizontal, vertical);
}
EAPI void
elm_box_padding_get(const Evas_Object *obj, Evas_Coord *horizontal, Evas_Coord *vertical)
elm_box_padding_get(const Evas_Object *obj,
Evas_Coord *horizontal,
Evas_Coord *vertical)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
evas_object_box_padding_get(wd->box, horizontal, vertical);
ELM_BOX_CHECK(obj);
ELM_BOX_DATA_GET(obj, sd);
evas_object_box_padding_get
(ELM_WIDGET_DATA(sd)->resize_obj, horizontal, vertical);
}
EAPI void
elm_box_align_set(Evas_Object *obj, double horizontal, double vertical)
elm_box_align_set(Evas_Object *obj,
double horizontal,
double vertical)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
evas_object_size_hint_align_set(wd->box, horizontal, vertical);
ELM_BOX_CHECK(obj);
ELM_BOX_DATA_GET(obj, sd);
evas_object_size_hint_align_set
(ELM_WIDGET_DATA(sd)->resize_obj, horizontal, vertical);
}
EAPI void
elm_box_align_get(const Evas_Object *obj, double *horizontal, double *vertical)
elm_box_align_get(const Evas_Object *obj,
double *horizontal,
double *vertical)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
evas_object_size_hint_align_get(wd->box, horizontal, vertical);
ELM_BOX_CHECK(obj);
ELM_BOX_DATA_GET(obj, sd);
evas_object_size_hint_align_get
(ELM_WIDGET_DATA(sd)->resize_obj, horizontal, vertical);
}
EAPI void
elm_box_recalculate(Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if ((!wd) || (wd->recalc)) return;
evas_object_smart_need_recalculate_set(wd->box, EINA_TRUE);
wd->recalc++;
evas_object_smart_calculate(wd->box);
wd->recalc--;
ELM_BOX_CHECK(obj);
ELM_BOX_DATA_GET(obj, sd);
if (sd->recalc) return;
evas_object_smart_need_recalculate_set
(ELM_WIDGET_DATA(sd)->resize_obj, EINA_TRUE);
sd->recalc++;
evas_object_smart_calculate(ELM_WIDGET_DATA(sd)->resize_obj);
sd->recalc--;
}