8c2145f882a10773ca4db59c3270ee9ffbf47c7f
[framework/uifw/elementary.git] / src / bin / test_photo.c
1 #include <Elementary.h>
2 #ifdef HAVE_CONFIG_H
3 # include "elementary_config.h"
4 #endif
5 #ifndef ELM_LIB_QUICKLAUNCH
6
7 static void drop_cb(void *mydata, Evas_Object *obj, void *evdata);
8 static void drag_stop_cb(void *mydata, Evas_Object *obj, void *evdata);
9 static void drag_start_cb(void *mydata, Evas_Object *obj, void *evdata);
10
11 void
12 test_photo(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
13 {
14    Evas_Object *win, *bg, *sc, *tb, *ph;
15    int i, j, n;
16    char buf[PATH_MAX];
17    const char *img[9] =
18      {
19         "panel_01.jpg",
20         "mystrale.jpg",
21         "mystrale_2.jpg",
22         "rock_02.jpg",
23         "sky_01.jpg",
24         "sky_02.jpg",
25         "sky_03.jpg",
26         "sky_04.jpg",
27         "wood_01.jpg"
28      };
29
30    elm_need_ethumb();
31
32    win = elm_win_add(NULL, "photo", ELM_WIN_BASIC);
33    elm_win_title_set(win, "Photo");
34    elm_win_autodel_set(win, EINA_TRUE);
35
36    bg = elm_bg_add(win);
37    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
38    elm_win_resize_object_add(win, bg);
39    evas_object_show(bg);
40
41    tb = elm_table_add(win);
42    evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
43
44    n = 0;
45    for (j = 0; j < 12; j++)
46      {
47         for (i = 0; i < 12; i++)
48           {
49              ph = elm_photo_add(win);
50              snprintf(buf, sizeof(buf), "%s/images/%s",
51                       elm_app_data_dir_get(), img[n]);
52              n++;
53              if (n >= 9) n = 0;
54              elm_photo_aspect_fixed_set(ph, EINA_FALSE);
55              elm_photo_size_set(ph, 80);
56              if (n == 8)
57                elm_photo_thumb_set(ph, buf, NULL);
58              else
59                elm_photo_file_set(ph, buf);
60 <<<<<<< HEAD
61              elm_photo_editable_set(ph, 1);
62 =======
63              elm_photo_editable_set(ph, EINA_TRUE);
64 >>>>>>> remotes/origin/upstream
65              evas_object_size_hint_weight_set(ph, EVAS_HINT_EXPAND,
66                                               EVAS_HINT_EXPAND);
67              evas_object_size_hint_align_set(ph, EVAS_HINT_FILL,
68                                              EVAS_HINT_FILL);
69              evas_object_smart_callback_add(ph, "drop",
70                                             drop_cb, NULL);
71              evas_object_smart_callback_add(ph, "drag,start",
72                                             drag_start_cb, NULL);
73              evas_object_smart_callback_add(ph, "drag,stop",
74                                             drag_stop_cb, NULL);
75
76              if ((n == 2) || (n == 3))
77                {
78                   elm_photo_fill_inside_set(ph, EINA_TRUE);
79                   elm_object_style_set(ph, "shadow");
80                }
81              elm_table_pack(tb, ph, i, j, 1, 1);
82              evas_object_show(ph);
83           }
84      }
85
86    sc = elm_scroller_add(win);
87    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
88    elm_win_resize_object_add(win, sc);
89
90    elm_object_content_set(sc, tb);
91    evas_object_show(tb);
92    evas_object_show(sc);
93
94    evas_object_resize(win, 300, 300);
95    evas_object_show(win);
96 }
97
98 /* Never called, elm_photo never call "drop" smart cb */
99 static void
100 drop_cb(void *mydata __UNUSED__, Evas_Object *obj, void *evdata __UNUSED__)
101 {
102    printf("Drop on obj %p\n", obj);
103 }
104
105 static void
106 drag_start_cb(void *mydata __UNUSED__, Evas_Object *obj __UNUSED__, void *evdata __UNUSED__)
107 {
108
109 }
110
111 static void
112 drag_stop_cb(void *mydata __UNUSED__, Evas_Object *obj __UNUSED__, void *evdata __UNUSED__)
113 {
114
115 }
116
117 /* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
118 #endif