The elm_toolbar_iteams_count have to return only the number of manually added items.
[framework/uifw/elementary.git] / src / examples / photocam_example_01.c
1 //Compile with:
2 //gcc -o photocam_example_01 photocam_example_01.c -g `pkg-config --cflags --libs elementary` -DDATA_DIR="\"<directory>\""
3 //where directory is the path where images/insanely_huge_test_image.jpg can be found.
4
5 #include <Elementary.h>
6
7 static void _fit(void *data, Evas_Object *obj, void *event_info);
8 static void _unfit(void *data, Evas_Object *obj, void *event_info);
9 static void _zoom(void *data, Evas_Object *obj, void *event_info);
10 static void _bring_in(void *data, Evas_Object *obj, void *event_info);
11
12 EAPI_MAIN int
13 elm_main(int argc, char **argv)
14 {
15    Evas_Object *win, *bg, *obj, *photocam;
16    char buf[PATH_MAX];
17
18    elm_app_info_set(elm_main, "elementary", "images/insanely_huge_test_image.jpg");
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);
23
24    bg = elm_bg_add(win);
25    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
26    elm_win_resize_object_add(win, bg);
27    evas_object_show(bg);
28
29    photocam = elm_photocam_add(win);
30    snprintf(buf, sizeof(buf), "%s/images/insanely_huge_test_image.jpg", elm_app_data_dir_get());
31    elm_photocam_file_set(photocam, buf);
32    elm_photocam_bounce_set(photocam, EINA_FALSE, EINA_TRUE);
33    evas_object_smart_callback_add(photocam, "loaded,detail", _bring_in, NULL);
34    evas_object_resize(photocam, 500, 400);
35    evas_object_show(photocam);
36
37    obj = elm_button_add(win);
38    elm_object_text_set(obj, "Fit");
39    evas_object_show(obj);
40    evas_object_resize(obj, 50, 30);
41    evas_object_move(obj, 10, 410);
42    evas_object_smart_callback_add(obj, "clicked", _fit, photocam);
43
44    obj = elm_button_add(win);
45    elm_object_text_set(obj, "Unfit");
46    evas_object_show(obj);
47    evas_object_resize(obj, 70, 30);
48    evas_object_move(obj, 70, 410);
49    evas_object_smart_callback_add(obj, "clicked", _unfit, photocam);
50
51    obj = elm_slider_add(win);
52    elm_object_text_set(obj, "Zoom");
53    evas_object_show(obj);
54    evas_object_resize(obj, 300, 30);
55    evas_object_move(obj, 150, 410);
56    evas_object_smart_callback_add(obj, "changed", _zoom, photocam);
57
58    evas_object_resize(win, 500, 440);
59    evas_object_show(win);
60
61    elm_run();
62    elm_shutdown();
63
64    return 0;
65 }
66 ELM_MAIN()
67
68 static void
69 _bring_in(void *data, Evas_Object *obj, void *event_info)
70 {
71    int w, h;
72    elm_photocam_image_size_get(obj, &w, &h);
73    elm_photocam_image_region_bring_in(obj, w/2, h/2, 500, 400);
74 }
75
76 static void
77 _fit(void *data, Evas_Object *obj, void *event_info)
78 {
79    int x, y, w, h;
80    elm_photocam_image_region_get(data, &x, &y, &w, &h);
81    printf("region: {%d, %d, %d, %d}\n", x, y, w, h);
82    elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
83 }
84
85 static void
86 _unfit(void *data, Evas_Object *obj, void *event_info)
87 {
88    elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
89 }
90
91 static void
92 _zoom(void *data, Evas_Object *obj, void *event_info)
93 {
94    double z = elm_slider_value_get(obj) * 8;
95    elm_photocam_zoom_set(data, z);
96 }