2009-12-01 23:22:35 -08:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include "elm_priv.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @defgroup Flip Flip
|
|
|
|
*
|
2010-04-12 01:12:02 -07:00
|
|
|
* This holds 2 content objects: one on the front and one on the back. It
|
|
|
|
* allows you to flip from front to back and vice-versa using various effects.
|
|
|
|
*
|
|
|
|
* Supported flip types:
|
|
|
|
* ELM_FLIP_ROTATE_Y_CENTER_AXIS
|
|
|
|
* ELM_FLIP_ROTATE_X_CENTER_AXIS
|
|
|
|
* ELM_FLIP_ROTATE_XZ_CENTER_AXIS
|
|
|
|
* ELM_FLIP_ROTATE_YZ_CENTER_AXIS
|
|
|
|
*
|
|
|
|
* Signals that you can add callbacks for are:
|
|
|
|
*
|
|
|
|
* "animate,done" - when a flip animation is finished
|
2009-12-01 23:22:35 -08:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct _Widget_Data Widget_Data;
|
|
|
|
|
|
|
|
struct _Widget_Data
|
|
|
|
{
|
2009-12-11 00:12:58 -08:00
|
|
|
Ecore_Animator *animator;
|
|
|
|
double start, len;
|
|
|
|
Elm_Flip_Mode mode;
|
2010-09-02 03:25:05 -07:00
|
|
|
Evas_Object *clip;
|
2009-12-01 23:22:35 -08:00
|
|
|
struct {
|
2010-03-08 20:00:08 -08:00
|
|
|
Evas_Object *content, *clip;
|
2009-12-01 23:22:35 -08:00
|
|
|
} front, back;
|
2009-12-11 00:12:58 -08:00
|
|
|
Eina_Bool state : 1;
|
2009-12-01 23:22:35 -08:00
|
|
|
};
|
|
|
|
|
2010-03-08 22:15:39 -08:00
|
|
|
static const char *widtype = NULL;
|
2009-12-01 23:22:35 -08:00
|
|
|
static void _del_hook(Evas_Object *obj);
|
|
|
|
static void _theme_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);
|
|
|
|
|
2010-01-26 00:17:26 -08:00
|
|
|
static void _configure(Evas_Object *obj);
|
|
|
|
|
2009-12-01 23:22:35 -08:00
|
|
|
static void
|
|
|
|
_del_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2009-12-11 00:12:58 -08:00
|
|
|
if (wd->animator) ecore_animator_del(wd->animator);
|
2009-12-01 23:22:35 -08:00
|
|
|
free(wd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_theme_hook(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2009-12-01 23:22:35 -08:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
|
2010-10-01 12:03:02 -07:00
|
|
|
static Eina_Bool
|
2010-10-06 13:24:19 -07:00
|
|
|
_elm_flip_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
|
2010-10-01 12:03:02 -07:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
|
|
|
|
if (!wd)
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
/* Try Focus cycle in subitem */
|
|
|
|
if (wd->state)
|
2010-10-06 13:24:13 -07:00
|
|
|
return elm_widget_focus_next_get(wd->front.content, dir, next);
|
2010-10-01 12:03:02 -07:00
|
|
|
else
|
2010-10-06 13:24:13 -07:00
|
|
|
return elm_widget_focus_next_get(wd->back.content, dir, next);
|
2010-10-01 12:03:02 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-12-01 23:22:35 -08:00
|
|
|
static void
|
|
|
|
_sizing_eval(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Coord minw = -1, minh = -1, minw2 = -1, minh2 = -1;
|
|
|
|
Evas_Coord maxw = -1, maxh = -1, maxw2 = -1, maxh2 = -1;
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2009-12-01 23:22:35 -08:00
|
|
|
if (wd->front.content)
|
|
|
|
evas_object_size_hint_min_get(wd->front.content, &minw, &minh);
|
|
|
|
if (wd->back.content)
|
|
|
|
evas_object_size_hint_min_get(wd->back.content, &minw2, &minh2);
|
|
|
|
if (wd->front.content)
|
|
|
|
evas_object_size_hint_max_get(wd->front.content, &maxw, &maxh);
|
|
|
|
if (wd->back.content)
|
|
|
|
evas_object_size_hint_max_get(wd->back.content, &maxw2, &maxh2);
|
|
|
|
|
|
|
|
if (minw2 > minw) minw = minw2;
|
|
|
|
if (minh2 > minh) minh = minh2;
|
|
|
|
if ((maxw2 >= 0) && (maxw2 < maxw)) maxw = maxw2;
|
|
|
|
if ((maxh2 >= 0) && (maxh2 < maxh)) maxh = maxh2;
|
|
|
|
|
|
|
|
evas_object_size_hint_min_set(obj, minw, minh);
|
|
|
|
evas_object_size_hint_max_set(obj, maxw, maxh);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
|
2009-12-01 23:22:35 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(data);
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2009-12-01 23:22:35 -08:00
|
|
|
_sizing_eval(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
|
2009-12-01 23:22:35 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Object *sub = event_info;
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2009-12-01 23:22:35 -08:00
|
|
|
if (sub == wd->front.content)
|
|
|
|
{
|
|
|
|
evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_changed_size_hints, obj);
|
|
|
|
wd->front.content = NULL;
|
2010-03-08 20:00:08 -08:00
|
|
|
evas_object_hide(wd->front.clip);
|
2009-12-01 23:22:35 -08:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
else if (sub == wd->back.content)
|
|
|
|
{
|
|
|
|
evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_changed_size_hints, obj);
|
|
|
|
wd->back.content = NULL;
|
2010-03-08 20:00:08 -08:00
|
|
|
evas_object_hide(wd->back.clip);
|
2009-12-01 23:22:35 -08:00
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-02 02:58:52 -07:00
|
|
|
static void
|
|
|
|
flip_show_hide(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (elm_flip_front_get(obj))
|
|
|
|
{
|
|
|
|
if (wd->front.content)
|
|
|
|
evas_object_show(wd->front.clip);
|
|
|
|
else
|
|
|
|
evas_object_hide(wd->front.clip);
|
|
|
|
if (wd->back.content)
|
|
|
|
evas_object_hide(wd->back.clip);
|
|
|
|
else
|
|
|
|
evas_object_hide(wd->back.clip);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (wd->front.content)
|
|
|
|
evas_object_hide(wd->front.clip);
|
|
|
|
else
|
|
|
|
evas_object_hide(wd->front.clip);
|
|
|
|
if (wd->back.content)
|
|
|
|
evas_object_show(wd->back.clip);
|
|
|
|
else
|
|
|
|
evas_object_hide(wd->back.clip);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-25 02:58:14 -07:00
|
|
|
static Eina_Bool
|
2009-12-11 00:12:58 -08:00
|
|
|
_flip(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
double t = ecore_loop_time_get() - wd->start;
|
|
|
|
Evas_Coord x, y, w, h;
|
|
|
|
double p, deg;
|
|
|
|
Evas_Map *mf, *mb;
|
2010-03-09 08:46:13 -08:00
|
|
|
Evas_Coord cx, cy, px, py, foc;
|
2009-12-11 00:12:58 -08:00
|
|
|
int lx, ly, lz, lr, lg, lb, lar, lag, lab;
|
2010-06-25 02:58:14 -07:00
|
|
|
if (!wd->animator) return ECORE_CALLBACK_CANCEL;
|
2009-12-11 00:12:58 -08:00
|
|
|
t = t / wd->len;
|
|
|
|
if (t > 1.0) t = 1.0;
|
|
|
|
|
2010-06-25 02:58:14 -07:00
|
|
|
if (!wd) return ECORE_CALLBACK_CANCEL;
|
2009-12-11 00:12:58 -08:00
|
|
|
|
|
|
|
mf = evas_map_new(4);
|
|
|
|
evas_map_smooth_set(mf, 0);
|
|
|
|
mb = evas_map_new(4);
|
|
|
|
evas_map_smooth_set(mb, 0);
|
|
|
|
|
|
|
|
if (wd->front.content)
|
2010-09-25 05:41:06 -07:00
|
|
|
{
|
|
|
|
evas_object_geometry_get(wd->front.content, &x, &y, &w, &h);
|
|
|
|
evas_map_util_points_populate_from_geometry(mf, x, y, w, h, 0);
|
|
|
|
}
|
2009-12-11 00:12:58 -08:00
|
|
|
if (wd->back.content)
|
2010-09-25 05:41:06 -07:00
|
|
|
{
|
|
|
|
evas_object_geometry_get(wd->back.content, &x, &y, &w, &h);
|
|
|
|
evas_map_util_points_populate_from_geometry(mb, x, y, w, h, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
evas_object_geometry_get(obj, &x, &y, &w, &h);
|
2009-12-11 00:12:58 -08:00
|
|
|
|
|
|
|
cx = x + (w / 2);
|
|
|
|
cy = y + (h / 2);
|
|
|
|
|
|
|
|
px = x + (w / 2);
|
|
|
|
py = y + (h / 2);
|
|
|
|
foc = 2048;
|
|
|
|
|
|
|
|
lx = cx;
|
|
|
|
ly = cy;
|
|
|
|
lz = -10000;
|
|
|
|
lr = 255;
|
|
|
|
lg = 255;
|
|
|
|
lb = 255;
|
|
|
|
lar = 0;
|
|
|
|
lag = 0;
|
|
|
|
lab = 0;
|
|
|
|
|
|
|
|
switch (wd->mode)
|
|
|
|
{
|
|
|
|
case ELM_FLIP_ROTATE_Y_CENTER_AXIS:
|
|
|
|
p = 1.0 - t;
|
|
|
|
p = 1.0 - (p * p);
|
|
|
|
if (wd->state) deg = 180.0 * p;
|
|
|
|
else deg = 180 + (180.0 * p);
|
|
|
|
evas_map_util_3d_rotate(mf, 0.0, deg, 0.0, cx, cy, 0);
|
|
|
|
evas_map_util_3d_rotate(mb, 0.0, deg + 180.0, 0.0, cx, cy, 0);
|
|
|
|
break;
|
|
|
|
case ELM_FLIP_ROTATE_X_CENTER_AXIS:
|
|
|
|
p = 1.0 - t;
|
|
|
|
p = 1.0 - (p * p);
|
|
|
|
if (wd->state) deg = 180.0 * p;
|
|
|
|
else deg = 180 + (180.0 * p);
|
|
|
|
evas_map_util_3d_rotate(mf, deg, 0.0, 0.0, cx, cy, 0);
|
|
|
|
evas_map_util_3d_rotate(mb, deg + 180.0, 0.0, 0.0, cx, cy, 0);
|
|
|
|
break;
|
|
|
|
case ELM_FLIP_ROTATE_XZ_CENTER_AXIS:
|
|
|
|
p = 1.0 - t;
|
|
|
|
p = 1.0 - (p * p);
|
|
|
|
if (wd->state) deg = 180.0 * p;
|
|
|
|
else deg = 180 + (180.0 * p);
|
|
|
|
evas_map_util_3d_rotate(mf, deg, 0.0, deg, cx, cy, 0);
|
|
|
|
evas_map_util_3d_rotate(mb, deg + 180.0, 0.0, deg + 180.0, cx, cy, 0);
|
|
|
|
break;
|
|
|
|
case ELM_FLIP_ROTATE_YZ_CENTER_AXIS:
|
|
|
|
p = 1.0 - t;
|
|
|
|
p = 1.0 - (p * p);
|
|
|
|
if (wd->state) deg = 180.0 * p;
|
|
|
|
else deg = 180 + (180.0 * p);
|
|
|
|
evas_map_util_3d_rotate(mf, 0.0, deg, deg, cx, cy, 0);
|
|
|
|
evas_map_util_3d_rotate(mb, 0.0, deg + 180.0, deg + 180.0, cx, cy, 0);
|
|
|
|
break;
|
2010-07-16 13:30:11 -07:00
|
|
|
case ELM_FLIP_CUBE_LEFT:
|
|
|
|
p = 1.0 - t;
|
|
|
|
p = 1.0 - (p * p);
|
|
|
|
deg = -90.0 * p;
|
|
|
|
if (wd->state)
|
|
|
|
{
|
|
|
|
evas_map_util_3d_rotate(mf, 0.0, deg, 0.0, cx, cy, w / 2);
|
|
|
|
evas_map_util_3d_rotate(mb, 0.0, deg + 90, 0.0, cx, cy, w / 2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evas_map_util_3d_rotate(mf, 0.0, deg + 90, 0.0, cx, cy, w / 2);
|
|
|
|
evas_map_util_3d_rotate(mb, 0.0, deg, 0.0, cx, cy, w / 2);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ELM_FLIP_CUBE_RIGHT:
|
|
|
|
p = 1.0 - t;
|
|
|
|
p = 1.0 - (p * p);
|
|
|
|
deg = 90.0 * p;
|
|
|
|
if (wd->state)
|
|
|
|
{
|
|
|
|
evas_map_util_3d_rotate(mf, 0.0, deg, 0.0, cx, cy, w / 2);
|
|
|
|
evas_map_util_3d_rotate(mb, 0.0, deg - 90, 0.0, cx, cy, w / 2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evas_map_util_3d_rotate(mf, 0.0, deg - 90, 0.0, cx, cy, w / 2);
|
|
|
|
evas_map_util_3d_rotate(mb, 0.0, deg, 0.0, cx, cy, w / 2);
|
|
|
|
}
|
|
|
|
break;
|
2010-09-02 02:58:52 -07:00
|
|
|
case ELM_FLIP_CUBE_UP:
|
|
|
|
p = 1.0 - t;
|
|
|
|
p = 1.0 - (p * p);
|
|
|
|
deg = -90.0 * p;
|
|
|
|
if (wd->state)
|
|
|
|
{
|
|
|
|
evas_map_util_3d_rotate(mf, deg, 0.0, 0.0, cx, cy, h / 2);
|
|
|
|
evas_map_util_3d_rotate(mb, deg + 90, 0.0, 0.0, cx, cy, h / 2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evas_map_util_3d_rotate(mf, deg + 90, 0.0, 0.0, cx, cy, h / 2);
|
|
|
|
evas_map_util_3d_rotate(mb, deg, 0.0, 0.0, cx, cy, h / 2);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ELM_FLIP_CUBE_DOWN:
|
|
|
|
p = 1.0 - t;
|
|
|
|
p = 1.0 - (p * p);
|
|
|
|
deg = 90.0 * p;
|
|
|
|
if (wd->state)
|
|
|
|
{
|
|
|
|
evas_map_util_3d_rotate(mf, deg, 0.0, 0.0, cx, cy, h / 2);
|
|
|
|
evas_map_util_3d_rotate(mb, deg - 90, 0.0, 0.0, cx, cy, h / 2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
evas_map_util_3d_rotate(mf, deg - 90, 0.0, 0.0, cx, cy, h / 2);
|
|
|
|
evas_map_util_3d_rotate(mb, deg, 0.0, 0.0, cx, cy, h / 2);
|
|
|
|
}
|
|
|
|
break;
|
2009-12-11 00:12:58 -08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (wd->front.content)
|
|
|
|
{
|
|
|
|
evas_map_util_3d_lighting(mf, lx, ly, lz, lr, lg, lb, lar, lag, lab);
|
|
|
|
evas_map_util_3d_perspective(mf, px, py, 0, foc);
|
|
|
|
evas_object_map_set(wd->front.content, mf);
|
|
|
|
evas_object_map_enable_set(wd->front.content, 1);
|
2010-03-08 20:00:08 -08:00
|
|
|
if (evas_map_util_clockwise_get(mf)) evas_object_show(wd->front.clip);
|
|
|
|
else evas_object_hide(wd->front.clip);
|
2009-12-11 00:12:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (wd->back.content)
|
|
|
|
{
|
|
|
|
evas_map_util_3d_lighting(mb, lx, ly, lz, lr, lg, lb, lar, lag, lab);
|
|
|
|
evas_map_util_3d_perspective(mb, px, py, 0, foc);
|
|
|
|
evas_object_map_set(wd->back.content, mb);
|
|
|
|
evas_object_map_enable_set(wd->back.content, 1);
|
2010-03-08 20:00:08 -08:00
|
|
|
if (evas_map_util_clockwise_get(mb)) evas_object_show(wd->back.clip);
|
|
|
|
else evas_object_hide(wd->back.clip);
|
2009-12-11 00:12:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
evas_map_free(mf);
|
|
|
|
evas_map_free(mb);
|
|
|
|
|
|
|
|
if (t >= 1.0)
|
|
|
|
{
|
|
|
|
evas_object_map_enable_set(wd->front.content, 0);
|
|
|
|
evas_object_map_enable_set(wd->back.content, 0);
|
2010-09-03 01:27:05 -07:00
|
|
|
// FIXME: hack around evas rendering bug (only fix makes evas bitch-slow
|
|
|
|
evas_object_resize(wd->front.content, 0, 0);
|
|
|
|
evas_object_resize(wd->back.content, 0, 0);
|
|
|
|
evas_smart_objects_calculate(evas_object_evas_get(obj));
|
|
|
|
// FIXME: end hack
|
2009-12-11 00:12:58 -08:00
|
|
|
wd->animator = NULL;
|
|
|
|
wd->state = !wd->state;
|
2010-01-26 00:17:26 -08:00
|
|
|
_configure(obj);
|
2009-12-11 00:12:58 -08:00
|
|
|
evas_object_smart_callback_call(obj, "animate,done", NULL);
|
2010-06-25 02:58:14 -07:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
2009-12-11 00:12:58 -08:00
|
|
|
}
|
2010-06-25 02:58:14 -07:00
|
|
|
return ECORE_CALLBACK_RENEW;
|
2009-12-11 00:12:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_configure(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
Evas_Coord x, y, w, h;
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2009-12-11 00:12:58 -08:00
|
|
|
evas_object_geometry_get(obj, &x, &y, &w, &h);
|
|
|
|
if (wd->front.content)
|
|
|
|
{
|
2010-01-26 00:17:26 -08:00
|
|
|
if (!wd->animator)
|
|
|
|
evas_object_move(wd->front.content, x, y);
|
2009-12-11 00:12:58 -08:00
|
|
|
evas_object_resize(wd->front.content, w, h);
|
|
|
|
}
|
|
|
|
if (wd->back.content)
|
|
|
|
{
|
2010-01-26 00:17:26 -08:00
|
|
|
if (!wd->animator)
|
|
|
|
evas_object_move(wd->back.content, x, y);
|
2009-12-11 00:12:58 -08:00
|
|
|
evas_object_resize(wd->back.content, w, h);
|
|
|
|
}
|
|
|
|
_flip(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_move(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
|
2009-12-11 00:12:58 -08:00
|
|
|
{
|
|
|
|
_configure(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-03-09 09:51:30 -08:00
|
|
|
_resize(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
|
2009-12-11 00:12:58 -08:00
|
|
|
{
|
|
|
|
_configure(obj);
|
|
|
|
}
|
|
|
|
|
2010-06-25 02:58:14 -07:00
|
|
|
static Eina_Bool
|
2009-12-11 00:12:58 -08:00
|
|
|
_animate(void *data)
|
|
|
|
{
|
|
|
|
return _flip(data);
|
|
|
|
}
|
|
|
|
|
2009-12-01 23:22:35 -08:00
|
|
|
/**
|
|
|
|
* Add a new flip to the parent
|
|
|
|
*
|
|
|
|
* @param parent The parent object
|
|
|
|
* @return The new object or NULL if it cannot be created
|
|
|
|
*
|
|
|
|
* @ingroup Flip
|
|
|
|
*/
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_flip_add(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
Evas_Object *obj;
|
|
|
|
Evas *e;
|
|
|
|
Widget_Data *wd;
|
|
|
|
|
2011-03-31 23:08:02 -07:00
|
|
|
ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
|
|
|
|
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_SET_WIDTYPE(widtype, "flip");
|
2009-12-01 23:22:35 -08:00
|
|
|
elm_widget_type_set(obj, "flip");
|
|
|
|
elm_widget_sub_object_add(parent, obj);
|
|
|
|
elm_widget_data_set(obj, wd);
|
|
|
|
elm_widget_del_hook_set(obj, _del_hook);
|
|
|
|
elm_widget_theme_hook_set(obj, _theme_hook);
|
2010-10-06 13:24:13 -07:00
|
|
|
elm_widget_focus_next_hook_set(obj, _elm_flip_focus_next_hook);
|
2010-09-29 05:22:30 -07:00
|
|
|
elm_widget_can_focus_set(obj, EINA_FALSE);
|
2009-12-01 23:22:35 -08:00
|
|
|
|
2010-09-02 03:25:05 -07:00
|
|
|
wd->clip = evas_object_rectangle_add(e);
|
2010-09-02 17:08:11 -07:00
|
|
|
evas_object_static_clip_set(wd->clip, 1);
|
2010-09-02 03:25:05 -07:00
|
|
|
evas_object_color_set(wd->clip, 255, 255, 255, 255);
|
|
|
|
evas_object_move(wd->clip, -49999, -49999);
|
|
|
|
evas_object_resize(wd->clip, 99999, 99999);
|
|
|
|
elm_widget_sub_object_add(obj, wd->clip);
|
|
|
|
evas_object_clip_set(wd->clip, evas_object_clip_get(obj));
|
|
|
|
evas_object_smart_member_add(wd->clip, obj);
|
|
|
|
|
2010-03-08 20:00:08 -08:00
|
|
|
wd->front.clip = evas_object_rectangle_add(e);
|
2010-09-02 17:08:11 -07:00
|
|
|
evas_object_static_clip_set(wd->front.clip, 1);
|
2010-09-02 03:25:05 -07:00
|
|
|
evas_object_data_set(wd->front.clip, "_elm_leaveme", obj);
|
2010-03-08 20:00:08 -08:00
|
|
|
evas_object_color_set(wd->front.clip, 255, 255, 255, 255);
|
|
|
|
evas_object_move(wd->front.clip, -49999, -49999);
|
|
|
|
evas_object_resize(wd->front.clip, 99999, 99999);
|
2010-09-02 02:58:52 -07:00
|
|
|
elm_widget_sub_object_add(obj, wd->front.clip);
|
2010-03-08 20:00:08 -08:00
|
|
|
evas_object_smart_member_add(wd->front.clip, obj);
|
2010-09-02 03:25:05 -07:00
|
|
|
evas_object_clip_set(wd->front.clip, wd->clip);
|
2010-03-08 20:00:08 -08:00
|
|
|
|
|
|
|
wd->back.clip = evas_object_rectangle_add(e);
|
2010-09-02 17:08:11 -07:00
|
|
|
evas_object_static_clip_set(wd->back.clip, 1);
|
2010-09-02 03:25:05 -07:00
|
|
|
evas_object_data_set(wd->back.clip, "_elm_leaveme", obj);
|
2010-03-08 20:00:08 -08:00
|
|
|
evas_object_color_set(wd->back.clip, 255, 255, 255, 255);
|
|
|
|
evas_object_move(wd->back.clip, -49999, -49999);
|
|
|
|
evas_object_resize(wd->back.clip, 99999, 99999);
|
|
|
|
elm_widget_sub_object_add(wd->back.clip, obj);
|
2010-09-02 02:58:52 -07:00
|
|
|
evas_object_smart_member_add(obj, wd->back.clip);
|
2010-09-02 03:25:05 -07:00
|
|
|
evas_object_clip_set(wd->back.clip, wd->clip);
|
2010-03-08 20:00:08 -08:00
|
|
|
|
2009-12-01 23:22:35 -08:00
|
|
|
evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
|
2009-12-11 00:12:58 -08:00
|
|
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _move, NULL);
|
|
|
|
evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, NULL);
|
|
|
|
|
|
|
|
wd->state = 1;
|
|
|
|
|
2009-12-01 23:22:35 -08:00
|
|
|
_sizing_eval(obj);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-10-14 11:54:42 -07:00
|
|
|
* Set the front content of the flip widget.
|
|
|
|
*
|
|
|
|
* Once the content object is set, a previously set one will be deleted.
|
|
|
|
* If you want to keep that old content object, use the
|
|
|
|
* elm_flip_content_front_unset() function.
|
2009-12-01 23:22:35 -08:00
|
|
|
*
|
|
|
|
* @param obj The flip object
|
2010-10-14 11:54:42 -07:00
|
|
|
* @param content The new front content object
|
2009-12-01 23:22:35 -08:00
|
|
|
*
|
|
|
|
* @ingroup Flip
|
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
elm_flip_content_front_set(Evas_Object *obj, Evas_Object *content)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-12-01 23:22:35 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2010-02-27 07:14:34 -08:00
|
|
|
if (wd->front.content == content) return;
|
2010-10-14 11:54:42 -07:00
|
|
|
if (wd->front.content) evas_object_del(wd->back.content);
|
2009-12-01 23:22:35 -08:00
|
|
|
wd->front.content = content;
|
|
|
|
if (content)
|
|
|
|
{
|
2010-05-24 01:26:18 -07:00
|
|
|
elm_widget_sub_object_add(obj, content);
|
2010-02-27 07:14:34 -08:00
|
|
|
evas_object_smart_member_add(content, obj);
|
2010-03-08 20:00:08 -08:00
|
|
|
evas_object_clip_set(content, wd->front.clip);
|
2009-12-01 23:22:35 -08:00
|
|
|
evas_object_event_callback_add(content,
|
|
|
|
EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_changed_size_hints, obj);
|
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
2010-09-25 05:41:06 -07:00
|
|
|
// force calc to contents are the right size before transition
|
|
|
|
evas_smart_objects_calculate(evas_object_evas_get(obj));
|
2010-09-02 02:58:52 -07:00
|
|
|
flip_show_hide(obj);
|
2009-12-11 00:12:58 -08:00
|
|
|
_configure(obj);
|
2009-12-01 23:22:35 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-10-14 11:54:42 -07:00
|
|
|
* Set the back content of the flip widget.
|
|
|
|
*
|
|
|
|
* Once the content object is set, a previously set one will be deleted.
|
|
|
|
* If you want to keep that old content object, use the
|
|
|
|
* elm_flip_content_back_unset() function.
|
2009-12-01 23:22:35 -08:00
|
|
|
*
|
|
|
|
* @param obj The flip object
|
2010-10-14 11:54:42 -07:00
|
|
|
* @param content The new back content object
|
2009-12-01 23:22:35 -08:00
|
|
|
*
|
|
|
|
* @ingroup Flip
|
|
|
|
*/
|
|
|
|
EAPI void
|
|
|
|
elm_flip_content_back_set(Evas_Object *obj, Evas_Object *content)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-12-01 23:22:35 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2010-02-27 07:14:34 -08:00
|
|
|
if (wd->back.content == content) return;
|
2010-10-14 11:54:42 -07:00
|
|
|
if (wd->back.content) evas_object_del(wd->back.content);
|
2009-12-01 23:22:35 -08:00
|
|
|
wd->back.content = content;
|
|
|
|
if (content)
|
|
|
|
{
|
2010-05-24 01:28:23 -07:00
|
|
|
elm_widget_sub_object_add(obj, content);
|
|
|
|
evas_object_smart_member_add(content, obj);
|
2010-03-08 20:00:08 -08:00
|
|
|
evas_object_clip_set(content, wd->back.clip);
|
2009-12-01 23:22:35 -08:00
|
|
|
evas_object_event_callback_add(content,
|
|
|
|
EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_changed_size_hints, obj);
|
|
|
|
_sizing_eval(obj);
|
|
|
|
}
|
2010-09-25 05:41:06 -07:00
|
|
|
// force calc to contents are the right size before transition
|
|
|
|
evas_smart_objects_calculate(evas_object_evas_get(obj));
|
2010-09-02 02:58:52 -07:00
|
|
|
flip_show_hide(obj);
|
2009-12-11 00:12:58 -08:00
|
|
|
_configure(obj);
|
2009-12-01 23:22:35 -08:00
|
|
|
}
|
|
|
|
|
2010-05-12 09:37:33 -07:00
|
|
|
/**
|
2010-10-14 11:54:42 -07:00
|
|
|
* Get the front content used for the flip
|
|
|
|
*
|
|
|
|
* Return the front content object which is set for this widget.
|
2010-05-12 09:37:33 -07:00
|
|
|
*
|
|
|
|
* @param obj The flip object
|
2010-10-14 11:54:42 -07:00
|
|
|
* @return The front content object that is being used
|
2010-05-12 09:37:33 -07:00
|
|
|
*
|
|
|
|
* @ingroup Flip
|
|
|
|
*/
|
2010-05-12 09:32:12 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_flip_content_front_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
return wd->front.content;
|
|
|
|
}
|
|
|
|
|
2010-10-14 11:54:42 -07:00
|
|
|
|
2010-05-12 09:37:33 -07:00
|
|
|
/**
|
2010-10-14 11:54:42 -07:00
|
|
|
* Get the back content used for the flip
|
|
|
|
*
|
|
|
|
* Return the back content object which is set for this widget.
|
2010-05-12 09:37:33 -07:00
|
|
|
*
|
|
|
|
* @param obj The flip object
|
2010-10-14 11:54:42 -07:00
|
|
|
* @return The back content object that is being used
|
2010-05-12 09:37:33 -07:00
|
|
|
*
|
|
|
|
* @ingroup Flip
|
|
|
|
*/
|
2010-05-12 09:32:12 -07:00
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_flip_content_back_get(const Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
return wd->back.content;
|
|
|
|
}
|
|
|
|
|
2010-10-14 11:54:42 -07:00
|
|
|
/**
|
|
|
|
* Unset the front content used for the flip
|
|
|
|
*
|
|
|
|
* Unparent and return the front content object which was set for this widget.
|
|
|
|
*
|
|
|
|
* @param obj The flip object
|
|
|
|
* @return The front content object that was being used
|
|
|
|
*
|
|
|
|
* @ingroup Flip
|
|
|
|
*/
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_flip_content_front_unset(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return NULL;
|
|
|
|
if (!wd->front.content) return NULL;
|
|
|
|
Evas_Object *content = wd->front.content;
|
2010-11-26 05:35:33 -08:00
|
|
|
evas_object_clip_unset(content);
|
2010-10-14 11:54:42 -07:00
|
|
|
elm_widget_sub_object_del(obj, content);
|
|
|
|
evas_object_smart_member_del(content);
|
|
|
|
wd->front.content = NULL;
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unset the back content used for the flip
|
|
|
|
*
|
|
|
|
* Unparent and return the back content object which was set for this widget.
|
|
|
|
*
|
|
|
|
* @param obj The flip object
|
|
|
|
* @return The back content object that was being used
|
|
|
|
*
|
|
|
|
* @ingroup Flip
|
|
|
|
*/
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_flip_content_back_unset(Evas_Object *obj)
|
|
|
|
{
|
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
|
|
|
if (!wd) return NULL;
|
|
|
|
if (!wd->back.content) return NULL;
|
|
|
|
Evas_Object *content = wd->back.content;
|
2010-11-26 05:35:33 -08:00
|
|
|
evas_object_clip_unset(content);
|
2010-10-14 11:54:42 -07:00
|
|
|
elm_widget_sub_object_del(obj, content);
|
|
|
|
evas_object_smart_member_del(content);
|
|
|
|
wd->back.content = NULL;
|
|
|
|
return content;
|
|
|
|
}
|
|
|
|
|
2009-12-01 23:22:35 -08:00
|
|
|
/**
|
2010-04-12 01:12:02 -07:00
|
|
|
* Get flip front visibility state
|
2009-12-01 23:22:35 -08:00
|
|
|
*
|
|
|
|
* @param obj The flip object
|
2010-04-12 01:12:02 -07:00
|
|
|
* @return If front front is showing or not currently
|
2009-12-01 23:22:35 -08:00
|
|
|
*
|
|
|
|
* @ingroup Flip
|
|
|
|
*/
|
|
|
|
EAPI Eina_Bool
|
2010-03-23 20:06:00 -07:00
|
|
|
elm_flip_front_get(const Evas_Object *obj)
|
2009-12-01 23:22:35 -08:00
|
|
|
{
|
2010-03-09 08:46:13 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
|
2009-12-01 23:22:35 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return EINA_FALSE;
|
2009-12-11 00:12:58 -08:00
|
|
|
return wd->state;
|
2009-12-01 23:22:35 -08:00
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Set flip perspective
|
|
|
|
*
|
|
|
|
* @param obj The flip object
|
|
|
|
* @param foc The coordinate to set the focus on
|
|
|
|
* @param x The X coordinate
|
|
|
|
* @param y The Y coordinate
|
|
|
|
*
|
|
|
|
* NOTE: This function currently does nothing.
|
|
|
|
*
|
|
|
|
* @ingroup Flip
|
|
|
|
*/
|
2009-12-01 23:22:35 -08:00
|
|
|
EAPI void
|
2010-03-09 09:51:30 -08:00
|
|
|
elm_flip_perspective_set(Evas_Object *obj, Evas_Coord foc __UNUSED__, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
|
2009-12-01 23:22:35 -08:00
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-12-01 23:22:35 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2009-12-01 23:22:35 -08:00
|
|
|
}
|
|
|
|
|
2010-04-12 01:12:02 -07:00
|
|
|
/**
|
|
|
|
* Runs the flip animation
|
|
|
|
*
|
|
|
|
* @param obj The flip object
|
|
|
|
* @param mode The mode type. Currently accepted modes are:
|
|
|
|
*
|
|
|
|
* ELM_FLIP_ROTATE_Y_CENTER_AXIS
|
|
|
|
* ELM_FLIP_ROTATE_X_CENTER_AXIS
|
|
|
|
* ELM_FLIP_ROTATE_XZ_CENTER_AXIS
|
|
|
|
* ELM_FLIP_ROTATE_YZ_CENTER_AXIS
|
2010-07-18 04:56:56 -07:00
|
|
|
* ELM_FLIP_CUBE_LEFT
|
|
|
|
* ELM_FLIP_CUBE_RIGHT
|
2010-09-02 02:58:52 -07:00
|
|
|
*
|
|
|
|
* FIXME: add - ELM_FLIP_CUBE_UP
|
|
|
|
* FIXMEL add - ELM_FLIP_CUBE_DOWN
|
2010-04-12 01:12:02 -07:00
|
|
|
*
|
|
|
|
* @ingroup Flip
|
|
|
|
*/
|
2009-12-01 23:22:35 -08:00
|
|
|
EAPI void
|
|
|
|
elm_flip_go(Evas_Object *obj, Elm_Flip_Mode mode)
|
|
|
|
{
|
2010-03-08 22:15:39 -08:00
|
|
|
ELM_CHECK_WIDTYPE(obj, widtype);
|
2009-12-01 23:22:35 -08:00
|
|
|
Widget_Data *wd = elm_widget_data_get(obj);
|
2010-03-09 08:46:13 -08:00
|
|
|
if (!wd) return;
|
2009-12-11 00:12:58 -08:00
|
|
|
if (!wd->animator) wd->animator = ecore_animator_add(_animate, obj);
|
2010-09-02 02:58:52 -07:00
|
|
|
flip_show_hide(obj);
|
2009-12-11 00:12:58 -08:00
|
|
|
wd->mode = mode;
|
|
|
|
wd->start = ecore_loop_time_get();
|
|
|
|
wd->len = 0.5;
|
2010-09-25 05:41:06 -07:00
|
|
|
// force calc to contents are the right size before transition
|
|
|
|
evas_smart_objects_calculate(evas_object_evas_get(obj));
|
2010-09-02 02:58:52 -07:00
|
|
|
_flip(obj);
|
2010-09-25 07:57:34 -07:00
|
|
|
// FIXME: hack around evas rendering bug (only fix makes evas bitch-slow
|
|
|
|
evas_object_map_enable_set(wd->front.content, 0);
|
|
|
|
evas_object_map_enable_set(wd->back.content, 0);
|
|
|
|
evas_object_resize(wd->front.content, 0, 0);
|
|
|
|
evas_object_resize(wd->back.content, 0, 0);
|
|
|
|
evas_smart_objects_calculate(evas_object_evas_get(obj));
|
|
|
|
_configure(obj);
|
|
|
|
// FIXME: end hack
|
2009-12-01 23:22:35 -08:00
|
|
|
}
|