2 //gcc -g `pkg-config --cflags --libs elementary` -DPACKAGE_DATA_DIR="\"<directory>\"" photocam_example_01.c -o photocam_example_01
4 #include <Elementary.h>
6 # include "elementary_config.h"
9 static void _fit(void *data, Evas_Object *obj, void *event_info);
10 static void _unfit(void *data, Evas_Object *obj, void *event_info);
11 static void _zoom(void *data, Evas_Object *obj, void *event_info);
12 static void _bring_in(void *data, Evas_Object *obj, void *event_info);
15 elm_main(int argc, char **argv)
17 Evas_Object *win, *bg, *bx, *obj, *photocam;
19 win = elm_win_add(NULL, "photocam", ELM_WIN_BASIC);
20 elm_win_title_set(win, "Photocam");
21 elm_win_autodel_set(win, EINA_TRUE);
22 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
25 elm_win_resize_object_add(win, bg);
28 photocam = elm_photocam_add(win);
29 elm_photocam_file_set(photocam, PACKAGE_DATA_DIR"/images/insanely_huge_test_image.jpg");
30 elm_photocam_bounce_set(photocam, EINA_FALSE, EINA_TRUE);
31 evas_object_smart_callback_add(photocam, "loaded,detail", _bring_in, NULL);
32 evas_object_resize(photocam, 500, 400);
33 evas_object_show(photocam);
35 obj = elm_button_add(win);
36 elm_object_text_set(obj, "Fit");
37 evas_object_show(obj);
38 evas_object_resize(obj, 50, 30);
39 evas_object_move(obj, 10, 410);
40 evas_object_smart_callback_add(obj, "clicked", _fit, photocam);
42 obj = elm_button_add(win);
43 elm_object_text_set(obj, "Unfit");
44 evas_object_show(obj);
45 evas_object_resize(obj, 70, 30);
46 evas_object_move(obj, 70, 410);
47 evas_object_smart_callback_add(obj, "clicked", _unfit, photocam);
49 obj = elm_slider_add(win);
50 elm_object_text_set(obj, "Zoom");
51 evas_object_show(obj);
52 evas_object_resize(obj, 300, 30);
53 evas_object_move(obj, 150, 410);
54 evas_object_smart_callback_add(obj, "changed", _zoom, photocam);
56 evas_object_resize(win, 500, 440);
57 evas_object_show(win);
66 _bring_in(void *data, Evas_Object *obj, void *event_info)
69 elm_photocam_image_size_get(obj, &w, &h);
70 elm_photocam_image_region_bring_in(obj, w/2, h/2, 500, 400);
74 _fit(void *data, Evas_Object *obj, void *event_info)
78 elm_photocam_region_get(data, &x, &y, &w, &h);
80 elm_photocam_image_region_get(data, &x, &y, &w, &h);
81 >>>>>>> remotes/origin/upstream
82 printf("region: {%d, %d, %d, %d}\n", x, y, w, h);
83 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
87 _unfit(void *data, Evas_Object *obj, void *event_info)
89 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
93 _zoom(void *data, Evas_Object *obj, void *event_info)
95 double z = elm_slider_value_get(obj) * 8;
96 elm_photocam_zoom_set(data, z);