1 #include <Elementary.h>
3 # include "elementary_config.h"
5 #ifndef ELM_LIB_QUICKLAUNCH
7 static Evas_Object *rect;
10 my_ph_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
16 my_ph_press(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
22 my_ph_longpressed(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
24 printf("longpressed\n");
28 my_ph_clicked_double(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
30 printf("clicked,double\n");
34 my_ph_load(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
40 my_ph_loaded(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
46 my_ph_load_details(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
48 printf("load,details\n");
52 my_ph_loaded_details(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
54 printf("loaded,details\n");
58 my_ph_zoom_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
60 printf("zoom,start\n");
64 my_ph_zoom_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
66 printf("zoom,stop\n");
70 my_ph_zoom_change(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
72 printf("zoom,change\n");
76 my_ph_anim_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
78 printf("anim,start\n");
82 my_ph_anim_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
84 printf("anim,stop\n");
88 my_ph_drag_start(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
90 printf("drag,start\n");
94 my_ph_drag_stop(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
96 printf("drag_stop\n");
100 my_ph_scroll(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
103 elm_photocam_region_get(obj, &x, &y, &w, &h);
104 printf("scroll %i %i %ix%i\n", x, y, w, h);
108 my_bt_open(void *data, Evas_Object *obj __UNUSED__, void *event_info)
110 Evas_Object *ph = data;
111 const char *file = event_info;
114 elm_photocam_file_set(ph, file);
118 my_bt_show_reg(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
120 elm_photocam_image_region_show(data, 30, 50, 500, 300);
124 my_bt_bring_reg(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
127 elm_photocam_image_region_bring_in(data, 800, 300, 500, 300);
131 my_bt_zoom_in(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
135 zoom = elm_photocam_zoom_get(data);
137 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
138 if (zoom >= (1.0 / 32.0)) elm_photocam_zoom_set(data, zoom);
142 my_bt_zoom_out(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
146 zoom = elm_photocam_zoom_get(data);
148 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
149 if (zoom <= 256.0) elm_photocam_zoom_set(data, zoom);
153 my_bt_pause(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
155 elm_photocam_paused_set(data, !elm_photocam_paused_get(data));
159 my_bt_zoom_fit(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
161 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
165 my_bt_zoom_fill(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
167 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL);
171 _photocam_mouse_wheel_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
173 Evas_Object *photocam = data;
174 Evas_Event_Mouse_Wheel *ev = (Evas_Event_Mouse_Wheel*) event_info;
177 //unset the mouse wheel
178 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
180 zoom = elm_photocam_zoom_get(photocam);
181 if ((ev->z>0) && (zoom == 1)) return;
196 elm_photocam_zoom_mode_set(photocam, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
197 if (zoom >= 1) elm_photocam_zoom_set(photocam, zoom);
201 _photocam_move_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
205 evas_object_geometry_get(data,&x,&y,&w,&h);
206 evas_object_resize(rect,w,h);
207 evas_object_move(rect,x,y);
211 test_photocam(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
213 Evas_Object *win, *bg, *ph, *tb2, *bt;
214 // these were just testing - use the "select photo" browser to select one
217 "/home/raster/t1.jpg", // 5 mpixel
218 "/home/raster/t2.jpg", // 18 mpixel
219 "/home/raster/t3.jpg", // 39 mpixel
220 "/home/raster/t4.jpg", // 192 mpixel
221 "/home/raster/t5.jpg" // 466 mpixel
224 win = elm_win_add(NULL, "photocam", ELM_WIN_BASIC);
225 elm_win_title_set(win, "Photocam");
226 elm_win_autodel_set(win, 1);
228 bg = elm_bg_add(win);
229 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
230 elm_win_resize_object_add(win, bg);
231 evas_object_show(bg);
233 ph = elm_photocam_add(win);
234 evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
235 elm_win_resize_object_add(win, ph);
236 evas_object_data_set(ph, "window", win);
238 rect = evas_object_rectangle_add(evas_object_evas_get(win));
239 evas_object_color_set(rect, 0, 0, 0, 0);
240 evas_object_repeat_events_set(rect,1);
241 evas_object_show(rect);
242 evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_WHEEL, _photocam_mouse_wheel_cb, ph);
243 evas_object_raise(rect);
245 evas_object_event_callback_add(ph, EVAS_CALLBACK_RESIZE, _photocam_move_resize_cb, ph);
246 evas_object_event_callback_add(ph, EVAS_CALLBACK_MOVE, _photocam_move_resize_cb, ph);
248 evas_object_smart_callback_add(ph, "clicked", my_ph_clicked, win);
249 evas_object_smart_callback_add(ph, "press", my_ph_press, win);
250 evas_object_smart_callback_add(ph, "longpressed", my_ph_longpressed, win);
251 evas_object_smart_callback_add(ph, "clicked,double", my_ph_clicked_double, win);
252 evas_object_smart_callback_add(ph, "load", my_ph_load, win);
253 evas_object_smart_callback_add(ph, "loaded", my_ph_loaded, win);
254 evas_object_smart_callback_add(ph, "load,details", my_ph_load_details, win);
255 evas_object_smart_callback_add(ph, "loaded,details", my_ph_loaded_details, win);
256 evas_object_smart_callback_add(ph, "zoom,start", my_ph_zoom_start, win);
257 evas_object_smart_callback_add(ph, "zoom,stop", my_ph_zoom_stop, win);
258 evas_object_smart_callback_add(ph, "zoom,change", my_ph_zoom_change, win);
259 evas_object_smart_callback_add(ph, "scroll,anim,start", my_ph_anim_start, win);
260 evas_object_smart_callback_add(ph, "scroll,anim,stop", my_ph_anim_stop, win);
261 evas_object_smart_callback_add(ph, "scroll,drag,start", my_ph_drag_start, win);
262 evas_object_smart_callback_add(ph, "scroll,drag,stop", my_ph_drag_stop, win);
263 evas_object_smart_callback_add(ph, "scroll", my_ph_scroll, win);
265 elm_photocam_file_set(ph, img[1]);
267 evas_object_show(ph);
269 tb2 = elm_table_add(win);
270 evas_object_size_hint_weight_set(tb2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
271 elm_win_resize_object_add(win, tb2);
273 bt = elm_button_add(win);
274 elm_object_text_set(bt, "Z -");
275 evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_out, ph);
276 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
277 evas_object_size_hint_align_set(bt, 0.1, 0.1);
278 elm_table_pack(tb2, bt, 0, 0, 1, 1);
279 evas_object_show(bt);
281 bt = elm_fileselector_button_add(win);
282 elm_object_text_set(bt, "Select Photo");
283 evas_object_smart_callback_add(bt, "file,chosen", my_bt_open, ph);
284 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
285 evas_object_size_hint_align_set(bt, 0.5, 0.1);
286 elm_table_pack(tb2, bt, 1, 0, 1, 1);
287 evas_object_show(bt);
289 bt = elm_button_add(win);
290 elm_object_text_set(bt, "Z +");
291 evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_in, ph);
292 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
293 evas_object_size_hint_align_set(bt, 0.9, 0.1);
294 elm_table_pack(tb2, bt, 2, 0, 1, 1);
295 evas_object_show(bt);
297 bt = elm_button_add(win);
298 elm_object_text_set(bt, "Show 30,50 500x300");
299 evas_object_smart_callback_add(bt, "clicked", my_bt_show_reg, ph);
300 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
301 evas_object_size_hint_align_set(bt, 0.1, 0.5);
302 elm_table_pack(tb2, bt, 0, 1, 1, 1);
303 evas_object_show(bt);
305 bt = elm_button_add(win);
306 elm_object_text_set(bt, "Bring 800,300 500x300");
307 evas_object_smart_callback_add(bt, "clicked", my_bt_bring_reg, ph);
308 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
309 evas_object_size_hint_align_set(bt, 0.9, 0.5);
310 elm_table_pack(tb2, bt, 2, 1, 1, 1);
311 evas_object_show(bt);
313 bt = elm_button_add(win);
314 elm_object_text_set(bt, "Pause On/Off");
315 evas_object_smart_callback_add(bt, "clicked", my_bt_pause, ph);
316 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
317 evas_object_size_hint_align_set(bt, 0.1, 0.9);
318 elm_table_pack(tb2, bt, 0, 2, 1, 1);
319 evas_object_show(bt);
321 bt = elm_button_add(win);
322 elm_object_text_set(bt, "Fit");
323 evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_fit, ph);
324 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
325 evas_object_size_hint_align_set(bt, 0.5, 0.9);
326 elm_table_pack(tb2, bt, 1, 2, 1, 1);
327 evas_object_show(bt);
329 bt = elm_button_add(win);
330 elm_object_text_set(bt, "Fill");
331 evas_object_smart_callback_add(bt, "clicked", my_bt_zoom_fill, ph);
332 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
333 evas_object_size_hint_align_set(bt, 0.9, 0.9);
334 elm_table_pack(tb2, bt, 2, 2, 1, 1);
335 evas_object_show(bt);
337 evas_object_show(tb2);
339 evas_object_resize(win, 800, 800);
340 evas_object_show(win);