1 #include <Elementary.h>
4 typedef struct _Widget_Data Widget_Data;
5 typedef struct _Slice Slice;
6 typedef struct _Vertex2 Vertex2;
7 typedef struct _Vertex3 Vertex3;
12 double u[4], v[4], x[4], y[4], z[4];
28 Ecore_Animator *animator;
32 Evas_Object *event[4];
34 Evas_Object *content, *clip;
37 Evas_Coord down_x, down_y, x, y, ox, oy, w, h;
38 Elm_Flip_Interaction intmode;
40 double dir_hitsize[4];
41 Eina_Bool dir_enabled[4];
42 int slices_w, slices_h;
43 Slice **slices, **slices2;
48 Eina_Bool started : 1;
49 Eina_Bool backflip : 1;
50 Eina_Bool pageflip : 1;
53 static const char *widtype = NULL;
54 static void _del_hook(Evas_Object *obj);
55 static void _theme_hook(Evas_Object *obj);
56 static void _sizing_eval(Evas_Object *obj);
57 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
58 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
60 static void _state_slices_clear(Widget_Data *st);
61 static void _configure(Evas_Object *obj);
63 static const char SIG_ANIMATE_BEGIN[] = "animate,begin";
64 static const char SIG_ANIMATE_DONE[] = "animate,done";
66 static const Evas_Smart_Cb_Description _signals[] = {
67 {SIG_ANIMATE_BEGIN, ""},
68 {SIG_ANIMATE_DONE, ""},
73 _del_hook(Evas_Object *obj)
75 Widget_Data *wd = elm_widget_data_get(obj);
77 if (wd->animator) ecore_animator_del(wd->animator);
78 _state_slices_clear(wd);
83 _theme_hook(Evas_Object *obj)
85 Widget_Data *wd = elm_widget_data_get(obj);
91 _elm_flip_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
93 Widget_Data *wd = elm_widget_data_get(obj);
98 /* Try Focus cycle in subitem */
100 return elm_widget_focus_next_get(wd->front.content, dir, next);
102 return elm_widget_focus_next_get(wd->back.content, dir, next);
107 _sizing_eval(Evas_Object *obj)
109 Widget_Data *wd = elm_widget_data_get(obj);
110 Evas_Coord minw = -1, minh = -1, minw2 = -1, minh2 = -1;
111 Evas_Coord maxw = -1, maxh = -1, maxw2 = -1, maxh2 = -1;
112 int fingx = 0, fingy = 0;
114 if (wd->front.content)
115 evas_object_size_hint_min_get(wd->front.content, &minw, &minh);
116 if (wd->back.content)
117 evas_object_size_hint_min_get(wd->back.content, &minw2, &minh2);
118 if (wd->front.content)
119 evas_object_size_hint_max_get(wd->front.content, &maxw, &maxh);
120 if (wd->back.content)
121 evas_object_size_hint_max_get(wd->back.content, &maxw2, &maxh2);
123 if (minw2 > minw) minw = minw2;
124 if (minh2 > minh) minh = minh2;
125 if ((maxw2 >= 0) && (maxw2 < maxw)) maxw = maxw2;
126 if ((maxh2 >= 0) && (maxh2 < maxh)) maxh = maxh2;
128 if (wd->dir_enabled[0]) fingy++;
129 if (wd->dir_enabled[1]) fingy++;
130 if (wd->dir_enabled[2]) fingx++;
131 if (wd->dir_enabled[3]) fingx++;
133 elm_coords_finger_size_adjust(fingx, &minw, fingy, &minh);
135 evas_object_size_hint_min_set(obj, minw, minh);
136 evas_object_size_hint_max_set(obj, maxw, maxh);
140 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
142 Widget_Data *wd = elm_widget_data_get(data);
148 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
150 Widget_Data *wd = elm_widget_data_get(obj);
151 Evas_Object *sub = event_info;
153 if (sub == wd->front.content)
155 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
156 _changed_size_hints, obj);
157 wd->front.content = NULL;
158 evas_object_hide(wd->front.clip);
161 else if (sub == wd->back.content)
163 evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
164 _changed_size_hints, obj);
165 wd->back.content = NULL;
166 evas_object_hide(wd->back.clip);
172 _slice_new(Widget_Data *st __UNUSED__, Evas_Object *obj)
176 sl = calloc(1, sizeof(Slice));
177 if (!sl) return NULL;
178 sl->obj = evas_object_image_add(evas_object_evas_get(obj));
179 elm_widget_sub_object_add(st->obj, sl->obj);
180 evas_object_clip_set(sl->obj, evas_object_clip_get(st->obj));
181 evas_object_smart_member_add(sl->obj, st->obj);
182 evas_object_image_smooth_scale_set(sl->obj, 0);
183 evas_object_pass_events_set(sl->obj, 1);
184 evas_object_image_source_set(sl->obj, obj);
189 _slice_free(Slice *sl)
191 evas_object_del(sl->obj);
196 _slice_apply(Widget_Data *st, Slice *sl,
197 Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__, Evas_Coord w, Evas_Coord h __UNUSED__,
198 Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
205 evas_map_smooth_set(m, 0);
206 for (i = 0; i < 4; i++)
208 evas_map_point_color_set(m, i, 255, 255, 255, 255);
211 int p[4] = { 0, 1, 2, 3 };
212 evas_map_point_coord_set(m, i, ox + sl->x[p[i]], oy + sl->y[p[i]], sl->z[p[i]]);
213 evas_map_point_image_uv_set(m, i, sl->u[p[i]] , sl->v[p[i]]);
215 else if (st->dir == 1)
217 int p[4] = { 1, 0, 3, 2 };
218 evas_map_point_coord_set(m, i, ox + (w - sl->x[p[i]]), oy + sl->y[p[i]], sl->z[p[i]]);
219 evas_map_point_image_uv_set(m, i, ow - sl->u[p[i]] , sl->v[p[i]]);
221 else if (st->dir == 2)
223 int p[4] = { 1, 0, 3, 2 };
224 evas_map_point_coord_set(m, i, ox + sl->y[p[i]], oy + sl->x[p[i]], sl->z[p[i]]);
225 evas_map_point_image_uv_set(m, i, sl->v[p[i]] , sl->u[p[i]]);
227 else if (st->dir == 3)
229 int p[4] = { 0, 1, 2, 3 };
230 evas_map_point_coord_set(m, i, ox + sl->y[p[i]], oy + (w - sl->x[p[i]]), sl->z[p[i]]);
231 evas_map_point_image_uv_set(m, i, sl->v[p[i]] , oh - sl->u[p[i]]);
234 evas_object_map_enable_set(sl->obj, EINA_TRUE);
235 evas_object_image_fill_set(sl->obj, 0, 0, ow, oh);
236 evas_object_map_set(sl->obj, m);
241 _slice_3d(Widget_Data *st __UNUSED__, Slice *sl, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
243 Evas_Map *m = (Evas_Map *)evas_object_map_get(sl->obj);
247 // vanishing point is center of page, and focal dist is 1024
248 evas_map_util_3d_perspective(m, x + (w / 2), y + (h / 2), 0, 1024);
249 for (i = 0; i < 4; i++)
252 evas_map_point_coord_get(m, i, &x, &y, &z);
253 evas_map_point_coord_set(m, i, x, y, 0);
255 if (evas_map_util_clockwise_get(m)) evas_object_show(sl->obj);
256 else evas_object_hide(sl->obj);
257 evas_object_map_set(sl->obj, m);
261 _slice_light(Widget_Data *st __UNUSED__, Slice *sl, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
263 Evas_Map *m = (Evas_Map *)evas_object_map_get(sl->obj);
267 evas_map_util_3d_lighting(m,
269 // (centered over page 10 * h toward camera)
270 x + (w / 2) , y + (h / 2) , -10000,
271 255, 255, 255, // light color
272 0 , 0 , 0); // ambient minimum
273 // multiply brightness by 1.2 to make lightish bits all white so we dont
274 // add shading where we could otherwise be pure white
275 for (i = 0; i < 4; i++)
279 evas_map_point_color_get(m, i, &r, &g, &b, &a);
280 r = (double)r * 1.2; if (r > 255) r = 255;
281 g = (double)g * 1.2; if (g > 255) g = 255;
282 b = (double)b * 1.2; if (b > 255) b = 255;
283 evas_map_point_color_set(m, i, r, g, b, a);
285 evas_object_map_set(sl->obj, m);
289 _slice_xyz(Widget_Data *st __UNUSED__, Slice *sl,
290 double x1, double y1, double z1,
291 double x2, double y2, double z2,
292 double x3, double y3, double z3,
293 double x4, double y4, double z4)
295 sl->x[0] = x1; sl->y[0] = y1; sl->z[0] = z1;
296 sl->x[1] = x2; sl->y[1] = y2; sl->z[1] = z2;
297 sl->x[2] = x3; sl->y[2] = y3; sl->z[2] = z3;
298 sl->x[3] = x4; sl->y[3] = y4; sl->z[3] = z4;
302 _slice_uv(Widget_Data *st __UNUSED__, Slice *sl,
303 double u1, double v1,
304 double u2, double v2,
305 double u3, double v3,
306 double u4, double v4)
308 sl->u[0] = u1; sl->v[0] = v1;
309 sl->u[1] = u2; sl->v[1] = v2;
310 sl->u[2] = u3; sl->v[2] = v3;
311 sl->u[3] = u4; sl->v[3] = v4;
315 _deform_point(Vertex2 *vi, Vertex3 *vo, double rho, double theta, double A)
321 // theta == cone angle (0 -> PI/2)
322 // A == distance of cone apex from origin
323 // rho == angle of cone from vertical axis (...-PI/2 to PI/2...)
327 d = sqrt((vi->x * vi->x) + pow(vi->y - A, 2));
329 b = asin(vi->x / d) / sin(theta);
332 v1.y = d + A - (r * (1 - cos(b)) * sin(theta));
333 v1.z = r * (1 - cos(b)) * cos(theta);
335 vo->x = (v1.x * cos(rho)) - (v1.z * sin(rho));
337 vo->z = (v1.x * sin(rho)) + (v1.z * cos(rho));
341 _interp_point(Vertex3 *vi1, Vertex3 *vi2, Vertex3 *vo, double v)
343 vo->x = (v * vi2->x) + ((1.0 - v) * vi1->x);
344 vo->y = (v * vi2->y) + ((1.0 - v) * vi1->y);
345 vo->z = (v * vi2->z) + ((1.0 - v) * vi1->z);
349 _state_slices_clear(Widget_Data *st)
356 for (j = 0; j < st->slices_h; j++)
358 for (i = 0; i < st->slices_w; i++)
360 if (st->slices[num]) _slice_free(st->slices[num]);
361 if (st->slices2[num]) _slice_free(st->slices2[num]);
375 _slice_obj_color_sum(Slice *s, int p, int *r, int *g, int *b, int *a)
378 int rr = 0, gg = 0, bb = 0, aa = 0;
381 m = (Evas_Map *)evas_object_map_get(s->obj);
383 evas_map_point_color_get(m, p, &rr, &gg, &bb, &aa);
384 *r += rr; *g += gg; *b += bb; *a += aa;
389 _slice_obj_color_set(Slice *s, int p, int r, int g, int b, int a)
394 m = (Evas_Map *)evas_object_map_get(s->obj);
396 evas_map_point_color_set(m, p, r, g, b, a);
397 evas_object_map_set(s->obj, m);
401 _slice_obj_vert_color_merge(Slice *s1, int p1, Slice *s2, int p2,
402 Slice *s3, int p3, Slice *s4, int p4)
404 int r = 0, g = 0, b = 0, a = 0, n = 0;
406 n += _slice_obj_color_sum(s1, p1, &r, &g, &b, &a);
407 n += _slice_obj_color_sum(s2, p2, &r, &g, &b, &a);
408 n += _slice_obj_color_sum(s3, p3, &r, &g, &b, &a);
409 n += _slice_obj_color_sum(s4, p4, &r, &g, &b, &a);
412 r /= n; g /= n; b /= n; a /= n;
414 _slice_obj_color_set(s1, p1, r, g, b, a);
415 _slice_obj_color_set(s2, p2, r, g, b, a);
416 _slice_obj_color_set(s3, p3, r, g, b, a);
417 _slice_obj_color_set(s4, p4, r, g, b, a);
421 _state_update(Widget_Data *st)
423 Evas_Coord x1, y1, x2, y2, mx, my;
424 Evas_Coord x, y, w, h, ox, oy, ow, oh;
425 int i, j, num, nn, jump, num2;
427 double b, minv = 0.0, minva, mgrad;
428 int gx, gy, gszw, gszh, gw, gh, col, row, nw, nh;
429 double rho, A, theta, perc, percm, n, rhol, Al, thetal;
432 Evas_Object *front, *back;
437 front = st->front.content;
438 back = st->front.content;
442 front = st->back.content;
443 back = st->back.content;
446 evas_object_geometry_get(st->obj, &x, &y, &w, &h);
447 ox = x; oy = y; ow = w; oh = h;
455 // no nothing. left drag is standard
457 else if (st->dir == 1)
462 else if (st->dir == 2)
466 tmp = x1; x1 = y1; y1 = tmp;
467 tmp = x2; x2 = y2; y2 = tmp;
468 tmp = w; w = h; h = tmp;
470 else if (st->dir == 3)
474 tmp = x1; x1 = y1; y1 = tmp;
475 tmp = x2; x2 = y2; y2 = tmp;
476 tmp = w; w = h; h = tmp;
481 if (x2 >= x1) x2 = x1 - 1;
486 else if (mx >= w) mx = w - 1;
488 else if (my >= h) my = h - 1;
490 mgrad = (double)(y1 - y2) / (double)(x1 - x2);
492 if (mx < 1) mx = 1; // quick hack to keep curl line visible
494 if (mgrad == 0.0) // special horizontal case
495 mgrad = 0.001; // quick dirty hack for now
500 b = my + (minv * mx);
502 if ((b >= -5) && (b <= (h + 5)))
504 if (minv > 0.0) // clamp to h
506 minv = (double)(h + 5 - my) / (double)(mx);
507 b = my + (minv * mx);
511 minv = (double)(-5 - my) / (double)(mx);
512 b = my + (minv * mx);
516 perc = (double)x2 / (double)x1;
517 percm = (double)mx / (double)x1;
518 if (perc < 0.0) perc = 0.0;
519 else if (perc > 1.0) perc = 1.0;
520 if (percm < 0.0) percm = 0.0;
521 else if (percm > 1.0) percm = 1.0;
523 minva = atan(minv) / (M_PI / 2);
524 if (minva < 0.0) minva = -minva;
529 if (A < -(h * 20)) A = -h * 20;
533 // rho = is how much the page is turned
535 n = 1.0 - cos(n * M_PI / 2.0);
541 // theta == curliness (how much page culrs in on itself
542 n = sin((1.0 - perc) * M_PI);
546 n = sin((1.0 - perc) * M_PI);
558 if (gszw < 4) gszw = 4;
559 if (gszh < 4) gszh = 4;
561 nw = (w + gszw - 1) / gszw;
562 nh = (h + gszh - 1) / gszh;
563 if ((st->slices_w != nw) || (st->slices_h != nh)) _state_slices_clear(st);
568 st->slices = calloc(st->slices_w * st->slices_h, sizeof(Slice *));
569 if (!st->slices) return 0;
570 st->slices2 = calloc(st->slices_w * st->slices_h, sizeof(Slice *));
579 num = (st->slices_w + 1) * (st->slices_h + 1);
581 tvi = alloca(sizeof(Vertex2) * num);
582 tvo = alloca(sizeof(Vertex3) * num);
583 tvol = alloca(sizeof(Vertex3) * (st->slices_w + 1));
585 for (col = 0, gx = 0; gx <= (w + gszw - 1); gx += gszw, col++)
590 vil.y = h - ((gx * h) / (w + gszw - 1));
591 _deform_point(&vil, &(tvol[col]), rhol, thetal, Al);
594 n = minva * sin(perc * M_PI);
598 for (col = 0, gx = 0; gx <= (w + gszw - 1); gx += gszw, col++)
600 for (gy = 0; gy <= (h + gszh - 1); gy += gszh)
605 if (gx > w) vi.x = w;
607 if (gy > h) vi.y = h;
609 _deform_point(&vi, &vo, rho, theta, A);
611 if (gy > h) tvo1.y = h;
613 _interp_point(&vo, &tvo1, &(tvo[num]), n);
618 jump = st->slices_h + 1;
619 for (col = 0, gx = 0; gx < w; gx += gszw, col++)
621 num = st->slices_h * col;
625 if ((gx + gw) > w) gw = w - gx;
627 for (row = 0, gy = 0; gy < h; gy += gszh, row++)
631 if (b > 0) nn = num + st->slices_h - row - 1;
635 if ((gy + gh) > h) gh = h - gy;
637 vo[0] = tvo[num2 + row];
638 vo[1] = tvo[num2 + row + jump];
639 vo[2] = tvo[num2 + row + jump + 1];
640 vo[3] = tvo[num2 + row + 1];
641 #define SWP(a, b) do {typeof(a) vt; vt = (a); (a) = (b); (b) = vt;} while (0)
646 vo[0].y = h - vo[0].y;
647 vo[1].y = h - vo[1].y;
648 vo[2].y = h - vo[2].y;
649 vo[3].y = h - vo[3].y;
656 sl = _slice_new(st, front);
660 vo[0].x, vo[0].y, vo[0].z,
661 vo[1].x, vo[1].y, vo[1].z,
662 vo[2].x, vo[2].y, vo[2].z,
663 vo[3].x, vo[3].y, vo[3].z);
667 gx + gw, gy + gh, gx, gy + gh);
670 gx, h - (gy + gh), gx + gw, h - (gy + gh),
671 gx + gw, h - gy, gx, h - gy);
674 sl = st->slices2[nn];
677 sl = _slice_new(st, back);
678 st->slices2[nn] = sl;
682 vo[1].x, vo[1].y, vo[1].z,
683 vo[0].x, vo[0].y, vo[0].z,
684 vo[3].x, vo[3].y, vo[3].z,
685 vo[2].x, vo[2].y, vo[2].z);
691 gx, gy + gh, gx + gw, gy + gh);
694 gx + gw, h - (gy + gh), gx, h - (gy + gh),
695 gx, h - gy, gx + gw, h - gy);
701 w - (gx + gw), gy, w - (gx), gy,
702 w - (gx), gy + gh, w - (gx + gw), gy + gh);
705 w - (gx + gw), h - (gy + gh), w - (gx), h - (gy + gh),
706 w - (gx), h - gy, w - (gx + gw), h - gy);
712 for (j = 0; j < st->slices_h; j++)
714 for (i = 0; i < st->slices_w; i++)
716 _slice_apply(st, st->slices[num], x, y, w, h, ox, oy, ow, oh);
717 _slice_apply(st, st->slices2[num], x, y, w, h, ox, oy, ow, oh);
718 _slice_light(st, st->slices[num], ox, oy, ow, oh);
719 _slice_light(st, st->slices2[num], ox, oy, ow, oh);
724 for (i = 0; i <= st->slices_w; i++)
726 num = i * st->slices_h;
727 for (j = 0; j <= st->slices_h; j++)
731 s[0] = s[1] = s[2] = s[3] = NULL;
732 if ((i > 0) && (j > 0))
733 s[0] = st->slices[num - 1 - st->slices_h];
734 if ((i < st->slices_w) && (j > 0))
735 s[1] = st->slices[num - 1];
736 if ((i > 0) && (j < st->slices_h))
737 s[2] = st->slices[num - st->slices_h];
738 if ((i < st->slices_w) && (j < st->slices_h))
739 s[3] = st->slices[num];
741 _slice_obj_vert_color_merge(s[0], 2, s[1], 3,
743 else if (st->dir == 1)
744 _slice_obj_vert_color_merge(s[0], 3, s[1], 2,
746 else if (st->dir == 2)
747 _slice_obj_vert_color_merge(s[0], 3, s[1], 2,
749 else if (st->dir == 3)
750 _slice_obj_vert_color_merge(s[0], 2, s[1], 3,
752 s[0] = s[1] = s[2] = s[3] = NULL;
753 if ((i > 0) && (j > 0))
754 s[0] = st->slices2[num - 1 - st->slices_h];
755 if ((i < st->slices_w) && (j > 0))
756 s[1] = st->slices2[num - 1];
757 if ((i > 0) && (j < st->slices_h))
758 s[2] = st->slices2[num - st->slices_h];
759 if ((i < st->slices_w) && (j < st->slices_h))
760 s[3] = st->slices2[num];
762 _slice_obj_vert_color_merge(s[0], 3, s[1], 2,
764 else if (st->dir == 1)
765 _slice_obj_vert_color_merge(s[0], 2, s[1], 3,
767 else if (st->dir == 2)
768 _slice_obj_vert_color_merge(s[0], 2, s[1], 3,
770 else if (st->dir == 3)
771 _slice_obj_vert_color_merge(s[0], 3, s[1], 2,
778 for (i = 0; i < st->slices_w; i++)
780 for (j = 0; j < st->slices_h; j++)
782 _slice_3d(st, st->slices[num], ox, oy, ow, oh);
783 _slice_3d(st, st->slices2[num], ox, oy, ow, oh);
792 _state_end(Widget_Data *st)
794 _state_slices_clear(st);
799 flip_show_hide(Evas_Object *obj)
801 Widget_Data *wd = elm_widget_data_get(obj);
802 if (elm_flip_front_get(obj))
806 if (wd->front.content)
808 evas_object_move(wd->front.content, 4999, 4999);
809 evas_object_show(wd->front.clip);
812 evas_object_hide(wd->front.clip);
813 if (wd->back.content)
814 evas_object_show(wd->back.clip);
816 evas_object_hide(wd->back.clip);
820 if (wd->front.content)
821 evas_object_show(wd->front.clip);
823 evas_object_hide(wd->front.clip);
824 if (wd->back.content)
825 evas_object_hide(wd->back.clip);
827 evas_object_hide(wd->back.clip);
834 if (wd->front.content)
835 evas_object_show(wd->front.clip);
837 evas_object_hide(wd->front.clip);
838 if (wd->back.content)
840 evas_object_move(wd->back.content, 4999, 4999);
841 evas_object_show(wd->back.clip);
844 evas_object_hide(wd->back.clip);
848 if (wd->front.content)
849 evas_object_hide(wd->front.clip);
851 evas_object_hide(wd->front.clip);
852 if (wd->back.content)
853 evas_object_show(wd->back.clip);
855 evas_object_hide(wd->back.clip);
861 _flip_do(Evas_Object *obj, double t, Elm_Flip_Mode mode, int lin, int rev)
863 Evas_Coord x, y, w, h;
866 Evas_Coord cx, cy, px, py, foc;
867 int lx, ly, lz, lr, lg, lb, lar, lag, lab;
868 Widget_Data *wd = elm_widget_data_get(obj);
872 mf = evas_map_new(4);
873 evas_map_smooth_set(mf, 0);
874 mb = evas_map_new(4);
875 evas_map_smooth_set(mb, 0);
877 if (wd->front.content)
879 const char *type = evas_object_type_get(wd->front.content);
881 // FIXME: only handles filled obj
882 if ((type) && (!strcmp(type, "image")))
885 evas_object_image_size_get(wd->front.content, &iw, &ih);
886 evas_object_geometry_get(wd->front.content, &x, &y, &w, &h);
887 evas_map_util_points_populate_from_geometry(mf, x, y, w, h, 0);
888 evas_map_point_image_uv_set(mf, 0, 0, 0);
889 evas_map_point_image_uv_set(mf, 1, iw, 0);
890 evas_map_point_image_uv_set(mf, 2, iw, ih);
891 evas_map_point_image_uv_set(mf, 3, 0, ih);
895 evas_object_geometry_get(wd->front.content, &x, &y, &w, &h);
896 evas_map_util_points_populate_from_geometry(mf, x, y, w, h, 0);
899 if (wd->back.content)
901 const char *type = evas_object_type_get(wd->back.content);
903 if ((type) && (!strcmp(type, "image")))
906 evas_object_image_size_get(wd->back.content, &iw, &ih);
907 evas_object_geometry_get(wd->back.content, &x, &y, &w, &h);
908 evas_map_util_points_populate_from_geometry(mb, x, y, w, h, 0);
909 evas_map_point_image_uv_set(mb, 0, 0, 0);
910 evas_map_point_image_uv_set(mb, 1, iw, 0);
911 evas_map_point_image_uv_set(mb, 2, iw, ih);
912 evas_map_point_image_uv_set(mb, 3, 0, ih);
916 evas_object_geometry_get(wd->back.content, &x, &y, &w, &h);
917 evas_map_util_points_populate_from_geometry(mb, x, y, w, h, 0);
921 evas_object_geometry_get(obj, &x, &y, &w, &h);
942 case ELM_FLIP_ROTATE_Y_CENTER_AXIS:
945 if (!lin) pp = (p * p);
947 if (wd->state) deg = 180.0 * p;
948 else deg = 180 + (180.0 * p);
950 evas_map_util_3d_rotate(mf, 0.0, deg, 0.0, cx, cy, 0);
951 evas_map_util_3d_rotate(mb, 0.0, 180 + deg, 0.0, cx, cy, 0);
953 case ELM_FLIP_ROTATE_X_CENTER_AXIS:
956 if (!lin) pp = (p * p);
958 if (wd->state) deg = 180.0 * p;
959 else deg = 180 + (180.0 * p);
961 evas_map_util_3d_rotate(mf, deg, 0.0, 0.0, cx, cy, 0);
962 evas_map_util_3d_rotate(mb, 180.0 + deg, 0.0, 0.0, cx, cy, 0);
964 case ELM_FLIP_ROTATE_XZ_CENTER_AXIS:
967 if (!lin) pp = (p * p);
969 if (wd->state) deg = 180.0 * p;
970 else deg = 180 + (180.0 * p);
972 evas_map_util_3d_rotate(mf, deg, 0.0, deg, cx, cy, 0);
973 evas_map_util_3d_rotate(mb, 180 + deg, 0.0, 180 + deg, cx, cy, 0);
975 case ELM_FLIP_ROTATE_YZ_CENTER_AXIS:
978 if (!lin) pp = (p * p);
980 if (wd->state) deg = 180.0 * p;
981 else deg = 180 + (180.0 * p);
983 evas_map_util_3d_rotate(mf, 0.0, deg, deg, cx, cy, 0);
984 evas_map_util_3d_rotate(mb, 0.0, 180.0 + deg, 180.0 + deg, cx, cy, 0);
986 case ELM_FLIP_CUBE_LEFT:
989 if (!lin) pp = (p * p);
994 evas_map_util_3d_rotate(mf, 0.0, deg, 0.0, cx, cy, w / 2);
995 evas_map_util_3d_rotate(mb, 0.0, deg + 90, 0.0, cx, cy, w / 2);
999 evas_map_util_3d_rotate(mf, 0.0, deg + 90, 0.0, cx, cy, w / 2);
1000 evas_map_util_3d_rotate(mb, 0.0, deg, 0.0, cx, cy, w / 2);
1003 case ELM_FLIP_CUBE_RIGHT:
1006 if (!lin) pp = (p * p);
1011 evas_map_util_3d_rotate(mf, 0.0, deg, 0.0, cx, cy, w / 2);
1012 evas_map_util_3d_rotate(mb, 0.0, deg - 90, 0.0, cx, cy, w / 2);
1016 evas_map_util_3d_rotate(mf, 0.0, deg - 90, 0.0, cx, cy, w / 2);
1017 evas_map_util_3d_rotate(mb, 0.0, deg, 0.0, cx, cy, w / 2);
1020 case ELM_FLIP_CUBE_UP:
1023 if (!lin) pp = (p * p);
1028 evas_map_util_3d_rotate(mf, deg, 0.0, 0.0, cx, cy, h / 2);
1029 evas_map_util_3d_rotate(mb, deg + 90, 0.0, 0.0, cx, cy, h / 2);
1033 evas_map_util_3d_rotate(mf, deg + 90, 0.0, 0.0, cx, cy, h / 2);
1034 evas_map_util_3d_rotate(mb, deg, 0.0, 0.0, cx, cy, h / 2);
1037 case ELM_FLIP_CUBE_DOWN:
1040 if (!lin) pp = (p * p);
1045 evas_map_util_3d_rotate(mf, deg, 0.0, 0.0, cx, cy, h / 2);
1046 evas_map_util_3d_rotate(mb, deg - 90, 0.0, 0.0, cx, cy, h / 2);
1050 evas_map_util_3d_rotate(mf, deg - 90, 0.0, 0.0, cx, cy, h / 2);
1051 evas_map_util_3d_rotate(mb, deg, 0.0, 0.0, cx, cy, h / 2);
1054 case ELM_FLIP_PAGE_LEFT:
1056 case ELM_FLIP_PAGE_RIGHT:
1058 case ELM_FLIP_PAGE_UP:
1060 case ELM_FLIP_PAGE_DOWN:
1067 if (wd->front.content)
1069 evas_map_util_3d_lighting(mf, lx, ly, lz, lr, lg, lb, lar, lag, lab);
1070 evas_map_util_3d_perspective(mf, px, py, 0, foc);
1071 evas_object_map_set(wd->front.content, mf);
1072 evas_object_map_enable_set(wd->front.content, 1);
1073 if (evas_map_util_clockwise_get(mf)) evas_object_show(wd->front.clip);
1074 else evas_object_hide(wd->front.clip);
1077 if (wd->back.content)
1079 evas_map_util_3d_lighting(mb, lx, ly, lz, lr, lg, lb, lar, lag, lab);
1080 evas_map_util_3d_perspective(mb, px, py, 0, foc);
1081 evas_object_map_set(wd->back.content, mb);
1082 evas_object_map_enable_set(wd->back.content, 1);
1083 if (evas_map_util_clockwise_get(mb)) evas_object_show(wd->back.clip);
1084 else evas_object_hide(wd->back.clip);
1092 _showhide(Evas_Object *obj)
1094 Widget_Data *wd = elm_widget_data_get(obj);
1095 Evas_Coord x, y, w, h;
1098 evas_object_geometry_get(obj, &x, &y, &w, &h);
1099 if (wd->front.content)
1101 if ((wd->pageflip) && (wd->state))
1103 evas_object_move(wd->front.content, 4999, 4999);
1108 evas_object_move(wd->front.content, x, y);
1110 evas_object_resize(wd->front.content, w, h);
1112 if (wd->back.content)
1114 if ((wd->pageflip) && (!wd->state))
1116 evas_object_move(wd->back.content, 4999, 4999);
1121 evas_object_move(wd->back.content, x, y);
1123 evas_object_resize(wd->back.content, w, h);
1129 _flip(Evas_Object *obj)
1131 Widget_Data *wd = elm_widget_data_get(obj);
1132 double t = ecore_loop_time_get() - wd->start;
1135 if (!wd) return ECORE_CALLBACK_CANCEL;
1136 if (!wd->animator) return ECORE_CALLBACK_CANCEL;
1139 if (t > 1.0) t = 1.0;
1141 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
1142 if (wd->mode == ELM_FLIP_PAGE_LEFT)
1145 wd->started = EINA_TRUE;
1146 wd->pageflip = EINA_TRUE;
1149 wd->x = (1.0 - t) * wd->down_x;
1151 flip_show_hide(obj);
1154 else if (wd->mode == ELM_FLIP_PAGE_RIGHT)
1157 wd->started = EINA_TRUE;
1158 wd->pageflip = EINA_TRUE;
1163 flip_show_hide(obj);
1166 else if (wd->mode == ELM_FLIP_PAGE_UP)
1169 wd->started = EINA_TRUE;
1170 wd->pageflip = EINA_TRUE;
1174 wd->y = (1.0 - t) * wd->down_y;
1175 flip_show_hide(obj);
1178 else if (wd->mode == ELM_FLIP_PAGE_DOWN)
1181 wd->started = EINA_TRUE;
1182 wd->pageflip = EINA_TRUE;
1187 flip_show_hide(obj);
1191 _flip_do(obj, t, wd->mode, 0, 0);
1195 wd->pageflip = EINA_FALSE;
1197 evas_object_map_enable_set(wd->front.content, 0);
1198 evas_object_map_enable_set(wd->back.content, 0);
1199 // FIXME: hack around evas rendering bug (only fix makes evas bitch-slow
1200 evas_object_resize(wd->front.content, 0, 0);
1201 evas_object_resize(wd->back.content, 0, 0);
1202 evas_smart_objects_calculate(evas_object_evas_get(obj));
1204 wd->animator = NULL;
1205 wd->state = !wd->state;
1207 flip_show_hide(obj);
1208 evas_object_smart_callback_call(obj, SIG_ANIMATE_DONE, NULL);
1209 return ECORE_CALLBACK_CANCEL;
1211 return ECORE_CALLBACK_RENEW;
1215 _configure(Evas_Object *obj)
1217 Widget_Data *wd = elm_widget_data_get(obj);
1218 Evas_Coord x, y, w, h;
1223 evas_object_geometry_get(obj, &x, &y, &w, &h);
1224 // FIXME: manual flip wont get fixed
1225 if (wd->animator) _flip(obj);
1229 fsize = (double)w * wd->dir_hitsize[0];
1230 elm_coords_finger_size_adjust(0, NULL, 1, &fsize);
1231 evas_object_move(wd->event[0], x, y);
1232 evas_object_resize(wd->event[0], w, fsize);
1236 fsize = (double)w * wd->dir_hitsize[1];
1237 elm_coords_finger_size_adjust(0, NULL, 1, &fsize);
1238 evas_object_move(wd->event[1], x, y + h - fsize);
1239 evas_object_resize(wd->event[1], w, fsize);
1243 fsize = (double)h * wd->dir_hitsize[2];
1244 elm_coords_finger_size_adjust(1, &fsize, 0, NULL);
1245 evas_object_move(wd->event[2], x, y);
1246 evas_object_resize(wd->event[2], fsize, h);
1250 fsize = (double)h * wd->dir_hitsize[3];
1251 elm_coords_finger_size_adjust(1, &fsize, 0, NULL);
1252 evas_object_move(wd->event[3], x + w - fsize, y);
1253 evas_object_resize(wd->event[3], fsize, h);
1258 _move(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1264 _resize(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1270 _animate(void *data)
1276 _pos_get(Widget_Data *wd, int *rev, Elm_Flip_Mode *m)
1278 Evas_Coord x, y, w, h;
1281 evas_object_geometry_get(wd->obj, &x, &y, &w, &h);
1282 switch (wd->intmode)
1284 case ELM_FLIP_INTERACTION_ROTATE:
1285 case ELM_FLIP_INTERACTION_CUBE:
1290 t = 1.0 - ((double)wd->x / (double)wd->down_x);
1293 else if (wd->dir == 1)
1296 t = 1.0 - ((double)(w - wd->x) / (double)(w - wd->down_x));
1298 else if (wd->dir == 2)
1301 t = 1.0 - ((double)wd->y / (double)wd->down_y);
1303 else if (wd->dir == 3)
1306 t = 1.0 - ((double)(h - wd->y) / (double)(h - wd->down_y));
1310 if (t < 0.0) t = 0.0;
1311 else if (t > 1.0) t = 1.0;
1313 if ((wd->dir == 0) || (wd->dir == 1))
1315 if (wd->intmode == ELM_FLIP_INTERACTION_ROTATE)
1316 *m = ELM_FLIP_ROTATE_Y_CENTER_AXIS;
1317 else if (wd->intmode == ELM_FLIP_INTERACTION_CUBE)
1320 *m = ELM_FLIP_CUBE_LEFT;
1322 *m = ELM_FLIP_CUBE_RIGHT;
1327 if (wd->intmode == ELM_FLIP_INTERACTION_ROTATE)
1328 *m = ELM_FLIP_ROTATE_X_CENTER_AXIS;
1329 else if (wd->intmode == ELM_FLIP_INTERACTION_CUBE)
1332 *m = ELM_FLIP_CUBE_UP;
1334 *m = ELM_FLIP_CUBE_DOWN;
1345 _event_anim(void *data, double pos)
1347 Widget_Data *wd = data;
1350 p = ecore_animator_pos_map(pos, ECORE_POS_MAP_ACCELERATE, 0.0, 0.0);
1354 wd->x = wd->ox * (1.0 - p);
1355 else if (wd->dir == 1)
1356 wd->x = wd->ox + ((wd->w - wd->ox) * p);
1357 else if (wd->dir == 2)
1358 wd->y = wd->oy * (1.0 - p);
1359 else if (wd->dir == 3)
1360 wd->y = wd->oy + ((wd->h - wd->oy) * p);
1365 wd->x = wd->ox + ((wd->w - wd->ox) * p);
1366 else if (wd->dir == 1)
1367 wd->x = wd->ox * (1.0 - p);
1368 else if (wd->dir == 2)
1369 wd->y = wd->oy + ((wd->h - wd->oy) * p);
1370 else if (wd->dir == 3)
1371 wd->y = wd->oy * (1.0 - p);
1373 switch (wd->intmode)
1375 case ELM_FLIP_INTERACTION_NONE:
1377 case ELM_FLIP_INTERACTION_ROTATE:
1378 case ELM_FLIP_INTERACTION_CUBE:
1380 Elm_Flip_Mode m = ELM_FLIP_ROTATE_X_CENTER_AXIS;
1382 p = _pos_get(wd, &rev, &m);
1383 _flip_do(wd->obj, p, m, 1, rev);
1386 case ELM_FLIP_INTERACTION_PAGE:
1387 wd->pageflip = EINA_TRUE;
1394 if (pos < 1.0) return ECORE_CALLBACK_RENEW;
1396 wd->pageflip = EINA_FALSE;
1398 evas_object_map_enable_set(wd->front.content, 0);
1399 evas_object_map_enable_set(wd->back.content, 0);
1400 // FIXME: hack around evas rendering bug (only fix makes evas bitch-slow
1401 evas_object_resize(wd->front.content, 0, 0);
1402 evas_object_resize(wd->back.content, 0, 0);
1403 evas_smart_objects_calculate(evas_object_evas_get(wd->obj));
1405 wd->animator = NULL;
1406 if (wd->finish) wd->state = !wd->state;
1407 flip_show_hide(wd->obj);
1408 _configure(wd->obj);
1409 wd->animator = NULL;
1410 evas_object_smart_callback_call(wd->obj, SIG_ANIMATE_DONE, NULL);
1412 return ECORE_CALLBACK_CANCEL;
1416 _update_job(void *data)
1418 Widget_Data *wd = data;
1420 Elm_Flip_Mode m = ELM_FLIP_ROTATE_X_CENTER_AXIS;
1424 switch (wd->intmode)
1426 case ELM_FLIP_INTERACTION_ROTATE:
1427 case ELM_FLIP_INTERACTION_CUBE:
1428 p = _pos_get(wd, &rev, &m);
1429 _flip_do(wd->obj, p, m, 1, rev);
1431 case ELM_FLIP_INTERACTION_PAGE:
1432 wd->pageflip = EINA_TRUE;
1442 _down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1444 Evas_Object *fl = data;
1445 Widget_Data *wd = elm_widget_data_get(fl);
1446 Evas_Event_Mouse_Down *ev = event_info;
1447 Evas_Coord x, y, w, h;
1450 if (ev->button != 1) return;
1451 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
1454 ecore_animator_del(wd->animator);
1455 wd->animator = NULL;
1457 wd->down = EINA_TRUE;
1458 wd->started = EINA_FALSE;
1459 evas_object_geometry_get(data, &x, &y, &w, &h);
1460 wd->x = ev->canvas.x - x;
1461 wd->y = ev->canvas.y - y;
1469 _up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1471 Evas_Object *fl = data;
1472 Widget_Data *wd = elm_widget_data_get(fl);
1473 Evas_Event_Mouse_Up *ev = event_info;
1474 Evas_Coord x, y, w, h;
1478 if (ev->button != 1) return;
1479 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
1481 evas_object_geometry_get(data, &x, &y, &w, &h);
1482 wd->x = ev->canvas.x - x;
1483 wd->y = ev->canvas.y - y;
1490 ecore_job_del(wd->job);
1493 wd->finish = EINA_FALSE;
1496 tm = (double)wd->x / (double)wd->w;
1497 if (wd->x < (wd->w / 2)) wd->finish = EINA_TRUE;
1499 else if (wd->dir == 1)
1501 if (wd->x > (wd->w / 2)) wd->finish = EINA_TRUE;
1502 tm = 1.0 - ((double)wd->x / (double)wd->w);
1504 else if (wd->dir == 2)
1506 if (wd->y < (wd->h / 2)) wd->finish = EINA_TRUE;
1507 tm = (double)wd->y / (double)wd->h;
1509 else if (wd->dir == 3)
1511 if (wd->y > (wd->h / 2)) wd->finish = EINA_TRUE;
1512 tm = 1.0 - ((double)wd->y / (double)wd->h);
1514 if (tm < 0.01) tm = 0.01;
1515 else if (tm > 0.99) tm = 0.99;
1516 if (!wd->finish) tm = 1.0 - tm;
1517 tm *= 1.0; // FIXME: config for anim time
1518 if (wd->animator) ecore_animator_del(wd->animator);
1519 wd->animator = ecore_animator_timeline_add(tm, _event_anim, wd);
1520 _event_anim(wd, 0.0);
1524 _move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1526 Evas_Object *fl = data;
1527 Widget_Data *wd = elm_widget_data_get(fl);
1528 Evas_Event_Mouse_Move *ev = event_info;
1529 Evas_Coord x, y, w, h;
1532 if (!wd->down) return;
1533 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
1534 evas_object_geometry_get(data, &x, &y, &w, &h);
1535 wd->x = ev->cur.canvas.x - x;
1536 wd->y = ev->cur.canvas.y - y;
1543 dx = wd->x - wd->down_x;
1544 dy = wd->y - wd->down_y;
1545 if (((dx * dx) + (dy * dy)) > (_elm_config->finger_size * _elm_config->finger_size / 4))
1548 if ((wd->x > (w / 2)) && (dx < 0) && (abs(dx) > abs(dy))) wd->dir = 0; // left
1549 else if ((wd->x < (w / 2)) && (dx >= 0) && (abs(dx) > abs(dy))) wd->dir = 1; // right
1550 else if ((wd->y > (h / 2)) && (dy < 0) && (abs(dy) >= abs(dx))) wd->dir = 2; // up
1551 else if ((wd->y < (h / 2)) && (dy >= 0) && (abs(dy) >= abs(dx))) wd->dir = 3; // down
1552 wd->started = EINA_TRUE;
1553 if (wd->intmode == ELM_FLIP_INTERACTION_PAGE)
1554 wd->pageflip = EINA_TRUE;
1555 flip_show_hide(data);
1556 evas_smart_objects_calculate(evas_object_evas_get(data));
1558 // FIXME: hack around evas rendering bug (only fix makes evas bitch-slow)
1559 evas_object_map_enable_set(wd->front.content, 0);
1560 evas_object_map_enable_set(wd->back.content, 0);
1561 // FIXME: XXX why does this bork interactive flip??
1562 // evas_object_resize(wd->front.content, 0, 0);
1563 // evas_object_resize(wd->back.content, 0, 0);
1564 evas_smart_objects_calculate(evas_object_evas_get(data));
1567 evas_object_smart_callback_call(obj, SIG_ANIMATE_BEGIN, NULL);
1571 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1572 if (wd->job) ecore_job_del(wd->job);
1573 wd->job = ecore_job_add(_update_job, wd);
1577 elm_flip_add(Evas_Object *parent)
1583 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1585 ELM_SET_WIDTYPE(widtype, "flip");
1586 elm_widget_type_set(obj, "flip");
1587 elm_widget_sub_object_add(parent, obj);
1588 elm_widget_data_set(obj, wd);
1589 elm_widget_del_hook_set(obj, _del_hook);
1590 elm_widget_theme_hook_set(obj, _theme_hook);
1591 elm_widget_focus_next_hook_set(obj, _elm_flip_focus_next_hook);
1592 elm_widget_can_focus_set(obj, EINA_FALSE);
1596 wd->clip = evas_object_rectangle_add(e);
1597 evas_object_static_clip_set(wd->clip, 1);
1598 evas_object_color_set(wd->clip, 255, 255, 255, 255);
1599 evas_object_move(wd->clip, -49999, -49999);
1600 evas_object_resize(wd->clip, 99999, 99999);
1601 elm_widget_sub_object_add(obj, wd->clip);
1602 evas_object_clip_set(wd->clip, evas_object_clip_get(obj));
1603 evas_object_smart_member_add(wd->clip, obj);
1605 wd->front.clip = evas_object_rectangle_add(e);
1606 evas_object_static_clip_set(wd->front.clip, 1);
1607 evas_object_data_set(wd->front.clip, "_elm_leaveme", obj);
1608 evas_object_color_set(wd->front.clip, 255, 255, 255, 255);
1609 evas_object_move(wd->front.clip, -49999, -49999);
1610 evas_object_resize(wd->front.clip, 99999, 99999);
1611 elm_widget_sub_object_add(obj, wd->front.clip);
1612 evas_object_smart_member_add(wd->front.clip, obj);
1613 evas_object_clip_set(wd->front.clip, wd->clip);
1615 wd->back.clip = evas_object_rectangle_add(e);
1616 evas_object_static_clip_set(wd->back.clip, 1);
1617 evas_object_data_set(wd->back.clip, "_elm_leaveme", obj);
1618 evas_object_color_set(wd->back.clip, 255, 255, 255, 255);
1619 evas_object_move(wd->back.clip, -49999, -49999);
1620 evas_object_resize(wd->back.clip, 99999, 99999);
1621 elm_widget_sub_object_add(wd->back.clip, obj);
1622 evas_object_smart_member_add(obj, wd->back.clip);
1623 evas_object_clip_set(wd->back.clip, wd->clip);
1625 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
1626 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _move, NULL);
1627 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, NULL);
1629 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1632 wd->intmode = ELM_FLIP_INTERACTION_NONE;
1640 elm_flip_content_front_set(Evas_Object *obj, Evas_Object *content)
1642 ELM_CHECK_WIDTYPE(obj, widtype);
1643 Widget_Data *wd = elm_widget_data_get(obj);
1646 if (wd->front.content == content) return;
1647 if (wd->front.content) evas_object_del(wd->back.content);
1648 wd->front.content = content;
1651 elm_widget_sub_object_add(obj, content);
1652 evas_object_smart_member_add(content, obj);
1653 evas_object_clip_set(content, wd->front.clip);
1654 evas_object_event_callback_add(content,
1655 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1656 _changed_size_hints, obj);
1659 // force calc to contents are the right size before transition
1660 evas_smart_objects_calculate(evas_object_evas_get(obj));
1661 flip_show_hide(obj);
1663 if (wd->intmode != ELM_FLIP_INTERACTION_NONE)
1665 for (i = 0; i < 4; i++) evas_object_raise(wd->event[i]);
1670 elm_flip_content_back_set(Evas_Object *obj, Evas_Object *content)
1672 ELM_CHECK_WIDTYPE(obj, widtype);
1673 Widget_Data *wd = elm_widget_data_get(obj);
1676 if (wd->back.content == content) return;
1677 if (wd->back.content) evas_object_del(wd->back.content);
1678 wd->back.content = content;
1681 elm_widget_sub_object_add(obj, content);
1682 evas_object_smart_member_add(content, obj);
1683 evas_object_clip_set(content, wd->back.clip);
1684 evas_object_event_callback_add(content,
1685 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1686 _changed_size_hints, obj);
1689 // force calc to contents are the right size before transition
1690 evas_smart_objects_calculate(evas_object_evas_get(obj));
1691 flip_show_hide(obj);
1693 if (wd->intmode != ELM_FLIP_INTERACTION_NONE)
1695 for (i = 0; i < 4; i++) evas_object_raise(wd->event[i]);
1700 elm_flip_content_front_get(const Evas_Object *obj)
1702 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1703 Widget_Data *wd = elm_widget_data_get(obj);
1704 return wd->front.content;
1709 elm_flip_content_back_get(const Evas_Object *obj)
1711 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1712 Widget_Data *wd = elm_widget_data_get(obj);
1713 return wd->back.content;
1717 elm_flip_content_front_unset(Evas_Object *obj)
1719 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1720 Widget_Data *wd = elm_widget_data_get(obj);
1721 if (!wd) return NULL;
1722 if (!wd->front.content) return NULL;
1723 Evas_Object *content = wd->front.content;
1724 evas_object_clip_unset(content);
1725 elm_widget_sub_object_del(obj, content);
1726 evas_object_smart_member_del(content);
1727 wd->front.content = NULL;
1732 elm_flip_content_back_unset(Evas_Object *obj)
1734 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1735 Widget_Data *wd = elm_widget_data_get(obj);
1736 if (!wd) return NULL;
1737 if (!wd->back.content) return NULL;
1738 Evas_Object *content = wd->back.content;
1739 evas_object_clip_unset(content);
1740 elm_widget_sub_object_del(obj, content);
1741 evas_object_smart_member_del(content);
1742 wd->back.content = NULL;
1747 elm_flip_front_get(const Evas_Object *obj)
1749 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1750 Widget_Data *wd = elm_widget_data_get(obj);
1751 if (!wd) return EINA_FALSE;
1756 elm_flip_perspective_set(Evas_Object *obj, Evas_Coord foc __UNUSED__, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
1758 ELM_CHECK_WIDTYPE(obj, widtype);
1759 Widget_Data *wd = elm_widget_data_get(obj);
1763 // FIXME: add ambient and lighting control
1766 elm_flip_go(Evas_Object *obj, Elm_Flip_Mode mode)
1768 ELM_CHECK_WIDTYPE(obj, widtype);
1769 Widget_Data *wd = elm_widget_data_get(obj);
1771 if (!wd->animator) wd->animator = ecore_animator_add(_animate, obj);
1772 flip_show_hide(obj);
1774 wd->start = ecore_loop_time_get();
1775 wd->len = 0.5; // FIXME: make config val
1776 if ((wd->mode == ELM_FLIP_PAGE_LEFT) ||
1777 (wd->mode == ELM_FLIP_PAGE_RIGHT) ||
1778 (wd->mode == ELM_FLIP_PAGE_UP) ||
1779 (wd->mode == ELM_FLIP_PAGE_DOWN))
1780 wd->pageflip = EINA_TRUE;
1781 // force calc to contents are the right size before transition
1782 evas_smart_objects_calculate(evas_object_evas_get(obj));
1784 // FIXME: hack around evas rendering bug (only fix makes evas bitch-slow)
1785 evas_object_map_enable_set(wd->front.content, 0);
1786 evas_object_map_enable_set(wd->back.content, 0);
1787 evas_object_resize(wd->front.content, 0, 0);
1788 evas_object_resize(wd->back.content, 0, 0);
1789 evas_smart_objects_calculate(evas_object_evas_get(obj));
1792 evas_object_smart_callback_call(obj, SIG_ANIMATE_BEGIN, NULL);
1796 elm_flip_interaction_set(Evas_Object *obj, Elm_Flip_Interaction mode)
1798 ELM_CHECK_WIDTYPE(obj, widtype);
1800 Widget_Data *wd = elm_widget_data_get(obj);
1802 if (wd->intmode == mode) return;
1804 for (i = 0; i < 4; i++)
1806 if (wd->intmode == ELM_FLIP_INTERACTION_NONE)
1810 evas_object_del(wd->event[i]);
1811 wd->event[i] = NULL;
1816 if ((wd->dir_enabled[i]) && (!wd->event[i]))
1818 wd->event[i] = evas_object_rectangle_add(evas_object_evas_get(obj));
1819 elm_widget_sub_object_add(obj, wd->event[i]);
1820 evas_object_clip_set(wd->event[i], evas_object_clip_get(obj));
1821 evas_object_color_set(wd->event[i], 0, 0, 0, 0);
1822 evas_object_show(wd->event[i]);
1823 evas_object_smart_member_add(wd->event[i], obj);
1824 evas_object_event_callback_add(wd->event[i], EVAS_CALLBACK_MOUSE_DOWN, _down_cb, obj);
1825 evas_object_event_callback_add(wd->event[i], EVAS_CALLBACK_MOUSE_UP, _up_cb, obj);
1826 evas_object_event_callback_add(wd->event[i], EVAS_CALLBACK_MOUSE_MOVE, _move_cb, obj);
1834 EAPI Elm_Flip_Interaction
1835 elm_flip_interaction_get(const Evas_Object *obj)
1837 ELM_CHECK_WIDTYPE(obj, widtype) ELM_FLIP_INTERACTION_NONE;
1838 Widget_Data *wd = elm_widget_data_get(obj);
1839 if (!wd) return ELM_FLIP_INTERACTION_NONE;
1844 elm_flip_interacton_direction_enabled_set(Evas_Object *obj, Elm_Flip_Direction dir, Eina_Bool enabled)
1846 ELM_CHECK_WIDTYPE(obj, widtype);
1847 Widget_Data *wd = elm_widget_data_get(obj);
1850 enabled = !!enabled;
1851 if (dir == ELM_FLIP_DIRECTION_UP) i = 0;
1852 else if (dir == ELM_FLIP_DIRECTION_DOWN) i = 1;
1853 else if (dir == ELM_FLIP_DIRECTION_LEFT) i = 2;
1854 else if (dir == ELM_FLIP_DIRECTION_RIGHT) i = 3;
1856 if (wd->dir_enabled[i] == enabled) return;
1857 wd->dir_enabled[i] = enabled;
1858 if (wd->intmode == ELM_FLIP_INTERACTION_NONE) return;
1859 if ((wd->dir_enabled[i]) && (!wd->event[i]))
1861 wd->event[i] = evas_object_rectangle_add(evas_object_evas_get(obj));
1862 elm_widget_sub_object_add(obj, wd->event[i]);
1863 evas_object_clip_set(wd->event[i], evas_object_clip_get(obj));
1864 evas_object_color_set(wd->event[i], 0, 0, 0, 0);
1865 evas_object_show(wd->event[i]);
1866 evas_object_smart_member_add(wd->event[i], obj);
1867 evas_object_event_callback_add(wd->event[i], EVAS_CALLBACK_MOUSE_DOWN, _down_cb, obj);
1868 evas_object_event_callback_add(wd->event[i], EVAS_CALLBACK_MOUSE_UP, _up_cb, obj);
1869 evas_object_event_callback_add(wd->event[i], EVAS_CALLBACK_MOUSE_MOVE, _move_cb, obj);
1871 else if (!(wd->dir_enabled[i]) && (wd->event[i]))
1873 evas_object_del(wd->event[i]);
1874 wd->event[i] = NULL;
1881 elm_flip_interacton_direction_enabled_get(Evas_Object *obj, Elm_Flip_Direction dir)
1883 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1884 Widget_Data *wd = elm_widget_data_get(obj);
1886 if (!wd) return EINA_FALSE;
1887 if (dir == ELM_FLIP_DIRECTION_UP) i = 0;
1888 else if (dir == ELM_FLIP_DIRECTION_DOWN) i = 1;
1889 else if (dir == ELM_FLIP_DIRECTION_LEFT) i = 2;
1890 else if (dir == ELM_FLIP_DIRECTION_RIGHT) i = 3;
1891 if (i < 0) return EINA_FALSE;
1892 return wd->dir_enabled[i];
1896 elm_flip_interacton_direction_hitsize_set(Evas_Object *obj, Elm_Flip_Direction dir, double hitsize)
1898 ELM_CHECK_WIDTYPE(obj, widtype);
1899 Widget_Data *wd = elm_widget_data_get(obj);
1902 if (dir == ELM_FLIP_DIRECTION_UP) i = 0;
1903 else if (dir == ELM_FLIP_DIRECTION_DOWN) i = 1;
1904 else if (dir == ELM_FLIP_DIRECTION_LEFT) i = 2;
1905 else if (dir == ELM_FLIP_DIRECTION_RIGHT) i = 3;
1907 if (hitsize < 0.0) hitsize = 0.0;
1908 else if (hitsize > 1.0) hitsize = 1.0;
1909 if (wd->dir_hitsize[i] == hitsize) return;
1910 wd->dir_hitsize[i] = hitsize;
1916 elm_flip_interacton_direction_hitsize_get(Evas_Object *obj, Elm_Flip_Direction dir)
1918 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1919 Widget_Data *wd = elm_widget_data_get(obj);
1921 if (!wd) return 0.0;
1922 if (dir == ELM_FLIP_DIRECTION_UP) i = 0;
1923 else if (dir == ELM_FLIP_DIRECTION_DOWN) i = 1;
1924 else if (dir == ELM_FLIP_DIRECTION_LEFT) i = 2;
1925 else if (dir == ELM_FLIP_DIRECTION_RIGHT) i = 3;
1926 if (i < 0) return 0.0;
1927 return wd->dir_hitsize[i];