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];
35 Evas_Object *content, *clip;
38 Evas_Coord down_x, down_y, x, y, ox, oy, w, h;
39 Elm_Flip_Interaction intmode;
41 double dir_hitsize[4];
42 Eina_Bool dir_enabled[4];
43 int slices_w, slices_h;
44 Slice **slices, **slices2;
49 Eina_Bool started : 1;
50 Eina_Bool backflip : 1;
51 Eina_Bool pageflip : 1;
54 static const char *widtype = NULL;
55 static void _del_hook(Evas_Object *obj);
56 static void _theme_hook(Evas_Object *obj);
57 static void _sizing_eval(Evas_Object *obj);
58 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
59 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
61 static void _state_slices_clear(Widget_Data *wd);
62 static void _configure(Evas_Object *obj);
64 static const char SIG_ANIMATE_BEGIN[] = "animate,begin";
65 static const char SIG_ANIMATE_DONE[] = "animate,done";
67 static const Evas_Smart_Cb_Description _signals[] = {
68 {SIG_ANIMATE_BEGIN, ""},
69 {SIG_ANIMATE_DONE, ""},
74 _del_hook(Evas_Object *obj)
76 Widget_Data *wd = elm_widget_data_get(obj);
78 if (wd->animator) ecore_animator_del(wd->animator);
79 _state_slices_clear(wd);
84 _theme_hook(Evas_Object *obj)
86 Widget_Data *wd = elm_widget_data_get(obj);
92 _elm_flip_focus_next_hook(const Evas_Object *obj,
93 Elm_Focus_Direction dir, Evas_Object **next)
95 Widget_Data *wd = elm_widget_data_get(obj);
96 if (!wd) return EINA_FALSE;
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);
106 _sizing_eval(Evas_Object *obj)
108 Widget_Data *wd = elm_widget_data_get(obj);
109 Evas_Coord minw = -1, minh = -1, minw2 = -1, minh2 = -1;
110 Evas_Coord maxw = -1, maxh = -1, maxw2 = -1, maxh2 = -1;
111 int fingx = 0, fingy = 0;
113 if (wd->front.content)
114 evas_object_size_hint_min_get(wd->front.content, &minw, &minh);
115 if (wd->back.content)
116 evas_object_size_hint_min_get(wd->back.content, &minw2, &minh2);
117 if (wd->front.content)
118 evas_object_size_hint_max_get(wd->front.content, &maxw, &maxh);
119 if (wd->back.content)
120 evas_object_size_hint_max_get(wd->back.content, &maxw2, &maxh2);
122 if (minw2 > minw) minw = minw2;
123 if (minh2 > minh) minh = minh2;
124 if ((maxw2 >= 0) && (maxw2 < maxw)) maxw = maxw2;
125 if ((maxh2 >= 0) && (maxh2 < maxh)) maxh = maxh2;
127 if (wd->dir_enabled[0]) fingy++;
128 if (wd->dir_enabled[1]) fingy++;
129 if (wd->dir_enabled[2]) fingx++;
130 if (wd->dir_enabled[3]) fingx++;
132 elm_coords_finger_size_adjust(fingx, &minw, fingy, &minh);
134 evas_object_size_hint_min_set(obj, minw, minh);
135 evas_object_size_hint_max_set(obj, maxw, maxh);
139 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
141 Widget_Data *wd = elm_widget_data_get(data);
147 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
149 Widget_Data *wd = elm_widget_data_get(obj);
150 Evas_Object *sub = event_info;
152 if (sub == wd->front.content)
154 evas_object_event_callback_del_full(sub,
155 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,
164 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
165 _changed_size_hints, obj);
166 wd->back.content = NULL;
167 evas_object_hide(wd->back.clip);
173 _slice_new(Widget_Data *wd, Evas_Object *obj)
177 sl = calloc(1, sizeof(Slice));
178 if (!sl) return NULL;
179 sl->obj = evas_object_image_add(evas_object_evas_get(obj));
180 elm_widget_sub_object_add(wd->obj, sl->obj);
181 evas_object_smart_member_add(sl->obj, wd->obj);
182 evas_object_image_smooth_scale_set(sl->obj, EINA_FALSE);
183 evas_object_pass_events_set(sl->obj, EINA_TRUE);
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 *wd, Slice *sl, Evas_Coord x __UNUSED__,
197 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, EINA_FALSE);
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]],
214 evas_map_point_image_uv_set(m, i, sl->u[p[i]] , sl->v[p[i]]);
216 else if (wd->dir == 1)
218 int p[4] = { 1, 0, 3, 2 };
219 evas_map_point_coord_set(m, i, ox + (w - sl->x[p[i]]),
220 oy + sl->y[p[i]], sl->z[p[i]]);
221 evas_map_point_image_uv_set(m, i, ow - sl->u[p[i]], sl->v[p[i]]);
223 else if (wd->dir == 2)
225 int p[4] = { 1, 0, 3, 2 };
226 evas_map_point_coord_set(m, i, ox + sl->y[p[i]], oy + sl->x[p[i]],
228 evas_map_point_image_uv_set(m, i, sl->v[p[i]] , sl->u[p[i]]);
230 else/* if (wd->dir == 3) will be this anyway */
232 int p[4] = { 0, 1, 2, 3 };
233 evas_map_point_coord_set(m, i, ox + sl->y[p[i]],
234 oy + (w - sl->x[p[i]]), sl->z[p[i]]);
235 evas_map_point_image_uv_set(m, i, sl->v[p[i]] , oh - sl->u[p[i]]);
238 evas_object_map_enable_set(sl->obj, EINA_TRUE);
239 evas_object_image_fill_set(sl->obj, 0, 0, ow, oh);
240 evas_object_map_set(sl->obj, m);
245 _slice_3d(Widget_Data *wd __UNUSED__, Slice *sl, Evas_Coord x, Evas_Coord y,
246 Evas_Coord w, Evas_Coord h)
248 Evas_Map *m = (Evas_Map *)evas_object_map_get(sl->obj);
252 // vanishing point is center of page, and focal dist is 1024
253 evas_map_util_3d_perspective(m, x + (w / 2), y + (h / 2), 0, 1024);
254 for (i = 0; i < 4; i++)
256 Evas_Coord xx, yy, zz;
257 evas_map_point_coord_get(m, i, &xx, &yy, &zz);
258 evas_map_point_coord_set(m, i, xx, yy, 0);
260 if (evas_map_util_clockwise_get(m)) evas_object_show(sl->obj);
261 else evas_object_hide(sl->obj);
262 evas_object_map_set(sl->obj, m);
266 _slice_light(Widget_Data *wd __UNUSED__, Slice *sl, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
268 Evas_Map *m = (Evas_Map *)evas_object_map_get(sl->obj);
272 evas_map_util_3d_lighting(m,
274 // (centered over page 10 * h toward camera)
275 x + (w / 2) , y + (h / 2) , -10000,
276 255, 255, 255, // light color
277 0 , 0 , 0); // ambient minimum
278 // multiply brightness by 1.2 to make lightish bits all white so we dont
279 // add shading where we could otherwise be pure white
280 for (i = 0; i < 4; i++)
284 evas_map_point_color_get(m, i, &r, &g, &b, &a);
285 r = (double)r * 1.2; if (r > 255) r = 255;
286 g = (double)g * 1.2; if (g > 255) g = 255;
287 b = (double)b * 1.2; if (b > 255) b = 255;
288 evas_map_point_color_set(m, i, r, g, b, a);
290 evas_object_map_set(sl->obj, m);
294 _slice_xyz(Widget_Data *wd __UNUSED__, Slice *sl,
295 double xx1, double yy1, double zz1,
296 double xx2, double yy2, double zz2,
297 double xx3, double yy3, double zz3,
298 double xx4, double yy4, double zz4)
300 sl->x[0] = xx1; sl->y[0] = yy1; sl->z[0] = zz1;
301 sl->x[1] = xx2; sl->y[1] = yy2; sl->z[1] = zz2;
302 sl->x[2] = xx3; sl->y[2] = yy3; sl->z[2] = zz3;
303 sl->x[3] = xx4; sl->y[3] = yy4; sl->z[3] = zz4;
307 _slice_uv(Widget_Data *wd __UNUSED__, Slice *sl,
308 double u1, double v1,
309 double u2, double v2,
310 double u3, double v3,
311 double u4, double v4)
313 sl->u[0] = u1; sl->v[0] = v1;
314 sl->u[1] = u2; sl->v[1] = v2;
315 sl->u[2] = u3; sl->v[2] = v3;
316 sl->u[3] = u4; sl->v[3] = v4;
320 _deform_point(Vertex2 *vi, Vertex3 *vo, double rho, double theta, double A)
326 // theta == cone angle (0 -> PI/2)
327 // A == distance of cone apex from origin
328 // rho == angle of cone from vertical axis (...-PI/2 to PI/2...)
332 d = sqrt((vi->x * vi->x) + pow(vi->y - A, 2));
334 b = asin(vi->x / d) / sin(theta);
337 v1.y = d + A - (r * (1 - cos(b)) * sin(theta));
338 v1.z = r * (1 - cos(b)) * cos(theta);
340 vo->x = (v1.x * cos(rho)) - (v1.z * sin(rho));
342 vo->z = (v1.x * sin(rho)) + (v1.z * cos(rho));
346 _interp_point(Vertex3 *vi1, Vertex3 *vi2, Vertex3 *vo, double v)
348 vo->x = (v * vi2->x) + ((1.0 - v) * vi1->x);
349 vo->y = (v * vi2->y) + ((1.0 - v) * vi1->y);
350 vo->z = (v * vi2->z) + ((1.0 - v) * vi1->z);
354 _state_slices_clear(Widget_Data *wd)
361 for (j = 0; j < wd->slices_h; j++)
363 for (i = 0; i < wd->slices_w; i++)
365 if (wd->slices[num]) _slice_free(wd->slices[num]);
366 if (wd->slices2[num]) _slice_free(wd->slices2[num]);
380 _slice_obj_color_sum(Slice *s, int p, int *r, int *g, int *b, int *a)
383 int rr = 0, gg = 0, bb = 0, aa = 0;
386 m = (Evas_Map *)evas_object_map_get(s->obj);
388 evas_map_point_color_get(m, p, &rr, &gg, &bb, &aa);
389 *r += rr; *g += gg; *b += bb; *a += aa;
394 _slice_obj_color_set(Slice *s, int p, int r, int g, int b, int a)
399 m = (Evas_Map *) evas_object_map_get(s->obj);
401 evas_map_point_color_set(m, p, r, g, b, a);
402 evas_object_map_set(s->obj, m);
406 _slice_obj_vert_color_merge(Slice *s1, int p1, Slice *s2, int p2,
407 Slice *s3, int p3, Slice *s4, int p4)
409 int r = 0, g = 0, b = 0, a = 0, n = 0;
411 n += _slice_obj_color_sum(s1, p1, &r, &g, &b, &a);
412 n += _slice_obj_color_sum(s2, p2, &r, &g, &b, &a);
413 n += _slice_obj_color_sum(s3, p3, &r, &g, &b, &a);
414 n += _slice_obj_color_sum(s4, p4, &r, &g, &b, &a);
417 r /= n; g /= n; b /= n; a /= n;
419 _slice_obj_color_set(s1, p1, r, g, b, a);
420 _slice_obj_color_set(s2, p2, r, g, b, a);
421 _slice_obj_color_set(s3, p3, r, g, b, a);
422 _slice_obj_color_set(s4, p4, r, g, b, a);
426 _state_update(Widget_Data *wd)
428 Evas_Coord xx1, yy1, xx2, yy2, mx, my;
429 Evas_Coord x, y, w, h, ox, oy, ow, oh;
430 int i, j, num, nn, jump, num2;
432 double b, minv = 0.0, minva, mgrad;
433 int gx, gy, gszw, gszh, gw, gh, col, row, nw, nh;
434 double rho, A, theta, perc, percm, n, rhol, Al, thetal;
436 Evas_Object *front, *back;
438 wd->backflip = EINA_TRUE;
441 front = wd->front.content;
442 back = wd->front.content;
446 front = wd->back.content;
447 back = wd->back.content;
450 evas_object_geometry_get(wd->obj, &x, &y, &w, &h);
451 ox = x; oy = y; ow = w; oh = h;
459 // no nothing. left drag is standard
461 else if (wd->dir == 1)
466 else if (wd->dir == 2)
470 tmp = xx1; xx1 = yy1; yy1 = tmp;
471 tmp = xx2; xx2 = yy2; yy2 = tmp;
472 tmp = w; w = h; h = tmp;
474 else/* if (wd->dir == 3) will be this anyway */
478 tmp = xx1; xx1 = yy1; yy1 = tmp;
479 tmp = xx2; xx2 = yy2; yy2 = tmp;
480 tmp = w; w = h; h = tmp;
485 if (xx2 >= xx1) xx2 = xx1 - 1;
486 mx = (xx1 + xx2) / 2;
487 my = (yy1 + yy2) / 2;
490 else if (mx >= w) mx = w - 1;
492 else if (my >= h) my = h - 1;
494 mgrad = (double)(yy1 - yy2) / (double)(xx1 - xx2);
496 if (mx < 1) mx = 1; // quick hack to keep curl line visible
498 if (mgrad == 0.0) // special horizontal case
499 mgrad = 0.001; // quick dirty hack for now
504 b = my + (minv * mx);
506 if ((b >= -5) && (b <= (h + 5)))
508 if (minv > 0.0) // clamp to h
510 minv = (double)(h + 5 - my) / (double)(mx);
511 b = my + (minv * mx);
515 minv = (double)(-5 - my) / (double)(mx);
516 b = my + (minv * mx);
520 perc = (double)xx2 / (double)xx1;
521 percm = (double)mx / (double)xx1;
522 if (perc < 0.0) perc = 0.0;
523 else if (perc > 1.0) perc = 1.0;
524 if (percm < 0.0) percm = 0.0;
525 else if (percm > 1.0) percm = 1.0;
527 minva = atan(minv) / (M_PI / 2);
528 if (minva < 0.0) minva = -minva;
533 if (A < -(h * 20)) A = -h * 20;
537 // rho = is how much the page is turned
539 n = 1.0 - cos(n * M_PI / 2.0);
545 // theta == curliness (how much page culrs in on itself
546 n = sin((1.0 - perc) * M_PI);
550 n = sin((1.0 - perc) * M_PI);
560 if (gszw < 4) gszw = 4;
561 if (gszh < 4) gszh = 4;
563 nw = (w + gszw - 1) / gszw;
564 nh = (h + gszh - 1) / gszh;
565 if ((wd->slices_w != nw) || (wd->slices_h != nh)) _state_slices_clear(wd);
570 wd->slices = calloc(wd->slices_w * wd->slices_h, sizeof(Slice *));
571 if (!wd->slices) return 0;
572 wd->slices2 = calloc(wd->slices_w * wd->slices_h, sizeof(Slice *));
581 num = (wd->slices_w + 1) * (wd->slices_h + 1);
583 tvo = alloca(sizeof(Vertex3) * num);
584 tvol = alloca(sizeof(Vertex3) * (wd->slices_w + 1));
586 for (col = 0, gx = 0; gx <= (w + gszw - 1); gx += gszw, col++)
591 vil.y = h - ((gx * h) / (w + gszw - 1));
592 _deform_point(&vil, &(tvol[col]), rhol, thetal, Al);
595 n = minva * sin(perc * M_PI);
599 for (col = 0, gx = 0; gx <= (w + gszw - 1); gx += gszw, col++)
601 for (gy = 0; gy <= (h + gszh - 1); gy += gszh)
606 if (gx > w) vi.x = w;
608 if (gy > h) vi.y = h;
610 _deform_point(&vi, &vo, rho, theta, A);
612 if (gy > h) tvo1.y = h;
614 _interp_point(&vo, &tvo1, &(tvo[num]), n);
619 jump = wd->slices_h + 1;
620 for (col = 0, gx = 0; gx < w; gx += gszw, col++)
622 num = wd->slices_h * col;
626 if ((gx + gw) > w) gw = w - gx;
628 for (row = 0, gy = 0; gy < h; gy += gszh, row++)
632 if (b > 0) nn = num + wd->slices_h - row - 1;
636 if ((gy + gh) > h) gh = h - gy;
638 vo[0] = tvo[num2 + row];
639 vo[1] = tvo[num2 + row + jump];
640 vo[2] = tvo[num2 + row + jump + 1];
641 vo[3] = tvo[num2 + row + 1];
642 #define SWP(a, b) do {typeof(a) vt; vt = (a); (a) = (b); (b) = vt;} while (0)
647 vo[0].y = h - vo[0].y;
648 vo[1].y = h - vo[1].y;
649 vo[2].y = h - vo[2].y;
650 vo[3].y = h - vo[3].y;
657 sl = _slice_new(wd, front);
661 vo[0].x, vo[0].y, vo[0].z,
662 vo[1].x, vo[1].y, vo[1].z,
663 vo[2].x, vo[2].y, vo[2].z,
664 vo[3].x, vo[3].y, vo[3].z);
667 gx, gy, gx + gw, gy, gx + gw, gy + gh, gx, gy + gh);
670 gx, h - (gy + gh), gx + gw, h - (gy + gh), gx + gw,
674 sl = wd->slices2[nn];
677 sl = _slice_new(wd, back);
678 wd->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);
689 _slice_uv(wd, sl, gx + gw, gy, gx, gy, gx, gy + gh, gx + gw,
692 _slice_uv(wd, sl, gx + gw, h - (gy + gh), gx, h - (gy + gh),
693 gx, h - gy, gx + gw, h - gy);
698 _slice_uv(wd, sl, w - (gx + gw), gy, w - (gx), gy, w - (gx),
699 gy + gh, w - (gx + gw), gy + gh);
701 _slice_uv(wd, sl, w - (gx + gw), h - (gy + gh), w - (gx),
702 h - (gy + gh), w - (gx), h - gy, w - (gx + gw),
708 for (num = 0; num < wd->slices_h * wd->slices_w; num++)
710 _slice_apply(wd, wd->slices[num], x, y, w, h, ox, oy, ow, oh);
711 _slice_apply(wd, wd->slices2[num], x, y, w, h, ox, oy, ow, oh);
712 _slice_light(wd, wd->slices[num], ox, oy, ow, oh);
713 _slice_light(wd, wd->slices2[num], ox, oy, ow, oh);
716 for (i = 0; i <= wd->slices_w; i++)
718 num = i * wd->slices_h;
719 for (j = 0; j <= wd->slices_h; j++)
721 Slice *s[4] = { NULL }, *s2[4] = { NULL };
723 if ((i > 0) && (j > 0))
724 s[0] = wd->slices[num - 1 - wd->slices_h],
725 s2[0] = wd->slices2[num - 1 - wd->slices_h];
726 if ((i < wd->slices_w) && (j > 0))
727 s[1] = wd->slices[num - 1],
728 s2[1] = wd->slices2[num - 1];
729 if ((i > 0) && (j < wd->slices_h))
730 s[2] = wd->slices[num - wd->slices_h],
731 s2[2] = wd->slices2[num - wd->slices_h];
732 if ((i < wd->slices_w) && (j < wd->slices_h))
733 s[3] = wd->slices[num],
734 s2[3] = wd->slices2[num];
738 _slice_obj_vert_color_merge(s[0], 2, s[1], 3, s[2], 1, s[3], 0);
739 _slice_obj_vert_color_merge(s2[0], 3, s2[1], 2, s2[2], 0, s2[3], 1);
742 _slice_obj_vert_color_merge(s[0], 3, s[1], 2, s[2], 0, s[3], 1);
743 _slice_obj_vert_color_merge(s2[0], 2, s2[1], 3, s2[2], 1, s2[3], 0);
746 _slice_obj_vert_color_merge(s[0], 3, s[1], 2, s[2], 0, s[3], 1);
747 _slice_obj_vert_color_merge(s2[0], 2, s2[1], 3, s2[2], 1, s2[3], 0);
750 _slice_obj_vert_color_merge(s[0], 2, s[1], 3, s[2], 1, s[3], 0);
751 _slice_obj_vert_color_merge(s2[0], 3, s2[1], 2, s2[2], 0, s2[3], 1);
757 for (num = 0; num < wd->slices_h * wd->slices_w; num++)
759 _slice_3d(wd, wd->slices[num], ox, oy, ow, oh);
760 _slice_3d(wd, wd->slices2[num], ox, oy, ow, oh);
767 _state_end(Widget_Data *wd)
769 _state_slices_clear(wd);
774 flip_show_hide(Evas_Object *obj)
776 Widget_Data *wd = elm_widget_data_get(obj);
777 if (elm_flip_front_visible_get(obj))
781 if (wd->front.content)
783 evas_object_move(wd->front.content, 4999, 4999);
784 evas_object_show(wd->front.clip);
787 evas_object_hide(wd->front.clip);
788 if (wd->back.content)
789 evas_object_show(wd->back.clip);
791 evas_object_hide(wd->back.clip);
795 if (wd->front.content)
796 evas_object_show(wd->front.clip);
798 evas_object_hide(wd->front.clip);
799 evas_object_hide(wd->back.clip);
806 if (wd->front.content)
807 evas_object_show(wd->front.clip);
809 evas_object_hide(wd->front.clip);
810 if (wd->back.content)
812 evas_object_move(wd->back.content, 4999, 4999);
813 evas_object_show(wd->back.clip);
816 evas_object_hide(wd->back.clip);
820 if (wd->front.content)
821 evas_object_hide(wd->front.clip);
823 evas_object_hide(wd->front.clip);
824 if (wd->back.content)
825 evas_object_show(wd->back.clip);
827 evas_object_hide(wd->back.clip);
833 _flip_do(Evas_Object *obj, double t, Elm_Flip_Mode mode, int lin, int rev)
835 Evas_Coord x, y, w, h;
838 Evas_Coord cx, cy, px, py, foc;
839 int lx, ly, lz, lr, lg, lb, lar, lag, lab;
840 Widget_Data *wd = elm_widget_data_get(obj);
844 mf = evas_map_new(4);
845 evas_map_smooth_set(mf, EINA_FALSE);
846 mb = evas_map_new(4);
847 evas_map_smooth_set(mb, EINA_FALSE);
849 if (wd->front.content)
851 const char *type = evas_object_type_get(wd->front.content);
853 // FIXME: only handles filled obj
854 if ((type) && (!strcmp(type, "image")))
857 evas_object_image_size_get(wd->front.content, &iw, &ih);
858 evas_object_geometry_get(wd->front.content, &x, &y, &w, &h);
859 evas_map_util_points_populate_from_geometry(mf, x, y, w, h, 0);
860 evas_map_point_image_uv_set(mf, 0, 0, 0);
861 evas_map_point_image_uv_set(mf, 1, iw, 0);
862 evas_map_point_image_uv_set(mf, 2, iw, ih);
863 evas_map_point_image_uv_set(mf, 3, 0, ih);
867 evas_object_geometry_get(wd->front.content, &x, &y, &w, &h);
868 evas_map_util_points_populate_from_geometry(mf, x, y, w, h, 0);
871 if (wd->back.content)
873 const char *type = evas_object_type_get(wd->back.content);
875 if ((type) && (!strcmp(type, "image")))
878 evas_object_image_size_get(wd->back.content, &iw, &ih);
879 evas_object_geometry_get(wd->back.content, &x, &y, &w, &h);
880 evas_map_util_points_populate_from_geometry(mb, x, y, w, h, 0);
881 evas_map_point_image_uv_set(mb, 0, 0, 0);
882 evas_map_point_image_uv_set(mb, 1, iw, 0);
883 evas_map_point_image_uv_set(mb, 2, iw, ih);
884 evas_map_point_image_uv_set(mb, 3, 0, ih);
888 evas_object_geometry_get(wd->back.content, &x, &y, &w, &h);
889 evas_map_util_points_populate_from_geometry(mb, x, y, w, h, 0);
893 evas_object_geometry_get(obj, &x, &y, &w, &h);
914 case ELM_FLIP_ROTATE_Y_CENTER_AXIS:
917 if (!lin) pp = (p * p);
919 if (wd->state) deg = 180.0 * p;
920 else deg = 180 + (180.0 * p);
922 evas_map_util_3d_rotate(mf, 0.0, deg, 0.0, cx, cy, 0);
923 evas_map_util_3d_rotate(mb, 0.0, 180 + deg, 0.0, cx, cy, 0);
925 case ELM_FLIP_ROTATE_X_CENTER_AXIS:
928 if (!lin) pp = (p * p);
930 if (wd->state) deg = 180.0 * p;
931 else deg = 180 + (180.0 * p);
933 evas_map_util_3d_rotate(mf, deg, 0.0, 0.0, cx, cy, 0);
934 evas_map_util_3d_rotate(mb, 180.0 + deg, 0.0, 0.0, cx, cy, 0);
936 case ELM_FLIP_ROTATE_XZ_CENTER_AXIS:
939 if (!lin) pp = (p * p);
941 if (wd->state) deg = 180.0 * p;
942 else deg = 180 + (180.0 * p);
944 evas_map_util_3d_rotate(mf, deg, 0.0, deg, cx, cy, 0);
945 evas_map_util_3d_rotate(mb, 180 + deg, 0.0, 180 + deg, cx, cy, 0);
947 case ELM_FLIP_ROTATE_YZ_CENTER_AXIS:
950 if (!lin) pp = (p * p);
952 if (wd->state) deg = 180.0 * p;
953 else deg = 180 + (180.0 * p);
955 evas_map_util_3d_rotate(mf, 0.0, deg, deg, cx, cy, 0);
956 evas_map_util_3d_rotate(mb, 0.0, 180.0 + deg, 180.0 + deg, cx, cy, 0);
958 case ELM_FLIP_CUBE_LEFT:
961 if (!lin) pp = (p * p);
966 evas_map_util_3d_rotate(mf, 0.0, deg, 0.0, cx, cy, w / 2);
967 evas_map_util_3d_rotate(mb, 0.0, deg + 90, 0.0, cx, cy, w / 2);
971 evas_map_util_3d_rotate(mf, 0.0, deg + 90, 0.0, cx, cy, w / 2);
972 evas_map_util_3d_rotate(mb, 0.0, deg, 0.0, cx, cy, w / 2);
975 case ELM_FLIP_CUBE_RIGHT:
978 if (!lin) pp = (p * p);
983 evas_map_util_3d_rotate(mf, 0.0, deg, 0.0, cx, cy, w / 2);
984 evas_map_util_3d_rotate(mb, 0.0, deg - 90, 0.0, cx, cy, w / 2);
988 evas_map_util_3d_rotate(mf, 0.0, deg - 90, 0.0, cx, cy, w / 2);
989 evas_map_util_3d_rotate(mb, 0.0, deg, 0.0, cx, cy, w / 2);
992 case ELM_FLIP_CUBE_UP:
995 if (!lin) pp = (p * p);
1000 evas_map_util_3d_rotate(mf, deg, 0.0, 0.0, cx, cy, h / 2);
1001 evas_map_util_3d_rotate(mb, deg + 90, 0.0, 0.0, cx, cy, h / 2);
1005 evas_map_util_3d_rotate(mf, deg + 90, 0.0, 0.0, cx, cy, h / 2);
1006 evas_map_util_3d_rotate(mb, deg, 0.0, 0.0, cx, cy, h / 2);
1009 case ELM_FLIP_CUBE_DOWN:
1012 if (!lin) pp = (p * p);
1017 evas_map_util_3d_rotate(mf, deg, 0.0, 0.0, cx, cy, h / 2);
1018 evas_map_util_3d_rotate(mb, deg - 90, 0.0, 0.0, cx, cy, h / 2);
1022 evas_map_util_3d_rotate(mf, deg - 90, 0.0, 0.0, cx, cy, h / 2);
1023 evas_map_util_3d_rotate(mb, deg, 0.0, 0.0, cx, cy, h / 2);
1026 case ELM_FLIP_PAGE_LEFT:
1028 case ELM_FLIP_PAGE_RIGHT:
1030 case ELM_FLIP_PAGE_UP:
1032 case ELM_FLIP_PAGE_DOWN:
1039 if (wd->front.content)
1041 evas_map_util_3d_lighting(mf, lx, ly, lz, lr, lg, lb, lar, lag, lab);
1042 evas_map_util_3d_perspective(mf, px, py, 0, foc);
1043 evas_object_map_set(wd->front.content, mf);
1044 evas_object_map_enable_set(wd->front.content, 1);
1045 if (evas_map_util_clockwise_get(mf)) evas_object_show(wd->front.clip);
1046 else evas_object_hide(wd->front.clip);
1049 if (wd->back.content)
1051 evas_map_util_3d_lighting(mb, lx, ly, lz, lr, lg, lb, lar, lag, lab);
1052 evas_map_util_3d_perspective(mb, px, py, 0, foc);
1053 evas_object_map_set(wd->back.content, mb);
1054 evas_object_map_enable_set(wd->back.content, 1);
1055 if (evas_map_util_clockwise_get(mb)) evas_object_show(wd->back.clip);
1056 else evas_object_hide(wd->back.clip);
1064 _showhide(Evas_Object *obj)
1066 Widget_Data *wd = elm_widget_data_get(obj);
1067 Evas_Coord x, y, w, h;
1070 evas_object_geometry_get(obj, &x, &y, &w, &h);
1071 if (wd->front.content)
1073 if ((wd->pageflip) && (wd->state))
1075 evas_object_move(wd->front.content, 4999, 4999);
1080 evas_object_move(wd->front.content, x, y);
1082 evas_object_resize(wd->front.content, w, h);
1084 if (wd->back.content)
1086 if ((wd->pageflip) && (!wd->state))
1088 evas_object_move(wd->back.content, 4999, 4999);
1093 evas_object_move(wd->back.content, x, y);
1095 evas_object_resize(wd->back.content, w, h);
1101 _flip(Evas_Object *obj)
1103 Widget_Data *wd = elm_widget_data_get(obj);
1104 double t = ecore_loop_time_get() - wd->start;
1107 if (!wd) return ECORE_CALLBACK_CANCEL;
1108 if (!wd->animator) return ECORE_CALLBACK_CANCEL;
1111 if (t > 1.0) t = 1.0;
1113 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
1114 if (wd->mode == ELM_FLIP_PAGE_LEFT)
1117 wd->started = EINA_TRUE;
1118 wd->pageflip = EINA_TRUE;
1121 wd->x = (1.0 - t) * wd->down_x;
1123 flip_show_hide(obj);
1126 else if (wd->mode == ELM_FLIP_PAGE_RIGHT)
1129 wd->started = EINA_TRUE;
1130 wd->pageflip = EINA_TRUE;
1135 flip_show_hide(obj);
1138 else if (wd->mode == ELM_FLIP_PAGE_UP)
1141 wd->started = EINA_TRUE;
1142 wd->pageflip = EINA_TRUE;
1146 wd->y = (1.0 - t) * wd->down_y;
1147 flip_show_hide(obj);
1150 else if (wd->mode == ELM_FLIP_PAGE_DOWN)
1153 wd->started = EINA_TRUE;
1154 wd->pageflip = EINA_TRUE;
1159 flip_show_hide(obj);
1163 _flip_do(obj, t, wd->mode, 0, 0);
1167 wd->pageflip = EINA_FALSE;
1169 evas_object_map_enable_set(wd->front.content, 0);
1170 evas_object_map_enable_set(wd->back.content, 0);
1171 // FIXME: hack around evas rendering bug (only fix makes evas bitch-slow
1172 evas_object_resize(wd->front.content, 0, 0);
1173 evas_object_resize(wd->back.content, 0, 0);
1174 evas_smart_objects_calculate(evas_object_evas_get(obj));
1176 wd->animator = NULL;
1177 wd->state = !wd->state;
1179 flip_show_hide(obj);
1180 evas_object_smart_callback_call(obj, SIG_ANIMATE_DONE, NULL);
1181 return ECORE_CALLBACK_CANCEL;
1183 return ECORE_CALLBACK_RENEW;
1187 _configure(Evas_Object *obj)
1189 Widget_Data *wd = elm_widget_data_get(obj);
1190 Evas_Coord x, y, w, h;
1195 evas_object_geometry_get(obj, &x, &y, &w, &h);
1196 // FIXME: manual flip wont get fixed
1197 if (wd->animator) _flip(obj);
1201 fsize = (double)w * wd->dir_hitsize[0];
1202 elm_coords_finger_size_adjust(0, NULL, 1, &fsize);
1203 evas_object_move(wd->event[0], x, y);
1204 evas_object_resize(wd->event[0], w, fsize);
1208 fsize = (double)w * wd->dir_hitsize[1];
1209 elm_coords_finger_size_adjust(0, NULL, 1, &fsize);
1210 evas_object_move(wd->event[1], x, y + h - fsize);
1211 evas_object_resize(wd->event[1], w, fsize);
1215 fsize = (double)h * wd->dir_hitsize[2];
1216 elm_coords_finger_size_adjust(1, &fsize, 0, NULL);
1217 evas_object_move(wd->event[2], x, y);
1218 evas_object_resize(wd->event[2], fsize, h);
1222 fsize = (double)h * wd->dir_hitsize[3];
1223 elm_coords_finger_size_adjust(1, &fsize, 0, NULL);
1224 evas_object_move(wd->event[3], x + w - fsize, y);
1225 evas_object_resize(wd->event[3], fsize, h);
1230 _move(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1236 _resize(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1242 _animate(void *data)
1248 _pos_get(Widget_Data *wd, int *rev, Elm_Flip_Mode *m)
1250 Evas_Coord x, y, w, h;
1253 evas_object_geometry_get(wd->obj, &x, &y, &w, &h);
1254 switch (wd->intmode)
1256 case ELM_FLIP_INTERACTION_ROTATE:
1257 case ELM_FLIP_INTERACTION_CUBE:
1262 t = 1.0 - ((double)wd->x / (double)wd->down_x);
1265 else if (wd->dir == 1)
1268 t = 1.0 - ((double)(w - wd->x) / (double)(w - wd->down_x));
1270 else if (wd->dir == 2)
1273 t = 1.0 - ((double)wd->y / (double)wd->down_y);
1275 else if (wd->dir == 3)
1278 t = 1.0 - ((double)(h - wd->y) / (double)(h - wd->down_y));
1282 if (t < 0.0) t = 0.0;
1283 else if (t > 1.0) t = 1.0;
1285 if ((wd->dir == 0) || (wd->dir == 1))
1287 if (wd->intmode == ELM_FLIP_INTERACTION_ROTATE)
1288 *m = ELM_FLIP_ROTATE_Y_CENTER_AXIS;
1289 else if (wd->intmode == ELM_FLIP_INTERACTION_CUBE)
1292 *m = ELM_FLIP_CUBE_LEFT;
1294 *m = ELM_FLIP_CUBE_RIGHT;
1299 if (wd->intmode == ELM_FLIP_INTERACTION_ROTATE)
1300 *m = ELM_FLIP_ROTATE_X_CENTER_AXIS;
1301 else if (wd->intmode == ELM_FLIP_INTERACTION_CUBE)
1304 *m = ELM_FLIP_CUBE_UP;
1306 *m = ELM_FLIP_CUBE_DOWN;
1317 _event_anim(void *data, double pos)
1319 Widget_Data *wd = data;
1322 p = ecore_animator_pos_map(pos, ECORE_POS_MAP_ACCELERATE, 0.0, 0.0);
1326 wd->x = wd->ox * (1.0 - p);
1327 else if (wd->dir == 1)
1328 wd->x = wd->ox + ((wd->w - wd->ox) * p);
1329 else if (wd->dir == 2)
1330 wd->y = wd->oy * (1.0 - p);
1331 else if (wd->dir == 3)
1332 wd->y = wd->oy + ((wd->h - wd->oy) * p);
1337 wd->x = wd->ox + ((wd->w - wd->ox) * p);
1338 else if (wd->dir == 1)
1339 wd->x = wd->ox * (1.0 - p);
1340 else if (wd->dir == 2)
1341 wd->y = wd->oy + ((wd->h - wd->oy) * p);
1342 else if (wd->dir == 3)
1343 wd->y = wd->oy * (1.0 - p);
1345 switch (wd->intmode)
1347 case ELM_FLIP_INTERACTION_NONE:
1349 case ELM_FLIP_INTERACTION_ROTATE:
1350 case ELM_FLIP_INTERACTION_CUBE:
1352 Elm_Flip_Mode m = ELM_FLIP_ROTATE_X_CENTER_AXIS;
1354 p = _pos_get(wd, &rev, &m);
1355 _flip_do(wd->obj, p, m, 1, rev);
1358 case ELM_FLIP_INTERACTION_PAGE:
1359 wd->pageflip = EINA_TRUE;
1366 if (pos < 1.0) return ECORE_CALLBACK_RENEW;
1368 wd->pageflip = EINA_FALSE;
1370 evas_object_map_enable_set(wd->front.content, 0);
1371 evas_object_map_enable_set(wd->back.content, 0);
1372 // FIXME: hack around evas rendering bug (only fix makes evas bitch-slow
1373 evas_object_resize(wd->front.content, 0, 0);
1374 evas_object_resize(wd->back.content, 0, 0);
1375 evas_smart_objects_calculate(evas_object_evas_get(wd->obj));
1377 wd->animator = NULL;
1378 if (wd->finish) wd->state = !wd->state;
1379 flip_show_hide(wd->obj);
1380 _configure(wd->obj);
1381 wd->animator = NULL;
1382 evas_object_smart_callback_call(wd->obj, SIG_ANIMATE_DONE, NULL);
1384 return ECORE_CALLBACK_CANCEL;
1388 _update_job(void *data)
1390 Widget_Data *wd = data;
1392 Elm_Flip_Mode m = ELM_FLIP_ROTATE_X_CENTER_AXIS;
1396 switch (wd->intmode)
1398 case ELM_FLIP_INTERACTION_ROTATE:
1399 case ELM_FLIP_INTERACTION_CUBE:
1400 p = _pos_get(wd, &rev, &m);
1401 _flip_do(wd->obj, p, m, 1, rev);
1403 case ELM_FLIP_INTERACTION_PAGE:
1404 wd->pageflip = EINA_TRUE;
1414 _down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1416 Evas_Object *fl = data;
1417 Widget_Data *wd = elm_widget_data_get(fl);
1418 Evas_Event_Mouse_Down *ev = event_info;
1419 Evas_Coord x, y, w, h;
1422 if (ev->button != 1) return;
1423 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
1426 ecore_animator_del(wd->animator);
1427 wd->animator = NULL;
1429 wd->down = EINA_TRUE;
1430 wd->started = EINA_FALSE;
1431 evas_object_geometry_get(data, &x, &y, &w, &h);
1432 wd->x = ev->canvas.x - x;
1433 wd->y = ev->canvas.y - y;
1441 _up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1443 Evas_Object *fl = data;
1444 Widget_Data *wd = elm_widget_data_get(fl);
1445 Evas_Event_Mouse_Up *ev = event_info;
1446 Evas_Coord x, y, w, h;
1450 if (ev->button != 1) return;
1451 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
1453 evas_object_geometry_get(data, &x, &y, &w, &h);
1454 wd->x = ev->canvas.x - x;
1455 wd->y = ev->canvas.y - y;
1462 ecore_job_del(wd->job);
1465 wd->finish = EINA_FALSE;
1468 tm = (double)wd->x / (double)wd->w;
1469 if (wd->x < (wd->w / 2)) wd->finish = EINA_TRUE;
1471 else if (wd->dir == 1)
1473 if (wd->x > (wd->w / 2)) wd->finish = EINA_TRUE;
1474 tm = 1.0 - ((double)wd->x / (double)wd->w);
1476 else if (wd->dir == 2)
1478 if (wd->y < (wd->h / 2)) wd->finish = EINA_TRUE;
1479 tm = (double)wd->y / (double)wd->h;
1481 else if (wd->dir == 3)
1483 if (wd->y > (wd->h / 2)) wd->finish = EINA_TRUE;
1484 tm = 1.0 - ((double)wd->y / (double)wd->h);
1486 if (tm < 0.01) tm = 0.01;
1487 else if (tm > 0.99) tm = 0.99;
1488 if (!wd->finish) tm = 1.0 - tm;
1489 tm *= 1.0; // FIXME: config for anim time
1490 if (wd->animator) ecore_animator_del(wd->animator);
1491 wd->animator = ecore_animator_timeline_add(tm, _event_anim, wd);
1492 _event_anim(wd, 0.0);
1496 _move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1498 Evas_Object *fl = data;
1499 Widget_Data *wd = elm_widget_data_get(fl);
1500 Evas_Event_Mouse_Move *ev = event_info;
1501 Evas_Coord x, y, w, h;
1504 if (!wd->down) return;
1505 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return ;
1506 evas_object_geometry_get(data, &x, &y, &w, &h);
1507 wd->x = ev->cur.canvas.x - x;
1508 wd->y = ev->cur.canvas.y - y;
1515 dx = wd->x - wd->down_x;
1516 dy = wd->y - wd->down_y;
1517 if (((dx * dx) + (dy * dy)) >
1518 (_elm_config->finger_size * _elm_config->finger_size / 4))
1521 if ((wd->x > (w / 2)) &&
1522 (dx < 0) && (abs(dx) > abs(dy)))
1523 wd->dir = 0; // left
1524 else if ((wd->x < (w / 2)) && (dx >= 0) &&
1525 (abs(dx) > abs(dy)))
1526 wd->dir = 1; // right
1527 else if ((wd->y > (h / 2)) && (dy < 0) && (abs(dy) >= abs(dx)))
1529 else if ((wd->y < (h / 2)) && (dy >= 0) && (abs(dy) >= abs(dx)))
1530 wd->dir = 3; // down
1531 wd->started = EINA_TRUE;
1532 if (wd->intmode == ELM_FLIP_INTERACTION_PAGE)
1533 wd->pageflip = EINA_TRUE;
1534 flip_show_hide(data);
1535 evas_smart_objects_calculate(evas_object_evas_get(data));
1537 // FIXME: hack around evas rendering bug (only fix makes evas bitch-slow)
1538 evas_object_map_enable_set(wd->front.content, EINA_FALSE);
1539 evas_object_map_enable_set(wd->back.content, EINA_FALSE);
1540 // FIXME: XXX why does this bork interactive flip??
1541 // evas_object_resize(wd->front.content, 0, 0);
1542 // evas_object_resize(wd->back.content, 0, 0);
1543 evas_smart_objects_calculate(evas_object_evas_get(data));
1546 evas_object_smart_callback_call(obj, SIG_ANIMATE_BEGIN, NULL);
1550 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1551 if (wd->job) ecore_job_del(wd->job);
1552 wd->job = ecore_job_add(_update_job, wd);
1556 _flip_content_front_set(Evas_Object *obj, Evas_Object *content)
1558 Widget_Data *wd = elm_widget_data_get(obj);
1563 if (wd->front.content == content) return;
1564 if (wd->front.content) evas_object_del(wd->front.content);
1565 wd->front.content = content;
1568 elm_widget_sub_object_add(obj, content);
1569 evas_object_smart_member_add(content, obj);
1570 //FIXME: smart member clip could be reset by the obj.
1571 evas_object_clip_set(content, wd->front.clip);
1572 evas_object_event_callback_add(content,
1573 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1574 _changed_size_hints, obj);
1578 // force calc to contents are the right size before transition
1579 evas_smart_objects_calculate(evas_object_evas_get(obj));
1580 flip_show_hide(obj);
1582 if (wd->intmode != ELM_FLIP_INTERACTION_NONE)
1584 for (i = 0; i < 4; i++) evas_object_raise(wd->event[i]);
1589 _flip_content_back_set(Evas_Object *obj, Evas_Object *content)
1591 Widget_Data *wd = elm_widget_data_get(obj);
1595 if (wd->back.content == content) return;
1596 if (wd->back.content) evas_object_del(wd->back.content);
1597 wd->back.content = content;
1600 elm_widget_sub_object_add(obj, content);
1601 evas_object_smart_member_add(content, obj);
1602 //FIXME: smart member clip could be reset by the obj.
1603 evas_object_clip_set(content, wd->back.clip);
1604 evas_object_event_callback_add(content,
1605 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1606 _changed_size_hints, obj);
1610 // force calc to contents are the right size before transition
1611 evas_smart_objects_calculate(evas_object_evas_get(obj));
1612 flip_show_hide(obj);
1614 if (wd->intmode != ELM_FLIP_INTERACTION_NONE)
1616 for (i = 0; i < 4; i++) evas_object_raise(wd->event[i]);
1620 static Evas_Object *
1621 _content_front_unset(Evas_Object *obj)
1623 Widget_Data *wd = elm_widget_data_get(obj);
1624 if ((!wd) || (!wd->front.content)) return NULL;
1626 Evas_Object *content = wd->front.content;
1627 elm_widget_sub_object_del(obj, content);
1628 evas_object_smart_member_del(content);
1632 static Evas_Object *
1633 _content_back_unset(Evas_Object *obj)
1635 Widget_Data *wd = elm_widget_data_get(obj);
1636 if ((!wd) || (!wd->back.content)) return NULL;
1638 Evas_Object *content = wd->back.content;
1639 elm_widget_sub_object_del(obj, content);
1640 evas_object_smart_member_del(content);
1645 _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
1647 ELM_CHECK_WIDTYPE(obj, widtype);
1649 if (!part || !strcmp(part, "front"))
1650 _flip_content_front_set(obj, content);
1651 else if (!strcmp(part, "back"))
1652 _flip_content_back_set(obj, content);
1655 static Evas_Object *
1656 _content_get_hook(const Evas_Object *obj, const char *part)
1658 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1659 Widget_Data *wd = elm_widget_data_get(obj);
1660 if (!wd) return NULL;
1662 if (!part || !strcmp(part, "front"))
1663 return wd->front.content;
1664 else if (!strcmp(part, "back"))
1665 return wd->back.content;
1670 static Evas_Object *
1671 _content_unset_hook(Evas_Object *obj, const char *part)
1673 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1675 if (!part || !strcmp(part, "front"))
1676 return _content_front_unset(obj);
1677 else if (!strcmp(part, "back"))
1678 return _content_back_unset(obj);
1684 elm_flip_add(Evas_Object *parent)
1690 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1692 ELM_SET_WIDTYPE(widtype, "flip");
1693 elm_widget_type_set(obj, "flip");
1694 elm_widget_sub_object_add(parent, obj);
1695 elm_widget_data_set(obj, wd);
1696 elm_widget_del_hook_set(obj, _del_hook);
1697 elm_widget_theme_hook_set(obj, _theme_hook);
1698 elm_widget_focus_next_hook_set(obj, _elm_flip_focus_next_hook);
1699 elm_widget_can_focus_set(obj, EINA_FALSE);
1700 elm_widget_content_set_hook_set(obj, _content_set_hook);
1701 elm_widget_content_get_hook_set(obj, _content_get_hook);
1702 elm_widget_content_unset_hook_set(obj, _content_unset_hook);
1706 wd->clip = evas_object_rectangle_add(e);
1707 evas_object_static_clip_set(wd->clip, EINA_TRUE);
1708 evas_object_move(wd->clip, -49999, -49999);
1709 evas_object_resize(wd->clip, 99999, 99999);
1710 elm_widget_sub_object_add(obj, wd->clip);
1711 evas_object_smart_member_add(wd->clip, obj);
1713 wd->front.clip = evas_object_rectangle_add(e);
1714 evas_object_static_clip_set(wd->front.clip, EINA_TRUE);
1715 evas_object_data_set(wd->front.clip, "_elm_leaveme", obj);
1716 evas_object_move(wd->front.clip, -49999, -49999);
1717 evas_object_resize(wd->front.clip, 99999, 99999);
1718 elm_widget_sub_object_add(obj, wd->front.clip);
1719 evas_object_smart_member_add(wd->front.clip, obj);
1720 evas_object_clip_set(wd->front.clip, wd->clip);
1722 wd->back.clip = evas_object_rectangle_add(e);
1723 evas_object_static_clip_set(wd->back.clip, EINA_TRUE);
1724 evas_object_data_set(wd->back.clip, "_elm_leaveme", obj);
1725 evas_object_move(wd->back.clip, -49999, -49999);
1726 evas_object_resize(wd->back.clip, 99999, 99999);
1727 elm_widget_sub_object_add(obj, wd->back.clip);
1728 evas_object_smart_member_add(wd->back.clip, obj);
1729 evas_object_clip_set(wd->back.clip, wd->clip);
1731 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
1732 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _move, NULL);
1733 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, NULL);
1734 evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1735 _changed_size_hints, obj);;
1737 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1739 wd->state = EINA_TRUE;
1740 wd->intmode = ELM_FLIP_INTERACTION_NONE;
1748 elm_flip_front_visible_get(const Evas_Object *obj)
1750 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1751 Widget_Data *wd = elm_widget_data_get(obj);
1752 if (!wd) return EINA_FALSE;
1757 elm_flip_perspective_set(Evas_Object *obj, Evas_Coord foc __UNUSED__, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
1759 ELM_CHECK_WIDTYPE(obj, widtype);
1760 Widget_Data *wd = elm_widget_data_get(obj);
1764 // FIXME: add ambient and lighting control
1767 elm_flip_go(Evas_Object *obj, Elm_Flip_Mode mode)
1769 ELM_CHECK_WIDTYPE(obj, widtype);
1770 Widget_Data *wd = elm_widget_data_get(obj);
1772 if (!wd->animator) wd->animator = ecore_animator_add(_animate, obj);
1773 flip_show_hide(obj);
1775 wd->start = ecore_loop_time_get();
1776 wd->len = 0.5; // FIXME: make config val
1777 if ((wd->mode == ELM_FLIP_PAGE_LEFT) ||
1778 (wd->mode == ELM_FLIP_PAGE_RIGHT) ||
1779 (wd->mode == ELM_FLIP_PAGE_UP) ||
1780 (wd->mode == ELM_FLIP_PAGE_DOWN))
1781 wd->pageflip = EINA_TRUE;
1782 // force calc to contents are the right size before transition
1783 evas_smart_objects_calculate(evas_object_evas_get(obj));
1785 // FIXME: hack around evas rendering bug (only fix makes evas bitch-slow)
1786 evas_object_map_enable_set(wd->front.content, 0);
1787 evas_object_map_enable_set(wd->back.content, 0);
1788 evas_object_resize(wd->front.content, 0, 0);
1789 evas_object_resize(wd->back.content, 0, 0);
1790 evas_smart_objects_calculate(evas_object_evas_get(obj));
1793 evas_object_smart_callback_call(obj, SIG_ANIMATE_BEGIN, NULL);
1797 elm_flip_interaction_set(Evas_Object *obj, Elm_Flip_Interaction mode)
1799 ELM_CHECK_WIDTYPE(obj, widtype);
1801 Widget_Data *wd = elm_widget_data_get(obj);
1803 if (wd->intmode == mode) return;
1805 for (i = 0; i < 4; i++)
1807 if (wd->intmode == ELM_FLIP_INTERACTION_NONE)
1811 evas_object_del(wd->event[i]);
1812 wd->event[i] = NULL;
1817 if ((wd->dir_enabled[i]) && (!wd->event[i]))
1819 Evas *e = evas_object_evas_get(obj);
1820 wd->event[i] = evas_object_rectangle_add(e);
1821 elm_widget_sub_object_add(obj, wd->event[i]);
1822 evas_object_data_set(wd->event[i], "_elm_leaveme", obj);
1823 evas_object_clip_set(wd->event[i], evas_object_clip_get(obj));
1824 evas_object_color_set(wd->event[i], 0, 0, 0, 0);
1825 evas_object_show(wd->event[i]);
1826 evas_object_smart_member_add(wd->event[i], obj);
1827 evas_object_event_callback_add(wd->event[i],
1828 EVAS_CALLBACK_MOUSE_DOWN,
1830 evas_object_event_callback_add(wd->event[i],
1831 EVAS_CALLBACK_MOUSE_UP,
1833 evas_object_event_callback_add(wd->event[i],
1834 EVAS_CALLBACK_MOUSE_MOVE,
1843 EAPI Elm_Flip_Interaction
1844 elm_flip_interaction_get(const Evas_Object *obj)
1846 ELM_CHECK_WIDTYPE(obj, widtype) ELM_FLIP_INTERACTION_NONE;
1847 Widget_Data *wd = elm_widget_data_get(obj);
1848 if (!wd) return ELM_FLIP_INTERACTION_NONE;
1853 elm_flip_interaction_direction_enabled_set(Evas_Object *obj, Elm_Flip_Direction dir, Eina_Bool enabled)
1855 ELM_CHECK_WIDTYPE(obj, widtype);
1856 Widget_Data *wd = elm_widget_data_get(obj);
1859 enabled = !!enabled;
1860 if (dir == ELM_FLIP_DIRECTION_UP) i = 0;
1861 else if (dir == ELM_FLIP_DIRECTION_DOWN) i = 1;
1862 else if (dir == ELM_FLIP_DIRECTION_LEFT) i = 2;
1863 else if (dir == ELM_FLIP_DIRECTION_RIGHT) i = 3;
1865 if (wd->dir_enabled[i] == enabled) return;
1866 wd->dir_enabled[i] = enabled;
1867 if (wd->intmode == ELM_FLIP_INTERACTION_NONE) return;
1868 if ((wd->dir_enabled[i]) && (!wd->event[i]))
1870 wd->event[i] = evas_object_rectangle_add(evas_object_evas_get(obj));
1871 elm_widget_sub_object_add(obj, wd->event[i]);
1872 evas_object_data_set(wd->event[i], "_elm_leaveme", obj);
1873 evas_object_clip_set(wd->event[i], evas_object_clip_get(obj));
1874 evas_object_color_set(wd->event[i], 0, 0, 0, 0);
1875 evas_object_show(wd->event[i]);
1876 evas_object_smart_member_add(wd->event[i], obj);
1877 evas_object_event_callback_add(wd->event[i], EVAS_CALLBACK_MOUSE_DOWN,
1879 evas_object_event_callback_add(wd->event[i], EVAS_CALLBACK_MOUSE_UP,
1881 evas_object_event_callback_add(wd->event[i], EVAS_CALLBACK_MOUSE_MOVE,
1884 else if (!(wd->dir_enabled[i]) && (wd->event[i]))
1886 evas_object_del(wd->event[i]);
1887 wd->event[i] = NULL;
1894 elm_flip_interaction_direction_enabled_get(Evas_Object *obj, Elm_Flip_Direction dir)
1896 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1897 Widget_Data *wd = elm_widget_data_get(obj);
1899 if (!wd) return EINA_FALSE;
1900 if (dir == ELM_FLIP_DIRECTION_UP) i = 0;
1901 else if (dir == ELM_FLIP_DIRECTION_DOWN) i = 1;
1902 else if (dir == ELM_FLIP_DIRECTION_LEFT) i = 2;
1903 else if (dir == ELM_FLIP_DIRECTION_RIGHT) i = 3;
1904 if (i < 0) return EINA_FALSE;
1905 return wd->dir_enabled[i];
1909 elm_flip_interaction_direction_hitsize_set(Evas_Object *obj, Elm_Flip_Direction dir, double hitsize)
1911 ELM_CHECK_WIDTYPE(obj, widtype);
1912 Widget_Data *wd = elm_widget_data_get(obj);
1915 if (dir == ELM_FLIP_DIRECTION_UP) i = 0;
1916 else if (dir == ELM_FLIP_DIRECTION_DOWN) i = 1;
1917 else if (dir == ELM_FLIP_DIRECTION_LEFT) i = 2;
1918 else if (dir == ELM_FLIP_DIRECTION_RIGHT) i = 3;
1920 if (hitsize < 0.0) hitsize = 0.0;
1921 else if (hitsize > 1.0) hitsize = 1.0;
1922 if (wd->dir_hitsize[i] == hitsize) return;
1923 wd->dir_hitsize[i] = hitsize;
1929 elm_flip_interaction_direction_hitsize_get(Evas_Object *obj, Elm_Flip_Direction dir)
1931 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1932 Widget_Data *wd = elm_widget_data_get(obj);
1934 if (!wd) return 0.0;
1935 if (dir == ELM_FLIP_DIRECTION_UP) i = 0;
1936 else if (dir == ELM_FLIP_DIRECTION_DOWN) i = 1;
1937 else if (dir == ELM_FLIP_DIRECTION_LEFT) i = 2;
1938 else if (dir == ELM_FLIP_DIRECTION_RIGHT) i = 3;
1939 if (i < 0) return 0.0;
1940 return wd->dir_hitsize[i];