Elementary photo widget

This code snippet shows how to use elementary photo widget. This widget is designed to show person's photo. When no image is loaded it shows a placeholder.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// create box for our photo objects
Evas_Object *box = elm_box_add(ad->win);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(ad->win, box);
evas_object_show(box);
// create the first photo
Evas_Object* photo = elm_photo_add(ad->win);
evas_object_size_hint_weight_set(photo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(photo, EVAS_HINT_FILL, EVAS_HINT_FILL);
// set  photo file (PHOTO_DIR should look like this "/opt/usr/apps/org.tizen.myproject/res/images")
char file[PATH_MAX];
snprintf(file, sizeof(file), "%s/image.png", PHOTO_DIR);
elm_photo_file_set(photo, file);
evas_object_show(photo);
elm_box_pack_end(box, photo);
// create another photo without sending an actual image file - placeholder is shown
Evas_Object* empty_photo = elm_photo_add(ad->win);
evas_object_size_hint_weight_set(empty_photo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(empty_photo, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(empty_photo);
elm_box_pack_end(box, empty_photo);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX