1 #include <Elementary.h>
5 * @defgroup Photocam Photocam
7 * This is a widget specifically for displaying high-resolution digital
8 * camera photos giving speedy feedback (fast load), low memory footprint
9 * and zooming and panning as well as fitting logic. It is entirely focused
10 * on jpeg images, and takes advantage of properties of the jpeg format (via
11 * evas loader features in the jpeg loader).
13 * Signals that you can add callbacks for are:
15 * "clicked" - This is called when a user has clicked the photo without dragging
17 * "press" - This is called when a user has pressed down on the photo.
18 * "longpressed" - This is called when a user has pressed down on the photo for
19 * a long time without dragging around.
20 * "clicked,double" - This is called when a user has double-clicked the photo.
21 * "load" - Photo load begins.
22 * "loaded" - This is called when the image file load is complete for the first
23 * view (low resolution blurry version).
24 * "load,detail" - Photo detailed data load begins.
25 * "loaded,detail" - This is called when the image file load is complete for
26 * the detailed image data (full resolution needed).
27 * "zoom,start" - Zoom animation started.
28 * "zoom,stop" - Zoom animation stopped.
29 * "zoom,change" - Zoom changed when using an auto zoom mode.
30 * "scroll" - the content has been scrolled (moved)
31 * "scroll,anim,start" - scrolling animation has started
32 * "scroll,anim,stop" - scrolling animation has stopped
33 * "scroll,drag,start" - dragging the contents around has started
34 * "scroll,drag,stop" - dragging the contents around has stopped
38 * TODO (maybe - optional future stuff):
40 * 1. wrap photo in theme edje so u can have styling around photo (like white
43 * 3. rotation flags in exif handling (nasty! should have rot in evas)
46 typedef struct _Widget_Data Widget_Data;
47 typedef struct _Pan Pan;
48 typedef struct _Grid Grid;
49 typedef struct _Grid_Item Grid_Item;
65 int tsize; // size of tile (tsize x tsize pixels)
66 int zoom; // zoom level tiles want for optimal display (1, 2, 4, 8)
67 int iw, ih; // size of image in pixels
68 int w, h; // size of grid image in pixels (represented by grid)
69 int gw, gh; // size of grid in tiles
70 Grid_Item *grid; // the grid (gw * gh items)
71 Eina_Bool dead : 1; // old grid. will die as soon as anim is over
78 Evas_Object *pan_smart;
80 Evas_Coord pan_x, pan_y, minw, minh;
83 Elm_Photocam_Zoom_Mode mode;
87 Ecore_Timer *scr_timer;
88 Ecore_Timer *long_timer;
89 Ecore_Animator *zoom_animator;
90 double t_start, t_end;
104 Evas_Coord x, y ,w ,h;
107 Evas_Object *img; // low res version of image (scale down == 8)
111 Eina_Bool main_load_pending : 1;
112 Eina_Bool resized : 1;
113 Eina_Bool longpressed : 1;
114 Eina_Bool on_hold : 1;
115 Eina_Bool paused : 1;
120 Evas_Object_Smart_Clipped_Data __clipped_data;
124 static const char *widtype = NULL;
125 static void _del_hook(Evas_Object *obj);
126 static void _theme_hook(Evas_Object *obj);
127 static void _on_focus_hook(void *data, Evas_Object *obj);
128 //static void _show_region_hook(void *data, Evas_Object *obj);
129 static void _sizing_eval(Evas_Object *obj);
130 static void _calc_job(void *data);
131 static Eina_Bool _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__,
132 Evas_Callback_Type type, void *event_info);
133 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);
134 static void grid_clear(Evas_Object *obj, Grid *g);
135 static Grid *grid_create(Evas_Object *obj);
136 static void grid_load(Evas_Object *obj, Grid *g);
138 static const char SIG_CLICKED[] = "clicked";
139 static const char SIG_PRESS[] = "press";
140 static const char SIG_LONGPRESSED[] = "longpressed";
141 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
142 static const char SIG_LOAD[] = "load";
143 static const char SIG_LOADED[] = "loaded";
144 static const char SIG_LOAD_DETAIL[] = "load,detail";
145 static const char SIG_LOADED_DETAIL[] = "loaded,detail";
146 static const char SIG_ZOOM_START[] = "zoom,start";
147 static const char SIG_ZOOM_STOP[] = "zoom,stop";
148 static const char SIG_ZOOM_CHANGE[] = "zoom,change";
149 static const char SIG_SCROLL[] = "scroll";
150 static const char SIG_SCROLL_ANIM_START[] = "scroll,anim,start";
151 static const char SIG_SCROLL_ANIM_STOP[] = "scroll,anim,stop";
152 static const char SIG_SCROLL_DRAG_START[] = "scroll,drag,start";
153 static const char SIG_SCROLL_DRAG_STOP[] = "scroll,drag,stop";
155 static const Evas_Smart_Cb_Description _signals[] = {
158 {SIG_LONGPRESSED, ""},
159 {SIG_CLICKED_DOUBLE, ""},
162 {SIG_LOAD_DETAIL, ""},
163 {SIG_LOADED_DETAIL, ""},
164 {SIG_ZOOM_START, ""},
166 {SIG_ZOOM_CHANGE, ""},
168 {SIG_SCROLL_ANIM_START, ""},
169 {SIG_SCROLL_ANIM_STOP, ""},
170 {SIG_SCROLL_DRAG_START, ""},
171 {SIG_SCROLL_DRAG_STOP, ""},
177 nearest_pow2(int num)
179 unsigned int n = num - 1;
189 img_place(Evas_Object *obj, Evas_Coord px, Evas_Coord py, Evas_Coord ox, Evas_Coord oy, Evas_Coord ow, Evas_Coord oh)
191 Widget_Data *wd = elm_widget_data_get(obj);
192 Evas_Coord ax, ay, gw, gh;
198 if (ow > gw) ax = (ow - gw) / 2;
199 if (oh > gh) ay = (oh - gh) / 2;
200 evas_object_move(wd->img, ox + 0 - px + ax, oy + 0 - py + ay);
201 evas_object_resize(wd->img, gw, gh);
205 wd->show.show = EINA_FALSE;
206 elm_smart_scroller_child_region_show(wd->scr, wd->show.x, wd->show.y, wd->show.w, wd->show.h);
211 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)
213 Widget_Data *wd = elm_widget_data_get(obj);
214 Evas_Coord ax, ay, gw, gh, tx, ty;
221 if (ow > gw) ax = (ow - gw) / 2;
222 if (oh > gh) ay = (oh - gh) / 2;
223 for (y = 0; y < g->gh; y++)
225 for (x = 0; x < g->gw; x++)
227 int tn, xx, yy, ww, hh;
229 tn = (y * g->gw) + x;
230 xx = g->grid[tn].out.x;
231 yy = g->grid[tn].out.y;
232 ww = g->grid[tn].out.w;
233 hh = g->grid[tn].out.h;
234 if ((gw != g->w) && (g->w > 0))
237 xx = (gw * xx) / g->w;
238 ww = ((gw * (tx + ww)) / g->w) - xx;
240 if ((gh != g->h) && (g->h > 0))
243 yy = (gh * yy) / g->h;
244 hh = ((gh * (ty + hh)) / g->h) - yy;
246 evas_object_move(g->grid[tn].img,
249 evas_object_resize(g->grid[tn].img, ww, hh);
255 grid_clear(Evas_Object *obj, Grid *g)
257 Widget_Data *wd = elm_widget_data_get(obj);
260 if (!g->grid) return;
261 for (y = 0; y < g->gh; y++)
263 for (x = 0; x < g->gw; x++)
267 tn = (y * g->gw) + x;
268 evas_object_del(g->grid[tn].img);
269 if (g->grid[tn].want)
272 if (!wd->preload_num)
274 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
275 "elm,state,busy,stop", "elm");
276 evas_object_smart_callback_call(obj, SIG_LOAD_DETAIL, NULL);
288 _tile_preloaded(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
290 Grid_Item *git = data;
295 evas_object_show(git->img);
297 git->wd->preload_num--;
298 if (!git->wd->preload_num)
300 edje_object_signal_emit(elm_smart_scroller_edje_object_get(git->wd->scr),
301 "elm,state,busy,stop", "elm");
302 evas_object_smart_callback_call(git->wd->obj, SIG_LOADED_DETAIL, NULL);
308 grid_zoom_calc(double zoom)
312 return nearest_pow2(z);
316 grid_create(Evas_Object *obj)
318 Widget_Data *wd = elm_widget_data_get(obj);
322 if (!wd) return NULL;
323 g = calloc(1, sizeof(Grid));
325 g->zoom = grid_zoom_calc(wd->zoom);
326 g->tsize = wd->tsize;
327 g->iw = wd->size.imw;
328 g->ih = wd->size.imh;
330 g->w = g->iw / g->zoom;
331 g->h = g->ih / g->zoom;
332 if (g->zoom >= 8) return NULL;
333 g->gw = (g->w + g->tsize - 1) / g->tsize;
334 g->gh = (g->h + g->tsize - 1) / g->tsize;
335 g->grid = calloc(1, sizeof(Grid_Item) * g->gw * g->gh);
342 for (y = 0; y < g->gh; y++)
344 for (x = 0; x < g->gw; x++)
348 tn = (y * g->gw) + x;
349 g->grid[tn].src.x = x * g->tsize;
350 if (x == (g->gw - 1))
351 g->grid[tn].src.w = g->w - ((g->gw - 1) * g->tsize);
353 g->grid[tn].src.w = g->tsize;
354 g->grid[tn].src.y = y * g->tsize;
355 if (y == (g->gh - 1))
356 g->grid[tn].src.h = g->h - ((g->gh - 1) * g->tsize);
358 g->grid[tn].src.h = g->tsize;
360 g->grid[tn].out.x = g->grid[tn].src.x;
361 g->grid[tn].out.y = g->grid[tn].src.y;
362 g->grid[tn].out.w = g->grid[tn].src.w;
363 g->grid[tn].out.h = g->grid[tn].src.h;
367 evas_object_image_add(evas_object_evas_get(obj));
368 evas_object_image_scale_hint_set
369 (g->grid[tn].img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
370 evas_object_pass_events_set(g->grid[tn].img, EINA_TRUE);
371 evas_object_smart_member_add(g->grid[tn].img,
373 elm_widget_sub_object_add(obj, g->grid[tn].img);
374 evas_object_image_filled_set(g->grid[tn].img, 1);
375 evas_object_event_callback_add(g->grid[tn].img,
376 EVAS_CALLBACK_IMAGE_PRELOADED,
385 grid_load(Evas_Object *obj, Grid *g)
387 Widget_Data *wd = elm_widget_data_get(obj);
389 Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh, gw, gh, tx, ty;
391 evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
392 evas_output_viewport_get(evas_object_evas_get(wd->obj), &cvx, &cvy, &cvw, &cvh);
395 for (y = 0; y < g->gh; y++)
397 for (x = 0; x < g->gw; x++)
399 int tn, xx, yy, ww, hh;
400 Eina_Bool visible = EINA_FALSE;
402 tn = (y * g->gw) + x;
403 xx = g->grid[tn].out.x;
404 yy = g->grid[tn].out.y;
405 ww = g->grid[tn].out.w;
406 hh = g->grid[tn].out.h;
407 if ((gw != g->w) && (g->w > 0))
410 xx = (gw * xx) / g->w;
411 ww = ((gw * (tx + ww)) / g->w) - xx;
413 if ((gh != g->h) && (g->h > 0))
416 yy = (gh * yy) / g->h;
417 hh = ((gh * (ty + hh)) / g->h) - yy;
419 if (ELM_RECTS_INTERSECT(xx - wd->pan_x + ox,
424 if ((visible) && (!g->grid[tn].have) && (!g->grid[tn].want))
426 g->grid[tn].want = 1;
427 evas_object_hide(g->grid[tn].img);
428 evas_object_image_file_set(g->grid[tn].img, NULL, NULL);
429 evas_object_image_load_scale_down_set(g->grid[tn].img, g->zoom);
430 evas_object_image_load_region_set(g->grid[tn].img,
435 evas_object_image_file_set(g->grid[tn].img, wd->file, NULL);
436 evas_object_image_preload(g->grid[tn].img, 0);
438 if (wd->preload_num == 1)
440 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
441 "elm,state,busy,start", "elm");
442 evas_object_smart_callback_call(obj, SIG_LOAD_DETAIL, NULL);
445 else if ((g->grid[tn].want) && (!visible))
448 if (!wd->preload_num)
450 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
451 "elm,state,busy,stop", "elm");
452 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL, NULL);
454 g->grid[tn].want = 0;
455 evas_object_hide(g->grid[tn].img);
456 evas_object_image_preload(g->grid[tn].img, 1);
457 evas_object_image_file_set(g->grid[tn].img, NULL, NULL);
459 else if ((g->grid[tn].have) && (!visible))
461 g->grid[tn].have = 0;
462 evas_object_hide(g->grid[tn].img);
463 evas_object_image_preload(g->grid[tn].img, 1);
464 evas_object_image_file_set(g->grid[tn].img, NULL, NULL);
471 grid_clearall(Evas_Object *obj)
473 Widget_Data *wd = elm_widget_data_get(obj);
476 EINA_LIST_FREE(wd->grids, g)
484 _smooth_update(Evas_Object *obj)
486 Widget_Data *wd = elm_widget_data_get(obj);
491 EINA_LIST_FOREACH(wd->grids, l, g)
493 for (y = 0; y < g->gh; y++)
495 for (x = 0; x < g->gw; x++)
499 tn = (y * g->gw) + x;
500 evas_object_image_smooth_scale_set(g->grid[tn].img, (!wd->nosmooth));
504 evas_object_image_smooth_scale_set(wd->img, (!wd->nosmooth));
512 for (y = 0; y < g->gh; y++)
514 for (x = 0; x < g->gw; x++)
518 tn = (y * g->gw) + x;
519 evas_object_raise(g->grid[tn].img);
525 _scr_timeout(void *data)
527 Widget_Data *wd = elm_widget_data_get(data);
528 if (!wd) return ECORE_CALLBACK_CANCEL;
530 if (!wd->nosmooth) _smooth_update(data);
531 wd->scr_timer = NULL;
532 return ECORE_CALLBACK_CANCEL;
536 _scr(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
538 Widget_Data *wd = elm_widget_data_get(data);
543 if (wd->nosmooth == 1) _smooth_update(data);
545 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
546 wd->scr_timer = ecore_timer_add(0.5, _scr_timeout, data);
550 _main_preloaded(void *data, Evas *e __UNUSED__, Evas_Object *o __UNUSED__, void *event_info __UNUSED__)
552 Evas_Object *obj = data;
553 Widget_Data *wd = elm_widget_data_get(obj);
556 evas_object_show(wd->img);
557 wd->main_load_pending = 0;
558 g = grid_create(obj);
561 wd->grids = eina_list_prepend(wd->grids, g);
562 grid_load(wd->obj, g);
564 if (wd->calc_job) ecore_job_del(wd->calc_job);
565 wd->calc_job = ecore_job_add(_calc_job, wd);
566 evas_object_smart_callback_call(data, SIG_LOADED, NULL);
568 if (!wd->preload_num)
570 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
571 "elm,state,busy,stop", "elm");
572 evas_object_smart_callback_call(obj, SIG_LOADED_DETAIL, NULL);
577 zoom_do(Evas_Object *obj, double t)
579 Widget_Data *wd = elm_widget_data_get(obj);
580 Evas_Coord xx, yy, ow, oh;
581 if (!wd) return ECORE_CALLBACK_CANCEL;
582 wd->size.w = (wd->size.ow * (1.0 - t)) + (wd->size.nw * t);
583 wd->size.h = (wd->size.oh * (1.0 - t)) + (wd->size.nh * t);
584 elm_smart_scroller_child_viewport_size_get(wd->scr, &ow, &oh);
585 xx = (wd->size.spos.x * wd->size.w) - (ow / 2);
586 yy = (wd->size.spos.y * wd->size.h) - (oh / 2);
588 else if (xx > (wd->size.w - ow)) xx = wd->size.w - ow;
590 else if (yy > (wd->size.h - oh)) yy = wd->size.h - oh;
592 wd->show.show = EINA_TRUE;
598 if (wd->calc_job) ecore_job_del(wd->calc_job);
599 wd->calc_job = ecore_job_add(_calc_job, wd);
602 Eina_List *l, *l_next;
605 EINA_LIST_FOREACH_SAFE(wd->grids, l, l_next, g)
609 wd->grids = eina_list_remove_list(wd->grids, l);
614 return ECORE_CALLBACK_CANCEL;
616 return ECORE_CALLBACK_RENEW;
621 _zoom_anim(void *data)
623 Evas_Object *obj = data;
624 Widget_Data *wd = elm_widget_data_get(obj);
627 if (!wd) return ECORE_CALLBACK_CANCEL;
628 t = ecore_loop_time_get();
631 else if (wd->t_end > wd->t_start)
632 t = (t - wd->t_start) / (wd->t_end - wd->t_start);
637 go = zoom_do(obj, t);
641 if (!wd->nosmooth) _smooth_update(data);
642 wd->zoom_animator = NULL;
643 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
649 _mouse_move(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
651 Widget_Data *wd = elm_widget_data_get(data);
652 // Evas_Event_Mouse_Move *ev = event_info;
657 _long_press(void *data)
659 Widget_Data *wd = elm_widget_data_get(data);
660 if (!wd) return ECORE_CALLBACK_CANCEL;
661 wd->long_timer = NULL;
662 wd->longpressed = EINA_TRUE;
663 evas_object_smart_callback_call(data, SIG_LONGPRESSED, NULL);
664 return ECORE_CALLBACK_CANCEL;
668 _mouse_down(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
670 Widget_Data *wd = elm_widget_data_get(data);
671 Evas_Event_Mouse_Down *ev = event_info;
673 if (ev->button != 1) return;
674 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
675 else wd->on_hold = EINA_FALSE;
676 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
677 evas_object_smart_callback_call(data, SIG_CLICKED_DOUBLE, NULL);
679 evas_object_smart_callback_call(data, SIG_PRESS, NULL);
680 wd->longpressed = EINA_FALSE;
681 if (wd->long_timer) ecore_timer_del(wd->long_timer);
682 wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, _long_press, data);
686 _mouse_up(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
688 Widget_Data *wd = elm_widget_data_get(data);
689 Evas_Event_Mouse_Up *ev = event_info;
691 if (ev->button != 1) return;
692 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) wd->on_hold = EINA_TRUE;
693 else wd->on_hold = EINA_FALSE;
696 ecore_timer_del(wd->long_timer);
697 wd->long_timer = NULL;
700 evas_object_smart_callback_call(data, SIG_CLICKED, NULL);
701 wd->on_hold = EINA_FALSE;
704 static Evas_Smart_Class _pan_sc = EVAS_SMART_CLASS_INIT_NULL;
707 _del_hook(Evas_Object *obj)
709 Widget_Data *wd = elm_widget_data_get(obj);
712 EINA_LIST_FREE(wd->grids, g)
714 if (g->grid) free(g->grid);
717 evas_object_del(wd->pan_smart);
718 wd->pan_smart = NULL;
719 if (wd->file) eina_stringshare_del(wd->file);
720 if (wd->calc_job) ecore_job_del(wd->calc_job);
721 if (wd->scr_timer) ecore_timer_del(wd->scr_timer);
722 if (wd->zoom_animator) ecore_animator_del(wd->zoom_animator);
723 if (wd->long_timer) ecore_timer_del(wd->long_timer);
728 _on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
730 Widget_Data *wd = elm_widget_data_get(obj);
732 if (elm_widget_focus_get(obj))
734 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,focus", "elm");
735 evas_object_focus_set(wd->obj, EINA_TRUE);
739 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr), "elm,action,unfocus", "elm");
740 evas_object_focus_set(wd->obj, EINA_FALSE);
745 _theme_hook(Evas_Object *obj)
747 Widget_Data *wd = elm_widget_data_get(obj);
749 elm_smart_scroller_object_theme_set(obj, wd->scr, "photocam", "base", elm_widget_style_get(obj));
750 // edje_object_scale_set(wd->scr, elm_widget_scale_get(obj) * _elm_config->scale);
756 _show_region_hook(void *data, Evas_Object *obj)
758 Widget_Data *wd = elm_widget_data_get(data);
759 Evas_Coord x, y, w, h;
761 elm_widget_show_region_get(obj, &x, &y, &w, &h);
762 elm_smart_scroller_child_region_show(wd->scr, x, y, w, h);
767 _sizing_eval(Evas_Object *obj)
769 Widget_Data *wd = elm_widget_data_get(obj);
770 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
772 // evas_object_size_hint_min_get(wd->scr, &minw, &minh);
773 evas_object_size_hint_max_get(wd->scr, &maxw, &maxh);
776 // if (wd->mode != ELM_LIST_LIMIT) minw = -1;
777 evas_object_size_hint_min_set(obj, minw, minh);
778 evas_object_size_hint_max_set(obj, maxw, maxh);
782 _calc_job(void *data)
784 Widget_Data *wd = data;
785 Evas_Coord minw, minh;
792 if (wd->mode != ELM_PHOTOCAM_ZOOM_MODE_MANUAL)
794 double tz = wd->zoom;
796 elm_photocam_zoom_set(wd->obj, tz);
799 if ((minw != wd->minw) || (minh != wd->minh))
803 evas_object_smart_callback_call(wd->pan_smart, "changed", NULL);
804 _sizing_eval(wd->obj);
807 evas_object_smart_changed(wd->pan_smart);
811 _pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
813 Pan *sd = evas_object_smart_data_get(obj);
815 if ((x == sd->wd->pan_x) && (y == sd->wd->pan_y)) return;
818 evas_object_smart_changed(obj);
822 _pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
824 Pan *sd = evas_object_smart_data_get(obj);
826 if (x) *x = sd->wd->pan_x;
827 if (y) *y = sd->wd->pan_y;
831 _pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y)
833 Pan *sd = evas_object_smart_data_get(obj);
836 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
837 ow = sd->wd->minw - ow;
839 oh = sd->wd->minh - oh;
846 _pan_min_get(Evas_Object *obj __UNUSED__, Evas_Coord *x, Evas_Coord *y)
853 _pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
855 Pan *sd = evas_object_smart_data_get(obj);
857 if (w) *w = sd->wd->minw;
858 if (h) *h = sd->wd->minh;
862 _pan_add(Evas_Object *obj)
865 Evas_Object_Smart_Clipped_Data *cd;
867 cd = evas_object_smart_data_get(obj);
869 sd = calloc(1, sizeof(Pan));
871 sd->__clipped_data = *cd;
873 evas_object_smart_data_set(obj, sd);
877 _pan_del(Evas_Object *obj)
879 Pan *sd = evas_object_smart_data_get(obj);
885 _pan_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
887 Pan *sd = evas_object_smart_data_get(obj);
890 evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
891 if ((ow == w) && (oh == h)) return;
893 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
894 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
898 _pan_calculate(Evas_Object *obj)
900 Pan *sd = evas_object_smart_data_get(obj);
901 Evas_Coord ox, oy, ow, oh;
905 evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
906 img_place(sd->wd->obj, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
907 EINA_LIST_FOREACH(sd->wd->grids, l, g)
909 grid_load(sd->wd->obj, g);
910 grid_place(sd->wd->obj, g, sd->wd->pan_x, sd->wd->pan_y, ox, oy, ow, oh);
915 _pan_move(Evas_Object *obj, Evas_Coord x __UNUSED__, Evas_Coord y __UNUSED__)
917 Pan *sd = evas_object_smart_data_get(obj);
919 if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
920 sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
924 _hold_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
926 Widget_Data *wd = elm_widget_data_get(obj);
928 elm_smart_scroller_hold_set(wd->scr, 1);
932 _hold_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
934 Widget_Data *wd = elm_widget_data_get(obj);
936 elm_smart_scroller_hold_set(wd->scr, 0);
940 _freeze_on(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
942 Widget_Data *wd = elm_widget_data_get(obj);
944 elm_smart_scroller_freeze_set(wd->scr, 1);
948 _freeze_off(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
950 Widget_Data *wd = elm_widget_data_get(obj);
952 elm_smart_scroller_freeze_set(wd->scr, 0);
956 _scr_anim_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
958 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_START, NULL);
962 _scr_anim_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
964 evas_object_smart_callback_call(data, SIG_SCROLL_ANIM_STOP, NULL);
968 _scr_drag_start(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
970 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_START, NULL);
974 _scr_drag_stop(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
976 evas_object_smart_callback_call(data, SIG_SCROLL_DRAG_STOP, NULL);
980 _scr_scroll(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
982 evas_object_smart_callback_call(data, SIG_SCROLL, NULL);
986 _event_hook(Evas_Object *obj, Evas_Object *src __UNUSED__,
987 Evas_Callback_Type type, void *event_info)
990 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
991 Evas_Event_Key_Down *ev = event_info;
992 Widget_Data *wd = elm_widget_data_get(obj);
993 if (!wd) return EINA_FALSE;
994 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
998 Evas_Coord step_x = 0;
999 Evas_Coord step_y = 0;
1002 Evas_Coord page_x = 0;
1003 Evas_Coord page_y = 0;
1005 elm_smart_scroller_child_pos_get(wd->scr, &x, &y);
1006 elm_smart_scroller_step_size_get(wd->scr, &step_x, &step_y);
1007 elm_smart_scroller_page_size_get(wd->scr, &page_x, &page_y);
1008 elm_smart_scroller_child_viewport_size_get(wd->scr, &v_w, &v_h);
1010 if ((!strcmp(ev->keyname, "Left")) ||
1011 (!strcmp(ev->keyname, "KP_Left")))
1015 else if ((!strcmp(ev->keyname, "Right")) ||
1016 (!strcmp(ev->keyname, "KP_Right")))
1020 else if ((!strcmp(ev->keyname, "Up")) ||
1021 (!strcmp(ev->keyname, "KP_Up")))
1025 else if ((!strcmp(ev->keyname, "Down")) ||
1026 (!strcmp(ev->keyname, "KP_Down")))
1030 else if ((!strcmp(ev->keyname, "Prior")) ||
1031 (!strcmp(ev->keyname, "KP_Prior")))
1034 y -= -(page_y * v_h) / 100;
1038 else if ((!strcmp(ev->keyname, "Next")) ||
1039 (!strcmp(ev->keyname, "KP_Next")))
1042 y += -(page_y * v_h) / 100;
1046 else if ((!strcmp(ev->keyname, "KP_Add")))
1048 zoom = elm_photocam_zoom_get(obj);
1050 elm_photocam_zoom_mode_set(obj, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
1051 elm_photocam_zoom_set(obj, zoom);
1054 else if ((!strcmp(ev->keyname, "KP_Subtract")))
1056 zoom = elm_photocam_zoom_get(obj);
1058 elm_photocam_zoom_mode_set(obj, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
1059 elm_photocam_zoom_set(obj, zoom);
1062 else return EINA_FALSE;
1064 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1065 elm_smart_scroller_child_pos_set(wd->scr, x, y);
1071 * Add a new Photocam object
1073 * @param parent The parent object
1074 * @return The new object or NULL if it cannot be created
1079 elm_photocam_add(Evas_Object *parent)
1084 Evas_Coord minw, minh;
1085 static Evas_Smart *smart = NULL;
1086 Eina_Bool bounce = _elm_config->thumbscroll_bounce_enable;
1088 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1090 ELM_SET_WIDTYPE(widtype, "photocam");
1091 elm_widget_type_set(obj, "photocam");
1092 elm_widget_sub_object_add(parent, obj);
1093 elm_widget_on_focus_hook_set(obj, _on_focus_hook, NULL);
1094 elm_widget_data_set(obj, wd);
1095 elm_widget_del_hook_set(obj, _del_hook);
1096 elm_widget_theme_hook_set(obj, _theme_hook);
1097 elm_widget_can_focus_set(obj, EINA_TRUE);
1098 elm_widget_event_hook_set(obj, _event_hook);
1100 wd->scr = elm_smart_scroller_add(e);
1101 elm_smart_scroller_widget_set(wd->scr, obj);
1102 elm_smart_scroller_object_theme_set(obj, wd->scr, "photocam", "base", "default");
1103 evas_object_smart_callback_add(wd->scr, "scroll", _scr, obj);
1104 evas_object_smart_callback_add(wd->scr, "drag", _scr, obj);
1105 elm_widget_resize_object_set(obj, wd->scr);
1107 evas_object_smart_callback_add(wd->scr, "animate,start", _scr_anim_start, obj);
1108 evas_object_smart_callback_add(wd->scr, "animate,stop", _scr_anim_stop, obj);
1109 evas_object_smart_callback_add(wd->scr, "drag,start", _scr_drag_start, obj);
1110 evas_object_smart_callback_add(wd->scr, "drag,stop", _scr_drag_stop, obj);
1111 evas_object_smart_callback_add(wd->scr, "scroll", _scr_scroll, obj);
1113 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, bounce);
1117 evas_object_smart_callback_add(obj, "scroll-hold-on", _hold_on, obj);
1118 evas_object_smart_callback_add(obj, "scroll-hold-off", _hold_off, obj);
1119 evas_object_smart_callback_add(obj, "scroll-freeze-on", _freeze_on, obj);
1120 evas_object_smart_callback_add(obj, "scroll-freeze-off", _freeze_off, obj);
1124 static Evas_Smart_Class sc;
1126 evas_object_smart_clipped_smart_set(&_pan_sc);
1128 sc.name = "elm_photocam_pan";
1129 sc.version = EVAS_SMART_CLASS_VERSION;
1132 sc.resize = _pan_resize;
1133 sc.move = _pan_move;
1134 sc.calculate = _pan_calculate;
1135 smart = evas_smart_class_new(&sc);
1139 wd->pan_smart = evas_object_smart_add(e, smart);
1140 wd->pan = evas_object_smart_data_get(wd->pan_smart);
1144 elm_smart_scroller_extern_pan_set(wd->scr, wd->pan_smart,
1145 _pan_set, _pan_get, _pan_max_get,
1146 _pan_min_get, _pan_child_size_get);
1149 wd->mode = ELM_PHOTOCAM_ZOOM_MODE_MANUAL;
1153 wd->img = evas_object_image_add(e);
1154 evas_object_image_scale_hint_set(wd->img, EVAS_IMAGE_SCALE_HINT_DYNAMIC);
1155 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_DOWN,
1157 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_UP,
1159 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_MOUSE_MOVE,
1161 evas_object_image_scale_hint_set(wd->img, EVAS_IMAGE_SCALE_HINT_STATIC);
1162 evas_object_smart_member_add(wd->img, wd->pan_smart);
1163 elm_widget_sub_object_add(obj, wd->img);
1164 evas_object_image_filled_set(wd->img, 1);
1165 evas_object_event_callback_add(wd->img, EVAS_CALLBACK_IMAGE_PRELOADED,
1166 _main_preloaded, obj);
1168 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
1170 evas_object_size_hint_min_set(obj, minw, minh);
1172 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1179 * Set the photo file to be shown
1181 * This sets (and shows) the specified file (with a relative or absolute path)
1182 * and will return a load error (same error that
1183 * evas_object_image_load_error_get() will return). The image will change and
1184 * adjust its size at this point and begin a background load process for this
1185 * photo that at some time in the future will be displayed at the full quality
1188 * @param obj The photocam object
1189 * @param file The photo file
1190 * @return The return error (see EVAS_LOAD_ERROR_NONE, EVAS_LOAD_ERROR_GENERIC etc.)
1194 EAPI Evas_Load_Error
1195 elm_photocam_file_set(Evas_Object *obj, const char *file)
1197 ELM_CHECK_WIDTYPE(obj, widtype) EVAS_LOAD_ERROR_NONE;
1198 Widget_Data *wd = elm_widget_data_get(obj);
1200 if (!wd) return EVAS_LOAD_ERROR_GENERIC;
1201 if (!eina_stringshare_replace(&wd->file, file)) return EVAS_LOAD_ERROR_NONE;
1204 evas_object_hide(wd->img);
1205 evas_object_image_smooth_scale_set(wd->img, (wd->nosmooth == 0));
1206 evas_object_image_file_set(wd->img, NULL, NULL);
1207 evas_object_image_load_scale_down_set(wd->img, 0);
1208 evas_object_image_file_set(wd->img, wd->file, NULL);
1209 evas_object_image_size_get(wd->img, &w, &h);
1212 wd->size.w = wd->size.imw / wd->zoom;
1213 wd->size.h = wd->size.imh / wd->zoom;
1214 if (wd->zoom_animator)
1217 if (wd->nosmooth == 0) _smooth_update(obj);
1218 ecore_animator_del(wd->zoom_animator);
1219 wd->zoom_animator = NULL;
1221 evas_object_image_file_set(wd->img, NULL, NULL);
1222 evas_object_image_load_scale_down_set(wd->img, 8);
1223 evas_object_image_file_set(wd->img, wd->file, NULL);
1224 evas_object_image_preload(wd->img, 0);
1225 wd->main_load_pending = 1;
1226 if (wd->calc_job) ecore_job_del(wd->calc_job);
1227 wd->calc_job = ecore_job_add(_calc_job, wd);
1228 evas_object_smart_callback_call(obj, SIG_LOAD, NULL);
1230 if (wd->preload_num == 1)
1232 edje_object_signal_emit(elm_smart_scroller_edje_object_get(wd->scr),
1233 "elm,state,busy,start", "elm");
1234 evas_object_smart_callback_call(obj, SIG_LOAD_DETAIL, NULL);
1237 double tz = wd->zoom;
1239 elm_photocam_zoom_set(wd->obj, tz);
1241 return evas_object_image_load_error_get(wd->img);
1245 * Returns the path of the current image file
1247 * @param obj The photocam object
1248 * @return Returns the path
1253 elm_photocam_file_get(const Evas_Object *obj)
1255 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1256 Widget_Data *wd = elm_widget_data_get(obj);
1257 if (!wd) return NULL;
1262 * Set the zoom level of the photo
1264 * This sets the zoom level. 1 will be 1:1 pixel for pixel. 2 will be 2:1
1265 * (that is 2x2 photo pixels will display as 1 on-screen pixel). 4:1 will be
1266 * 4x4 photo pixels as 1 screen pixel, and so on. The @p zoom parameter must
1267 * be greater than 0. It is usggested to stick to powers of 2. (1, 2, 4, 8,
1270 * @param obj The photocam object
1271 * @param zoom The zoom level to set
1276 elm_photocam_zoom_set(Evas_Object *obj, double zoom)
1278 ELM_CHECK_WIDTYPE(obj, widtype);
1279 Widget_Data *wd = elm_widget_data_get(obj);
1281 Grid *g, *g_zoom = NULL;
1282 Evas_Coord pw, ph, rx, ry, rw, rh;
1284 int zoom_changed = 0, started = 0;
1287 if (zoom <= (1.0 / 256.0)) zoom = (1.0 / 256.0);
1288 if (zoom == wd->zoom) return;
1290 wd->size.ow = wd->size.w;
1291 wd->size.oh = wd->size.h;
1292 elm_smart_scroller_child_pos_get(wd->scr, &rx, &ry);
1293 elm_smart_scroller_child_viewport_size_get(wd->scr, &rw, &rh);
1294 if ((rw <= 0) || (rh <= 0)) return;
1296 if (wd->mode == ELM_PHOTOCAM_ZOOM_MODE_MANUAL)
1298 wd->size.nw = (double)wd->size.imw / wd->zoom;
1299 wd->size.nh = (double)wd->size.imh / wd->zoom;
1301 else if (wd->mode == ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT)
1303 if ((wd->size.imw < 1) || (wd->size.imh < 1))
1310 ph = (wd->size.imh * rw) / wd->size.imw;
1313 pw = (wd->size.imw * rh) / wd->size.imh;
1320 if (wd->size.imw > wd->size.imh)
1321 z = wd->size.imw / pw;
1323 z = wd->size.imh / ph;
1325 else if (z >= 4) z = 4;
1326 else if (z >= 2) z = 2;
1328 if (z != wd->zoom) zoom_changed = 1;
1334 else if (wd->mode == ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL)
1336 if ((wd->size.imw < 1) || (wd->size.imh < 1))
1343 ph = (wd->size.imh * rw) / wd->size.imw;
1346 pw = (wd->size.imw * rh) / wd->size.imh;
1353 if (wd->size.imw > wd->size.imh)
1354 z = wd->size.imw / pw;
1356 z = wd->size.imh / ph;
1358 else if (z >= 4) z = 4;
1359 else if (z >= 2) z = 2;
1361 if (z != wd->zoom) zoom_changed = 1;
1367 if (wd->main_load_pending)
1369 wd->size.w = wd->size.nw;
1370 wd->size.h = wd->size.nh;
1373 EINA_LIST_FOREACH(wd->grids, l, g)
1375 if (g->zoom == grid_zoom_calc(wd->zoom))
1377 wd->grids = eina_list_remove(wd->grids, g);
1378 wd->grids = eina_list_prepend(wd->grids, g);
1383 g = grid_create(obj);
1386 if (eina_list_count(wd->grids) > 1)
1388 g_zoom = eina_list_last(wd->grids)->data;
1389 wd->grids = eina_list_remove(wd->grids, g_zoom);
1390 grid_clear(obj, g_zoom);
1392 EINA_LIST_FOREACH(wd->grids, l, g_zoom)
1397 wd->grids = eina_list_prepend(wd->grids, g);
1401 EINA_LIST_FREE(wd->grids, g)
1408 wd->t_start = ecore_loop_time_get();
1409 wd->t_end = wd->t_start + _elm_config->zoom_friction;
1410 if ((wd->size.w > 0) && (wd->size.h > 0))
1412 wd->size.spos.x = (double)(rx + (rw / 2)) / (double)wd->size.w;
1413 wd->size.spos.y = (double)(ry + (rh / 2)) / (double)wd->size.h;
1417 wd->size.spos.x = 0.5;
1418 wd->size.spos.y = 0.5;
1420 if (rw > wd->size.w) wd->size.spos.x = 0.5;
1421 if (rh > wd->size.h) wd->size.spos.y = 0.5;
1422 if (wd->size.spos.x > 1.0) wd->size.spos.x = 1.0;
1423 if (wd->size.spos.y > 1.0) wd->size.spos.y = 1.0;
1430 if (!wd->zoom_animator)
1432 wd->zoom_animator = ecore_animator_add(_zoom_anim, obj);
1434 if (wd->nosmooth == 1) _smooth_update(obj);
1438 an = wd->zoom_animator;
1441 if (!_zoom_anim(obj))
1443 ecore_animator_del(an);
1447 if (wd->calc_job) ecore_job_del(wd->calc_job);
1448 wd->calc_job = ecore_job_add(_calc_job, wd);
1452 evas_object_smart_callback_call(obj, SIG_ZOOM_START, NULL);
1454 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
1457 evas_object_smart_callback_call(obj, SIG_ZOOM_CHANGE, NULL);
1461 * Get the zoom level of the photo
1463 * This returns the current zoom level of the photocam object. Note that if
1464 * you set the fill mode to other than ELM_PHOTOCAM_ZOOM_MODE_MANUAL
1465 * (which is the default), the zoom level may be changed at any time by the
1466 * photocam object itself to account for photo size and photocam viewpoer size
1468 * @param obj The photocam object
1469 * @return The current zoom level
1474 elm_photocam_zoom_get(const Evas_Object *obj)
1476 ELM_CHECK_WIDTYPE(obj, widtype) 1.0;
1477 Widget_Data *wd = elm_widget_data_get(obj);
1478 if (!wd) return 1.0;
1485 * This sets the zoom mode to manual or one of several automatic levels.
1486 * Manual (ELM_PHOTOCAM_ZOOM_MODE_MANUAL) means that zoom is set manually by
1487 * elm_photocam_zoom_set() and will stay at that level until changed by code
1488 * or until zoom mode is changed. This is the default mode.
1489 * The Automatic modes will allow the photocam object to automatically
1490 * adjust zoom mode based on properties. ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT) will
1491 * adjust zoom so the photo fits EXACTLY inside the scroll frame with no pixels
1492 * outside this area. ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL will be similar but
1493 * ensure no pixels within the frame are left unfilled.
1495 * @param obj The photocam object
1496 * @param mode The desired mode
1501 elm_photocam_zoom_mode_set(Evas_Object *obj, Elm_Photocam_Zoom_Mode mode)
1503 ELM_CHECK_WIDTYPE(obj, widtype);
1504 Widget_Data *wd = elm_widget_data_get(obj);
1506 if (wd->mode == mode) return;
1509 double tz = wd->zoom;
1511 elm_photocam_zoom_set(wd->obj, tz);
1518 * This gets the current zoom mode of the photocam object
1520 * @param obj The photocam object
1521 * @return The current zoom mode
1525 EAPI Elm_Photocam_Zoom_Mode
1526 elm_photocam_zoom_mode_get(const Evas_Object *obj)
1528 ELM_CHECK_WIDTYPE(obj, widtype) ELM_PHOTOCAM_ZOOM_MODE_LAST;
1529 Widget_Data *wd = elm_widget_data_get(obj);
1530 if (!wd) return ELM_PHOTOCAM_ZOOM_MODE_LAST;
1535 * Get the current image pixel width and height
1537 * This gets the current photo pixel width and height (for the original).
1538 * The size will be returned in the integers @p w and @p h that are pointed
1541 * @param obj The photocam object
1542 * @param w A pointer to the width return
1543 * @param h A pointer to the height return
1548 elm_photocam_image_size_get(const Evas_Object *obj, int *w, int *h)
1550 ELM_CHECK_WIDTYPE(obj, widtype);
1551 Widget_Data *wd = elm_widget_data_get(obj);
1553 if (w) *w = wd->size.imw;
1554 if (h) *h = wd->size.imh;
1558 * Get the current area of the image that is currently shown
1560 * This gets the region
1564 elm_photocam_region_get(const Evas_Object *obj, int *x, int *y, int *w, int *h)
1566 ELM_CHECK_WIDTYPE(obj, widtype);
1567 Widget_Data *wd = elm_widget_data_get(obj);
1568 Evas_Coord sx, sy, sw, sh;
1570 elm_smart_scroller_child_pos_get(wd->scr, &sx, &sy);
1571 elm_smart_scroller_child_viewport_size_get(wd->scr, &sw, &sh);
1576 *x = (wd->size.imw * sx) / wd->size.w;
1577 if (*x > wd->size.imw) *x = wd->size.imw;
1578 else if (*x < 0) *x = 0;
1582 *w = (wd->size.imw * sw) / wd->size.w;
1583 if (*w > wd->size.imw) *w = wd->size.imw;
1584 else if (*w < 0) *w = 0;
1597 *y = (wd->size.imh * sy) / wd->size.h;
1598 if (*y > wd->size.imh) *y = wd->size.imh;
1599 else if (*y < 0) *y = 0;
1603 *h = (wd->size.imh * sh) / wd->size.h;
1604 if (*h > wd->size.imh) *h = wd->size.imh;
1605 else if (*h < 0) *h = 0;
1616 * Set the viewed portion of the image
1618 * This sets the region of the image to be viewed
1620 * @param obj The photocam object
1621 * @param x X-coordinate of region in image original pixels
1622 * @param y Y-coordinate of region in image original pixels
1623 * @param w Width of region in image original pixels
1624 * @param h Height of region in image original pixels
1629 elm_photocam_image_region_show(Evas_Object *obj, int x, int y, int w, int h __UNUSED__)
1631 ELM_CHECK_WIDTYPE(obj, widtype);
1632 Widget_Data *wd = elm_widget_data_get(obj);
1635 if ((wd->size.imw < 1) || (wd->size.imh < 1)) return;
1636 rx = (x * wd->size.w) / wd->size.imw;
1637 ry = (y * wd->size.h) / wd->size.imh;
1638 rw = (w * wd->size.w) / wd->size.imw;
1639 rh = (w * wd->size.h) / wd->size.imh;
1642 if ((rx + rw) > wd->size.w) rx = wd->size.w - rw;
1643 if ((ry + rh) > wd->size.h) ry = wd->size.h - rh;
1644 if (wd->zoom_animator)
1647 ecore_animator_del(wd->zoom_animator);
1648 wd->zoom_animator = NULL;
1650 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
1652 elm_smart_scroller_child_region_show(wd->scr, rx, ry, rw, rh);
1656 * Bring in the viewed portion of the image
1658 * This brings in the region of the image over time
1660 * @param obj The photocam object
1661 * @param x X-coordinate of region in image original pixels
1662 * @param y Y-coordinate of region in image original pixels
1663 * @param w Width of region in image original pixels
1664 * @param h Height of region in image original pixels
1669 elm_photocam_image_region_bring_in(Evas_Object *obj, int x, int y, int w, int h __UNUSED__)
1671 ELM_CHECK_WIDTYPE(obj, widtype);
1672 Widget_Data *wd = elm_widget_data_get(obj);
1675 if ((wd->size.imw < 1) || (wd->size.imh < 1)) return;
1676 rx = (x * wd->size.w) / wd->size.imw;
1677 ry = (y * wd->size.h) / wd->size.imh;
1678 rw = (w * wd->size.w) / wd->size.imw;
1679 rh = (w * wd->size.h) / wd->size.imh;
1682 if ((rx + rw) > wd->size.w) rx = wd->size.w - rw;
1683 if ((ry + rh) > wd->size.h) ry = wd->size.h - rh;
1684 if (wd->zoom_animator)
1687 if (!wd->nosmooth) _smooth_update(obj);
1688 ecore_animator_del(wd->zoom_animator);
1689 wd->zoom_animator = NULL;
1691 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
1693 elm_smart_scroller_region_bring_in(wd->scr, rx, ry, rw, rh);
1697 * Set the paused state for photocam
1699 * This sets the paused state to on (1) or off (0) for photocam. The default
1700 * is on. This will stop zooming using animation ch change zoom levels and
1701 * change instantly. This will stop any existing animations that are running.
1703 * @param obj The photocam object
1704 * @param paused The pause state to set
1709 elm_photocam_paused_set(Evas_Object *obj, Eina_Bool paused)
1711 ELM_CHECK_WIDTYPE(obj, widtype);
1712 Widget_Data *wd = elm_widget_data_get(obj);
1714 if (wd->paused == !!paused) return;
1715 wd->paused = paused;
1718 if (wd->zoom_animator)
1720 ecore_animator_del(wd->zoom_animator);
1721 wd->zoom_animator = NULL;
1723 evas_object_smart_callback_call(obj, SIG_ZOOM_STOP, NULL);
1729 * Get the paused state for photocam
1731 * This gets the current paused state for the photocam object.
1733 * @param obj The photocam object
1734 * @return The current paused state
1739 elm_photocam_paused_get(const Evas_Object *obj)
1741 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1742 Widget_Data *wd = elm_widget_data_get(obj);
1743 if (!wd) return EINA_FALSE;
1748 * Get the internal low-res image used for photocam
1750 * This gets the internal image object inside photocam. Do not modify it. It
1751 * is for inspection only, and hooking callbacks to. Nothing else. It may be
1752 * deleted at any time as well.
1754 * @param obj The photocam object
1755 * @return The internal image object handle, or NULL if none exists
1760 elm_photocam_internal_image_get(const Evas_Object *obj)
1762 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1763 Widget_Data *wd = elm_widget_data_get(obj);
1764 if (!wd) return NULL;
1769 * Set the photocam scrolling bouncing.
1771 * @param obj The photocam object
1772 * @param h_bounce bouncing for horizontal
1773 * @param v_bounce bouncing for vertical
1777 elm_photocam_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
1779 ELM_CHECK_WIDTYPE(obj, widtype);
1780 Widget_Data *wd = elm_widget_data_get(obj);
1782 elm_smart_scroller_bounce_allow_set(wd->scr, h_bounce, v_bounce);
1787 * Get the photocam scrolling bouncing.
1789 * @param obj The photocam object
1790 * @param h_bounce bouncing for horizontal
1791 * @param v_bounce bouncing for vertical
1795 elm_photocam_bounce_get(const Evas_Object *obj, Eina_Bool *h_bounce, Eina_Bool *v_bounce)
1797 ELM_CHECK_WIDTYPE(obj, widtype);
1798 Widget_Data *wd = elm_widget_data_get(obj);
1800 elm_smart_scroller_bounce_allow_get(wd->scr, h_bounce, v_bounce);