summaryrefslogtreecommitdiff
path: root/src/examples/elementary/photocam_example_01.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-03-23 12:56:14 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-03-23 13:24:41 -0700
commitc2a1c49ab2042f559b28e840e54feb8494888e0e (patch)
treec6eb110b7c479499854eede9d0c3ab0a80c9a11a /src/examples/elementary/photocam_example_01.c
parent9340855597e7e465435c69b6278650346688da14 (diff)
elementary: move all legacy files to their expected new location.
Diffstat (limited to 'src/examples/elementary/photocam_example_01.c')
-rw-r--r--src/examples/elementary/photocam_example_01.c159
1 files changed, 159 insertions, 0 deletions
diff --git a/src/examples/elementary/photocam_example_01.c b/src/examples/elementary/photocam_example_01.c
new file mode 100644
index 0000000000..7826591fc1
--- /dev/null
+++ b/src/examples/elementary/photocam_example_01.c
@@ -0,0 +1,159 @@
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
7static void _fit(void *data, Evas_Object *obj, void *event_info);
8static void _unfit(void *data, Evas_Object *obj, void *event_info);
9static void _zoom(void *data, Evas_Object *obj, void *event_info);
10static void _bring_in(void *data, Evas_Object *obj, void *event_info);
11static void _orient(void *data, Evas_Object *obj, void *event_info);
12static void _orient_do(void *data, Evas_Object *obj, void *event_info);
13
14typedef struct _Orient_Data Orient_Data;
15struct _Orient_Data
16{
17 Evas_Object *ph;
18 Evas_Image_Orient orient;
19};
20
21EAPI_MAIN int
22elm_main(int argc, char **argv)
23{
24 Evas_Object *win, *obj, *photocam, *menu;
25 Orient_Data *orient_data;
26 char buf[PATH_MAX];
27
28 elm_app_info_set(elm_main, "elementary", "images/insanely_huge_test_image.jpg");
29 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
30
31 win = elm_win_util_standard_add("photocam", "Photocam");
32 elm_win_autodel_set(win, EINA_TRUE);
33
34 photocam = elm_photocam_add(win);
35 snprintf(buf, sizeof(buf), "%s/images/insanely_huge_test_image.jpg", elm_app_data_dir_get());
36 elm_photocam_file_set(photocam, buf);
37 elm_scroller_bounce_set(photocam, EINA_FALSE, EINA_TRUE);
38 evas_object_smart_callback_add(photocam, "loaded,detail", _bring_in, NULL);
39 evas_object_resize(photocam, 500, 400);
40 evas_object_show(photocam);
41
42 obj = elm_button_add(win);
43 elm_object_text_set(obj, "Fit");
44 evas_object_show(obj);
45 evas_object_resize(obj, 50, 30);
46 evas_object_move(obj, 10, 410);
47 evas_object_smart_callback_add(obj, "clicked", _fit, photocam);
48
49 obj = elm_button_add(win);
50 elm_object_text_set(obj, "Unfit");
51 evas_object_show(obj);
52 evas_object_resize(obj, 70, 30);
53 evas_object_move(obj, 70, 410);
54 evas_object_smart_callback_add(obj, "clicked", _unfit, photocam);
55
56 orient_data = (Orient_Data *)malloc(sizeof(Orient_Data));
57 orient_data->ph = photocam;
58 orient_data->orient = 0;
59 menu = elm_menu_add(win);
60 elm_menu_item_add(menu, NULL, NULL, "orient 0", _orient_do, orient_data);
61 orient_data = (Orient_Data *)malloc(sizeof(Orient_Data));
62 orient_data->ph = photocam;
63 orient_data->orient = 1;
64 elm_menu_item_add(menu, NULL, NULL, "orient 90", _orient_do, orient_data);
65 orient_data = (Orient_Data *)malloc(sizeof(Orient_Data));
66 orient_data->ph = photocam;
67 orient_data->orient = 2;
68 elm_menu_item_add(menu, NULL, NULL, "orient 180", _orient_do, orient_data);
69 orient_data = (Orient_Data *)malloc(sizeof(Orient_Data));
70 orient_data->ph = photocam;
71 orient_data->orient = 3;
72 elm_menu_item_add(menu, NULL, NULL, "orient 270", _orient_do, orient_data);
73 orient_data = (Orient_Data *)malloc(sizeof(Orient_Data));
74 orient_data->ph = photocam;
75 orient_data->orient = 4;
76 elm_menu_item_add(menu, NULL, NULL, "flip horizontal", _orient_do, orient_data);
77 orient_data = (Orient_Data *)malloc(sizeof(Orient_Data));
78 orient_data->ph = photocam;
79 orient_data->orient = 5;
80 elm_menu_item_add(menu, NULL, NULL, "flip vertical", _orient_do, orient_data);
81 orient_data = (Orient_Data *)malloc(sizeof(Orient_Data));
82 orient_data->ph = photocam;
83 orient_data->orient = 6;
84 elm_menu_item_add(menu, NULL, NULL, "flip transverse", _orient_do, orient_data);
85 orient_data = (Orient_Data *)malloc(sizeof(Orient_Data));
86 orient_data->ph = photocam;
87 orient_data->orient = 7;
88 elm_menu_item_add(menu, NULL, NULL, "flip transpose", _orient_do, orient_data);
89
90 obj = elm_button_add(win);
91 elm_object_text_set(obj, "Orient");
92 evas_object_show(obj);
93 evas_object_resize(obj, 70, 30);
94 evas_object_move(obj, 470, 410);
95 evas_object_smart_callback_add(obj, "clicked", _orient, menu);
96
97 obj = elm_slider_add(win);
98 elm_object_text_set(obj, "Zoom");
99 evas_object_show(obj);
100 evas_object_resize(obj, 300, 30);
101 evas_object_move(obj, 150, 410);
102 evas_object_smart_callback_add(obj, "changed", _zoom, photocam);
103
104 evas_object_resize(win, 500, 440);
105 evas_object_show(win);
106
107 elm_run();
108
109 return 0;
110}
111ELM_MAIN()
112
113static void
114_bring_in(void *data, Evas_Object *obj, void *event_info)
115{
116 int w, h;
117 elm_photocam_image_size_get(obj, &w, &h);
118 elm_photocam_image_region_bring_in(obj, w/2, h/2, 500, 400);
119}
120
121static void
122_fit(void *data, Evas_Object *obj, void *event_info)
123{
124 int x, y, w, h;
125 elm_photocam_image_region_get(data, &x, &y, &w, &h);
126 printf("region: {%d, %d, %d, %d}\n", x, y, w, h);
127 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
128}
129
130static void
131_unfit(void *data, Evas_Object *obj, void *event_info)
132{
133 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
134}
135
136static void
137_zoom(void *data, Evas_Object *obj, void *event_info)
138{
139 double z = elm_slider_value_get(obj) * 8;
140 elm_photocam_zoom_set(data, z);
141}
142
143static void
144_orient(void *data, Evas_Object *obj, void *event_info)
145{
146 Evas_Object *mn = data;
147 if (!mn) return;
148
149 evas_object_show(mn);
150}
151
152static void
153_orient_do(void *data, Evas_Object *obj, void *event_info)
154{
155 Orient_Data *orient_data = data;
156 if (!orient_data) return;
157
158 elm_photocam_image_orient_set(orient_data->ph, orient_data->orient);
159}