diff options
Diffstat (limited to 'libraries/elementary/src/bin/test_bg.c')
-rw-r--r-- | libraries/elementary/src/bin/test_bg.c | 270 |
1 files changed, 270 insertions, 0 deletions
diff --git a/libraries/elementary/src/bin/test_bg.c b/libraries/elementary/src/bin/test_bg.c new file mode 100644 index 0000000..d0a3829 --- /dev/null +++ b/libraries/elementary/src/bin/test_bg.c | |||
@@ -0,0 +1,270 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include "elementary_config.h" | ||
3 | #endif | ||
4 | #include <Elementary.h> | ||
5 | #ifndef ELM_LIB_QUICKLAUNCH | ||
6 | |||
7 | static void | ||
8 | _cb_size_radio_changed(void *data, Evas_Object *obj, void *event __UNUSED__) | ||
9 | { | ||
10 | Evas_Object *o_bg = data; | ||
11 | int size; | ||
12 | size = elm_radio_value_get((Evas_Object *)obj); | ||
13 | elm_bg_load_size_set(o_bg, size, size); | ||
14 | } | ||
15 | |||
16 | static void | ||
17 | _cb_radio_changed(void *data, Evas_Object *obj, void *event __UNUSED__) | ||
18 | { | ||
19 | Evas_Object *o_bg = data; | ||
20 | |||
21 | elm_bg_option_set(o_bg, elm_radio_value_get((Evas_Object *)obj)); | ||
22 | } | ||
23 | |||
24 | static void | ||
25 | _cb_overlay_changed(void *data, Evas_Object *obj, void *event __UNUSED__) | ||
26 | { | ||
27 | Evas_Object *o_bg = data; | ||
28 | |||
29 | if (elm_check_state_get(obj)) | ||
30 | { | ||
31 | Evas_Object *parent, *over; | ||
32 | char buff[PATH_MAX]; | ||
33 | |||
34 | snprintf(buff, sizeof(buff), "%s/objects/test.edj", elm_app_data_dir_get()); | ||
35 | parent = elm_object_parent_widget_get(o_bg); | ||
36 | over = edje_object_add(evas_object_evas_get(parent)); | ||
37 | edje_object_file_set(over, buff, "bg_overlay"); | ||
38 | elm_object_part_content_set(o_bg, "overlay", over); | ||
39 | } | ||
40 | else | ||
41 | elm_object_part_content_set(o_bg, "overlay", NULL); | ||
42 | } | ||
43 | |||
44 | static void | ||
45 | _cb_color_changed(void *data, Evas_Object *obj, void *event __UNUSED__) | ||
46 | { | ||
47 | Evas_Object *o_bg = data; | ||
48 | double val = 0.0; | ||
49 | |||
50 | val = elm_spinner_value_get(obj); | ||
51 | if (val == 1.0) | ||
52 | elm_bg_color_set(o_bg, 255, 255, 255); | ||
53 | else if (val == 2.0) | ||
54 | elm_bg_color_set(o_bg, 255, 0, 0); | ||
55 | else if (val == 3.0) | ||
56 | elm_bg_color_set(o_bg, 0, 0, 255); | ||
57 | else if (val == 4.0) | ||
58 | elm_bg_color_set(o_bg, 0, 255, 0); | ||
59 | } | ||
60 | |||
61 | void | ||
62 | test_bg_plain(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
63 | { | ||
64 | Evas_Object *win, *bg; | ||
65 | |||
66 | win = elm_win_add(NULL, "bg-plain", ELM_WIN_BASIC); | ||
67 | elm_win_title_set(win, "Bg Plain"); | ||
68 | elm_win_autodel_set(win, EINA_TRUE); | ||
69 | |||
70 | bg = elm_bg_add(win); | ||
71 | /* allow bg to expand in x & y */ | ||
72 | evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
73 | elm_win_resize_object_add(win, bg); | ||
74 | evas_object_show(bg); | ||
75 | |||
76 | /* set size hints. a minimum size for the bg. this should propagate back | ||
77 | * to the window thus limiting its size based off the bg as the bg is one | ||
78 | * of the window's resize objects. */ | ||
79 | evas_object_size_hint_min_set(bg, 160, 160); | ||
80 | /* and set a maximum size. not needed very often. normally used together | ||
81 | * with evas_object_size_hint_min_set() at the same size to make a | ||
82 | * window not resizable */ | ||
83 | evas_object_size_hint_max_set(bg, 640, 640); | ||
84 | /* and now just resize the window to a size you want. normally widgets | ||
85 | * will determine the initial size though */ | ||
86 | evas_object_resize(win, 320, 320); | ||
87 | /* and show the window */ | ||
88 | evas_object_show(win); | ||
89 | } | ||
90 | |||
91 | void | ||
92 | test_bg_image(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
93 | { | ||
94 | Evas_Object *win, *bg; | ||
95 | Evas_Object *box, *hbox, *o_bg; | ||
96 | Evas_Object *rd, *rdg; | ||
97 | char buf[PATH_MAX]; | ||
98 | |||
99 | win = elm_win_add(NULL, "bg-image", ELM_WIN_BASIC); | ||
100 | elm_win_title_set(win, "Bg Image"); | ||
101 | elm_win_autodel_set(win, EINA_TRUE); | ||
102 | |||
103 | bg = elm_bg_add(win); | ||
104 | evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
105 | elm_win_resize_object_add(win, bg); | ||
106 | evas_object_show(bg); | ||
107 | |||
108 | box = elm_box_add(win); | ||
109 | evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
110 | elm_win_resize_object_add(win, box); | ||
111 | evas_object_show(box); | ||
112 | |||
113 | o_bg = elm_bg_add(win); | ||
114 | snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get()); | ||
115 | elm_bg_file_set(o_bg, buf, NULL); | ||
116 | evas_object_size_hint_weight_set(o_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
117 | evas_object_size_hint_align_set(o_bg, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
118 | elm_box_pack_end(box, o_bg); | ||
119 | |||
120 | hbox = elm_box_add(win); | ||
121 | elm_box_horizontal_set(hbox, EINA_TRUE); | ||
122 | evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, EVAS_HINT_FILL); | ||
123 | evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
124 | |||
125 | rd = elm_radio_add(win); | ||
126 | elm_radio_state_value_set(rd, 50); | ||
127 | elm_object_text_set(rd, "50 x 50"); | ||
128 | evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL); | ||
129 | evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, o_bg); | ||
130 | elm_box_pack_end(hbox, rd); | ||
131 | evas_object_show(rd); | ||
132 | rdg = rd; | ||
133 | |||
134 | rd = elm_radio_add(win); | ||
135 | elm_radio_state_value_set(rd, 100); | ||
136 | elm_radio_group_add(rd, rdg); | ||
137 | elm_object_text_set(rd, "100 x 100"); | ||
138 | evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL); | ||
139 | evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, o_bg); | ||
140 | elm_box_pack_end(hbox, rd); | ||
141 | evas_object_show(rd); | ||
142 | |||
143 | rd = elm_radio_add(win); | ||
144 | elm_radio_state_value_set(rd, 200); | ||
145 | elm_radio_group_add(rd, rdg); | ||
146 | elm_object_text_set(rd, "200 x 200"); | ||
147 | evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL); | ||
148 | evas_object_smart_callback_add(rd, "changed", _cb_size_radio_changed, o_bg); | ||
149 | elm_box_pack_end(hbox, rd); | ||
150 | evas_object_show(rd); | ||
151 | |||
152 | elm_radio_value_set(rdg, 200); | ||
153 | |||
154 | elm_box_pack_end(box, hbox); | ||
155 | evas_object_show(hbox); | ||
156 | |||
157 | evas_object_show(o_bg); | ||
158 | evas_object_size_hint_min_set(bg, 160, 160); | ||
159 | evas_object_size_hint_max_set(bg, 640, 640); | ||
160 | evas_object_resize(win, 320, 320); | ||
161 | evas_object_show(win); | ||
162 | } | ||
163 | |||
164 | void | ||
165 | test_bg_options(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) | ||
166 | { | ||
167 | Evas_Object *win, *bg; | ||
168 | Evas_Object *box, *hbox, *o_bg; | ||
169 | Evas_Object *rd, *rdg; | ||
170 | char buf[PATH_MAX]; | ||
171 | |||
172 | win = elm_win_add(NULL, "bg-options", ELM_WIN_BASIC); | ||
173 | elm_win_title_set(win, "Bg Options"); | ||
174 | elm_win_autodel_set(win, EINA_TRUE); | ||
175 | |||
176 | bg = elm_bg_add(win); | ||
177 | evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
178 | elm_win_resize_object_add(win, bg); | ||
179 | evas_object_show(bg); | ||
180 | |||
181 | box = elm_box_add(win); | ||
182 | evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
183 | elm_win_resize_object_add(win, box); | ||
184 | evas_object_show(box); | ||
185 | |||
186 | o_bg = elm_bg_add(win); | ||
187 | snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get()); | ||
188 | elm_bg_file_set(o_bg, buf, NULL); | ||
189 | evas_object_size_hint_weight_set(o_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
190 | evas_object_size_hint_align_set(o_bg, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
191 | elm_box_pack_end(box, o_bg); | ||
192 | evas_object_show(o_bg); | ||
193 | |||
194 | hbox = elm_box_add(win); | ||
195 | elm_box_horizontal_set(hbox, EINA_TRUE); | ||
196 | evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, EVAS_HINT_FILL); | ||
197 | evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
198 | |||
199 | rd = elm_radio_add(win); | ||
200 | elm_radio_state_value_set(rd, ELM_BG_OPTION_CENTER); | ||
201 | elm_object_text_set(rd, "Center"); | ||
202 | evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL); | ||
203 | evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg); | ||
204 | elm_box_pack_end(hbox, rd); | ||
205 | evas_object_show(rd); | ||
206 | rdg = rd; | ||
207 | |||
208 | rd = elm_radio_add(win); | ||
209 | elm_radio_state_value_set(rd, ELM_BG_OPTION_SCALE); | ||
210 | elm_radio_group_add(rd, rdg); | ||
211 | elm_object_text_set(rd, "Scale"); | ||
212 | evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL); | ||
213 | evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg); | ||
214 | elm_box_pack_end(hbox, rd); | ||
215 | evas_object_show(rd); | ||
216 | |||
217 | rd = elm_radio_add(win); | ||
218 | elm_radio_state_value_set(rd, ELM_BG_OPTION_STRETCH); | ||
219 | elm_radio_group_add(rd, rdg); | ||
220 | elm_object_text_set(rd, "Stretch"); | ||
221 | evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL); | ||
222 | evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg); | ||
223 | elm_box_pack_end(hbox, rd); | ||
224 | evas_object_show(rd); | ||
225 | |||
226 | rd = elm_radio_add(win); | ||
227 | elm_radio_state_value_set(rd, ELM_BG_OPTION_TILE); | ||
228 | elm_radio_group_add(rd, rdg); | ||
229 | elm_object_text_set(rd, "Tile"); | ||
230 | evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL); | ||
231 | evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg); | ||
232 | elm_box_pack_end(hbox, rd); | ||
233 | evas_object_show(rd); | ||
234 | |||
235 | elm_radio_value_set(rdg, ELM_BG_OPTION_SCALE); | ||
236 | |||
237 | rd = elm_check_add(win); | ||
238 | elm_object_text_set(rd, "Show Overlay"); | ||
239 | evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL); | ||
240 | evas_object_smart_callback_add(rd, "changed", _cb_overlay_changed, o_bg); | ||
241 | elm_box_pack_end(hbox, rd); | ||
242 | evas_object_show(rd); | ||
243 | |||
244 | /* color choices ... this is ghetto, but we don't have a 'colorpicker' | ||
245 | * widget yet :( */ | ||
246 | rd = elm_spinner_add(win); | ||
247 | elm_object_style_set(rd, "vertical"); | ||
248 | elm_spinner_min_max_set(rd, 1, 4); | ||
249 | elm_spinner_label_format_set(rd, "%.0f"); | ||
250 | elm_spinner_editable_set(rd, EINA_FALSE); | ||
251 | elm_spinner_special_value_add(rd, 1, "White"); | ||
252 | elm_spinner_special_value_add(rd, 2, "Red"); | ||
253 | elm_spinner_special_value_add(rd, 3, "Blue"); | ||
254 | elm_spinner_special_value_add(rd, 4, "Green"); | ||
255 | evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); | ||
256 | evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, EVAS_HINT_FILL); | ||
257 | evas_object_smart_callback_add(rd, "changed", _cb_color_changed, o_bg); | ||
258 | elm_box_pack_end(hbox, rd); | ||
259 | evas_object_show(rd); | ||
260 | |||
261 | elm_box_pack_end(box, hbox); | ||
262 | evas_object_show(hbox); | ||
263 | |||
264 | evas_object_size_hint_min_set(bg, 160, 160); | ||
265 | evas_object_size_hint_max_set(bg, 640, 640); | ||
266 | evas_object_resize(win, 320, 320); | ||
267 | evas_object_show(win); | ||
268 | } | ||
269 | |||
270 | #endif | ||