1 #include <Elementary.h>
3 #include "els_scroller.h"
6 * TODO (maybe - optional future stuff):
8 * 1. wrap photo in theme edje so u can have styling around photo (like white
11 * 3. rotation flags in exif handling (nasty! should have rot in evas)
14 typedef struct _Widget_Data Widget_Data;
15 typedef struct _Pan Pan;
16 typedef struct _Grid Grid;
17 typedef struct _Grid_Item Grid_Item;
33 int tsize; // size of tile (tsize x tsize pixels)
34 int zoom; // zoom level tiles want for optimal display (1, 2, 4, 8)
35 int iw, ih; // size of image in pixels
36 int w, h; // size of grid image in pixels (represented by grid)
37 int gw, gh; // size of grid in tiles
38 Grid_Item *grid; // the grid (gw * gh items)
39 Eina_Bool dead : 1; // old grid. will die as soon as anim is over
46 Evas_Object *pan_smart;
52 >>>>>>> remotes/origin/upstream
54 Evas_Coord pan_x, pan_y, minw, minh;
57 Elm_Photocam_Zoom_Mode mode;
60 Evas_Coord pvx, pvy, px, py, zoom_point_x, zoom_point_y;
70 Ecore_Animator *animator;
73 >>>>>>> remotes/origin/upstream
77 Ecore_Timer *scr_timer;
78 Ecore_Timer *long_timer;
79 Ecore_Animator *zoom_animator;
80 double t_start, t_end;
94 Evas_Coord x, y ,w ,h;
97 Evas_Object *img; // low res version of image (scale down == 8)
101 Eina_Bool main_load_pending : 1;
102 Eina_Bool resized : 1;
103 Eina_Bool longpressed : 1;
104 Eina_Bool on_hold : 1;
105 Eina_Bool paused : 1;
106 Eina_Bool do_region : 1;
109 Eina_Bool do_gesture : 1;
110 Eina_Bool zoom_gest : 1;
111 >>>>>>> remotes/origin/upstream
116 Evas_Object_Smart_Clipped_Data __clipped_data;
120 static const char *widtype = NULL;
121 static void _del_hook(Evas_Object *obj);
122 static void _theme_hook(Evas_Object *obj);
123 static void _on_focus_hook(void *data, Evas_Object *obj);
124 //static void _show_region_hook(void *data, Evas_Object *obj);
125 static void _sizing_eval(Evas_Object *obj);
126 static void _calc_job(void *data);
127 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__,
128 Evas_Callback_Type type, void *event_info);
129 static void grid_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh);
130 static void grid_clear(Evas_Object *obj, Grid *g);
131 static Grid *grid_create(Evas_Object *obj);
132 static void grid_load(Evas_Object *obj, Grid *g);
134 static const char SIG_CLICKED[] = "clicked";
135 static const char SIG_PRESS[] = "press";
136 static const char SIG_LONGPRESSED[] = "longpressed";
137 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
138 static const char SIG_LOAD[] = "load";
139 static const char SIG_LOADED[] = "loaded";
140 static const char SIG_LOAD_DETAIL[] = "load,detail";
141 static const char SIG_LOADED_DETAIL[] = "loaded,detail";
142 static const char SIG_ZOOM_START[] = "zoom,start";
143 static const char SIG_ZOOM_STOP[] = "zoom,stop";
144 static const char SIG_ZOOM_CHANGE[] = "zoom,change";
145 static const char SIG_SCROLL[] = "scroll";
146 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
147 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
148 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
149 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
151 static const Evas_Smart_Cb_Description _signals[] = {
154 {SIG_LONGPRESSED, ""},
155 {SIG_CLICKED_DOUBLE, ""},
158 {SIG_LOAD_DETAIL, ""},
159 {SIG_LOADED_DETAIL, ""},
160 {SIG_ZOOM_START, ""},
162 {SIG_ZOOM_CHANGE, ""},
164 {SIG_SCROLL_ANIM_START, ""},
165 {SIG_SCROLL_ANIM_STOP, ""},
166 {SIG_SCROLL_DRAG_START, ""},
167 {SIG_SCROLL_DRAG_STOP, ""},
173 nearest_pow2(int num)
175 unsigned int n = num - 1;
185 img_place(Evas_Object *obj, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
187 Widget_Data *wd = elm_widget_data_get(obj);
188 Evas_Coord ax, ay, gw, gh;
195 if (ow > gw) ax = (ow - gw) / 2;
196 if (oh > gh) ay = (oh - gh) / 2;
200 if (ow > gw) ax = (ow - gw) / 2;
201 if (oh > gh) ay = (oh - gh) / 2;
203 >>>>>>> remotes/origin/upstream
204 evas_object_move(wd->img, ox + 0 - px + ax, oy + 0 - py + ay);
205 evas_object_resize(wd->img, gw, gh);
209 wd->show.show = EINA_FALSE;
210 elm_smart_scroller_child_region_show(wd->scr, wd->show.x, wd->show.y, wd->show.w, wd->show.h);
215 grid_place(Evas_Object *obj, Grid *g, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
217 Widget_Data *wd = elm_widget_data_get(obj);
218 Evas_Coord ax, ay, gw, gh, tx, ty;
226 if (ow > gw) ax = (ow - gw) / 2;
227 if (oh > gh) ay = (oh - gh) / 2;
231 if (ow > gw) ax = (ow - gw) / 2;
232 if (oh > gh) ay = (oh - gh) / 2;
234 >>>>>>> remotes/origin/upstream
235 for (y = 0; y < g->gh; y++)
237 for (x = 0; x < g->gw; x++)
239 int tn, xx, yy, ww, hh;
241 tn = (y * g->gw) + x;
242 xx = g->grid[tn].out.x;
243 yy = g->grid[tn].out.y;
244 ww = g->grid[tn].out.w;
245 hh = g->grid[tn].out.h;
246 if ((gw != g->w) && (g->w > 0))
249 xx = (gw * xx) / g->w;
250 ww = ((gw * (tx + ww)) / g->w) - xx;
252 if ((gh != g->h) && (g->h > 0))
255 yy = (gh * yy) / g->h;
256 hh = ((gh * (ty + hh)) / g->h) - yy;
258 evas_object_move(g->grid[tn].img,
261 evas_object_resize(g->grid[tn].img, ww, hh);
267 grid_clear(Evas_Object *obj, Grid *g)
269 Widget_Data *wd = elm_widget_data_get(obj);
272 if (!g->grid) return;
273 for (y = 0; y < g->gh; y++)
275 for (x = 0; x < g->gw; x++)
279 tn = (y * g->gw) + x;
280 evas_object_del(g->grid[tn].img);
281 if (g->grid[tn].want)
284 if (!wd->preload_num)
286 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
287 "elm,state,busy,stop", "elm");
288 evas_object_smart_callback_call(obj, SIG_LOAD_DETAIL, NULL);
300 _tile_preloaded(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
302 Grid_Item *git = data;
307 evas_object_show(git->img);
309 git->wd->preload_num--;
310 if (!git->wd->preload_num)
312 edje_object_signal_emit(elm_smart_scroller_edje_object_get(git->wd->scr),
313 "elm,state,busy,stop", "elm");
314 evas_object_smart_callback_call(git->wd->obj, SIG_LOADED_DETAIL, NULL);
320 grid_zoom_calc(double zoom)
324 return nearest_pow2(z);
328 grid_create(Evas_Object *obj)
330 Widget_Data *wd = elm_widget_data_get(obj);
334 if (!wd) return NULL;
335 g = calloc(1, sizeof(Grid));
338 g->zoom = grid_zoom_calc(wd->zoom);
339 g->tsize = wd->tsize;
340 g->iw = wd->size.imw;
341 g->ih = wd->size.imh;
343 g->w = g->iw / g->zoom;
344 g->h = g->ih / g->zoom;
352 g->gw = (g->w + g->tsize - 1) / g->tsize;
353 g->gh = (g->h + g->tsize - 1) / g->tsize;
360 g->grid = calloc(1, sizeof(Grid_Item) * g->gw * g->gh);
367 for (y = 0; y < g->gh; y++)
369 for (x = 0; x < g->gw; x++)
373 tn = (y * g->gw) + x;
374 g->grid[tn].src.x = x * g->tsize;
375 if (x == (g->gw - 1))
376 g->grid[tn].src.w = g->w - ((g->gw - 1) * g->tsize);
378 g->grid[tn].src.w = g->tsize;
379 g->grid[tn].src.y = y * g->tsize;
380 if (y == (g->gh - 1))
381 g->grid[tn].src.h = g->h - ((g->gh - 1) * g->tsize);
383 g->grid[tn].src.h = g->tsize;
385 g->grid[tn].out.x = g->grid[tn].src.x;
386 g->grid[tn].out.y = g->grid[tn].src.y;
387 g->grid[tn].out.w = g->grid[tn].src.w;
388 g->grid[tn].out.h = g->grid[tn].src.h;
392 evas_object_image_add(evas_object_evas_get(obj));
393 evas_object_image_load_orientation_set(g->grid[tn].img, EINA_TRUE);
394 evas_object_image_scale_hint_set
395 (g->grid[tn].img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
396 evas_object_pass_events_set(g->grid[tn].img, EINA_TRUE);
397 evas_object_smart_member_add(g->grid[tn].img,
399 elm_widget_sub_object_add(obj, g->grid[tn].img);
400 evas_object_image_filled_set(g->grid[tn].img, 1);
401 evas_object_event_callback_add(g->grid[tn].img,
402 EVAS_CALLBACK_IMAGE_PRELOADED,
411 grid_load(Evas_Object *obj, Grid *g)
413 Widget_Data *wd = elm_widget_data_get(obj);
415 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh, gw, gh, tx, ty;
417 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
418 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh);
421 for (y = 0; y < g->gh; y++)
423 for (x = 0; x < g->gw; x++)
425 int tn, xx, yy, ww, hh;
426 Eina_Bool visible = EINA_FALSE;
428 tn = (y * g->gw) + x;
429 xx = g->grid[tn].out.x;
430 yy = g->grid[tn].out.y;
431 ww = g->grid[tn].out.w;
432 hh = g->grid[tn].out.h;
433 if ((gw != g->w) && (g->w > 0))
436 xx = (gw * xx) / g->w;
437 ww = ((gw * (tx + ww)) / g->w) - xx;
439 if ((gh != g->h) && (g->h > 0))
442 yy = (gh * yy) / g->h;
443 hh = ((gh * (ty + hh)) / g->h) - yy;
445 if (ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
450 if ((visible) && (!g->grid[tn].have) && (!g->grid[tn].want))
452 g->grid[tn].want = 1;
453 evas_object_hide(g->grid[tn].img);
454 evas_object_image_file_set(g->grid[tn].img, NULL, NULL);
455 evas_object_image_load_scale_down_set(g->grid[tn].img, g->zoom);
456 evas_object_image_load_region_set(g->grid[tn].img,
461 evas_object_image_file_set(g->grid[tn].img, wd->file, NULL);
462 evas_object_image_preload(g->grid[tn].img, 0);
464 if (wd->preload_num == 1)
466 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
467 "elm,state,busy,start", "elm");
468 evas_object_smart_callback_call(obj, SIG_LOAD_DETAIL, NULL);
471 else if ((g->grid[tn].want) && (!visible))
474 if (!wd->preload_num)
476 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
477 "elm,state,busy,stop", "elm");
478 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL, NULL);
480 g->grid[tn].want = 0;
481 evas_object_hide(g->grid[tn].img);
482 evas_object_image_preload(g->grid[tn].img, 1);
483 evas_object_image_file_set(g->grid[tn].img, NULL, NULL);
485 else if ((g->grid[tn].have) && (!visible))
487 g->grid[tn].have = 0;
488 evas_object_hide(g->grid[tn].img);
489 evas_object_image_preload(g->grid[tn].img, 1);
490 evas_object_image_file_set(g->grid[tn].img, NULL, NULL);
497 grid_clearall(Evas_Object *obj)
499 Widget_Data *wd = elm_widget_data_get(obj);
502 EINA_LIST_FREE(wd->grids, g)
510 _smooth_update(Evas_Object *obj)
512 Widget_Data *wd = elm_widget_data_get(obj);
517 EINA_LIST_FOREACH(wd->grids, l, g)
519 for (y = 0; y < g->gh; y++)
521 for (x = 0; x < g->gw; x++)
525 tn = (y * g->gw) + x;
526 evas_object_image_smooth_scale_set(g->grid[tn].img, (!wd->nosmooth));
530 evas_object_image_smooth_scale_set(wd->img, (!wd->nosmooth));
538 for (y = 0; y < g->gh; y++)
540 for (x = 0; x < g->gw; x++)
544 tn = (y * g->gw) + x;
545 evas_object_raise(g->grid[tn].img);
551 _scr_timeout(void *data)
553 Widget_Data *wd = elm_widget_data_get(data);
554 if (!wd) return ECORE_CALLBACK_CANCEL;
556 if (!wd->nosmooth) _smooth_update(data);
557 wd->scr_timer = NULL;
558 return ECORE_CALLBACK_CANCEL;
562 _scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
564 Widget_Data *wd = elm_widget_data_get(data);
569 if (wd->nosmooth == 1) _smooth_update(data);
571 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
572 wd->scr_timer = ecore_timer_add(0.5, _scr_timeout, data);
576 _main_preloaded(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
578 Evas_Object *obj = data;
579 Widget_Data *wd = elm_widget_data_get(obj);
582 evas_object_show(wd->img);
583 wd->main_load_pending = 0;
584 g = grid_create(obj);
587 wd->grids = eina_list_prepend(wd->grids, g);
588 grid_load(wd->obj, g);
590 if (wd->calc_job) ecore_job_del(wd->calc_job);
591 wd->calc_job = ecore_job_add(_calc_job, wd);
592 evas_object_smart_callback_call(data, SIG_LOADED, NULL);
594 if (!wd->preload_num)
596 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
597 "elm,state,busy,stop", "elm");
598 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL, NULL);
603 zoom_do(Evas_Object *obj, double t)
605 Widget_Data *wd = elm_widget_data_get(obj);
606 Evas_Coord xx, yy, ow, oh;
607 if (!wd) return ECORE_CALLBACK_CANCEL;
608 wd->size.w = (wd->size.ow * (1.0 - t)) + (wd->size.nw * t);
609 wd->size.h = (wd->size.oh * (1.0 - t)) + (wd->size.nh * t);
610 elm_smart_scroller_child_viewport_size_get(wd->scr, &ow, &oh);
611 xx = (wd->size.spos.x * wd->size.w) - (ow / 2);
612 yy = (wd->size.spos.y * wd->size.h) - (oh / 2);
614 else if (xx > (wd->size.w - ow)) xx = wd->size.w - ow;
616 else if (yy > (wd->size.h - oh)) yy = wd->size.h - oh;
618 wd->show.show = EINA_TRUE;
624 if (wd->calc_job) ecore_job_del(wd->calc_job);
625 wd->calc_job = ecore_job_add(_calc_job, wd);
628 Eina_List *l, *l_next;
631 EINA_LIST_FOREACH_SAFE(wd->grids, l, l_next, g)
635 wd->grids = eina_list_remove_list(wd->grids, l);
640 return ECORE_CALLBACK_CANCEL;
642 return ECORE_CALLBACK_RENEW;
647 _zoom_anim(void *data)
649 Evas_Object *obj = data;
650 Widget_Data *wd = elm_widget_data_get(obj);
653 if (!wd) return ECORE_CALLBACK_CANCEL;
654 t = ecore_loop_time_get();
657 else if (wd->t_end > wd->t_start)
658 t = (t - wd->t_start) / (wd->t_end - wd->t_start);
663 go = zoom_do(obj, t);
667 if (!wd->nosmooth) _smooth_update(data);
668 wd->zoom_animator = NULL;
669 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
675 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
677 Widget_Data *wd = elm_widget_data_get(data);
678 // Evas_Event_Mouse_Move *ev = event_info;
683 _long_press(void *data)
685 Widget_Data *wd = elm_widget_data_get(data);
686 if (!wd) return ECORE_CALLBACK_CANCEL;
687 wd->long_timer = NULL;
688 wd->longpressed = EINA_TRUE;
689 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
690 return ECORE_CALLBACK_CANCEL;
694 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
696 Widget_Data *wd = elm_widget_data_get(data);
697 Evas_Event_Mouse_Down *ev = event_info;
699 if (ev->button != 1) return;
700 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
701 else wd->on_hold = EINA_FALSE;
702 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
703 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
705 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
706 wd->longpressed = EINA_FALSE;
707 if (wd->long_timer) ecore_timer_del(wd->long_timer);
708 wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
712 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
714 Widget_Data *wd = elm_widget_data_get(data);
715 Evas_Event_Mouse_Up *ev = event_info;
717 if (ev->button != 1) return;
718 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
719 else wd->on_hold = EINA_FALSE;
722 ecore_timer_del(wd->long_timer);
723 wd->long_timer = NULL;
726 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
727 wd->on_hold = EINA_FALSE;
730 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_NULL;
733 _del_hook(Evas_Object *obj)
735 Widget_Data *wd = elm_widget_data_get(obj);
738 EINA_LIST_FREE(wd->grids, g)
740 if (g->grid) free(g->grid);
743 evas_object_del(wd->pan_smart);
744 wd->pan_smart = NULL;
745 if (wd->file) eina_stringshare_del(wd->file);
746 if (wd->calc_job) ecore_job_del(wd->calc_job);
747 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
748 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
751 if (wd->gzoom.bounce.animator) ecore_animator_del(wd->gzoom.bounce.animator);
752 >>>>>>> remotes/origin/upstream
753 if (wd->long_timer) ecore_timer_del(wd->long_timer);
758 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
760 Widget_Data *wd = elm_widget_data_get(obj);
762 if (elm_widget_focus_get(obj))
764 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,focus", "elm");
765 evas_object_focus_set(wd->obj, EINA_TRUE);
769 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,unfocus", "elm");
770 evas_object_focus_set(wd->obj, EINA_FALSE);
775 _theme_hook(Evas_Object *obj)
777 Widget_Data *wd = elm_widget_data_get(obj);
779 elm_smart_scroller_object_theme_set(obj, wd->scr, "photocam", "base", elm_widget_style_get(obj));
780 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
786 _show_region_hook(void *data, Evas_Object *obj)
788 Widget_Data *wd = elm_widget_data_get(data);
789 Evas_Coord x, y, w, h;
791 elm_widget_show_region_get(obj, &x, &y, &w, &h);
792 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
797 _sizing_eval(Evas_Object *obj)
799 Widget_Data *wd = elm_widget_data_get(obj);
800 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
802 // evas_object_size_hint_min_get(wd->scr, &minw, &minh);
803 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
806 // if (wd->mode != ELM_LIST_LIMIT) minw = -1;
807 evas_object_size_hint_min_set(obj, minw, minh);
808 evas_object_size_hint_max_set(obj, maxw, maxh);
812 _calc_job(void *data)
814 Widget_Data *wd = data;
815 Evas_Coord minw, minh;
822 if (wd->mode != ELM_PHOTOCAM_ZOOM_MODE_MANUAL)
824 double tz = wd->zoom;
826 elm_photocam_zoom_set(wd->obj, tz);
829 if ((minw != wd->minw) || (minh != wd->minh))
833 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
834 _sizing_eval(wd->obj);
837 evas_object_smart_changed(wd->pan_smart);
841 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
843 Pan *sd = evas_object_smart_data_get(obj);
845 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
848 evas_object_smart_changed(obj);
852 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
854 Pan *sd = evas_object_smart_data_get(obj);
856 if (x) *x = sd->wd->pan_x;
857 if (y) *y = sd->wd->pan_y;
861 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
863 Pan *sd = evas_object_smart_data_get(obj);
866 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
867 ow = sd->wd->minw - ow;
869 oh = sd->wd->minh - oh;
876 _pan_min_get(Evas_Object *obj __UNUSED__, Evas_Coord *x, Evas_Coord *y)
883 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
885 Pan *sd = evas_object_smart_data_get(obj);
887 if (w) *w = sd->wd->minw;
888 if (h) *h = sd->wd->minh;
892 _pan_add(Evas_Object *obj)
895 Evas_Object_Smart_Clipped_Data *cd;
897 cd = evas_object_smart_data_get(obj);
899 sd = calloc(1, sizeof(Pan));
901 sd->__clipped_data = *cd;
903 evas_object_smart_data_set(obj, sd);
907 _pan_del(Evas_Object *obj)
909 Pan *sd = evas_object_smart_data_get(obj);
915 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
917 Pan *sd = evas_object_smart_data_get(obj);
920 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
921 if ((ow == w) && (oh == h)) return;
923 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
924 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
928 _pan_calculate(Evas_Object *obj)
930 Pan *sd = evas_object_smart_data_get(obj);
931 Evas_Coord ox, oy, ow, oh;
935 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
937 img_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
938 EINA_LIST_FOREACH(sd->wd->grids, l, g)
940 grid_load(sd->wd->obj, g);
941 grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
943 img_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y,
944 ox - sd->wd->gzoom.imx, oy - sd->wd->gzoom.imy, ow, oh);
945 EINA_LIST_FOREACH(sd->wd->grids, l, g)
947 grid_load(sd->wd->obj, g);
948 grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y,
949 ox - sd->wd->gzoom.imx, oy - sd->wd->gzoom.imy, ow, oh);
950 >>>>>>> remotes/origin/upstream
955 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
957 Pan *sd = evas_object_smart_data_get(obj);
959 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
960 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
964 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
966 Widget_Data *wd = elm_widget_data_get(obj);
968 elm_smart_scroller_hold_set(wd->scr, 1);
972 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
974 Widget_Data *wd = elm_widget_data_get(obj);
976 elm_smart_scroller_hold_set(wd->scr, 0);
980 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
982 Widget_Data *wd = elm_widget_data_get(obj);
984 elm_smart_scroller_freeze_set(wd->scr, 1);
988 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
990 Widget_Data *wd = elm_widget_data_get(obj);
992 elm_smart_scroller_freeze_set(wd->scr, 0);
996 _scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
998 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
1002 _scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1004 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
1008 _scr_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1010 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
1014 _scr_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1016 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
1020 _scr_scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1022 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
1026 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__,
1027 Evas_Callback_Type type, void *event_info)
1030 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
1031 Evas_Event_Key_Down *ev = event_info;
1032 Widget_Data *wd = elm_widget_data_get(obj);
1033 if (!wd) return EINA_FALSE;
1034 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
1038 Evas_Coord step_x = 0;
1039 Evas_Coord step_y = 0;
1042 Evas_Coord page_x = 0;
1043 Evas_Coord page_y = 0;
1045 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
1046 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
1047 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
1048 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
1050 if ((!strcmp(ev->keyname, "Left")) ||
1051 (!strcmp(ev->keyname, "KP_Left")))
1055 else if ((!strcmp(ev->keyname, "Right")) ||
1056 (!strcmp(ev->keyname, "KP_Right")))
1060 else if ((!strcmp(ev->keyname, "Up")) ||
1061 (!strcmp(ev->keyname, "KP_Up")))
1065 else if ((!strcmp(ev->keyname, "Down")) ||
1066 (!strcmp(ev->keyname, "KP_Down")))
1070 else if ((!strcmp(ev->keyname, "Prior")) ||
1071 (!strcmp(ev->keyname, "KP_Prior")))
1074 y -= -(page_y * v_h) / 100;
1078 else if ((!strcmp(ev->keyname, "Next")) ||
1079 (!strcmp(ev->keyname, "KP_Next")))
1082 y += -(page_y * v_h) / 100;
1086 else if ((!strcmp(ev->keyname, "KP_Add")))
1088 zoom = elm_photocam_zoom_get(obj);
1090 elm_photocam_zoom_mode_set(obj, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
1091 elm_photocam_zoom_set(obj, zoom);
1094 else if ((!strcmp(ev->keyname, "KP_Subtract")))
1096 zoom = elm_photocam_zoom_get(obj);
1098 elm_photocam_zoom_mode_set(obj, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
1099 elm_photocam_zoom_set(obj, zoom);
1102 else return EINA_FALSE;
1104 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1105 elm_smart_scroller_child_pos_set(wd->scr, x, y);
1113 _bounce_eval(void *_wd)
1115 Widget_Data *wd = (Widget_Data *)_wd;
1118 if (!wd) return ECORE_CALLBACK_CANCEL;
1119 if ((wd->gzoom.imx == wd->gzoom.bounce.x_end) &&
1120 (wd->gzoom.imy == wd->gzoom.bounce.y_end))
1124 wd->zoom_gest = EINA_FALSE;
1125 wd->gzoom.bounce.animator = NULL;
1126 _freeze_off(NULL, wd->obj, NULL);
1127 return ECORE_CALLBACK_CANCEL;
1130 t = ecore_loop_time_get();
1131 tt = (t - wd->gzoom.bounce.t_start) / (wd->gzoom.bounce.t_end - wd->gzoom.bounce.t_start);
1133 tt = 1.0 - (tt * tt);
1135 if (t > wd->gzoom.bounce.t_end)
1139 wd->zoom_gest = EINA_FALSE;
1140 _freeze_off(NULL, wd->obj, NULL);
1141 zoom_do(wd->obj, 1.0);
1142 wd->gzoom.bounce.animator = NULL;
1143 return ECORE_CALLBACK_CANCEL;
1146 if (wd->gzoom.imx != wd->gzoom.bounce.x_end)
1147 wd->gzoom.imx = wd->gzoom.bounce.x_start * (1.0 - tt) + wd->gzoom.bounce.x_end * tt;
1149 if (wd->gzoom.imy != wd->gzoom.bounce.y_end)
1150 wd->gzoom.imy = wd->gzoom.bounce.y_start * (1.0 - tt) + wd->gzoom.bounce.y_end * tt;
1152 zoom_do(wd->obj, 1.0 - (1.0 - tt));
1153 return ECORE_CALLBACK_RENEW;
1157 _gzoom(Widget_Data *_wd, Evas_Coord px, Evas_Coord py, Elm_Gesture_Zoom_Info* gest)
1159 Widget_Data *wd = (Widget_Data *)_wd;
1160 Evas_Coord rx, ry, rw, rh;
1161 int regx, regy, regw, regh, ix, iy, iw, ih;
1165 wd->mode = ELM_PHOTOCAM_ZOOM_MODE_MANUAL;
1166 wd->zoom = wd->gest_start / gest->zoom;
1167 wd->size.ow = wd->size.w;
1168 wd->size.oh = wd->size.h;
1169 elm_smart_scroller_child_pos_get(wd->scr, &rx, &ry);
1170 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
1171 if ((rw <= 0) || (rh <= 0)) return;
1173 wd->size.nw = (double)wd->size.imw / wd->zoom;
1174 wd->size.nh = (double)wd->size.imh / wd->zoom;
1176 elm_photocam_image_region_get(wd->obj, ®x, ®y, ®w, ®h);
1177 evas_object_geometry_get(wd->img, &ix, &iy, &iw, &ih);
1182 xx = (px / wd->zoom) - wd->pvx;
1183 yy = (py / wd->zoom) - wd->pvy;
1187 if ((xx < 0) || (rw > wd->size.nw))
1192 else if ((xx + rw) > wd->size.nw)
1194 wd->gzoom.imx = xx + rw - wd->size.nw;
1195 xx = wd->size.nw - rw;
1198 if ((yy < 0) || (rh > wd->size.nh))
1203 else if ((yy + rh) > wd->size.nh)
1205 wd->gzoom.imy = yy + rh - wd->size.nh;
1206 yy = wd->size.nh - rh;
1209 wd->size.spos.x = (double)(xx + (rw / 2)) / (double)(wd->size.nw);
1210 wd->size.spos.y = (double)(yy + (rh / 2)) / (double)(wd->size.nh);
1212 zoom_do(wd->obj, 1.0);
1215 static Evas_Event_Flags
1216 _gzoom_start(void *_wd, void *event_info)
1218 Widget_Data *wd = (Widget_Data *)_wd;
1219 Elm_Gesture_Zoom_Info *p = (Elm_Gesture_Zoom_Info *) event_info;
1222 double marginx = 0, marginy = 0;
1224 if (wd->gzoom.bounce.animator)
1226 ecore_animator_del(wd->gzoom.bounce.animator);
1227 wd->gzoom.bounce.animator = NULL;
1229 wd->zoom_gest = EINA_TRUE;
1230 _freeze_on(NULL, wd->obj, NULL);
1232 elm_photocam_image_region_get(wd->obj, &x, &y, &w, &h);
1233 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
1235 if (rw > wd->size.nw)
1236 marginx = (rw - wd->size.nw) / 2;
1237 if (rh > wd->size.nh)
1238 marginy = (rh - wd->size.nh) / 2;
1240 wd->gest_start = wd->zoom;
1242 wd->zoom_point_x = x + ((p->x - marginx) * wd->zoom) + wd->gzoom.imx;
1243 wd->zoom_point_y = y + ((p->y - marginy) * wd->zoom) + wd->gzoom.imy;
1245 return EVAS_EVENT_FLAG_NONE;
1248 static Evas_Event_Flags
1249 _gzoom_move(void *_wd, void *event_info)
1251 Widget_Data *wd = (Widget_Data *)_wd;
1252 Elm_Gesture_Zoom_Info *p = (Elm_Gesture_Zoom_Info *) event_info;
1254 _gzoom(wd, wd->zoom_point_x, wd->zoom_point_y, p);
1255 return EVAS_EVENT_FLAG_NONE;
1258 static Evas_Event_Flags
1259 _gzoom_end(void *_wd, void *event_info __UNUSED__)
1261 Widget_Data *wd = (Widget_Data *)_wd;
1264 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
1265 wd->gest_start = 1.0;
1267 if (wd->gzoom.imx || wd->gzoom.imy)
1271 t = ecore_loop_time_get();
1272 wd->gzoom.bounce.x_start = wd->gzoom.imx;
1273 wd->gzoom.bounce.y_start = wd->gzoom.imy;
1274 wd->gzoom.bounce.x_end = 0;
1275 wd->gzoom.bounce.y_end = 0;
1277 if (rw > wd->size.nw &&
1283 if ((wd->size.imw < rw) && (wd->size.imh < rh))
1286 wd->size.nw = wd->size.imw;
1287 wd->size.nh = wd->size.imh;
1291 ph = (wd->size.imh * rw) / wd->size.imw;
1294 pw = (wd->size.imw * rh) / wd->size.imh;
1301 if (wd->size.imw > wd->size.imh)
1302 z = (double)wd->size.imw / pw;
1304 z = (double)wd->size.imh / ph;
1310 wd->gzoom.bounce.x_end = (wd->size.nw - rw) / 2;
1311 wd->gzoom.bounce.y_end = (wd->size.nh - rh) / 2;
1317 xx = (wd->zoom_point_x / wd->zoom) - wd->pvx;
1318 yy = (wd->zoom_point_y / wd->zoom) - wd->pvy;
1323 if (rw > wd->size.nw)
1324 wd->gzoom.bounce.x_end = (wd->size.nw -rw) / 2;
1325 if ((xx + rw) > wd->size.nw)
1326 xx = wd->size.nw - rw;
1328 if (rh > wd->size.nh)
1329 wd->gzoom.bounce.y_end = (wd->size.nh - rh) / 2;
1330 if ((yy + rh) > wd->size.nh)
1331 yy = wd->size.nh - rh;
1333 wd->size.spos.x = (double)(xx + (rw / 2)) / (double)(wd->size.nw);
1334 wd->size.spos.y = (double)(yy + (rh / 2)) / (double)(wd->size.nh);
1337 wd->gzoom.bounce.t_start = t;
1338 wd->gzoom.bounce.t_end = t + _elm_config->page_scroll_friction;
1340 wd->gzoom.bounce.animator = ecore_animator_add(_bounce_eval, wd);
1344 _freeze_off(NULL, wd->obj, NULL);
1345 wd->zoom_gest = EINA_FALSE;
1348 return EVAS_EVENT_FLAG_NONE;
1351 >>>>>>> remotes/origin/upstream
1353 elm_photocam_add(Evas_Object *parent)
1358 Evas_Coord minw, minh;
1359 static Evas_Smart *smart = NULL;
1360 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1362 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1364 ELM_SET_WIDTYPE(widtype, "photocam");
1365 elm_widget_type_set(obj, "photocam");
1366 elm_widget_sub_object_add(parent, obj);
1367 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1368 elm_widget_data_set(obj, wd);
1369 elm_widget_del_hook_set(obj, _del_hook);
1370 elm_widget_theme_hook_set(obj, _theme_hook);
1371 elm_widget_can_focus_set(obj, EINA_TRUE);
1372 elm_widget_event_hook_set(obj, _event_hook);
1374 wd->scr = elm_smart_scroller_add(e);
1375 elm_smart_scroller_widget_set(wd->scr, obj);
1376 elm_smart_scroller_object_theme_set(obj, wd->scr, "photocam", "base", "default");
1377 evas_object_smart_callback_add(wd->scr, "scroll", _scr, obj);
1378 evas_object_smart_callback_add(wd->scr, "drag", _scr, obj);
1379 elm_widget_resize_object_set(obj, wd->scr);
1381 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
1382 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
1383 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1384 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1385 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1387 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
1391 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1392 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1393 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1394 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1398 static Evas_Smart_Class sc;
1400 evas_object_smart_clipped_smart_set(&_pan_sc);
1402 sc.name = "elm_photocam_pan";
1403 sc.version = EVAS_SMART_CLASS_VERSION;
1406 sc.resize = _pan_resize;
1407 sc.move = _pan_move;
1408 sc.calculate = _pan_calculate;
1409 smart = evas_smart_class_new(&sc);
1413 wd->pan_smart = evas_object_smart_add(e, smart);
1414 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1418 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1419 _pan_set, _pan_get, _pan_max_get,
1420 _pan_min_get, _pan_child_size_get);
1424 wd->mode = ELM_PHOTOCAM_ZOOM_MODE_MANUAL;
1427 wd->zoom_gest = EINA_FALSE;
1428 wd->gest_start = 1.0;
1430 wd->mode = ELM_PHOTOCAM_ZOOM_MODE_MANUAL;
1431 >>>>>>> remotes/origin/upstream
1434 wd->img = evas_object_image_add(e);
1435 evas_object_image_load_orientation_set(wd->img, EINA_TRUE);
1436 evas_object_image_scale_hint_set(wd->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
1437 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_DOWN,
1439 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_UP,
1441 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_MOVE,
1443 evas_object_image_scale_hint_set(wd->img, EVAS_IMAGE_SCALE_HINT_STATIC);
1444 evas_object_smart_member_add(wd->img, wd->pan_smart);
1445 elm_widget_sub_object_add(obj, wd->img);
1446 evas_object_image_filled_set(wd->img, 1);
1447 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_IMAGE_PRELOADED,
1448 _main_preloaded, obj);
1450 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
1452 evas_object_size_hint_min_set(obj, minw, minh);
1454 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1460 EAPI Evas_Load_Error
1461 elm_photocam_file_set(Evas_Object *obj, const char *file)
1463 ELM_CHECK_WIDTYPE(obj, widtype) EVAS_LOAD_ERROR_NONE;
1464 Widget_Data *wd = elm_widget_data_get(obj);
1466 if (!wd) return EVAS_LOAD_ERROR_GENERIC;
1467 if (!eina_stringshare_replace(&wd->file, file)) return EVAS_LOAD_ERROR_NONE;
1470 evas_object_hide(wd->img);
1471 evas_object_image_smooth_scale_set(wd->img, (wd->nosmooth == 0));
1472 evas_object_image_file_set(wd->img, NULL, NULL);
1473 evas_object_image_load_scale_down_set(wd->img, 0);
1474 evas_object_image_file_set(wd->img, wd->file, NULL);
1475 evas_object_image_size_get(wd->img, &w, &h);
1476 wd->do_region = evas_object_image_region_support_get(wd->img);
1479 wd->size.w = wd->size.imw / wd->zoom;
1480 wd->size.h = wd->size.imh / wd->zoom;
1483 if (wd->gzoom.bounce.animator)
1485 ecore_animator_del(wd->gzoom.bounce.animator);
1486 wd->gzoom.bounce.animator = NULL;
1488 >>>>>>> remotes/origin/upstream
1489 if (wd->zoom_animator)
1492 if (wd->nosmooth == 0) _smooth_update(obj);
1493 ecore_animator_del(wd->zoom_animator);
1494 wd->zoom_animator = NULL;
1496 evas_object_image_file_set(wd->img, NULL, NULL);
1497 evas_object_image_load_scale_down_set(wd->img, 8);
1498 evas_object_image_file_set(wd->img, wd->file, NULL);
1499 evas_object_image_preload(wd->img, 0);
1500 wd->main_load_pending = 1;
1501 if (wd->calc_job) ecore_job_del(wd->calc_job);
1502 wd->calc_job = ecore_job_add(_calc_job, wd);
1503 evas_object_smart_callback_call(obj, SIG_LOAD, NULL);
1505 if (wd->preload_num == 1)
1507 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
1508 "elm,state,busy,start", "elm");
1509 evas_object_smart_callback_call(obj, SIG_LOAD_DETAIL, NULL);
1513 double tz = wd->zoom;
1515 elm_photocam_zoom_set(wd->obj, tz);
1519 double tz = wd->zoom;
1521 elm_photocam_zoom_set(wd->obj, tz);
1523 >>>>>>> remotes/origin/upstream
1524 return evas_object_image_load_error_get(wd->img);
1528 elm_photocam_file_get(const Evas_Object *obj)
1530 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1531 Widget_Data *wd = elm_widget_data_get(obj);
1532 if (!wd) return NULL;
1537 elm_photocam_zoom_set(Evas_Object *obj, double zoom)
1539 ELM_CHECK_WIDTYPE(obj, widtype);
1540 Widget_Data *wd = elm_widget_data_get(obj);
1542 Grid *g, *g_zoom = NULL;
1543 Evas_Coord pw, ph, rx, ry, rw, rh;
1545 int zoom_changed = 0, started = 0;
1548 if (zoom <= (1.0 / 256.0)) zoom = (1.0 / 256.0);
1549 if (zoom == wd->zoom) return;
1551 wd->size.ow = wd->size.w;
1552 wd->size.oh = wd->size.h;
1553 elm_smart_scroller_child_pos_get(wd->scr, &rx, &ry);
1554 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
1555 if ((rw <= 0) || (rh <= 0)) return;
1557 if (wd->mode == ELM_PHOTOCAM_ZOOM_MODE_MANUAL)
1559 wd->size.nw = (double)wd->size.imw / wd->zoom;
1560 wd->size.nh = (double)wd->size.imh / wd->zoom;
1562 else if (wd->mode == ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT)
1564 if ((wd->size.imw < 1) || (wd->size.imh < 1))
1571 ph = (wd->size.imh * rw) / wd->size.imw;
1574 pw = (wd->size.imw * rh) / wd->size.imh;
1581 if (wd->size.imw > wd->size.imh)
1582 z = (double)wd->size.imw / pw;
1584 z = (double)wd->size.imh / ph;
1592 else if (wd->mode == ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL)
1594 if ((wd->size.imw < 1) || (wd->size.imh < 1))
1601 ph = (wd->size.imh * rw) / wd->size.imw;
1604 pw = (wd->size.imw * rh) / wd->size.imh;
1611 if (wd->size.imw > wd->size.imh)
1612 z = (double)wd->size.imw / pw;
1614 z = (double)wd->size.imh / ph;
1624 else if (wd->mode == ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT_IN)
1626 if ((wd->size.imw < 1) || (wd->size.imh < 1))
1631 else if ((wd->size.imw < rw) && (wd->size.imh < rh))
1633 if (1 != wd->zoom) zoom_changed = 1;
1635 wd->size.nw = wd->size.imw;
1636 wd->size.nh = wd->size.imh;
1640 ph = (wd->size.imh * rw) / wd->size.imw;
1643 pw = (wd->size.imw * rh) / wd->size.imh;
1648 if (wd->size.imw > wd->size.imh)
1649 z = (double)wd->size.imw / pw;
1651 z = (double)wd->size.imh / ph;
1659 >>>>>>> remotes/origin/upstream
1660 if (wd->main_load_pending)
1662 wd->size.w = wd->size.nw;
1663 wd->size.h = wd->size.nh;
1666 EINA_LIST_FOREACH(wd->grids, l, g)
1668 if (g->zoom == grid_zoom_calc(wd->zoom))
1670 wd->grids = eina_list_remove(wd->grids, g);
1671 wd->grids = eina_list_prepend(wd->grids, g);
1676 g = grid_create(obj);
1679 if (eina_list_count(wd->grids) > 1)
1681 g_zoom = eina_list_last(wd->grids)->data;
1682 wd->grids = eina_list_remove(wd->grids, g_zoom);
1683 grid_clear(obj, g_zoom);
1685 EINA_LIST_FOREACH(wd->grids, l, g_zoom)
1690 wd->grids = eina_list_prepend(wd->grids, g);
1694 EINA_LIST_FREE(wd->grids, g)
1704 >>>>>>> remotes/origin/upstream
1705 wd->t_start = ecore_loop_time_get();
1706 wd->t_end = wd->t_start + _elm_config->zoom_friction;
1707 if ((wd->size.w > 0) && (wd->size.h > 0))
1709 wd->size.spos.x = (double)(rx + (rw / 2)) / (double)wd->size.w;
1710 wd->size.spos.y = (double)(ry + (rh / 2)) / (double)wd->size.h;
1714 wd->size.spos.x = 0.5;
1715 wd->size.spos.y = 0.5;
1717 if (rw > wd->size.w) wd->size.spos.x = 0.5;
1718 if (rh > wd->size.h) wd->size.spos.y = 0.5;
1719 if (wd->size.spos.x > 1.0) wd->size.spos.x = 1.0;
1720 if (wd->size.spos.y > 1.0) wd->size.spos.y = 1.0;
1727 if (!wd->zoom_animator)
1729 wd->zoom_animator = ecore_animator_add(_zoom_anim, obj);
1731 if (wd->nosmooth == 1) _smooth_update(obj);
1735 an = wd->zoom_animator;
1738 if (!_zoom_anim(obj))
1740 ecore_animator_del(an);
1744 if (wd->calc_job) ecore_job_del(wd->calc_job);
1745 wd->calc_job = ecore_job_add(_calc_job, wd);
1749 evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL);
1751 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
1754 evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL);
1758 elm_photocam_zoom_get(const Evas_Object *obj)
1760 ELM_CHECK_WIDTYPE(obj, widtype) 1.0;
1761 Widget_Data *wd = elm_widget_data_get(obj);
1762 if (!wd) return 1.0;
1767 elm_photocam_zoom_mode_set(Evas_Object *obj, Elm_Photocam_Zoom_Mode mode)
1769 ELM_CHECK_WIDTYPE(obj, widtype);
1770 Widget_Data *wd = elm_widget_data_get(obj);
1772 if (wd->mode == mode) return;
1776 double tz = wd->zoom;
1778 elm_photocam_zoom_set(wd->obj, tz);
1782 double tz = wd->zoom;
1784 elm_photocam_zoom_set(wd->obj, tz);
1786 >>>>>>> remotes/origin/upstream
1789 EAPI Elm_Photocam_Zoom_Mode
1790 elm_photocam_zoom_mode_get(const Evas_Object *obj)
1792 ELM_CHECK_WIDTYPE(obj, widtype) ELM_PHOTOCAM_ZOOM_MODE_LAST;
1793 Widget_Data *wd = elm_widget_data_get(obj);
1794 if (!wd) return ELM_PHOTOCAM_ZOOM_MODE_LAST;
1799 elm_photocam_image_size_get(const Evas_Object *obj, int *w, int *h)
1801 ELM_CHECK_WIDTYPE(obj, widtype);
1802 Widget_Data *wd = elm_widget_data_get(obj);
1804 if (w) *w = wd->size.imw;
1805 if (h) *h = wd->size.imh;
1810 elm_photocam_region_get(const Evas_Object *obj, int *x, int *y, int *w, int *h)
1813 EINA_DEPRECATED EAPI void
1814 elm_photocam_region_get(const Evas_Object *obj, int *x, int *y, int *w, int *h)
1816 return elm_photocam_image_region_get(obj, x, y, w, h);
1820 elm_photocam_image_region_get(const Evas_Object *obj, int *x, int *y, int *w, int *h)
1822 >>>>>>> remotes/origin/upstream
1823 ELM_CHECK_WIDTYPE(obj, widtype);
1824 Widget_Data *wd = elm_widget_data_get(obj);
1825 Evas_Coord sx, sy, sw, sh;
1827 elm_smart_scroller_child_pos_get(wd->scr, &sx, &sy);
1828 elm_smart_scroller_child_viewport_size_get(wd->scr, &sw, &sh);
1833 *x = (wd->size.imw * sx) / wd->size.w;
1834 if (*x > wd->size.imw) *x = wd->size.imw;
1838 *w = (wd->size.imw * sw) / wd->size.w;
1839 if (*w > wd->size.imw) *w = wd->size.imw;
1840 else if (*w < 0) *w = 0;
1853 *y = (wd->size.imh * sy) / wd->size.h;
1854 if (*y > wd->size.imh) *y = wd->size.imh;
1858 *h = (wd->size.imh * sh) / wd->size.h;
1859 if (*h > wd->size.imh) *h = wd->size.imh;
1860 else if (*h < 0) *h = 0;
1871 elm_photocam_image_region_show(Evas_Object *obj, int x, int y, int w, int h __UNUSED__)
1873 ELM_CHECK_WIDTYPE(obj, widtype);
1874 Widget_Data *wd = elm_widget_data_get(obj);
1877 if ((wd->size.imw < 1) || (wd->size.imh < 1)) return;
1878 rx = (x * wd->size.w) / wd->size.imw;
1879 ry = (y * wd->size.h) / wd->size.imh;
1880 rw = (w * wd->size.w) / wd->size.imw;
1881 rh = (h * wd->size.h) / wd->size.imh;
1884 if ((rx + rw) > wd->size.w) rx = wd->size.w - rw;
1885 if ((ry + rh) > wd->size.h) ry = wd->size.h - rh;
1888 if (wd->gzoom.bounce.animator)
1890 ecore_animator_del(wd->gzoom.bounce.animator);
1891 wd->gzoom.bounce.animator = NULL;
1894 >>>>>>> remotes/origin/upstream
1895 if (wd->zoom_animator)
1898 ecore_animator_del(wd->zoom_animator);
1899 wd->zoom_animator = NULL;
1901 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
1903 elm_smart_scroller_child_region_show(wd->scr, rx, ry, rw, rh);
1907 elm_photocam_image_region_bring_in(Evas_Object *obj, int x, int y, int w, int h __UNUSED__)
1909 ELM_CHECK_WIDTYPE(obj, widtype);
1910 Widget_Data *wd = elm_widget_data_get(obj);
1913 if ((wd->size.imw < 1) || (wd->size.imh < 1)) return;
1914 rx = (x * wd->size.w) / wd->size.imw;
1915 ry = (y * wd->size.h) / wd->size.imh;
1916 rw = (w * wd->size.w) / wd->size.imw;
1917 rh = (h * wd->size.h) / wd->size.imh;
1920 if ((rx + rw) > wd->size.w) rx = wd->size.w - rw;
1921 if ((ry + rh) > wd->size.h) ry = wd->size.h - rh;
1924 if (wd->gzoom.bounce.animator)
1926 ecore_animator_del(wd->gzoom.bounce.animator);
1927 wd->gzoom.bounce.animator = NULL;
1930 >>>>>>> remotes/origin/upstream
1931 if (wd->zoom_animator)
1934 if (!wd->nosmooth) _smooth_update(obj);
1935 ecore_animator_del(wd->zoom_animator);
1936 wd->zoom_animator = NULL;
1938 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
1940 elm_smart_scroller_region_bring_in(wd->scr, rx, ry, rw, rh);
1944 elm_photocam_paused_set(Evas_Object *obj, Eina_Bool paused)
1946 ELM_CHECK_WIDTYPE(obj, widtype);
1947 Widget_Data *wd = elm_widget_data_get(obj);
1949 if (wd->paused == !!paused) return;
1950 wd->paused = paused;
1955 if (wd->gzoom.bounce.animator)
1957 ecore_animator_del(wd->gzoom.bounce.animator);
1958 wd->gzoom.bounce.animator = NULL;
1961 >>>>>>> remotes/origin/upstream
1962 if (wd->zoom_animator)
1964 ecore_animator_del(wd->zoom_animator);
1965 wd->zoom_animator = NULL;
1967 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
1973 elm_photocam_paused_get(const Evas_Object *obj)
1975 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1976 Widget_Data *wd = elm_widget_data_get(obj);
1977 if (!wd) return EINA_FALSE;
1982 elm_photocam_internal_image_get(const Evas_Object *obj)
1984 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1985 Widget_Data *wd = elm_widget_data_get(obj);
1986 if (!wd) return NULL;
1991 elm_photocam_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
1993 ELM_CHECK_WIDTYPE(obj, widtype);
1994 Widget_Data *wd = elm_widget_data_get(obj);
1996 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
2000 elm_photocam_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
2002 ELM_CHECK_WIDTYPE(obj, widtype);
2003 Widget_Data *wd = elm_widget_data_get(obj);
2005 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);
2011 elm_photocam_gesture_enabled_set(Evas_Object *obj, Eina_Bool gesture)
2013 ELM_CHECK_WIDTYPE(obj, widtype);
2014 Widget_Data *wd = elm_widget_data_get(obj);
2016 if (wd->do_gesture == !!gesture) return;
2020 evas_object_del(wd->gest);
2026 wd->gest = elm_gesture_layer_add(wd->obj);
2027 if (!wd->gest) return;
2028 elm_gesture_layer_attach(wd->gest, wd->obj);
2029 elm_gesture_layer_cb_set(wd->gest, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_START,
2031 elm_gesture_layer_cb_set(wd->gest, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_MOVE,
2033 elm_gesture_layer_cb_set(wd->gest, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_END,
2035 elm_gesture_layer_cb_set(wd->gest, ELM_GESTURE_ZOOM, ELM_GESTURE_STATE_ABORT,
2039 wd->do_gesture = !!gesture;
2043 elm_photocam_gesture_enabled_get(const Evas_Object *obj)
2045 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2046 Widget_Data *wd = elm_widget_data_get(obj);
2047 if (!wd) return EINA_FALSE;
2049 return wd->do_gesture;
2051 >>>>>>> remotes/origin/upstream