b1c6148886575efc900ea37e9c055b5da1c2aae9
[framework/uifw/elementary.git] / src / examples / photocam_example_01.c
1 //Compile with:
2 //gcc -g `pkg-config --cflags --libs elementary` -DPACKAGE_DATA_DIR="\"<directory>\"" photocam_example_01.c -o photocam_example_01
3
4 #include <Elementary.h>
5 #ifdef HAVE_CONFIG_H
6 # include "elementary_config.h"
7 #endif
8
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);
13
14 EAPI_MAIN int
15 elm_main(int argc, char **argv)
16 {
17    Evas_Object *win, *bg, *bx, *obj, *photocam;
18
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    elm_win_resize_object_add(win, bg);
26    evas_object_show(bg);
27
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);
34
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);
41
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);
48
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);
55
56    evas_object_resize(win, 500, 440);
57    evas_object_show(win);
58
59    elm_run();
60
61    return 0;
62 }
63 ELM_MAIN()
64
65 static void
66 _bring_in(void *data, Evas_Object *obj, void *event_info)
67 {
68    int w, h;
69    elm_photocam_image_size_get(obj, &w, &h);
70    elm_photocam_image_region_bring_in(obj, w/2, h/2, 500, 400);
71 }
72
73 static void
74 _fit(void *data, Evas_Object *obj, void *event_info)
75 {
76    int x, y, w, h;
77 <<<<<<< HEAD
78    elm_photocam_region_get(data, &x, &y, &w, &h);
79 =======
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);
84 }
85
86 static void
87 _unfit(void *data, Evas_Object *obj, void *event_info)
88 {
89    elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
90 }
91
92 static void
93 _zoom(void *data, Evas_Object *obj, void *event_info)
94 {
95    double z = elm_slider_value_get(obj) * 8;
96    elm_photocam_zoom_set(data, z);
97 }