fixed plugin image size problem
[framework/uifw/elementary.git] / src / bin / test_factory.c
1 #ifdef HAVE_CONFIG_H
2 # include "elementary_config.h"
3 #endif
4 #include <Elementary.h>
5 #ifndef ELM_LIB_QUICKLAUNCH
6
7 // 16 ^ 4 = 65k
8 #define BLOK 16
9 // homogenous layout
10 //#define HOMOG 1
11 // aligned to top of box
12 #define ZEROALIGN 1
13 #define DEFSZ 64
14
15 static void
16 fac_unrealize(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
17 {
18    // setting factory content to null deletes it
19    printf("--------DELETE for factory %p [f: %p]\n", elm_object_content_get(obj), obj);
20    elm_object_content_set(obj, NULL);
21 }
22
23 static void
24 fac_realize_end(void *data, Evas_Object *obj, void *event_info __UNUSED__)
25 {
26    Evas_Object *win = data;
27    Evas_Object *bx, *bt;
28    int i;
29
30    bx = elm_box_add(win);
31    printf("   ADD lv 3 = %p [%i]\n", bx, (BLOK * (int)(long)evas_object_data_get(obj, "num")));
32 #ifdef HOMOG
33    elm_box_homogeneous_set(bx, EINA_TRUE);
34 #endif
35 #ifdef ZEROALIGN
36    elm_box_align_set(bx, 0.0, 0.0);
37 #endif
38
39    for (i = 0; i < BLOK; i++)
40      {
41         char buf[32];
42
43         snprintf(buf, sizeof(buf), "%i",
44                  (i + (BLOK * (int)(long)evas_object_data_get(obj, "num"))));
45
46         bt = elm_button_add(win);
47         evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
48         evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
49         elm_object_text_set(bt, buf);
50         elm_box_pack_end(bx, bt);
51         evas_object_show(bt);
52      }
53
54    elm_object_content_set(obj, bx);
55    evas_object_show(bx);
56 }
57
58 static void
59 fac_realize2(void *data, Evas_Object *obj, void *event_info __UNUSED__)
60 {
61    Evas_Object *win = data;
62    Evas_Object *bx, *fc;
63    int i;
64
65    bx = elm_box_add(win);
66    printf("  ADD lv 2 = %p [%i]\n", bx, (BLOK * (int)(long)evas_object_data_get(obj, "num")));
67 #ifdef HOMOG
68    elm_box_homogeneous_set(bx, EINA_TRUE);
69 #endif
70 #ifdef ZEROALIGN
71    elm_box_align_set(bx, 0.0, 0.0);
72 #endif
73
74    for (i = 0; i < BLOK; i++)
75      {
76         fc = elm_factory_add(win);
77         elm_factory_maxmin_mode_set(fc, EINA_TRUE);
78         // initial height per factory of DEFSZ
79         // scrollbar will be wrong until enough
80         // children have been realized and the
81         // real size is known
82         evas_object_data_set(fc, "num", (void *)(long)(i + (BLOK * (int)(long)evas_object_data_get(obj, "num"))));
83         evas_object_size_hint_min_set(fc, 0, DEFSZ);
84         evas_object_size_hint_weight_set(fc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
85         evas_object_size_hint_align_set(fc, EVAS_HINT_FILL, EVAS_HINT_FILL);
86         evas_object_smart_callback_add(fc, "realize", fac_realize_end, win);
87         evas_object_smart_callback_add(fc, "unrealize", fac_unrealize, win);
88         elm_box_pack_end(bx, fc);
89         evas_object_show(fc);
90      }
91
92    elm_object_content_set(obj, bx);
93    evas_object_show(bx);
94 }
95
96 static void
97 fac_realize1(void *data, Evas_Object *obj, void *event_info __UNUSED__)
98 {
99    Evas_Object *win = data;
100    Evas_Object *bx, *fc;
101    int i;
102
103    bx = elm_box_add(win);
104    printf(" ADD lv 1 = %p [%i]\n", bx, (BLOK * (int)(long)evas_object_data_get(obj, "num")));
105 #ifdef HOMOG
106    elm_box_homogeneous_set(bx, EINA_TRUE);
107 #endif
108 #ifdef ZEROALIGN
109    elm_box_align_set(bx, 0.0, 0.0);
110 #endif
111
112    for (i = 0; i < BLOK; i++)
113      {
114         fc = elm_factory_add(win);
115         elm_factory_maxmin_mode_set(fc, EINA_TRUE);
116         // initial height per factory of DEFSZ
117         // scrollbar will be wrong until enough
118         // children have been realized and the
119         // real size is known
120         evas_object_data_set(fc, "num", (void *)(long)(i + (BLOK * (int)(long)evas_object_data_get(obj, "num"))));
121         evas_object_size_hint_min_set(fc, 0, DEFSZ);
122         evas_object_size_hint_weight_set(fc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
123         evas_object_size_hint_align_set(fc, EVAS_HINT_FILL, EVAS_HINT_FILL);
124         evas_object_smart_callback_add(fc, "realize", fac_realize2, win);
125 //        evas_object_smart_callback_add(fc, "unrealize", fac_unrealize, win);
126         elm_box_pack_end(bx, fc);
127         evas_object_show(fc);
128      }
129
130    elm_object_content_set(obj, bx);
131    evas_object_show(bx);
132 }
133
134 void
135 test_factory(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
136 {
137    Evas_Object *win, *bx, *sc, *fc;
138    int i;
139
140    win = elm_win_util_standard_add("factory", "Factory");
141    elm_win_autodel_set(win, EINA_TRUE);
142
143    bx = elm_box_add(win);
144 #ifdef HOMOG
145    elm_box_homogeneous_set(bx, EINA_TRUE);
146 #endif
147 #ifdef ZEROALIGN
148    elm_box_align_set(bx, 0.0, 0.0);
149 #endif
150    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
151
152    for (i = 0; i < BLOK; i++)
153      {
154         fc = elm_factory_add(win);
155         elm_factory_maxmin_mode_set(fc, EINA_TRUE);
156         // initial height per factory of DEFSZ
157         // scrollbar will be wrong until enough
158         // children have been realized and the
159         // real size is known
160         evas_object_data_set(fc, "num", (void *)(long)i);
161         evas_object_size_hint_min_set(fc, 0, DEFSZ);
162         evas_object_size_hint_weight_set(fc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
163         evas_object_size_hint_align_set(fc, EVAS_HINT_FILL, EVAS_HINT_FILL);
164         evas_object_smart_callback_add(fc, "realize", fac_realize1, win);
165 //        evas_object_smart_callback_add(fc, "unrealize", fac_unrealize, win);
166         elm_box_pack_end(bx, fc);
167         evas_object_show(fc);
168      }
169
170    sc = elm_scroller_add(win);
171    elm_scroller_bounce_set(sc, EINA_FALSE, EINA_TRUE);
172    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
173    elm_win_resize_object_add(win, sc);
174
175    elm_object_content_set(sc, bx);
176    evas_object_show(bx);
177
178    evas_object_show(sc);
179
180    evas_object_resize(win, 320, 480);
181    evas_object_show(win);
182 }
183 #endif