1 #include <Elementary.h>
5 * @defgroup Photocam Photocam
8 * This is a widget specifically for displaying high-resolution digital
9 * camera photos giving speedy feedback (fast load), low memory footprint
10 * and zooming and panning as well as fitting logic. It is entirely focused
11 * on jpeg images, and takes advantage of properties of the jpeg format (via
12 * evas loader features in the jpeg loader).
14 * Signals that you can add callbacks for are:
16 * "clicked" - This is called when a user has clicked the photo without dragging
18 * "press" - This is called when a user has pressed down on the photo.
19 * "longpressed" - This is called when a user has pressed down on the photo for
20 * a long time without dragging around.
21 * "clicked,double" - This is called when a user has double-clicked the photo.
22 * "load" - Photo load begins.
23 * "loaded" - This is called when the image file load is complete for the first
24 * view (low resolution blurry version).
25 * "load,detail" - Photo detailed data load begins.
26 * "loaded,detail" - This is called when the image file load is complete for
27 * the detailed image data (full resolution needed).
28 * "zoom,start" - Zoom animation started.
29 * "zoom,stop" - Zoom animation stopped.
30 * "zoom,change" - Zoom changed when using an auto zoom mode.
31 * "scroll" - the content has been scrolled (moved)
32 * "scroll,anim,start" - scrolling animation has started
33 * "scroll,anim,stop" - scrolling animation has stopped
34 * "scroll,drag,start" - dragging the contents around has started
35 * "scroll,drag,stop" - dragging the contents around has stopped
39 * TODO (maybe - optional future stuff):
41 * 1. wrap photo in theme edje so u can have styling around photo (like white
44 * 3. rotation flags in exif handling (nasty! should have rot in evas)
47 typedef struct _Widget_Data Widget_Data;
48 typedef struct _Pan Pan;
49 typedef struct _Grid Grid;
50 typedef struct _Grid_Item Grid_Item;
66 int tsize; // size of tile (tsize x tsize pixels)
67 int zoom; // zoom level tiles want for optimal display (1, 2, 4, 8)
68 int iw, ih; // size of image in pixels
69 int w, h; // size of grid image in pixels (represented by grid)
70 int gw, gh; // size of grid in tiles
71 Grid_Item *grid; // the grid (gw * gh items)
72 Eina_Bool dead : 1; // old grid. will die as soon as anim is over
79 Evas_Object *pan_smart;
81 Evas_Coord pan_x, pan_y, minw, minh;
84 Elm_Photocam_Zoom_Mode mode;
88 Ecore_Timer *scr_timer;
89 Ecore_Timer *long_timer;
90 Ecore_Animator *zoom_animator;
91 double t_start, t_end;
105 Evas_Coord x, y ,w ,h;
108 Evas_Object *img; // low res version of image (scale down == 8)
112 Eina_Bool main_load_pending : 1;
113 Eina_Bool resized : 1;
114 Eina_Bool longpressed : 1;
115 Eina_Bool on_hold : 1;
116 Eina_Bool paused : 1;
121 Evas_Object_Smart_Clipped_Data __clipped_data;
125 static const char *widtype = NULL;
126 static void _del_hook(Evas_Object *obj);
127 static void _theme_hook(Evas_Object *obj);
128 static void _on_focus_hook(void *data, Evas_Object *obj);
129 //static void _show_region_hook(void *data, Evas_Object *obj);
130 static void _sizing_eval(Evas_Object *obj);
131 static void _calc_job(void *data);
132 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__,
133 Evas_Callback_Type type, void *event_info);
134 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);
135 static void grid_clear(Evas_Object *obj, Grid *g);
136 static Grid *grid_create(Evas_Object *obj);
137 static void grid_load(Evas_Object *obj, Grid *g);
139 static const char SIG_CLICKED[] = "clicked";
140 static const char SIG_PRESS[] = "press";
141 static const char SIG_LONGPRESSED[] = "longpressed";
142 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
143 static const char SIG_LOAD[] = "load";
144 static const char SIG_LOADED[] = "loaded";
145 static const char SIG_LOAD_DETAIL[] = "load,detail";
146 static const char SIG_LOADED_DETAIL[] = "loaded,detail";
147 static const char SIG_ZOOM_START[] = "zoom,start";
148 static const char SIG_ZOOM_STOP[] = "zoom,stop";
149 static const char SIG_ZOOM_CHANGE[] = "zoom,change";
150 static const char SIG_SCROLL[] = "scroll";
151 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
152 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
153 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
154 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
156 static const Evas_Smart_Cb_Description _signals[] = {
159 {SIG_LONGPRESSED, ""},
160 {SIG_CLICKED_DOUBLE, ""},
163 {SIG_LOAD_DETAIL, ""},
164 {SIG_LOADED_DETAIL, ""},
165 {SIG_ZOOM_START, ""},
167 {SIG_ZOOM_CHANGE, ""},
169 {SIG_SCROLL_ANIM_START, ""},
170 {SIG_SCROLL_ANIM_STOP, ""},
171 {SIG_SCROLL_DRAG_START, ""},
172 {SIG_SCROLL_DRAG_STOP, ""},
178 nearest_pow2(int num)
180 unsigned int n = num - 1;
190 img_place(Evas_Object *obj, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
192 Widget_Data *wd = elm_widget_data_get(obj);
193 Evas_Coord ax, ay, gw, gh;
199 if (ow > gw) ax = (ow - gw) / 2;
200 if (oh > gh) ay = (oh - gh) / 2;
201 evas_object_move(wd->img, ox + 0 - px + ax, oy + 0 - py + ay);
202 evas_object_resize(wd->img, gw, gh);
206 wd->show.show = EINA_FALSE;
207 elm_smart_scroller_child_region_show(wd->scr, wd->show.x, wd->show.y, wd->show.w, wd->show.h);
212 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)
214 Widget_Data *wd = elm_widget_data_get(obj);
215 Evas_Coord ax, ay, gw, gh, tx, ty;
222 if (ow > gw) ax = (ow - gw) / 2;
223 if (oh > gh) ay = (oh - gh) / 2;
224 for (y = 0; y < g->gh; y++)
226 for (x = 0; x < g->gw; x++)
228 int tn, xx, yy, ww, hh;
230 tn = (y * g->gw) + x;
231 xx = g->grid[tn].out.x;
232 yy = g->grid[tn].out.y;
233 ww = g->grid[tn].out.w;
234 hh = g->grid[tn].out.h;
235 if ((gw != g->w) && (g->w > 0))
238 xx = (gw * xx) / g->w;
239 ww = ((gw * (tx + ww)) / g->w) - xx;
241 if ((gh != g->h) && (g->h > 0))
244 yy = (gh * yy) / g->h;
245 hh = ((gh * (ty + hh)) / g->h) - yy;
247 evas_object_move(g->grid[tn].img,
250 evas_object_resize(g->grid[tn].img, ww, hh);
256 grid_clear(Evas_Object *obj, Grid *g)
258 Widget_Data *wd = elm_widget_data_get(obj);
261 if (!g->grid) return;
262 for (y = 0; y < g->gh; y++)
264 for (x = 0; x < g->gw; x++)
268 tn = (y * g->gw) + x;
269 evas_object_del(g->grid[tn].img);
270 if (g->grid[tn].want)
273 if (!wd->preload_num)
275 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
276 "elm,state,busy,stop", "elm");
277 evas_object_smart_callback_call(obj, SIG_LOAD_DETAIL, NULL);
289 _tile_preloaded(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
291 Grid_Item *git = data;
296 evas_object_show(git->img);
298 git->wd->preload_num--;
299 if (!git->wd->preload_num)
301 edje_object_signal_emit(elm_smart_scroller_edje_object_get(git->wd->scr),
302 "elm,state,busy,stop", "elm");
303 evas_object_smart_callback_call(git->wd->obj, SIG_LOADED_DETAIL, NULL);
309 grid_zoom_calc(double zoom)
313 return nearest_pow2(z);
317 grid_create(Evas_Object *obj)
319 Widget_Data *wd = elm_widget_data_get(obj);
323 if (!wd) return NULL;
324 g = calloc(1, sizeof(Grid));
326 g->zoom = grid_zoom_calc(wd->zoom);
327 g->tsize = wd->tsize;
328 g->iw = wd->size.imw;
329 g->ih = wd->size.imh;
331 g->w = g->iw / g->zoom;
332 g->h = g->ih / g->zoom;
333 if (g->zoom >= 8) return NULL;
334 g->gw = (g->w + g->tsize - 1) / g->tsize;
335 g->gh = (g->h + g->tsize - 1) / g->tsize;
336 g->grid = calloc(1, sizeof(Grid_Item) * g->gw * g->gh);
343 for (y = 0; y < g->gh; y++)
345 for (x = 0; x < g->gw; x++)
349 tn = (y * g->gw) + x;
350 g->grid[tn].src.x = x * g->tsize;
351 if (x == (g->gw - 1))
352 g->grid[tn].src.w = g->w - ((g->gw - 1) * g->tsize);
354 g->grid[tn].src.w = g->tsize;
355 g->grid[tn].src.y = y * g->tsize;
356 if (y == (g->gh - 1))
357 g->grid[tn].src.h = g->h - ((g->gh - 1) * g->tsize);
359 g->grid[tn].src.h = g->tsize;
361 g->grid[tn].out.x = g->grid[tn].src.x;
362 g->grid[tn].out.y = g->grid[tn].src.y;
363 g->grid[tn].out.w = g->grid[tn].src.w;
364 g->grid[tn].out.h = g->grid[tn].src.h;
368 evas_object_image_add(evas_object_evas_get(obj));
369 evas_object_image_scale_hint_set
370 (g->grid[tn].img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
371 evas_object_pass_events_set(g->grid[tn].img, EINA_TRUE);
372 evas_object_smart_member_add(g->grid[tn].img,
374 elm_widget_sub_object_add(obj, g->grid[tn].img);
375 evas_object_image_filled_set(g->grid[tn].img, 1);
376 evas_object_event_callback_add(g->grid[tn].img,
377 EVAS_CALLBACK_IMAGE_PRELOADED,
386 grid_load(Evas_Object *obj, Grid *g)
388 Widget_Data *wd = elm_widget_data_get(obj);
390 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh, gw, gh, tx, ty;
392 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
393 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh);
396 for (y = 0; y < g->gh; y++)
398 for (x = 0; x < g->gw; x++)
400 int tn, xx, yy, ww, hh;
401 Eina_Bool visible = EINA_FALSE;
403 tn = (y * g->gw) + x;
404 xx = g->grid[tn].out.x;
405 yy = g->grid[tn].out.y;
406 ww = g->grid[tn].out.w;
407 hh = g->grid[tn].out.h;
408 if ((gw != g->w) && (g->w > 0))
411 xx = (gw * xx) / g->w;
412 ww = ((gw * (tx + ww)) / g->w) - xx;
414 if ((gh != g->h) && (g->h > 0))
417 yy = (gh * yy) / g->h;
418 hh = ((gh * (ty + hh)) / g->h) - yy;
420 if (ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
425 if ((visible) && (!g->grid[tn].have) && (!g->grid[tn].want))
427 g->grid[tn].want = 1;
428 evas_object_hide(g->grid[tn].img);
429 evas_object_image_file_set(g->grid[tn].img, NULL, NULL);
430 evas_object_image_load_scale_down_set(g->grid[tn].img, g->zoom);
431 evas_object_image_load_region_set(g->grid[tn].img,
436 evas_object_image_file_set(g->grid[tn].img, wd->file, NULL);
437 evas_object_image_preload(g->grid[tn].img, 0);
439 if (wd->preload_num == 1)
441 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
442 "elm,state,busy,start", "elm");
443 evas_object_smart_callback_call(obj, SIG_LOAD_DETAIL, NULL);
446 else if ((g->grid[tn].want) && (!visible))
449 if (!wd->preload_num)
451 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
452 "elm,state,busy,stop", "elm");
453 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL, NULL);
455 g->grid[tn].want = 0;
456 evas_object_hide(g->grid[tn].img);
457 evas_object_image_preload(g->grid[tn].img, 1);
458 evas_object_image_file_set(g->grid[tn].img, NULL, NULL);
460 else if ((g->grid[tn].have) && (!visible))
462 g->grid[tn].have = 0;
463 evas_object_hide(g->grid[tn].img);
464 evas_object_image_preload(g->grid[tn].img, 1);
465 evas_object_image_file_set(g->grid[tn].img, NULL, NULL);
472 grid_clearall(Evas_Object *obj)
474 Widget_Data *wd = elm_widget_data_get(obj);
477 EINA_LIST_FREE(wd->grids, g)
485 _smooth_update(Evas_Object *obj)
487 Widget_Data *wd = elm_widget_data_get(obj);
492 EINA_LIST_FOREACH(wd->grids, l, g)
494 for (y = 0; y < g->gh; y++)
496 for (x = 0; x < g->gw; x++)
500 tn = (y * g->gw) + x;
501 evas_object_image_smooth_scale_set(g->grid[tn].img, (!wd->nosmooth));
505 evas_object_image_smooth_scale_set(wd->img, (!wd->nosmooth));
513 for (y = 0; y < g->gh; y++)
515 for (x = 0; x < g->gw; x++)
519 tn = (y * g->gw) + x;
520 evas_object_raise(g->grid[tn].img);
526 _scr_timeout(void *data)
528 Widget_Data *wd = elm_widget_data_get(data);
529 if (!wd) return ECORE_CALLBACK_CANCEL;
531 if (!wd->nosmooth) _smooth_update(data);
532 wd->scr_timer = NULL;
533 return ECORE_CALLBACK_CANCEL;
537 _scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
539 Widget_Data *wd = elm_widget_data_get(data);
544 if (wd->nosmooth == 1) _smooth_update(data);
546 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
547 wd->scr_timer = ecore_timer_add(0.5, _scr_timeout, data);
551 _main_preloaded(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
553 Evas_Object *obj = data;
554 Widget_Data *wd = elm_widget_data_get(obj);
557 evas_object_show(wd->img);
558 wd->main_load_pending = 0;
559 g = grid_create(obj);
562 wd->grids = eina_list_prepend(wd->grids, g);
563 grid_load(wd->obj, g);
565 if (wd->calc_job) ecore_job_del(wd->calc_job);
566 wd->calc_job = ecore_job_add(_calc_job, wd);
567 evas_object_smart_callback_call(data, SIG_LOADED, NULL);
569 if (!wd->preload_num)
571 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
572 "elm,state,busy,stop", "elm");
573 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL, NULL);
578 zoom_do(Evas_Object *obj, double t)
580 Widget_Data *wd = elm_widget_data_get(obj);
581 Evas_Coord xx, yy, ow, oh;
582 if (!wd) return ECORE_CALLBACK_CANCEL;
583 wd->size.w = (wd->size.ow * (1.0 - t)) + (wd->size.nw * t);
584 wd->size.h = (wd->size.oh * (1.0 - t)) + (wd->size.nh * t);
585 elm_smart_scroller_child_viewport_size_get(wd->scr, &ow, &oh);
586 xx = (wd->size.spos.x * wd->size.w) - (ow / 2);
587 yy = (wd->size.spos.y * wd->size.h) - (oh / 2);
589 else if (xx > (wd->size.w - ow)) xx = wd->size.w - ow;
591 else if (yy > (wd->size.h - oh)) yy = wd->size.h - oh;
593 wd->show.show = EINA_TRUE;
599 if (wd->calc_job) ecore_job_del(wd->calc_job);
600 wd->calc_job = ecore_job_add(_calc_job, wd);
603 Eina_List *l, *l_next;
606 EINA_LIST_FOREACH_SAFE(wd->grids, l, l_next, g)
610 wd->grids = eina_list_remove_list(wd->grids, l);
615 return ECORE_CALLBACK_CANCEL;
617 return ECORE_CALLBACK_RENEW;
622 _zoom_anim(void *data)
624 Evas_Object *obj = data;
625 Widget_Data *wd = elm_widget_data_get(obj);
628 if (!wd) return ECORE_CALLBACK_CANCEL;
629 t = ecore_loop_time_get();
632 else if (wd->t_end > wd->t_start)
633 t = (t - wd->t_start) / (wd->t_end - wd->t_start);
638 go = zoom_do(obj, t);
642 if (!wd->nosmooth) _smooth_update(data);
643 wd->zoom_animator = NULL;
644 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
650 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
652 Widget_Data *wd = elm_widget_data_get(data);
653 // Evas_Event_Mouse_Move *ev = event_info;
658 _long_press(void *data)
660 Widget_Data *wd = elm_widget_data_get(data);
661 if (!wd) return ECORE_CALLBACK_CANCEL;
662 wd->long_timer = NULL;
663 wd->longpressed = EINA_TRUE;
664 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
665 return ECORE_CALLBACK_CANCEL;
669 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
671 Widget_Data *wd = elm_widget_data_get(data);
672 Evas_Event_Mouse_Down *ev = event_info;
674 if (ev->button != 1) return;
675 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
676 else wd->on_hold = EINA_FALSE;
677 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
678 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
680 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
681 wd->longpressed = EINA_FALSE;
682 if (wd->long_timer) ecore_timer_del(wd->long_timer);
683 wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
687 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
689 Widget_Data *wd = elm_widget_data_get(data);
690 Evas_Event_Mouse_Up *ev = event_info;
692 if (ev->button != 1) return;
693 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
694 else wd->on_hold = EINA_FALSE;
697 ecore_timer_del(wd->long_timer);
698 wd->long_timer = NULL;
701 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
702 wd->on_hold = EINA_FALSE;
705 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_NULL;
708 _del_hook(Evas_Object *obj)
710 Widget_Data *wd = elm_widget_data_get(obj);
713 EINA_LIST_FREE(wd->grids, g)
715 if (g->grid) free(g->grid);
718 evas_object_del(wd->pan_smart);
719 wd->pan_smart = NULL;
720 if (wd->file) eina_stringshare_del(wd->file);
721 if (wd->calc_job) ecore_job_del(wd->calc_job);
722 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
723 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
724 if (wd->long_timer) ecore_timer_del(wd->long_timer);
729 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
731 Widget_Data *wd = elm_widget_data_get(obj);
733 if (elm_widget_focus_get(obj))
735 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,focus", "elm");
736 evas_object_focus_set(wd->obj, EINA_TRUE);
740 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,unfocus", "elm");
741 evas_object_focus_set(wd->obj, EINA_FALSE);
746 _theme_hook(Evas_Object *obj)
748 Widget_Data *wd = elm_widget_data_get(obj);
750 elm_smart_scroller_object_theme_set(obj, wd->scr, "photocam", "base", elm_widget_style_get(obj));
751 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
757 _show_region_hook(void *data, Evas_Object *obj)
759 Widget_Data *wd = elm_widget_data_get(data);
760 Evas_Coord x, y, w, h;
762 elm_widget_show_region_get(obj, &x, &y, &w, &h);
763 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
768 _sizing_eval(Evas_Object *obj)
770 Widget_Data *wd = elm_widget_data_get(obj);
771 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
773 // evas_object_size_hint_min_get(wd->scr, &minw, &minh);
774 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
777 // if (wd->mode != ELM_LIST_LIMIT) minw = -1;
778 evas_object_size_hint_min_set(obj, minw, minh);
779 evas_object_size_hint_max_set(obj, maxw, maxh);
783 _calc_job(void *data)
785 Widget_Data *wd = data;
786 Evas_Coord minw, minh;
793 if (wd->mode != ELM_PHOTOCAM_ZOOM_MODE_MANUAL)
795 double tz = wd->zoom;
797 elm_photocam_zoom_set(wd->obj, tz);
800 if ((minw != wd->minw) || (minh != wd->minh))
804 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
805 _sizing_eval(wd->obj);
808 evas_object_smart_changed(wd->pan_smart);
812 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
814 Pan *sd = evas_object_smart_data_get(obj);
816 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
819 evas_object_smart_changed(obj);
823 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
825 Pan *sd = evas_object_smart_data_get(obj);
827 if (x) *x = sd->wd->pan_x;
828 if (y) *y = sd->wd->pan_y;
832 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
834 Pan *sd = evas_object_smart_data_get(obj);
837 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
838 ow = sd->wd->minw - ow;
840 oh = sd->wd->minh - oh;
847 _pan_min_get(Evas_Object *obj __UNUSED__, Evas_Coord *x, Evas_Coord *y)
854 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
856 Pan *sd = evas_object_smart_data_get(obj);
858 if (w) *w = sd->wd->minw;
859 if (h) *h = sd->wd->minh;
863 _pan_add(Evas_Object *obj)
866 Evas_Object_Smart_Clipped_Data *cd;
868 cd = evas_object_smart_data_get(obj);
870 sd = calloc(1, sizeof(Pan));
872 sd->__clipped_data = *cd;
874 evas_object_smart_data_set(obj, sd);
878 _pan_del(Evas_Object *obj)
880 Pan *sd = evas_object_smart_data_get(obj);
886 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
888 Pan *sd = evas_object_smart_data_get(obj);
891 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
892 if ((ow == w) && (oh == h)) return;
894 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
895 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
899 _pan_calculate(Evas_Object *obj)
901 Pan *sd = evas_object_smart_data_get(obj);
902 Evas_Coord ox, oy, ow, oh;
906 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
907 img_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
908 EINA_LIST_FOREACH(sd->wd->grids, l, g)
910 grid_load(sd->wd->obj, g);
911 grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
916 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
918 Pan *sd = evas_object_smart_data_get(obj);
920 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
921 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
925 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
927 Widget_Data *wd = elm_widget_data_get(obj);
929 elm_smart_scroller_hold_set(wd->scr, 1);
933 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
935 Widget_Data *wd = elm_widget_data_get(obj);
937 elm_smart_scroller_hold_set(wd->scr, 0);
941 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
943 Widget_Data *wd = elm_widget_data_get(obj);
945 elm_smart_scroller_freeze_set(wd->scr, 1);
949 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
951 Widget_Data *wd = elm_widget_data_get(obj);
953 elm_smart_scroller_freeze_set(wd->scr, 0);
957 _scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
959 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
963 _scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
965 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
969 _scr_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
971 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
975 _scr_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
977 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
981 _scr_scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
983 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
987 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__,
988 Evas_Callback_Type type, void *event_info)
991 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
992 Evas_Event_Key_Down *ev = event_info;
993 Widget_Data *wd = elm_widget_data_get(obj);
994 if (!wd) return EINA_FALSE;
995 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
999 Evas_Coord step_x = 0;
1000 Evas_Coord step_y = 0;
1003 Evas_Coord page_x = 0;
1004 Evas_Coord page_y = 0;
1006 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
1007 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
1008 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
1009 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
1011 if ((!strcmp(ev->keyname, "Left")) ||
1012 (!strcmp(ev->keyname, "KP_Left")))
1016 else if ((!strcmp(ev->keyname, "Right")) ||
1017 (!strcmp(ev->keyname, "KP_Right")))
1021 else if ((!strcmp(ev->keyname, "Up")) ||
1022 (!strcmp(ev->keyname, "KP_Up")))
1026 else if ((!strcmp(ev->keyname, "Down")) ||
1027 (!strcmp(ev->keyname, "KP_Down")))
1031 else if ((!strcmp(ev->keyname, "Prior")) ||
1032 (!strcmp(ev->keyname, "KP_Prior")))
1035 y -= -(page_y * v_h) / 100;
1039 else if ((!strcmp(ev->keyname, "Next")) ||
1040 (!strcmp(ev->keyname, "KP_Next")))
1043 y += -(page_y * v_h) / 100;
1047 else if ((!strcmp(ev->keyname, "KP_Add")))
1049 zoom = elm_photocam_zoom_get(obj);
1051 elm_photocam_zoom_mode_set(obj, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
1052 elm_photocam_zoom_set(obj, zoom);
1055 else if ((!strcmp(ev->keyname, "KP_Subtract")))
1057 zoom = elm_photocam_zoom_get(obj);
1059 elm_photocam_zoom_mode_set(obj, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
1060 elm_photocam_zoom_set(obj, zoom);
1063 else return EINA_FALSE;
1065 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1066 elm_smart_scroller_child_pos_set(wd->scr, x, y);
1072 * Add a new Photocam object
1074 * @param parent The parent object
1075 * @return The new object or NULL if it cannot be created
1080 elm_photocam_add(Evas_Object *parent)
1085 Evas_Coord minw, minh;
1086 static Evas_Smart *smart = NULL;
1087 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1089 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1091 ELM_SET_WIDTYPE(widtype, "photocam");
1092 elm_widget_type_set(obj, "photocam");
1093 elm_widget_sub_object_add(parent, obj);
1094 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1095 elm_widget_data_set(obj, wd);
1096 elm_widget_del_hook_set(obj, _del_hook);
1097 elm_widget_theme_hook_set(obj, _theme_hook);
1098 elm_widget_can_focus_set(obj, EINA_TRUE);
1099 elm_widget_event_hook_set(obj, _event_hook);
1101 wd->scr = elm_smart_scroller_add(e);
1102 elm_smart_scroller_widget_set(wd->scr, obj);
1103 elm_smart_scroller_object_theme_set(obj, wd->scr, "photocam", "base", "default");
1104 evas_object_smart_callback_add(wd->scr, "scroll", _scr, obj);
1105 evas_object_smart_callback_add(wd->scr, "drag", _scr, obj);
1106 elm_widget_resize_object_set(obj, wd->scr);
1108 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
1109 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
1110 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1111 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1112 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1114 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
1118 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1119 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1120 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1121 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1125 static Evas_Smart_Class sc;
1127 evas_object_smart_clipped_smart_set(&_pan_sc);
1129 sc.name = "elm_photocam_pan";
1130 sc.version = EVAS_SMART_CLASS_VERSION;
1133 sc.resize = _pan_resize;
1134 sc.move = _pan_move;
1135 sc.calculate = _pan_calculate;
1136 smart = evas_smart_class_new(&sc);
1140 wd->pan_smart = evas_object_smart_add(e, smart);
1141 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1145 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1146 _pan_set, _pan_get, _pan_max_get,
1147 _pan_min_get, _pan_child_size_get);
1150 wd->mode = ELM_PHOTOCAM_ZOOM_MODE_MANUAL;
1154 wd->img = evas_object_image_add(e);
1155 evas_object_image_scale_hint_set(wd->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
1156 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_DOWN,
1158 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_UP,
1160 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_MOVE,
1162 evas_object_image_scale_hint_set(wd->img, EVAS_IMAGE_SCALE_HINT_STATIC);
1163 evas_object_smart_member_add(wd->img, wd->pan_smart);
1164 elm_widget_sub_object_add(obj, wd->img);
1165 evas_object_image_filled_set(wd->img, 1);
1166 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_IMAGE_PRELOADED,
1167 _main_preloaded, obj);
1169 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
1171 evas_object_size_hint_min_set(obj, minw, minh);
1173 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1180 * Set the photo file to be shown
1182 * This sets (and shows) the specified file (with a relative or absolute path)
1183 * and will return a load error (same error that
1184 * evas_object_image_load_error_get() will return). The image will change and
1185 * adjust its size at this point and begin a background load process for this
1186 * photo that at some time in the future will be displayed at the full quality
1189 * @param obj The photocam object
1190 * @param file The photo file
1191 * @return The return error (see EVAS_LOAD_ERROR_NONE, EVAS_LOAD_ERROR_GENERIC etc.)
1195 EAPI Evas_Load_Error
1196 elm_photocam_file_set(Evas_Object *obj, const char *file)
1198 ELM_CHECK_WIDTYPE(obj, widtype) EVAS_LOAD_ERROR_NONE;
1199 Widget_Data *wd = elm_widget_data_get(obj);
1201 if (!wd) return EVAS_LOAD_ERROR_GENERIC;
1202 if (!eina_stringshare_replace(&wd->file, file)) return EVAS_LOAD_ERROR_NONE;
1205 evas_object_hide(wd->img);
1206 evas_object_image_smooth_scale_set(wd->img, (wd->nosmooth == 0));
1207 evas_object_image_file_set(wd->img, NULL, NULL);
1208 evas_object_image_load_scale_down_set(wd->img, 0);
1209 evas_object_image_file_set(wd->img, wd->file, NULL);
1210 evas_object_image_size_get(wd->img, &w, &h);
1213 wd->size.w = wd->size.imw / wd->zoom;
1214 wd->size.h = wd->size.imh / wd->zoom;
1215 if (wd->zoom_animator)
1218 if (wd->nosmooth == 0) _smooth_update(obj);
1219 ecore_animator_del(wd->zoom_animator);
1220 wd->zoom_animator = NULL;
1222 evas_object_image_file_set(wd->img, NULL, NULL);
1223 evas_object_image_load_scale_down_set(wd->img, 8);
1224 evas_object_image_file_set(wd->img, wd->file, NULL);
1225 evas_object_image_preload(wd->img, 0);
1226 wd->main_load_pending = 1;
1227 if (wd->calc_job) ecore_job_del(wd->calc_job);
1228 wd->calc_job = ecore_job_add(_calc_job, wd);
1229 evas_object_smart_callback_call(obj, SIG_LOAD, NULL);
1231 if (wd->preload_num == 1)
1233 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
1234 "elm,state,busy,start", "elm");
1235 evas_object_smart_callback_call(obj, SIG_LOAD_DETAIL, NULL);
1238 double tz = wd->zoom;
1240 elm_photocam_zoom_set(wd->obj, tz);
1242 return evas_object_image_load_error_get(wd->img);
1246 * Returns the path of the current image file
1248 * @param obj The photocam object
1249 * @return Returns the path
1254 elm_photocam_file_get(const Evas_Object *obj)
1256 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1257 Widget_Data *wd = elm_widget_data_get(obj);
1258 if (!wd) return NULL;
1263 * Set the zoom level of the photo
1265 * This sets the zoom level. 1 will be 1:1 pixel for pixel. 2 will be 2:1
1266 * (that is 2x2 photo pixels will display as 1 on-screen pixel). 4:1 will be
1267 * 4x4 photo pixels as 1 screen pixel, and so on. The @p zoom parameter must
1268 * be greater than 0. It is usggested to stick to powers of 2. (1, 2, 4, 8,
1271 * @param obj The photocam object
1272 * @param zoom The zoom level to set
1277 elm_photocam_zoom_set(Evas_Object *obj, double zoom)
1279 ELM_CHECK_WIDTYPE(obj, widtype);
1280 Widget_Data *wd = elm_widget_data_get(obj);
1282 Grid *g, *g_zoom = NULL;
1283 Evas_Coord pw, ph, rx, ry, rw, rh;
1285 int zoom_changed = 0, started = 0;
1288 if (zoom <= (1.0 / 256.0)) zoom = (1.0 / 256.0);
1289 if (zoom == wd->zoom) return;
1291 wd->size.ow = wd->size.w;
1292 wd->size.oh = wd->size.h;
1293 elm_smart_scroller_child_pos_get(wd->scr, &rx, &ry);
1294 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
1295 if ((rw <= 0) || (rh <= 0)) return;
1297 if (wd->mode == ELM_PHOTOCAM_ZOOM_MODE_MANUAL)
1299 wd->size.nw = (double)wd->size.imw / wd->zoom;
1300 wd->size.nh = (double)wd->size.imh / wd->zoom;
1302 else if (wd->mode == ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT)
1304 if ((wd->size.imw < 1) || (wd->size.imh < 1))
1311 ph = (wd->size.imh * rw) / wd->size.imw;
1314 pw = (wd->size.imw * rh) / wd->size.imh;
1321 if (wd->size.imw > wd->size.imh)
1322 z = wd->size.imw / pw;
1324 z = wd->size.imh / ph;
1326 else if (z >= 4) z = 4;
1327 else if (z >= 2) z = 2;
1329 if (z != wd->zoom) zoom_changed = 1;
1335 else if (wd->mode == ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL)
1337 if ((wd->size.imw < 1) || (wd->size.imh < 1))
1344 ph = (wd->size.imh * rw) / wd->size.imw;
1347 pw = (wd->size.imw * rh) / wd->size.imh;
1354 if (wd->size.imw > wd->size.imh)
1355 z = wd->size.imw / pw;
1357 z = wd->size.imh / ph;
1359 else if (z >= 4) z = 4;
1360 else if (z >= 2) z = 2;
1362 if (z != wd->zoom) zoom_changed = 1;
1368 if (wd->main_load_pending)
1370 wd->size.w = wd->size.nw;
1371 wd->size.h = wd->size.nh;
1374 EINA_LIST_FOREACH(wd->grids, l, g)
1376 if (g->zoom == grid_zoom_calc(wd->zoom))
1378 wd->grids = eina_list_remove(wd->grids, g);
1379 wd->grids = eina_list_prepend(wd->grids, g);
1384 g = grid_create(obj);
1387 if (eina_list_count(wd->grids) > 1)
1389 g_zoom = eina_list_last(wd->grids)->data;
1390 wd->grids = eina_list_remove(wd->grids, g_zoom);
1391 grid_clear(obj, g_zoom);
1393 EINA_LIST_FOREACH(wd->grids, l, g_zoom)
1398 wd->grids = eina_list_prepend(wd->grids, g);
1402 EINA_LIST_FREE(wd->grids, g)
1409 wd->t_start = ecore_loop_time_get();
1410 wd->t_end = wd->t_start + _elm_config->zoom_friction;
1411 if ((wd->size.w > 0) && (wd->size.h > 0))
1413 wd->size.spos.x = (double)(rx + (rw / 2)) / (double)wd->size.w;
1414 wd->size.spos.y = (double)(ry + (rh / 2)) / (double)wd->size.h;
1418 wd->size.spos.x = 0.5;
1419 wd->size.spos.y = 0.5;
1421 if (rw > wd->size.w) wd->size.spos.x = 0.5;
1422 if (rh > wd->size.h) wd->size.spos.y = 0.5;
1423 if (wd->size.spos.x > 1.0) wd->size.spos.x = 1.0;
1424 if (wd->size.spos.y > 1.0) wd->size.spos.y = 1.0;
1431 if (!wd->zoom_animator)
1433 wd->zoom_animator = ecore_animator_add(_zoom_anim, obj);
1435 if (wd->nosmooth == 1) _smooth_update(obj);
1439 an = wd->zoom_animator;
1442 if (!_zoom_anim(obj))
1444 ecore_animator_del(an);
1448 if (wd->calc_job) ecore_job_del(wd->calc_job);
1449 wd->calc_job = ecore_job_add(_calc_job, wd);
1453 evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL);
1455 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
1458 evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL);
1462 * Get the zoom level of the photo
1464 * This returns the current zoom level of the photocam object. Note that if
1465 * you set the fill mode to other than ELM_PHOTOCAM_ZOOM_MODE_MANUAL
1466 * (which is the default), the zoom level may be changed at any time by the
1467 * photocam object itself to account for photo size and photocam viewpoer size
1469 * @param obj The photocam object
1470 * @return The current zoom level
1475 elm_photocam_zoom_get(const Evas_Object *obj)
1477 ELM_CHECK_WIDTYPE(obj, widtype) 1.0;
1478 Widget_Data *wd = elm_widget_data_get(obj);
1479 if (!wd) return 1.0;
1486 * This sets the zoom mode to manual or one of several automatic levels.
1487 * Manual (ELM_PHOTOCAM_ZOOM_MODE_MANUAL) means that zoom is set manually by
1488 * elm_photocam_zoom_set() and will stay at that level until changed by code
1489 * or until zoom mode is changed. This is the default mode.
1490 * The Automatic modes will allow the photocam object to automatically
1491 * adjust zoom mode based on properties. ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT) will
1492 * adjust zoom so the photo fits EXACTLY inside the scroll frame with no pixels
1493 * outside this area. ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL will be similar but
1494 * ensure no pixels within the frame are left unfilled.
1496 * @param obj The photocam object
1497 * @param mode The desired mode
1502 elm_photocam_zoom_mode_set(Evas_Object *obj, Elm_Photocam_Zoom_Mode mode)
1504 ELM_CHECK_WIDTYPE(obj, widtype);
1505 Widget_Data *wd = elm_widget_data_get(obj);
1507 if (wd->mode == mode) return;
1510 double tz = wd->zoom;
1512 elm_photocam_zoom_set(wd->obj, tz);
1519 * This gets the current zoom mode of the photocam object
1521 * @param obj The photocam object
1522 * @return The current zoom mode
1526 EAPI Elm_Photocam_Zoom_Mode
1527 elm_photocam_zoom_mode_get(const Evas_Object *obj)
1529 ELM_CHECK_WIDTYPE(obj, widtype) ELM_PHOTOCAM_ZOOM_MODE_LAST;
1530 Widget_Data *wd = elm_widget_data_get(obj);
1531 if (!wd) return ELM_PHOTOCAM_ZOOM_MODE_LAST;
1536 * Get the current image pixel width and height
1538 * This gets the current photo pixel width and height (for the original).
1539 * The size will be returned in the integers @p w and @p h that are pointed
1542 * @param obj The photocam object
1543 * @param w A pointer to the width return
1544 * @param h A pointer to the height return
1549 elm_photocam_image_size_get(const Evas_Object *obj, int *w, int *h)
1551 ELM_CHECK_WIDTYPE(obj, widtype);
1552 Widget_Data *wd = elm_widget_data_get(obj);
1554 if (w) *w = wd->size.imw;
1555 if (h) *h = wd->size.imh;
1559 * Get the current area of the image that is currently shown
1561 * This gets the region
1565 elm_photocam_region_get(const Evas_Object *obj, int *x, int *y, int *w, int *h)
1567 ELM_CHECK_WIDTYPE(obj, widtype);
1568 Widget_Data *wd = elm_widget_data_get(obj);
1569 Evas_Coord sx, sy, sw, sh;
1571 elm_smart_scroller_child_pos_get(wd->scr, &sx, &sy);
1572 elm_smart_scroller_child_viewport_size_get(wd->scr, &sw, &sh);
1577 *x = (wd->size.imw * sx) / wd->size.w;
1578 if (*x > wd->size.imw) *x = wd->size.imw;
1579 else if (*x < 0) *x = 0;
1583 *w = (wd->size.imw * sw) / wd->size.w;
1584 if (*w > wd->size.imw) *w = wd->size.imw;
1585 else if (*w < 0) *w = 0;
1598 *y = (wd->size.imh * sy) / wd->size.h;
1599 if (*y > wd->size.imh) *y = wd->size.imh;
1600 else if (*y < 0) *y = 0;
1604 *h = (wd->size.imh * sh) / wd->size.h;
1605 if (*h > wd->size.imh) *h = wd->size.imh;
1606 else if (*h < 0) *h = 0;
1617 * Set the viewed portion of the image
1619 * This sets the region of the image to be viewed
1621 * @param obj The photocam object
1622 * @param x X-coordinate of region in image original pixels
1623 * @param y Y-coordinate of region in image original pixels
1624 * @param w Width of region in image original pixels
1625 * @param h Height of region in image original pixels
1630 elm_photocam_image_region_show(Evas_Object *obj, int x, int y, int w, int h __UNUSED__)
1632 ELM_CHECK_WIDTYPE(obj, widtype);
1633 Widget_Data *wd = elm_widget_data_get(obj);
1636 if ((wd->size.imw < 1) || (wd->size.imh < 1)) return;
1637 rx = (x * wd->size.w) / wd->size.imw;
1638 ry = (y * wd->size.h) / wd->size.imh;
1639 rw = (w * wd->size.w) / wd->size.imw;
1640 rh = (w * wd->size.h) / wd->size.imh;
1643 if ((rx + rw) > wd->size.w) rx = wd->size.w - rw;
1644 if ((ry + rh) > wd->size.h) ry = wd->size.h - rh;
1645 if (wd->zoom_animator)
1648 ecore_animator_del(wd->zoom_animator);
1649 wd->zoom_animator = NULL;
1651 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
1653 elm_smart_scroller_child_region_show(wd->scr, rx, ry, rw, rh);
1657 * Bring in the viewed portion of the image
1659 * This brings in the region of the image over time
1661 * @param obj The photocam object
1662 * @param x X-coordinate of region in image original pixels
1663 * @param y Y-coordinate of region in image original pixels
1664 * @param w Width of region in image original pixels
1665 * @param h Height of region in image original pixels
1670 elm_photocam_image_region_bring_in(Evas_Object *obj, int x, int y, int w, int h __UNUSED__)
1672 ELM_CHECK_WIDTYPE(obj, widtype);
1673 Widget_Data *wd = elm_widget_data_get(obj);
1676 if ((wd->size.imw < 1) || (wd->size.imh < 1)) return;
1677 rx = (x * wd->size.w) / wd->size.imw;
1678 ry = (y * wd->size.h) / wd->size.imh;
1679 rw = (w * wd->size.w) / wd->size.imw;
1680 rh = (w * wd->size.h) / wd->size.imh;
1683 if ((rx + rw) > wd->size.w) rx = wd->size.w - rw;
1684 if ((ry + rh) > wd->size.h) ry = wd->size.h - rh;
1685 if (wd->zoom_animator)
1688 if (!wd->nosmooth) _smooth_update(obj);
1689 ecore_animator_del(wd->zoom_animator);
1690 wd->zoom_animator = NULL;
1692 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
1694 elm_smart_scroller_region_bring_in(wd->scr, rx, ry, rw, rh);
1698 * Set the paused state for photocam
1700 * This sets the paused state to on (1) or off (0) for photocam. The default
1701 * is on. This will stop zooming using animation ch change zoom levels and
1702 * change instantly. This will stop any existing animations that are running.
1704 * @param obj The photocam object
1705 * @param paused The pause state to set
1710 elm_photocam_paused_set(Evas_Object *obj, Eina_Bool paused)
1712 ELM_CHECK_WIDTYPE(obj, widtype);
1713 Widget_Data *wd = elm_widget_data_get(obj);
1715 if (wd->paused == !!paused) return;
1716 wd->paused = paused;
1719 if (wd->zoom_animator)
1721 ecore_animator_del(wd->zoom_animator);
1722 wd->zoom_animator = NULL;
1724 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
1730 * Get the paused state for photocam
1732 * This gets the current paused state for the photocam object.
1734 * @param obj The photocam object
1735 * @return The current paused state
1740 elm_photocam_paused_get(const Evas_Object *obj)
1742 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1743 Widget_Data *wd = elm_widget_data_get(obj);
1744 if (!wd) return EINA_FALSE;
1749 * Get the internal low-res image used for photocam
1751 * This gets the internal image object inside photocam. Do not modify it. It
1752 * is for inspection only, and hooking callbacks to. Nothing else. It may be
1753 * deleted at any time as well.
1755 * @param obj The photocam object
1756 * @return The internal image object handle, or NULL if none exists
1761 elm_photocam_internal_image_get(const Evas_Object *obj)
1763 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1764 Widget_Data *wd = elm_widget_data_get(obj);
1765 if (!wd) return NULL;
1770 * Set the photocam scrolling bouncing.
1772 * @param obj The photocam object
1773 * @param h_bounce bouncing for horizontal
1774 * @param v_bounce bouncing for vertical
1778 elm_photocam_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
1780 ELM_CHECK_WIDTYPE(obj, widtype);
1781 Widget_Data *wd = elm_widget_data_get(obj);
1783 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
1788 * Get the photocam scrolling bouncing.
1790 * @param obj The photocam object
1791 * @param h_bounce bouncing for horizontal
1792 * @param v_bounce bouncing for vertical
1796 elm_photocam_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
1798 ELM_CHECK_WIDTYPE(obj, widtype);
1799 Widget_Data *wd = elm_widget_data_get(obj);
1801 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);