summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung@gmail.com>2013-06-18 05:37:44 +0900
committerDaniel Juyung Seo <seojuyung@gmail.com>2013-06-18 05:37:44 +0900
commit6232555331ff6ab24370332e74d7958d8c40dd84 (patch)
tree5639a049d20edab5debfb2cedabaf6923719495c
parent19217a89367e1800735244dce2e73573d4d87ed6 (diff)
updated.
-rw-r--r--source/2-step/10-evas-callback/main.c319
-rw-r--r--source/2-step/11-timer/main.c319
-rw-r--r--source/2-step/2-layout/main.c314
-rw-r--r--source/2-step/3-top/main.c314
-rw-r--r--source/2-step/4-middle/main.c314
-rw-r--r--source/2-step/5-arrow/main.c314
-rw-r--r--source/2-step/6-bottom/main.c314
-rw-r--r--source/2-step/7-focus/main.c319
-rw-r--r--source/2-step/8-transit/main.c319
-rw-r--r--source/2-step/9-free/main.c319
-rw-r--r--source/3-final/src/main.c47
11 files changed, 3209 insertions, 3 deletions
diff --git a/source/2-step/10-evas-callback/main.c b/source/2-step/10-evas-callback/main.c
new file mode 100644
index 0000000..7857c3b
--- /dev/null
+++ b/source/2-step/10-evas-callback/main.c
@@ -0,0 +1,319 @@
1#include <Elementary.h>
2
3#define PACKAGE_BIN_DIR "/usr/local/bin"
4#define PACKAGE_DATA_DIR "/usr/local/share/sample"
5
6Evas_Object *create_button(Evas_Object *parent);
7Evas_Object *create_image(Evas_Object *parent, char *path, char *group);
8void btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
9void btn_clicked(void *data, Evas_Object *obj, void *event_info);
10void _left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
11void _right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
12void _btn_effect(Evas_Object *obj);
13
14Evas_Object *
15create_win()
16{
17 Evas_Object *win = NULL;
18
19 // TODO 2
20 win = elm_win_util_standard_add(elm_app_name_get(), elm_app_name_get());
21 // TODO 7
22 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
23 elm_win_autodel_set(win, EINA_TRUE);
24 evas_object_resize(win, 720, 400);
25 evas_object_show(win);
26
27 return win;
28}
29
30Evas_Object *
31create_layout(Evas_Object *win)
32{
33 Evas_Object *layout = NULL;
34 char buf[PATH_MAX];
35
36 layout = elm_layout_add(win);
37 // TODO 2
38 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
39 // TODO 2
40 elm_layout_file_set(layout, buf, "main");
41 // TODO 2
42 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
43 elm_win_resize_object_add(win, layout);
44 evas_object_show(layout);
45
46 return layout;
47}
48
49void
50create_top_contents(Evas_Object *layout)
51{
52 Evas_Object *table = NULL, *btn = NULL, *img = NULL, *label = NULL;
53 int i =0;
54 char buf[PATH_MAX], buf2[PATH_MAX];
55
56 // TODO 3
57 table = elm_table_add(layout);
58
59 for (i = 0; i < 5; i++)
60 {
61 btn = create_button(table);
62 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
63 snprintf(buf2, sizeof(buf2), "icon%d", i);
64 img = create_image(btn, buf, buf2);
65 // TODO 3
66 elm_object_content_set(btn, img);
67
68 elm_table_pack(table, btn, i, 0, 1, 1);
69
70 label = elm_label_add(table);
71 snprintf(buf2, sizeof(buf2), "<color=#ffffff>item%d</color>", i);
72 // TODO 3
73 elm_object_text_set(label, buf2);
74 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
75 evas_object_show(label);
76
77 elm_table_pack(table, label, i, 1, 1, 1);
78 }
79
80 elm_layout_content_set(layout, "elm.swallow.top", table);
81 evas_object_show(table);
82
83}
84
85void
86create_middle_contents(Evas_Object *layout)
87{
88 Evas_Object *table = NULL, *btn = NULL, *img = NULL;
89 Evas_Coord padding_size = 0;
90 int i = 0, j = 0;
91 char buf[PATH_MAX];
92
93 table = elm_table_add(layout);
94 // TODO 4
95 padding_size = 7 * elm_config_scale_get();
96 elm_table_padding_set(table, padding_size, padding_size);
97
98 for (i = 0; i < 3; i++)
99 {
100 for (j = 0; j < 6; j++)
101 {
102 btn = create_button(table);
103
104 // TODO 10
105 // elm_button "clicked" smart callback
106 //evas_object_**(**, **, btn_clicked, NULL);
107
108 // TODO 10
109 // evas object mouse in callback
110 //evas_object_**(**, **, btn_mouse_in, NULL);
111
112 snprintf(buf, sizeof(buf), "%s/images/%d.jpg", elm_app_data_dir_get(), ((i * 6) + j));
113 img = create_image(btn, buf, NULL);
114 elm_object_content_set(btn, img);
115 // TODO 4
116 elm_table_pack(table, btn, j, i, 1, 1);
117 }
118 }
119
120 // TODO 4
121 elm_layout_content_set(layout, "elm.swallow.middle", table);
122 evas_object_show(table);
123}
124
125void
126create_arrows(Evas_Object *layout)
127{
128 Evas_Object *btn = NULL, *img = NULL;
129 char buf[PATH_MAX];
130
131 //Create a Left arrow
132 btn = create_button(layout);
133 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
134 // TODO 5
135 img = create_image(btn, buf, "left_arrow");
136 elm_object_content_set(btn, img);
137 // TODO 5
138 elm_layout_content_set(layout, "elm.swallow.left_arrow", btn);
139 evas_object_show(btn);
140 // TODO 10
141 //evas_object_smart_callback_add(btn, **, _left_arrow_clicked_cb, layout);
142
143 //Create a Right arrow
144 btn = create_button(layout);
145 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
146 // TODO 5
147 img = create_image(btn, buf, "right_arrow");
148 elm_object_content_set(btn, img);
149 // TODO 5
150 elm_layout_content_set(layout, "elm.swallow.right_arrow", btn);
151 evas_object_show(btn);
152 // TODO 10
153 //evas_object_smart_callback_add(btn, **, _right_arrow_clicked_cb, layout);
154}
155
156void
157toolbar_it_cb(void *data, Evas_Object *obj, void *event_info)
158{
159 Elm_Object_Item *it = event_info;
160 printf("%s\n", elm_object_item_text_get(it));
161 Evas_Object *layout = data;
162 if (!layout) return;
163 // TODO 6
164 elm_layout_text_set(layout, "elm.text.news", elm_object_item_text_get(it));
165}
166
167void
168create_bottom_contents(Evas_Object *layout)
169{
170 Evas_Object *toolbar = NULL;
171
172 // TODO 6
173 toolbar = elm_toolbar_add(layout);
174 elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);
175 elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE);
176 elm_toolbar_homogeneous_set(toolbar, EINA_TRUE);
177
178 // TODO 6
179 elm_toolbar_item_append(toolbar, NULL, "Guide", toolbar_it_cb, layout);
180 elm_toolbar_item_append(toolbar, NULL, "Time Line View", toolbar_it_cb, layout);
181 elm_toolbar_item_append(toolbar, NULL, "Recorded TV", toolbar_it_cb, layout);
182 elm_toolbar_item_append(toolbar, NULL, "Downloads", toolbar_it_cb, layout);
183 elm_toolbar_item_append(toolbar, NULL, "Favorites", toolbar_it_cb, layout);
184 elm_toolbar_item_append(toolbar, NULL, "YouTube", toolbar_it_cb, layout);
185
186 elm_layout_content_set(layout, "elm.swallow.bottom", toolbar);
187 evas_object_show(toolbar);
188}
189
190void
191init(void)
192{
193 Evas_Object *win = NULL, *layout = NULL;
194
195 //Create a Window
196 win = create_win();
197
198 //Create a Layout
199 layout = create_layout(win);
200
201 //Create Top Contents
202 create_top_contents(layout);
203
204 //Create Middle Contents
205 create_middle_contents(layout);
206
207 //Create Arrows
208 create_arrows(layout);
209
210 //Create Bottom Contents
211 create_bottom_contents(layout);
212}
213
214Evas_Object *
215create_button(Evas_Object *parent)
216{
217 Evas_Object *btn = NULL;
218
219 btn = elm_button_add(parent);
220 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
221 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
222 evas_object_show(btn);
223
224 return btn;
225}
226
227Evas_Object *
228create_image(Evas_Object *parent, char *path, char *group)
229{
230 Evas_Object *img = NULL;
231
232 img = elm_image_add(parent);
233 elm_image_file_set(img, path, group);
234 evas_object_show(img);
235
236 return img;
237}
238
239void
240btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
241{
242 _btn_effect(obj);
243}
244
245void
246btn_clicked(void *data, Evas_Object *obj, void *event_info)
247{
248 _btn_effect(obj);
249}
250
251Eina_Bool
252_left_arrow_timer_cb(void *data)
253{
254 Evas_Object *layout = data;
255 if (!data) return ECORE_CALLBACK_CANCEL;
256 // TODO 11
257 //elm_layout_signal_emit(layout, ** , **);
258
259 // TODO 11
260 //return ECORE_CALLBACK_**;
261}
262
263// TODO 10
264void
265_left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
266{
267 Evas_Object *layout = data;
268 if (!layout) return;
269 // TODO 10
270 //elm_layout_signal_emit(layout, **, **);
271
272 // TODO 11
273 //ecore_timer_add(**, _left_arrow_timer_cb, layout);
274}
275
276// TODO 10
277void
278_right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
279{
280 Evas_Object *layout = data;
281 if (!layout) return;
282 elm_exit();
283}
284
285void
286_btn_effect(Evas_Object *obj)
287{
288 evas_object_raise(obj);
289
290 Elm_Transit *transit = elm_transit_add();
291 elm_transit_object_add(transit, obj);
292 elm_transit_duration_set(transit, 0.25);
293 // TODO 8
294 elm_transit_auto_reverse_set(transit, EINA_TRUE);
295 elm_transit_effect_zoom_add(transit, 1.0, 1.25);
296 elm_transit_smooth_set(transit, EINA_FALSE);
297 elm_transit_go(transit);
298}
299
300EAPI_MAIN int
301elm_main(int argc, char **argv)
302{
303 //Set App Directory
304 // TODO 2
305 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
306 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
307 elm_app_info_set(elm_main, "sample", "images/bg.jpg");
308
309 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
310
311 init();
312
313 elm_run();
314
315 elm_shutdown();
316
317 return 0;
318}
319ELM_MAIN()
diff --git a/source/2-step/11-timer/main.c b/source/2-step/11-timer/main.c
new file mode 100644
index 0000000..fc92e12
--- /dev/null
+++ b/source/2-step/11-timer/main.c
@@ -0,0 +1,319 @@
1#include <Elementary.h>
2
3#define PACKAGE_BIN_DIR "/usr/local/bin"
4#define PACKAGE_DATA_DIR "/usr/local/share/sample"
5
6Evas_Object *create_button(Evas_Object *parent);
7Evas_Object *create_image(Evas_Object *parent, char *path, char *group);
8void btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
9void btn_clicked(void *data, Evas_Object *obj, void *event_info);
10void _left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
11void _right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
12void _btn_effect(Evas_Object *obj);
13
14Evas_Object *
15create_win()
16{
17 Evas_Object *win = NULL;
18
19 // TODO 2
20 win = elm_win_util_standard_add(elm_app_name_get(), elm_app_name_get());
21 // TODO 7
22 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
23 elm_win_autodel_set(win, EINA_TRUE);
24 evas_object_resize(win, 720, 400);
25 evas_object_show(win);
26
27 return win;
28}
29
30Evas_Object *
31create_layout(Evas_Object *win)
32{
33 Evas_Object *layout = NULL;
34 char buf[PATH_MAX];
35
36 layout = elm_layout_add(win);
37 // TODO 2
38 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
39 // TODO 2
40 elm_layout_file_set(layout, buf, "main");
41 // TODO 2
42 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
43 elm_win_resize_object_add(win, layout);
44 evas_object_show(layout);
45
46 return layout;
47}
48
49void
50create_top_contents(Evas_Object *layout)
51{
52 Evas_Object *table = NULL, *btn = NULL, *img = NULL, *label = NULL;
53 int i =0;
54 char buf[PATH_MAX], buf2[PATH_MAX];
55
56 // TODO 3
57 table = elm_table_add(layout);
58
59 for (i = 0; i < 5; i++)
60 {
61 btn = create_button(table);
62 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
63 snprintf(buf2, sizeof(buf2), "icon%d", i);
64 img = create_image(btn, buf, buf2);
65 // TODO 3
66 elm_object_content_set(btn, img);
67
68 elm_table_pack(table, btn, i, 0, 1, 1);
69
70 label = elm_label_add(table);
71 snprintf(buf2, sizeof(buf2), "<color=#ffffff>item%d</color>", i);
72 // TODO 3
73 elm_object_text_set(label, buf2);
74 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
75 evas_object_show(label);
76
77 elm_table_pack(table, label, i, 1, 1, 1);
78 }
79
80 elm_layout_content_set(layout, "elm.swallow.top", table);
81 evas_object_show(table);
82
83}
84
85void
86create_middle_contents(Evas_Object *layout)
87{
88 Evas_Object *table = NULL, *btn = NULL, *img = NULL;
89 Evas_Coord padding_size = 0;
90 int i = 0, j = 0;
91 char buf[PATH_MAX];
92
93 table = elm_table_add(layout);
94 // TODO 4
95 padding_size = 7 * elm_config_scale_get();
96 elm_table_padding_set(table, padding_size, padding_size);
97
98 for (i = 0; i < 3; i++)
99 {
100 for (j = 0; j < 6; j++)
101 {
102 btn = create_button(table);
103
104 // TODO 10
105 // elm_button "clicked" smart callback
106 evas_object_smart_callback_add(btn, "clicked", btn_clicked, NULL);
107
108 // TODO 10
109 // evas object mouse in callback
110 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, btn_mouse_in, NULL);
111
112 snprintf(buf, sizeof(buf), "%s/images/%d.jpg", elm_app_data_dir_get(), ((i * 6) + j));
113 img = create_image(btn, buf, NULL);
114 elm_object_content_set(btn, img);
115 // TODO 4
116 elm_table_pack(table, btn, j, i, 1, 1);
117 }
118 }
119
120 // TODO 4
121 elm_layout_content_set(layout, "elm.swallow.middle", table);
122 evas_object_show(table);
123}
124
125void
126create_arrows(Evas_Object *layout)
127{
128 Evas_Object *btn = NULL, *img = NULL;
129 char buf[PATH_MAX];
130
131 //Create a Left arrow
132 btn = create_button(layout);
133 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
134 // TODO 5
135 img = create_image(btn, buf, "left_arrow");
136 elm_object_content_set(btn, img);
137 // TODO 5
138 elm_layout_content_set(layout, "elm.swallow.left_arrow", btn);
139 evas_object_show(btn);
140 // TODO 10
141 evas_object_smart_callback_add(btn, "clicked", _left_arrow_clicked_cb, layout);
142
143 //Create a Right arrow
144 btn = create_button(layout);
145 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
146 // TODO 5
147 img = create_image(btn, buf, "right_arrow");
148 elm_object_content_set(btn, img);
149 // TODO 5
150 elm_layout_content_set(layout, "elm.swallow.right_arrow", btn);
151 evas_object_show(btn);
152 // TODO 10
153 evas_object_smart_callback_add(btn, "clicked", _right_arrow_clicked_cb, layout);
154}
155
156void
157toolbar_it_cb(void *data, Evas_Object *obj, void *event_info)
158{
159 Elm_Object_Item *it = event_info;
160 printf("%s\n", elm_object_item_text_get(it));
161 Evas_Object *layout = data;
162 if (!layout) return;
163 // TODO 6
164 elm_layout_text_set(layout, "elm.text.news", elm_object_item_text_get(it));
165}
166
167void
168create_bottom_contents(Evas_Object *layout)
169{
170 Evas_Object *toolbar = NULL;
171
172 // TODO 6
173 toolbar = elm_toolbar_add(layout);
174 elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);
175 elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE);
176 elm_toolbar_homogeneous_set(toolbar, EINA_TRUE);
177
178 // TODO 6
179 elm_toolbar_item_append(toolbar, NULL, "Guide", toolbar_it_cb, layout);
180 elm_toolbar_item_append(toolbar, NULL, "Time Line View", toolbar_it_cb, layout);
181 elm_toolbar_item_append(toolbar, NULL, "Recorded TV", toolbar_it_cb, layout);
182 elm_toolbar_item_append(toolbar, NULL, "Downloads", toolbar_it_cb, layout);
183 elm_toolbar_item_append(toolbar, NULL, "Favorites", toolbar_it_cb, layout);
184 elm_toolbar_item_append(toolbar, NULL, "YouTube", toolbar_it_cb, layout);
185
186 elm_layout_content_set(layout, "elm.swallow.bottom", toolbar);
187 evas_object_show(toolbar);
188}
189
190void
191init(void)
192{
193 Evas_Object *win = NULL, *layout = NULL;
194
195 //Create a Window
196 win = create_win();
197
198 //Create a Layout
199 layout = create_layout(win);
200
201 //Create Top Contents
202 create_top_contents(layout);
203
204 //Create Middle Contents
205 create_middle_contents(layout);
206
207 //Create Arrows
208 create_arrows(layout);
209
210 //Create Bottom Contents
211 create_bottom_contents(layout);
212}
213
214Evas_Object *
215create_button(Evas_Object *parent)
216{
217 Evas_Object *btn = NULL;
218
219 btn = elm_button_add(parent);
220 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
221 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
222 evas_object_show(btn);
223
224 return btn;
225}
226
227Evas_Object *
228create_image(Evas_Object *parent, char *path, char *group)
229{
230 Evas_Object *img = NULL;
231
232 img = elm_image_add(parent);
233 elm_image_file_set(img, path, group);
234 evas_object_show(img);
235
236 return img;
237}
238
239void
240btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
241{
242 _btn_effect(obj);
243}
244
245void
246btn_clicked(void *data, Evas_Object *obj, void *event_info)
247{
248 _btn_effect(obj);
249}
250
251Eina_Bool
252_left_arrow_timer_cb(void *data)
253{
254 Evas_Object *layout = data;
255 if (!data) return ECORE_CALLBACK_CANCEL;
256 // TODO 11
257 //elm_layout_signal_emit(layout, ** , **);
258
259 // TODO 11
260 //return ECORE_CALLBACK_**;
261}
262
263// TODO 10
264void
265_left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
266{
267 Evas_Object *layout = data;
268 if (!layout) return;
269 // TODO 10
270 elm_layout_signal_emit(layout, "elm,state,arrow,hide" , "elm");
271
272 // TODO 11
273 //ecore_timer_add(**, _left_arrow_timer_cb, layout);
274}
275
276// TODO 10
277void
278_right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
279{
280 Evas_Object *layout = data;
281 if (!layout) return;
282 elm_exit();
283}
284
285void
286_btn_effect(Evas_Object *obj)
287{
288 evas_object_raise(obj);
289
290 Elm_Transit *transit = elm_transit_add();
291 elm_transit_object_add(transit, obj);
292 elm_transit_duration_set(transit, 0.25);
293 // TODO 8
294 elm_transit_auto_reverse_set(transit, EINA_TRUE);
295 elm_transit_effect_zoom_add(transit, 1.0, 1.25);
296 elm_transit_smooth_set(transit, EINA_FALSE);
297 elm_transit_go(transit);
298}
299
300EAPI_MAIN int
301elm_main(int argc, char **argv)
302{
303 //Set App Directory
304 // TODO 2
305 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
306 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
307 elm_app_info_set(elm_main, "sample", "images/bg.jpg");
308
309 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
310
311 init();
312
313 elm_run();
314
315 elm_shutdown();
316
317 return 0;
318}
319ELM_MAIN()
diff --git a/source/2-step/2-layout/main.c b/source/2-step/2-layout/main.c
new file mode 100644
index 0000000..34fe29d
--- /dev/null
+++ b/source/2-step/2-layout/main.c
@@ -0,0 +1,314 @@
1#include <Elementary.h>
2
3#define PACKAGE_BIN_DIR "/usr/local/bin"
4#define PACKAGE_DATA_DIR "/usr/local/share/sample"
5
6Evas_Object *create_button(Evas_Object *parent);
7Evas_Object *create_image(Evas_Object *parent, char *path, char *group);
8void btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
9void btn_clicked(void *data, Evas_Object *obj, void *event_info);
10void _left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
11void _right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
12void _btn_effect(Evas_Object *obj);
13
14Evas_Object *
15create_win()
16{
17 Evas_Object *win = NULL;
18
19 // TODO 2
20 //win = elm_win_util_standard_add(**, **);
21 // TODO 7
22 //elm_win_**_set(win, EINA_TRUE);
23 elm_win_autodel_set(win, EINA_TRUE);
24 evas_object_resize(win, 720, 400);
25 evas_object_show(win);
26
27 return win;
28}
29
30Evas_Object *
31create_layout(Evas_Object *win)
32{
33 Evas_Object *layout = NULL;
34 char buf[PATH_MAX];
35
36 layout = elm_layout_add(win);
37 // TODO 2
38 //snprintf(buf, sizeof(buf), "%s/edj/layout.edj", **);
39 // TODO 2
40 //elm_layout_**_set(layout, buf, **);
41 // TODO 2
42 //evas_object_size_hint_weight_set(layout, **, **);
43 elm_win_resize_object_add(win, layout);
44 evas_object_show(layout);
45
46 return layout;
47}
48
49void
50create_top_contents(Evas_Object *layout)
51{
52 Evas_Object *table = NULL, *btn = NULL, *img = NULL, *label = NULL;
53 int i =0;
54 char buf[PATH_MAX], buf2[PATH_MAX];
55
56 // TODO 3
57 //table = **(layout);
58
59 for (i = 0; i < 5; i++)
60 {
61 btn = create_button(table);
62 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
63 snprintf(buf2, sizeof(buf2), "icon%d", i);
64 img = create_image(btn, buf, buf2);
65 // TODO 3
66 //elm_object_content_set(**, **);
67
68 elm_table_pack(table, btn, i, 0, 1, 1);
69
70 label = elm_label_add(table);
71 snprintf(buf2, sizeof(buf2), "<color=#ffffff>item%d</color>", i);
72 // TODO 3
73 //elm_object_text_set(**, **);
74 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
75 evas_object_show(label);
76
77 elm_table_pack(table, label, i, 1, 1, 1);
78 }
79
80 elm_layout_content_set(layout, "elm.swallow.top", table);
81 evas_object_show(table);
82
83}
84
85void
86create_middle_contents(Evas_Object *layout)
87{
88 Evas_Object *table = NULL, *btn = NULL, *img = NULL;
89 Evas_Coord padding_size = 0;
90 int i = 0, j = 0;
91 char buf[PATH_MAX];
92
93 table = elm_table_add(layout);
94 // TODO 4
95 //padding_size = 7 * elm_config_scale_get();
96 //elm_table_**_set(table, padding_size, padding_size);
97
98 for (i = 0; i < 3; i++)
99 {
100 for (j = 0; j < 6; j++)
101 {
102 btn = create_button(table);
103
104 // TODO 10
105 // elm_button "clicked" smart callback
106 //evas_object_**(**, **, btn_clicked, NULL);
107
108 // TODO 10
109 // evas object mouse in callback
110 //evas_object_**(**, **, btn_mouse_in, NULL);
111
112 snprintf(buf, sizeof(buf), "%s/images/%d.jpg", elm_app_data_dir_get(), ((i * 6) + j));
113 img = create_image(btn, buf, NULL);
114 elm_object_content_set(btn, img);
115 // TODO 4
116 //elm_table_pack();
117 }
118 }
119
120 // TODO 4
121 //elm_layout_content_set(**, **, **);
122 evas_object_show(table);
123}
124
125void
126create_arrows(Evas_Object *layout)
127{
128 Evas_Object *btn = NULL, *img = NULL;
129 char buf[PATH_MAX];
130
131 //Create a Left arrow
132 btn = create_button(layout);
133 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
134 // TODO 5
135 //img = create_image(btn, buf, **);
136 elm_object_content_set(btn, img);
137 // TODO 5
138 //elm_layout_content_set(layout, **, btn);
139 evas_object_show(btn);
140 // TODO 10
141 //evas_object_smart_callback_add(btn, **, _left_arrow_clicked_cb, layout);
142
143 //Create a Right arrow
144 btn = create_button(layout);
145 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
146 // TODO 5
147 //img = create_image(btn, buf, **);
148 elm_object_content_set(btn, img);
149 // TODO 5
150 //elm_layout_content_set(layout, **, btn);
151 evas_object_show(btn);
152 // TODO 10
153 //evas_object_smart_callback_add(btn, **, _right_arrow_clicked_cb, layout);
154}
155
156void
157toolbar_it_cb(void *data, Evas_Object *obj, void *event_info)
158{
159 Elm_Object_Item *it = event_info;
160 printf("%s\n", elm_object_item_text_get(it));
161 Evas_Object *layout = data;
162 if (!layout) return;
163 // TODO 6
164 //elm_layout_text_set(layout, "elm.text.news", **);
165}
166
167void
168create_bottom_contents(Evas_Object *layout)
169{
170 Evas_Object *toolbar = NULL;
171
172 toolbar = elm_toolbar_add(layout);
173 elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);
174 elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE);
175 // TODO 6
176 //elm_toolbar_**_set(toolbar, EINA_TRUE);
177
178 // TODO 6
179 //elm_toolbar_item_append();
180
181 elm_layout_content_set(layout, "elm.swallow.bottom", toolbar);
182 evas_object_show(toolbar);
183}
184
185void
186init(void)
187{
188 Evas_Object *win = NULL, *layout = NULL;
189
190 //Create a Window
191 win = create_win();
192
193 //Create a Layout
194 layout = create_layout(win);
195
196 //Create Top Contents
197 create_top_contents(layout);
198
199 //Create Middle Contents
200 create_middle_contents(layout);
201
202 //Create Arrows
203 create_arrows(layout);
204
205 //Create Bottom Contents
206 create_bottom_contents(layout);
207}
208
209Evas_Object *
210create_button(Evas_Object *parent)
211{
212 Evas_Object *btn = NULL;
213
214 btn = elm_button_add(parent);
215 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
216 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
217 evas_object_show(btn);
218
219 return btn;
220}
221
222Evas_Object *
223create_image(Evas_Object *parent, char *path, char *group)
224{
225 Evas_Object *img = NULL;
226
227 img = elm_image_add(parent);
228 elm_image_file_set(img, path, group);
229 evas_object_show(img);
230
231 return img;
232}
233
234void
235btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
236{
237 _btn_effect(obj);
238}
239
240void
241btn_clicked(void *data, Evas_Object *obj, void *event_info)
242{
243 _btn_effect(obj);
244}
245
246Eina_Bool
247_left_arrow_timer_cb(void *data)
248{
249 Evas_Object *layout = data;
250 if (!data) return ECORE_CALLBACK_CANCEL;
251 // TODO 11
252 //elm_layout_signal_emit(layout, ** , **);
253
254 // TODO 11
255 //return ECORE_CALLBACK_**;
256}
257
258// TODO 10
259void
260_left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
261{
262 Evas_Object *layout = data;
263 if (!layout) return;
264 // TODO 10
265 //elm_layout_signal_emit(layout, **, **);
266
267 // TODO 11
268 //ecore_timer_add(**, _left_arrow_timer_cb, layout);
269}
270
271// TODO 10
272void
273_right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
274{
275 Evas_Object *layout = data;
276 if (!layout) return;
277 elm_exit();
278}
279
280void
281_btn_effect(Evas_Object *obj)
282{
283 evas_object_raise(obj);
284
285 Elm_Transit *transit = elm_transit_add();
286 elm_transit_object_add(transit, obj);
287 elm_transit_duration_set(transit, 0.25);
288 // TODO 8
289 //elm_transit_**_set(transit, EINA_TRUE);
290 elm_transit_effect_zoom_add(transit, 1.0, 1.25);
291 elm_transit_smooth_set(transit, EINA_FALSE);
292 elm_transit_go(transit);
293}
294
295EAPI_MAIN int
296elm_main(int argc, char **argv)
297{
298 //Set App Directory
299 // TODO 2
300 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
301 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
302 elm_app_info_set(elm_main, "sample", "images/bg.jpg");
303
304 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
305
306 init();
307
308 elm_run();
309
310 elm_shutdown();
311
312 return 0;
313}
314ELM_MAIN()
diff --git a/source/2-step/3-top/main.c b/source/2-step/3-top/main.c
new file mode 100644
index 0000000..b236751
--- /dev/null
+++ b/source/2-step/3-top/main.c
@@ -0,0 +1,314 @@
1#include <Elementary.h>
2
3#define PACKAGE_BIN_DIR "/usr/local/bin"
4#define PACKAGE_DATA_DIR "/usr/local/share/sample"
5
6Evas_Object *create_button(Evas_Object *parent);
7Evas_Object *create_image(Evas_Object *parent, char *path, char *group);
8void btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
9void btn_clicked(void *data, Evas_Object *obj, void *event_info);
10void _left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
11void _right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
12void _btn_effect(Evas_Object *obj);
13
14Evas_Object *
15create_win()
16{
17 Evas_Object *win = NULL;
18
19 // TODO 2
20 win = elm_win_util_standard_add(elm_app_name_get(), elm_app_name_get());
21 // TODO 7
22 //elm_win_**_set(win, EINA_TRUE);
23 elm_win_autodel_set(win, EINA_TRUE);
24 evas_object_resize(win, 720, 400);
25 evas_object_show(win);
26
27 return win;
28}
29
30Evas_Object *
31create_layout(Evas_Object *win)
32{
33 Evas_Object *layout = NULL;
34 char buf[PATH_MAX];
35
36 layout = elm_layout_add(win);
37 // TODO 2
38 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
39 // TODO 2
40 elm_layout_file_set(layout, buf, "main");
41 // TODO 2
42 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
43 elm_win_resize_object_add(win, layout);
44 evas_object_show(layout);
45
46 return layout;
47}
48
49void
50create_top_contents(Evas_Object *layout)
51{
52 Evas_Object *table = NULL, *btn = NULL, *img = NULL, *label = NULL;
53 int i =0;
54 char buf[PATH_MAX], buf2[PATH_MAX];
55
56 // TODO 3
57 //table = **(layout);
58
59 for (i = 0; i < 5; i++)
60 {
61 btn = create_button(table);
62 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
63 snprintf(buf2, sizeof(buf2), "icon%d", i);
64 img = create_image(btn, buf, buf2);
65 // TODO 3
66 //elm_object_content_set(**, **);
67
68 elm_table_pack(table, btn, i, 0, 1, 1);
69
70 label = elm_label_add(table);
71 snprintf(buf2, sizeof(buf2), "<color=#ffffff>item%d</color>", i);
72 // TODO 3
73 //elm_object_text_set(**, **);
74 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
75 evas_object_show(label);
76
77 elm_table_pack(table, label, i, 1, 1, 1);
78 }
79
80 elm_layout_content_set(layout, "elm.swallow.top", table);
81 evas_object_show(table);
82
83}
84
85void
86create_middle_contents(Evas_Object *layout)
87{
88 Evas_Object *table = NULL, *btn = NULL, *img = NULL;
89 Evas_Coord padding_size = 0;
90 int i = 0, j = 0;
91 char buf[PATH_MAX];
92
93 table = elm_table_add(layout);
94 // TODO 4
95 //padding_size = 7 * elm_config_scale_get();
96 //elm_table_**_set(table, padding_size, padding_size);
97
98 for (i = 0; i < 3; i++)
99 {
100 for (j = 0; j < 6; j++)
101 {
102 btn = create_button(table);
103
104 // TODO 10
105 // elm_button "clicked" smart callback
106 //evas_object_**(**, **, btn_clicked, NULL);
107
108 // TODO 10
109 // evas object mouse in callback
110 //evas_object_**(**, **, btn_mouse_in, NULL);
111
112 snprintf(buf, sizeof(buf), "%s/images/%d.jpg", elm_app_data_dir_get(), ((i * 6) + j));
113 img = create_image(btn, buf, NULL);
114 elm_object_content_set(btn, img);
115 // TODO 4
116 //elm_table_pack();
117 }
118 }
119
120 // TODO 4
121 //elm_layout_content_set(**, **, **);
122 evas_object_show(table);
123}
124
125void
126create_arrows(Evas_Object *layout)
127{
128 Evas_Object *btn = NULL, *img = NULL;
129 char buf[PATH_MAX];
130
131 //Create a Left arrow
132 btn = create_button(layout);
133 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
134 // TODO 5
135 //img = create_image(btn, buf, **);
136 elm_object_content_set(btn, img);
137 // TODO 5
138 //elm_layout_content_set(layout, **, btn);
139 evas_object_show(btn);
140 // TODO 10
141 //evas_object_smart_callback_add(btn, **, _left_arrow_clicked_cb, layout);
142
143 //Create a Right arrow
144 btn = create_button(layout);
145 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
146 // TODO 5
147 //img = create_image(btn, buf, **);
148 elm_object_content_set(btn, img);
149 // TODO 5
150 //elm_layout_content_set(layout, **, btn);
151 evas_object_show(btn);
152 // TODO 10
153 //evas_object_smart_callback_add(btn, **, _right_arrow_clicked_cb, layout);
154}
155
156void
157toolbar_it_cb(void *data, Evas_Object *obj, void *event_info)
158{
159 Elm_Object_Item *it = event_info;
160 printf("%s\n", elm_object_item_text_get(it));
161 Evas_Object *layout = data;
162 if (!layout) return;
163 // TODO 6
164 //elm_layout_text_set(layout, "elm.text.news", **);
165}
166
167void
168create_bottom_contents(Evas_Object *layout)
169{
170 Evas_Object *toolbar = NULL;
171
172 toolbar = elm_toolbar_add(layout);
173 elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);
174 elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE);
175 // TODO 6
176 //elm_toolbar_**_set(toolbar, EINA_TRUE);
177
178 // TODO 6
179 //elm_toolbar_item_append();
180
181 elm_layout_content_set(layout, "elm.swallow.bottom", toolbar);
182 evas_object_show(toolbar);
183}
184
185void
186init(void)
187{
188 Evas_Object *win = NULL, *layout = NULL;
189
190 //Create a Window
191 win = create_win();
192
193 //Create a Layout
194 layout = create_layout(win);
195
196 //Create Top Contents
197 create_top_contents(layout);
198
199 //Create Middle Contents
200 create_middle_contents(layout);
201
202 //Create Arrows
203 create_arrows(layout);
204
205 //Create Bottom Contents
206 create_bottom_contents(layout);
207}
208
209Evas_Object *
210create_button(Evas_Object *parent)
211{
212 Evas_Object *btn = NULL;
213
214 btn = elm_button_add(parent);
215 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
216 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
217 evas_object_show(btn);
218
219 return btn;
220}
221
222Evas_Object *
223create_image(Evas_Object *parent, char *path, char *group)
224{
225 Evas_Object *img = NULL;
226
227 img = elm_image_add(parent);
228 elm_image_file_set(img, path, group);
229 evas_object_show(img);
230
231 return img;
232}
233
234void
235btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
236{
237 _btn_effect(obj);
238}
239
240void
241btn_clicked(void *data, Evas_Object *obj, void *event_info)
242{
243 _btn_effect(obj);
244}
245
246Eina_Bool
247_left_arrow_timer_cb(void *data)
248{
249 Evas_Object *layout = data;
250 if (!data) return ECORE_CALLBACK_CANCEL;
251 // TODO 11
252 //elm_layout_signal_emit(layout, ** , **);
253
254 // TODO 11
255 //return ECORE_CALLBACK_**;
256}
257
258// TODO 10
259void
260_left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
261{
262 Evas_Object *layout = data;
263 if (!layout) return;
264 // TODO 10
265 //elm_layout_signal_emit(layout, **, **);
266
267 // TODO 11
268 //ecore_timer_add(**, _left_arrow_timer_cb, layout);
269}
270
271// TODO 10
272void
273_right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
274{
275 Evas_Object *layout = data;
276 if (!layout) return;
277 elm_exit();
278}
279
280void
281_btn_effect(Evas_Object *obj)
282{
283 evas_object_raise(obj);
284
285 Elm_Transit *transit = elm_transit_add();
286 elm_transit_object_add(transit, obj);
287 elm_transit_duration_set(transit, 0.25);
288 // TODO 8
289 //elm_transit_**_set(transit, EINA_TRUE);
290 elm_transit_effect_zoom_add(transit, 1.0, 1.25);
291 elm_transit_smooth_set(transit, EINA_FALSE);
292 elm_transit_go(transit);
293}
294
295EAPI_MAIN int
296elm_main(int argc, char **argv)
297{
298 //Set App Directory
299 // TODO 2
300 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
301 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
302 elm_app_info_set(elm_main, "sample", "images/bg.jpg");
303
304 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
305
306 init();
307
308 elm_run();
309
310 elm_shutdown();
311
312 return 0;
313}
314ELM_MAIN()
diff --git a/source/2-step/4-middle/main.c b/source/2-step/4-middle/main.c
new file mode 100644
index 0000000..1d310f7
--- /dev/null
+++ b/source/2-step/4-middle/main.c
@@ -0,0 +1,314 @@
1#include <Elementary.h>
2
3#define PACKAGE_BIN_DIR "/usr/local/bin"
4#define PACKAGE_DATA_DIR "/usr/local/share/sample"
5
6Evas_Object *create_button(Evas_Object *parent);
7Evas_Object *create_image(Evas_Object *parent, char *path, char *group);
8void btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
9void btn_clicked(void *data, Evas_Object *obj, void *event_info);
10void _left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
11void _right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
12void _btn_effect(Evas_Object *obj);
13
14Evas_Object *
15create_win()
16{
17 Evas_Object *win = NULL;
18
19 // TODO 2
20 win = elm_win_util_standard_add(elm_app_name_get(), elm_app_name_get());
21 // TODO 7
22 //elm_win_**_set(win, EINA_TRUE);
23 elm_win_autodel_set(win, EINA_TRUE);
24 evas_object_resize(win, 720, 400);
25 evas_object_show(win);
26
27 return win;
28}
29
30Evas_Object *
31create_layout(Evas_Object *win)
32{
33 Evas_Object *layout = NULL;
34 char buf[PATH_MAX];
35
36 layout = elm_layout_add(win);
37 // TODO 2
38 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
39 // TODO 2
40 elm_layout_file_set(layout, buf, "main");
41 // TODO 2
42 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
43 elm_win_resize_object_add(win, layout);
44 evas_object_show(layout);
45
46 return layout;
47}
48
49void
50create_top_contents(Evas_Object *layout)
51{
52 Evas_Object *table = NULL, *btn = NULL, *img = NULL, *label = NULL;
53 int i =0;
54 char buf[PATH_MAX], buf2[PATH_MAX];
55
56 // TODO 3
57 table = elm_table_add(layout);
58
59 for (i = 0; i < 5; i++)
60 {
61 btn = create_button(table);
62 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
63 snprintf(buf2, sizeof(buf2), "icon%d", i);
64 img = create_image(btn, buf, buf2);
65 // TODO 3
66 elm_object_content_set(btn, img);
67
68 elm_table_pack(table, btn, i, 0, 1, 1);
69
70 label = elm_label_add(table);
71 snprintf(buf2, sizeof(buf2), "<color=#ffffff>item%d</color>", i);
72 // TODO 3
73 elm_object_text_set(label, buf2);
74 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
75 evas_object_show(label);
76
77 elm_table_pack(table, label, i, 1, 1, 1);
78 }
79
80 elm_layout_content_set(layout, "elm.swallow.top", table);
81 evas_object_show(table);
82
83}
84
85void
86create_middle_contents(Evas_Object *layout)
87{
88 Evas_Object *table = NULL, *btn = NULL, *img = NULL;
89 Evas_Coord padding_size = 0;
90 int i = 0, j = 0;
91 char buf[PATH_MAX];
92
93 table = elm_table_add(layout);
94 // TODO 4
95 //padding_size = 7 * elm_config_scale_get();
96 //elm_table_**_set(table, padding_size, padding_size);
97
98 for (i = 0; i < 3; i++)
99 {
100 for (j = 0; j < 6; j++)
101 {
102 btn = create_button(table);
103
104 // TODO 10
105 // elm_button "clicked" smart callback
106 //evas_object_**(**, **, btn_clicked, NULL);
107
108 // TODO 10
109 // evas object mouse in callback
110 //evas_object_**(**, **, btn_mouse_in, NULL);
111
112 snprintf(buf, sizeof(buf), "%s/images/%d.jpg", elm_app_data_dir_get(), ((i * 6) + j));
113 img = create_image(btn, buf, NULL);
114 elm_object_content_set(btn, img);
115 // TODO 4
116 //elm_table_pack();
117 }
118 }
119
120 // TODO 4
121 //elm_layout_content_set(**, **, **);
122 evas_object_show(table);
123}
124
125void
126create_arrows(Evas_Object *layout)
127{
128 Evas_Object *btn = NULL, *img = NULL;
129 char buf[PATH_MAX];
130
131 //Create a Left arrow
132 btn = create_button(layout);
133 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
134 // TODO 5
135 //img = create_image(btn, buf, **);
136 elm_object_content_set(btn, img);
137 // TODO 5
138 //elm_layout_content_set(layout, **, btn);
139 evas_object_show(btn);
140 // TODO 10
141 //evas_object_smart_callback_add(btn, **, _left_arrow_clicked_cb, layout);
142
143 //Create a Right arrow
144 btn = create_button(layout);
145 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
146 // TODO 5
147 //img = create_image(btn, buf, **);
148 elm_object_content_set(btn, img);
149 // TODO 5
150 //elm_layout_content_set(layout, **, btn);
151 evas_object_show(btn);
152 // TODO 10
153 //evas_object_smart_callback_add(btn, **, _right_arrow_clicked_cb, layout);
154}
155
156void
157toolbar_it_cb(void *data, Evas_Object *obj, void *event_info)
158{
159 Elm_Object_Item *it = event_info;
160 printf("%s\n", elm_object_item_text_get(it));
161 Evas_Object *layout = data;
162 if (!layout) return;
163 // TODO 6
164 //elm_layout_text_set(layout, "elm.text.news", **);
165}
166
167void
168create_bottom_contents(Evas_Object *layout)
169{
170 Evas_Object *toolbar = NULL;
171
172 toolbar = elm_toolbar_add(layout);
173 elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);
174 elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE);
175 // TODO 6
176 //elm_toolbar_**_set(toolbar, EINA_TRUE);
177
178 // TODO 6
179 //elm_toolbar_item_append();
180
181 elm_layout_content_set(layout, "elm.swallow.bottom", toolbar);
182 evas_object_show(toolbar);
183}
184
185void
186init(void)
187{
188 Evas_Object *win = NULL, *layout = NULL;
189
190 //Create a Window
191 win = create_win();
192
193 //Create a Layout
194 layout = create_layout(win);
195
196 //Create Top Contents
197 create_top_contents(layout);
198
199 //Create Middle Contents
200 create_middle_contents(layout);
201
202 //Create Arrows
203 create_arrows(layout);
204
205 //Create Bottom Contents
206 create_bottom_contents(layout);
207}
208
209Evas_Object *
210create_button(Evas_Object *parent)
211{
212 Evas_Object *btn = NULL;
213
214 btn = elm_button_add(parent);
215 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
216 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
217 evas_object_show(btn);
218
219 return btn;
220}
221
222Evas_Object *
223create_image(Evas_Object *parent, char *path, char *group)
224{
225 Evas_Object *img = NULL;
226
227 img = elm_image_add(parent);
228 elm_image_file_set(img, path, group);
229 evas_object_show(img);
230
231 return img;
232}
233
234void
235btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
236{
237 _btn_effect(obj);
238}
239
240void
241btn_clicked(void *data, Evas_Object *obj, void *event_info)
242{
243 _btn_effect(obj);
244}
245
246Eina_Bool
247_left_arrow_timer_cb(void *data)
248{
249 Evas_Object *layout = data;
250 if (!data) return ECORE_CALLBACK_CANCEL;
251 // TODO 11
252 //elm_layout_signal_emit(layout, ** , **);
253
254 // TODO 11
255 //return ECORE_CALLBACK_**;
256}
257
258// TODO 10
259void
260_left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
261{
262 Evas_Object *layout = data;
263 if (!layout) return;
264 // TODO 10
265 //elm_layout_signal_emit(layout, **, **);
266
267 // TODO 11
268 //ecore_timer_add(**, _left_arrow_timer_cb, layout);
269}
270
271// TODO 10
272void
273_right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
274{
275 Evas_Object *layout = data;
276 if (!layout) return;
277 elm_exit();
278}
279
280void
281_btn_effect(Evas_Object *obj)
282{
283 evas_object_raise(obj);
284
285 Elm_Transit *transit = elm_transit_add();
286 elm_transit_object_add(transit, obj);
287 elm_transit_duration_set(transit, 0.25);
288 // TODO 8
289 //elm_transit_**_set(transit, EINA_TRUE);
290 elm_transit_effect_zoom_add(transit, 1.0, 1.25);
291 elm_transit_smooth_set(transit, EINA_FALSE);
292 elm_transit_go(transit);
293}
294
295EAPI_MAIN int
296elm_main(int argc, char **argv)
297{
298 //Set App Directory
299 // TODO 2
300 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
301 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
302 elm_app_info_set(elm_main, "sample", "images/bg.jpg");
303
304 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
305
306 init();
307
308 elm_run();
309
310 elm_shutdown();
311
312 return 0;
313}
314ELM_MAIN()
diff --git a/source/2-step/5-arrow/main.c b/source/2-step/5-arrow/main.c
new file mode 100644
index 0000000..9feebc2
--- /dev/null
+++ b/source/2-step/5-arrow/main.c
@@ -0,0 +1,314 @@
1#include <Elementary.h>
2
3#define PACKAGE_BIN_DIR "/usr/local/bin"
4#define PACKAGE_DATA_DIR "/usr/local/share/sample"
5
6Evas_Object *create_button(Evas_Object *parent);
7Evas_Object *create_image(Evas_Object *parent, char *path, char *group);
8void btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
9void btn_clicked(void *data, Evas_Object *obj, void *event_info);
10void _left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
11void _right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
12void _btn_effect(Evas_Object *obj);
13
14Evas_Object *
15create_win()
16{
17 Evas_Object *win = NULL;
18
19 // TODO 2
20 win = elm_win_util_standard_add(elm_app_name_get(), elm_app_name_get());
21 // TODO 7
22 //elm_win_**_set(win, EINA_TRUE);
23 elm_win_autodel_set(win, EINA_TRUE);
24 evas_object_resize(win, 720, 400);
25 evas_object_show(win);
26
27 return win;
28}
29
30Evas_Object *
31create_layout(Evas_Object *win)
32{
33 Evas_Object *layout = NULL;
34 char buf[PATH_MAX];
35
36 layout = elm_layout_add(win);
37 // TODO 2
38 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
39 // TODO 2
40 elm_layout_file_set(layout, buf, "main");
41 // TODO 2
42 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
43 elm_win_resize_object_add(win, layout);
44 evas_object_show(layout);
45
46 return layout;
47}
48
49void
50create_top_contents(Evas_Object *layout)
51{
52 Evas_Object *table = NULL, *btn = NULL, *img = NULL, *label = NULL;
53 int i =0;
54 char buf[PATH_MAX], buf2[PATH_MAX];
55
56 // TODO 3
57 table = elm_table_add(layout);
58
59 for (i = 0; i < 5; i++)
60 {
61 btn = create_button(table);
62 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
63 snprintf(buf2, sizeof(buf2), "icon%d", i);
64 img = create_image(btn, buf, buf2);
65 // TODO 3
66 elm_object_content_set(btn, img);
67
68 elm_table_pack(table, btn, i, 0, 1, 1);
69
70 label = elm_label_add(table);
71 snprintf(buf2, sizeof(buf2), "<color=#ffffff>item%d</color>", i);
72 // TODO 3
73 elm_object_text_set(label, buf2);
74 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
75 evas_object_show(label);
76
77 elm_table_pack(table, label, i, 1, 1, 1);
78 }
79
80 elm_layout_content_set(layout, "elm.swallow.top", table);
81 evas_object_show(table);
82
83}
84
85void
86create_middle_contents(Evas_Object *layout)
87{
88 Evas_Object *table = NULL, *btn = NULL, *img = NULL;
89 Evas_Coord padding_size = 0;
90 int i = 0, j = 0;
91 char buf[PATH_MAX];
92
93 table = elm_table_add(layout);
94 // TODO 4
95 padding_size = 7 * elm_config_scale_get();
96 elm_table_padding_set(table, padding_size, padding_size);
97
98 for (i = 0; i < 3; i++)
99 {
100 for (j = 0; j < 6; j++)
101 {
102 btn = create_button(table);
103
104 // TODO 10
105 // elm_button "clicked" smart callback
106 //evas_object_**(**, **, btn_clicked, NULL);
107
108 // TODO 10
109 // evas object mouse in callback
110 //evas_object_**(**, **, btn_mouse_in, NULL);
111
112 snprintf(buf, sizeof(buf), "%s/images/%d.jpg", elm_app_data_dir_get(), ((i * 6) + j));
113 img = create_image(btn, buf, NULL);
114 elm_object_content_set(btn, img);
115 // TODO 4
116 elm_table_pack(table, btn, j, i, 1, 1);
117 }
118 }
119
120 // TODO 4
121 elm_layout_content_set(layout, "elm.swallow.middle", table);
122 evas_object_show(table);
123}
124
125void
126create_arrows(Evas_Object *layout)
127{
128 Evas_Object *btn = NULL, *img = NULL;
129 char buf[PATH_MAX];
130
131 //Create a Left arrow
132 btn = create_button(layout);
133 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
134 // TODO 5
135 //img = create_image(btn, buf, **);
136 elm_object_content_set(btn, img);
137 // TODO 5
138 //elm_layout_content_set(layout, **, btn);
139 evas_object_show(btn);
140 // TODO 10
141 //evas_object_smart_callback_add(btn, **, _left_arrow_clicked_cb, layout);
142
143 //Create a Right arrow
144 btn = create_button(layout);
145 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
146 // TODO 5
147 //img = create_image(btn, buf, **);
148 elm_object_content_set(btn, img);
149 // TODO 5
150 //elm_layout_content_set(layout, **, btn);
151 evas_object_show(btn);
152 // TODO 10
153 //evas_object_smart_callback_add(btn, **, _right_arrow_clicked_cb, layout);
154}
155
156void
157toolbar_it_cb(void *data, Evas_Object *obj, void *event_info)
158{
159 Elm_Object_Item *it = event_info;
160 printf("%s\n", elm_object_item_text_get(it));
161 Evas_Object *layout = data;
162 if (!layout) return;
163 // TODO 6
164 //elm_layout_text_set(layout, "elm.text.news", **);
165}
166
167void
168create_bottom_contents(Evas_Object *layout)
169{
170 Evas_Object *toolbar = NULL;
171
172 toolbar = elm_toolbar_add(layout);
173 elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);
174 elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE);
175 // TODO 6
176 //elm_toolbar_**_set(toolbar, EINA_TRUE);
177
178 // TODO 6
179 //elm_toolbar_item_append();
180
181 elm_layout_content_set(layout, "elm.swallow.bottom", toolbar);
182 evas_object_show(toolbar);
183}
184
185void
186init(void)
187{
188 Evas_Object *win = NULL, *layout = NULL;
189
190 //Create a Window
191 win = create_win();
192
193 //Create a Layout
194 layout = create_layout(win);
195
196 //Create Top Contents
197 create_top_contents(layout);
198
199 //Create Middle Contents
200 create_middle_contents(layout);
201
202 //Create Arrows
203 create_arrows(layout);
204
205 //Create Bottom Contents
206 create_bottom_contents(layout);
207}
208
209Evas_Object *
210create_button(Evas_Object *parent)
211{
212 Evas_Object *btn = NULL;
213
214 btn = elm_button_add(parent);
215 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
216 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
217 evas_object_show(btn);
218
219 return btn;
220}
221
222Evas_Object *
223create_image(Evas_Object *parent, char *path, char *group)
224{
225 Evas_Object *img = NULL;
226
227 img = elm_image_add(parent);
228 elm_image_file_set(img, path, group);
229 evas_object_show(img);
230
231 return img;
232}
233
234void
235btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
236{
237 _btn_effect(obj);
238}
239
240void
241btn_clicked(void *data, Evas_Object *obj, void *event_info)
242{
243 _btn_effect(obj);
244}
245
246Eina_Bool
247_left_arrow_timer_cb(void *data)
248{
249 Evas_Object *layout = data;
250 if (!data) return ECORE_CALLBACK_CANCEL;
251 // TODO 11
252 //elm_layout_signal_emit(layout, ** , **);
253
254 // TODO 11
255 //return ECORE_CALLBACK_**;
256}
257
258// TODO 10
259void
260_left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
261{
262 Evas_Object *layout = data;
263 if (!layout) return;
264 // TODO 10
265 //elm_layout_signal_emit(layout, **, **);
266
267 // TODO 11
268 //ecore_timer_add(**, _left_arrow_timer_cb, layout);
269}
270
271// TODO 10
272void
273_right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
274{
275 Evas_Object *layout = data;
276 if (!layout) return;
277 elm_exit();
278}
279
280void
281_btn_effect(Evas_Object *obj)
282{
283 evas_object_raise(obj);
284
285 Elm_Transit *transit = elm_transit_add();
286 elm_transit_object_add(transit, obj);
287 elm_transit_duration_set(transit, 0.25);
288 // TODO 8
289 //elm_transit_**_set(transit, EINA_TRUE);
290 elm_transit_effect_zoom_add(transit, 1.0, 1.25);
291 elm_transit_smooth_set(transit, EINA_FALSE);
292 elm_transit_go(transit);
293}
294
295EAPI_MAIN int
296elm_main(int argc, char **argv)
297{
298 //Set App Directory
299 // TODO 2
300 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
301 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
302 elm_app_info_set(elm_main, "sample", "images/bg.jpg");
303
304 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
305
306 init();
307
308 elm_run();
309
310 elm_shutdown();
311
312 return 0;
313}
314ELM_MAIN()
diff --git a/source/2-step/6-bottom/main.c b/source/2-step/6-bottom/main.c
new file mode 100644
index 0000000..adc6f82
--- /dev/null
+++ b/source/2-step/6-bottom/main.c
@@ -0,0 +1,314 @@
1#include <Elementary.h>
2
3#define PACKAGE_BIN_DIR "/usr/local/bin"
4#define PACKAGE_DATA_DIR "/usr/local/share/sample"
5
6Evas_Object *create_button(Evas_Object *parent);
7Evas_Object *create_image(Evas_Object *parent, char *path, char *group);
8void btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
9void btn_clicked(void *data, Evas_Object *obj, void *event_info);
10void _left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
11void _right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
12void _btn_effect(Evas_Object *obj);
13
14Evas_Object *
15create_win()
16{
17 Evas_Object *win = NULL;
18
19 // TODO 2
20 win = elm_win_util_standard_add(elm_app_name_get(), elm_app_name_get());
21 // TODO 7
22 //elm_win_**_set(win, EINA_TRUE);
23 elm_win_autodel_set(win, EINA_TRUE);
24 evas_object_resize(win, 720, 400);
25 evas_object_show(win);
26
27 return win;
28}
29
30Evas_Object *
31create_layout(Evas_Object *win)
32{
33 Evas_Object *layout = NULL;
34 char buf[PATH_MAX];
35
36 layout = elm_layout_add(win);
37 // TODO 2
38 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
39 // TODO 2
40 elm_layout_file_set(layout, buf, "main");
41 // TODO 2
42 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
43 elm_win_resize_object_add(win, layout);
44 evas_object_show(layout);
45
46 return layout;
47}
48
49void
50create_top_contents(Evas_Object *layout)
51{
52 Evas_Object *table = NULL, *btn = NULL, *img = NULL, *label = NULL;
53 int i =0;
54 char buf[PATH_MAX], buf2[PATH_MAX];
55
56 // TODO 3
57 table = elm_table_add(layout);
58
59 for (i = 0; i < 5; i++)
60 {
61 btn = create_button(table);
62 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
63 snprintf(buf2, sizeof(buf2), "icon%d", i);
64 img = create_image(btn, buf, buf2);
65 // TODO 3
66 elm_object_content_set(btn, img);
67
68 elm_table_pack(table, btn, i, 0, 1, 1);
69
70 label = elm_label_add(table);
71 snprintf(buf2, sizeof(buf2), "<color=#ffffff>item%d</color>", i);
72 // TODO 3
73 elm_object_text_set(label, buf2);
74 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
75 evas_object_show(label);
76
77 elm_table_pack(table, label, i, 1, 1, 1);
78 }
79
80 elm_layout_content_set(layout, "elm.swallow.top", table);
81 evas_object_show(table);
82
83}
84
85void
86create_middle_contents(Evas_Object *layout)
87{
88 Evas_Object *table = NULL, *btn = NULL, *img = NULL;
89 Evas_Coord padding_size = 0;
90 int i = 0, j = 0;
91 char buf[PATH_MAX];
92
93 table = elm_table_add(layout);
94 // TODO 4
95 padding_size = 7 * elm_config_scale_get();
96 elm_table_padding_set(table, padding_size, padding_size);
97
98 for (i = 0; i < 3; i++)
99 {
100 for (j = 0; j < 6; j++)
101 {
102 btn = create_button(table);
103
104 // TODO 10
105 // elm_button "clicked" smart callback
106 //evas_object_**(**, **, btn_clicked, NULL);
107
108 // TODO 10
109 // evas object mouse in callback
110 //evas_object_**(**, **, btn_mouse_in, NULL);
111
112 snprintf(buf, sizeof(buf), "%s/images/%d.jpg", elm_app_data_dir_get(), ((i * 6) + j));
113 img = create_image(btn, buf, NULL);
114 elm_object_content_set(btn, img);
115 // TODO 4
116 elm_table_pack(table, btn, j, i, 1, 1);
117 }
118 }
119
120 // TODO 4
121 elm_layout_content_set(layout, "elm.swallow.middle", table);
122 evas_object_show(table);
123}
124
125void
126create_arrows(Evas_Object *layout)
127{
128 Evas_Object *btn = NULL, *img = NULL;
129 char buf[PATH_MAX];
130
131 //Create a Left arrow
132 btn = create_button(layout);
133 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
134 // TODO 5
135 img = create_image(btn, buf, "left_arrow");
136 elm_object_content_set(btn, img);
137 // TODO 5
138 elm_layout_content_set(layout, "elm.swallow.left_arrow", btn);
139 evas_object_show(btn);
140 // TODO 10
141 //evas_object_smart_callback_add(btn, **, _left_arrow_clicked_cb, layout);
142
143 //Create a Right arrow
144 btn = create_button(layout);
145 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
146 // TODO 5
147 img = create_image(btn, buf, "right_arrow");
148 elm_object_content_set(btn, img);
149 // TODO 5
150 elm_layout_content_set(layout, "elm.swallow.right_arrow", btn);
151 evas_object_show(btn);
152 // TODO 10
153 //evas_object_smart_callback_add(btn, **, _right_arrow_clicked_cb, layout);
154}
155
156void
157toolbar_it_cb(void *data, Evas_Object *obj, void *event_info)
158{
159 Elm_Object_Item *it = event_info;
160 printf("%s\n", elm_object_item_text_get(it));
161 Evas_Object *layout = data;
162 if (!layout) return;
163 // TODO 6
164 //elm_layout_text_set(layout, "elm.text.news", **);
165}
166
167void
168create_bottom_contents(Evas_Object *layout)
169{
170 Evas_Object *toolbar = NULL;
171
172 toolbar = elm_toolbar_add(layout);
173 elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);
174 elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE);
175 // TODO 6
176 //elm_toolbar_**_set(toolbar, EINA_TRUE);
177
178 // TODO 6
179 //elm_toolbar_item_append();
180
181 elm_layout_content_set(layout, "elm.swallow.bottom", toolbar);
182 evas_object_show(toolbar);
183}
184
185void
186init(void)
187{
188 Evas_Object *win = NULL, *layout = NULL;
189
190 //Create a Window
191 win = create_win();
192
193 //Create a Layout
194 layout = create_layout(win);
195
196 //Create Top Contents
197 create_top_contents(layout);
198
199 //Create Middle Contents
200 create_middle_contents(layout);
201
202 //Create Arrows
203 create_arrows(layout);
204
205 //Create Bottom Contents
206 create_bottom_contents(layout);
207}
208
209Evas_Object *
210create_button(Evas_Object *parent)
211{
212 Evas_Object *btn = NULL;
213
214 btn = elm_button_add(parent);
215 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
216 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
217 evas_object_show(btn);
218
219 return btn;
220}
221
222Evas_Object *
223create_image(Evas_Object *parent, char *path, char *group)
224{
225 Evas_Object *img = NULL;
226
227 img = elm_image_add(parent);
228 elm_image_file_set(img, path, group);
229 evas_object_show(img);
230
231 return img;
232}
233
234void
235btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
236{
237 _btn_effect(obj);
238}
239
240void
241btn_clicked(void *data, Evas_Object *obj, void *event_info)
242{
243 _btn_effect(obj);
244}
245
246Eina_Bool
247_left_arrow_timer_cb(void *data)
248{
249 Evas_Object *layout = data;
250 if (!data) return ECORE_CALLBACK_CANCEL;
251 // TODO 11
252 //elm_layout_signal_emit(layout, ** , **);
253
254 // TODO 11
255 //return ECORE_CALLBACK_**;
256}
257
258// TODO 10
259void
260_left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
261{
262 Evas_Object *layout = data;
263 if (!layout) return;
264 // TODO 10
265 //elm_layout_signal_emit(layout, **, **);
266
267 // TODO 11
268 //ecore_timer_add(**, _left_arrow_timer_cb, layout);
269}
270
271// TODO 10
272void
273_right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
274{
275 Evas_Object *layout = data;
276 if (!layout) return;
277 elm_exit();
278}
279
280void
281_btn_effect(Evas_Object *obj)
282{
283 evas_object_raise(obj);
284
285 Elm_Transit *transit = elm_transit_add();
286 elm_transit_object_add(transit, obj);
287 elm_transit_duration_set(transit, 0.25);
288 // TODO 8
289 //elm_transit_**_set(transit, EINA_TRUE);
290 elm_transit_effect_zoom_add(transit, 1.0, 1.25);
291 elm_transit_smooth_set(transit, EINA_FALSE);
292 elm_transit_go(transit);
293}
294
295EAPI_MAIN int
296elm_main(int argc, char **argv)
297{
298 //Set App Directory
299 // TODO 2
300 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
301 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
302 elm_app_info_set(elm_main, "sample", "images/bg.jpg");
303
304 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
305
306 init();
307
308 elm_run();
309
310 elm_shutdown();
311
312 return 0;
313}
314ELM_MAIN()
diff --git a/source/2-step/7-focus/main.c b/source/2-step/7-focus/main.c
new file mode 100644
index 0000000..16498ec
--- /dev/null
+++ b/source/2-step/7-focus/main.c
@@ -0,0 +1,319 @@
1#include <Elementary.h>
2
3#define PACKAGE_BIN_DIR "/usr/local/bin"
4#define PACKAGE_DATA_DIR "/usr/local/share/sample"
5
6Evas_Object *create_button(Evas_Object *parent);
7Evas_Object *create_image(Evas_Object *parent, char *path, char *group);
8void btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
9void btn_clicked(void *data, Evas_Object *obj, void *event_info);
10void _left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
11void _right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
12void _btn_effect(Evas_Object *obj);
13
14Evas_Object *
15create_win()
16{
17 Evas_Object *win = NULL;
18
19 // TODO 2
20 win = elm_win_util_standard_add(elm_app_name_get(), elm_app_name_get());
21 // TODO 7
22 //elm_win_**_set(win, EINA_TRUE);
23 elm_win_autodel_set(win, EINA_TRUE);
24 evas_object_resize(win, 720, 400);
25 evas_object_show(win);
26
27 return win;
28}
29
30Evas_Object *
31create_layout(Evas_Object *win)
32{
33 Evas_Object *layout = NULL;
34 char buf[PATH_MAX];
35
36 layout = elm_layout_add(win);
37 // TODO 2
38 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
39 // TODO 2
40 elm_layout_file_set(layout, buf, "main");
41 // TODO 2
42 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
43 elm_win_resize_object_add(win, layout);
44 evas_object_show(layout);
45
46 return layout;
47}
48
49void
50create_top_contents(Evas_Object *layout)
51{
52 Evas_Object *table = NULL, *btn = NULL, *img = NULL, *label = NULL;
53 int i =0;
54 char buf[PATH_MAX], buf2[PATH_MAX];
55
56 // TODO 3
57 table = elm_table_add(layout);
58
59 for (i = 0; i < 5; i++)
60 {
61 btn = create_button(table);
62 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
63 snprintf(buf2, sizeof(buf2), "icon%d", i);
64 img = create_image(btn, buf, buf2);
65 // TODO 3
66 elm_object_content_set(btn, img);
67
68 elm_table_pack(table, btn, i, 0, 1, 1);
69
70 label = elm_label_add(table);
71 snprintf(buf2, sizeof(buf2), "<color=#ffffff>item%d</color>", i);
72 // TODO 3
73 elm_object_text_set(label, buf2);
74 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
75 evas_object_show(label);
76
77 elm_table_pack(table, label, i, 1, 1, 1);
78 }
79
80 elm_layout_content_set(layout, "elm.swallow.top", table);
81 evas_object_show(table);
82
83}
84
85void
86create_middle_contents(Evas_Object *layout)
87{
88 Evas_Object *table = NULL, *btn = NULL, *img = NULL;
89 Evas_Coord padding_size = 0;
90 int i = 0, j = 0;
91 char buf[PATH_MAX];
92
93 table = elm_table_add(layout);
94 // TODO 4
95 padding_size = 7 * elm_config_scale_get();
96 elm_table_padding_set(table, padding_size, padding_size);
97
98 for (i = 0; i < 3; i++)
99 {
100 for (j = 0; j < 6; j++)
101 {
102 btn = create_button(table);
103
104 // TODO 10
105 // elm_button "clicked" smart callback
106 //evas_object_**(**, **, btn_clicked, NULL);
107
108 // TODO 10
109 // evas object mouse in callback
110 //evas_object_**(**, **, btn_mouse_in, NULL);
111
112 snprintf(buf, sizeof(buf), "%s/images/%d.jpg", elm_app_data_dir_get(), ((i * 6) + j));
113 img = create_image(btn, buf, NULL);
114 elm_object_content_set(btn, img);
115 // TODO 4
116 elm_table_pack(table, btn, j, i, 1, 1);
117 }
118 }
119
120 // TODO 4
121 elm_layout_content_set(layout, "elm.swallow.middle", table);
122 evas_object_show(table);
123}
124
125void
126create_arrows(Evas_Object *layout)
127{
128 Evas_Object *btn = NULL, *img = NULL;
129 char buf[PATH_MAX];
130
131 //Create a Left arrow
132 btn = create_button(layout);
133 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
134 // TODO 5
135 img = create_image(btn, buf, "left_arrow");
136 elm_object_content_set(btn, img);
137 // TODO 5
138 elm_layout_content_set(layout, "elm.swallow.left_arrow", btn);
139 evas_object_show(btn);
140 // TODO 10
141 //evas_object_smart_callback_add(btn, **, _left_arrow_clicked_cb, layout);
142
143 //Create a Right arrow
144 btn = create_button(layout);
145 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
146 // TODO 5
147 img = create_image(btn, buf, "right_arrow");
148 elm_object_content_set(btn, img);
149 // TODO 5
150 elm_layout_content_set(layout, "elm.swallow.right_arrow", btn);
151 evas_object_show(btn);
152 // TODO 10
153 //evas_object_smart_callback_add(btn, **, _right_arrow_clicked_cb, layout);
154}
155
156void
157toolbar_it_cb(void *data, Evas_Object *obj, void *event_info)
158{
159 Elm_Object_Item *it = event_info;
160 printf("%s\n", elm_object_item_text_get(it));
161 Evas_Object *layout = data;
162 if (!layout) return;
163 // TODO 6
164 elm_layout_text_set(layout, "elm.text.news", elm_object_item_text_get(it));
165}
166
167void
168create_bottom_contents(Evas_Object *layout)
169{
170 Evas_Object *toolbar = NULL;
171
172 // TODO 6
173 toolbar = elm_toolbar_add(layout);
174 elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);
175 elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE);
176 elm_toolbar_homogeneous_set(toolbar, EINA_TRUE);
177
178 // TODO 6
179 elm_toolbar_item_append(toolbar, NULL, "Guide", toolbar_it_cb, layout);
180 elm_toolbar_item_append(toolbar, NULL, "Time Line View", toolbar_it_cb, layout);
181 elm_toolbar_item_append(toolbar, NULL, "Recorded TV", toolbar_it_cb, layout);
182 elm_toolbar_item_append(toolbar, NULL, "Downloads", toolbar_it_cb, layout);
183 elm_toolbar_item_append(toolbar, NULL, "Favorites", toolbar_it_cb, layout);
184 elm_toolbar_item_append(toolbar, NULL, "YouTube", toolbar_it_cb, layout);
185
186 elm_layout_content_set(layout, "elm.swallow.bottom", toolbar);
187 evas_object_show(toolbar);
188}
189
190void
191init(void)
192{
193 Evas_Object *win = NULL, *layout = NULL;
194
195 //Create a Window
196 win = create_win();
197
198 //Create a Layout
199 layout = create_layout(win);
200
201 //Create Top Contents
202 create_top_contents(layout);
203
204 //Create Middle Contents
205 create_middle_contents(layout);
206
207 //Create Arrows
208 create_arrows(layout);
209
210 //Create Bottom Contents
211 create_bottom_contents(layout);
212}
213
214Evas_Object *
215create_button(Evas_Object *parent)
216{
217 Evas_Object *btn = NULL;
218
219 btn = elm_button_add(parent);
220 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
221 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
222 evas_object_show(btn);
223
224 return btn;
225}
226
227Evas_Object *
228create_image(Evas_Object *parent, char *path, char *group)
229{
230 Evas_Object *img = NULL;
231
232 img = elm_image_add(parent);
233 elm_image_file_set(img, path, group);
234 evas_object_show(img);
235
236 return img;
237}
238
239void
240btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
241{
242 _btn_effect(obj);
243}
244
245void
246btn_clicked(void *data, Evas_Object *obj, void *event_info)
247{
248 _btn_effect(obj);
249}
250
251Eina_Bool
252_left_arrow_timer_cb(void *data)
253{
254 Evas_Object *layout = data;
255 if (!data) return ECORE_CALLBACK_CANCEL;
256 // TODO 11
257 //elm_layout_signal_emit(layout, ** , **);
258
259 // TODO 11
260 //return ECORE_CALLBACK_**;
261}
262
263// TODO 10
264void
265_left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
266{
267 Evas_Object *layout = data;
268 if (!layout) return;
269 // TODO 10
270 //elm_layout_signal_emit(layout, **, **);
271
272 // TODO 11
273 //ecore_timer_add(**, _left_arrow_timer_cb, layout);
274}
275
276// TODO 10
277void
278_right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
279{
280 Evas_Object *layout = data;
281 if (!layout) return;
282 elm_exit();
283}
284
285void
286_btn_effect(Evas_Object *obj)
287{
288 evas_object_raise(obj);
289
290 Elm_Transit *transit = elm_transit_add();
291 elm_transit_object_add(transit, obj);
292 elm_transit_duration_set(transit, 0.25);
293 // TODO 8
294 //elm_transit_**_set(transit, EINA_TRUE);
295 elm_transit_effect_zoom_add(transit, 1.0, 1.25);
296 elm_transit_smooth_set(transit, EINA_FALSE);
297 elm_transit_go(transit);
298}
299
300EAPI_MAIN int
301elm_main(int argc, char **argv)
302{
303 //Set App Directory
304 // TODO 2
305 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
306 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
307 elm_app_info_set(elm_main, "sample", "images/bg.jpg");
308
309 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
310
311 init();
312
313 elm_run();
314
315 elm_shutdown();
316
317 return 0;
318}
319ELM_MAIN()
diff --git a/source/2-step/8-transit/main.c b/source/2-step/8-transit/main.c
new file mode 100644
index 0000000..a1b6b1f
--- /dev/null
+++ b/source/2-step/8-transit/main.c
@@ -0,0 +1,319 @@
1#include <Elementary.h>
2
3#define PACKAGE_BIN_DIR "/usr/local/bin"
4#define PACKAGE_DATA_DIR "/usr/local/share/sample"
5
6Evas_Object *create_button(Evas_Object *parent);
7Evas_Object *create_image(Evas_Object *parent, char *path, char *group);
8void btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
9void btn_clicked(void *data, Evas_Object *obj, void *event_info);
10void _left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
11void _right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
12void _btn_effect(Evas_Object *obj);
13
14Evas_Object *
15create_win()
16{
17 Evas_Object *win = NULL;
18
19 // TODO 2
20 win = elm_win_util_standard_add(elm_app_name_get(), elm_app_name_get());
21 // TODO 7
22 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
23 elm_win_autodel_set(win, EINA_TRUE);
24 evas_object_resize(win, 720, 400);
25 evas_object_show(win);
26
27 return win;
28}
29
30Evas_Object *
31create_layout(Evas_Object *win)
32{
33 Evas_Object *layout = NULL;
34 char buf[PATH_MAX];
35
36 layout = elm_layout_add(win);
37 // TODO 2
38 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
39 // TODO 2
40 elm_layout_file_set(layout, buf, "main");
41 // TODO 2
42 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
43 elm_win_resize_object_add(win, layout);
44 evas_object_show(layout);
45
46 return layout;
47}
48
49void
50create_top_contents(Evas_Object *layout)
51{
52 Evas_Object *table = NULL, *btn = NULL, *img = NULL, *label = NULL;
53 int i =0;
54 char buf[PATH_MAX], buf2[PATH_MAX];
55
56 // TODO 3
57 table = elm_table_add(layout);
58
59 for (i = 0; i < 5; i++)
60 {
61 btn = create_button(table);
62 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
63 snprintf(buf2, sizeof(buf2), "icon%d", i);
64 img = create_image(btn, buf, buf2);
65 // TODO 3
66 elm_object_content_set(btn, img);
67
68 elm_table_pack(table, btn, i, 0, 1, 1);
69
70 label = elm_label_add(table);
71 snprintf(buf2, sizeof(buf2), "<color=#ffffff>item%d</color>", i);
72 // TODO 3
73 elm_object_text_set(label, buf2);
74 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
75 evas_object_show(label);
76
77 elm_table_pack(table, label, i, 1, 1, 1);
78 }
79
80 elm_layout_content_set(layout, "elm.swallow.top", table);
81 evas_object_show(table);
82
83}
84
85void
86create_middle_contents(Evas_Object *layout)
87{
88 Evas_Object *table = NULL, *btn = NULL, *img = NULL;
89 Evas_Coord padding_size = 0;
90 int i = 0, j = 0;
91 char buf[PATH_MAX];
92
93 table = elm_table_add(layout);
94 // TODO 4
95 padding_size = 7 * elm_config_scale_get();
96 elm_table_padding_set(table, padding_size, padding_size);
97
98 for (i = 0; i < 3; i++)
99 {
100 for (j = 0; j < 6; j++)
101 {
102 btn = create_button(table);
103
104 // TODO 10
105 // elm_button "clicked" smart callback
106 //evas_object_**(**, **, btn_clicked, NULL);
107
108 // TODO 10
109 // evas object mouse in callback
110 //evas_object_**(**, **, btn_mouse_in, NULL);
111
112 snprintf(buf, sizeof(buf), "%s/images/%d.jpg", elm_app_data_dir_get(), ((i * 6) + j));
113 img = create_image(btn, buf, NULL);
114 elm_object_content_set(btn, img);
115 // TODO 4
116 elm_table_pack(table, btn, j, i, 1, 1);
117 }
118 }
119
120 // TODO 4
121 elm_layout_content_set(layout, "elm.swallow.middle", table);
122 evas_object_show(table);
123}
124
125void
126create_arrows(Evas_Object *layout)
127{
128 Evas_Object *btn = NULL, *img = NULL;
129 char buf[PATH_MAX];
130
131 //Create a Left arrow
132 btn = create_button(layout);
133 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
134 // TODO 5
135 img = create_image(btn, buf, "left_arrow");
136 elm_object_content_set(btn, img);
137 // TODO 5
138 elm_layout_content_set(layout, "elm.swallow.left_arrow", btn);
139 evas_object_show(btn);
140 // TODO 10
141 //evas_object_smart_callback_add(btn, **, _left_arrow_clicked_cb, layout);
142
143 //Create a Right arrow
144 btn = create_button(layout);
145 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
146 // TODO 5
147 img = create_image(btn, buf, "right_arrow");
148 elm_object_content_set(btn, img);
149 // TODO 5
150 elm_layout_content_set(layout, "elm.swallow.right_arrow", btn);
151 evas_object_show(btn);
152 // TODO 10
153 //evas_object_smart_callback_add(btn, **, _right_arrow_clicked_cb, layout);
154}
155
156void
157toolbar_it_cb(void *data, Evas_Object *obj, void *event_info)
158{
159 Elm_Object_Item *it = event_info;
160 printf("%s\n", elm_object_item_text_get(it));
161 Evas_Object *layout = data;
162 if (!layout) return;
163 // TODO 6
164 elm_layout_text_set(layout, "elm.text.news", elm_object_item_text_get(it));
165}
166
167void
168create_bottom_contents(Evas_Object *layout)
169{
170 Evas_Object *toolbar = NULL;
171
172 // TODO 6
173 toolbar = elm_toolbar_add(layout);
174 elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);
175 elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE);
176 elm_toolbar_homogeneous_set(toolbar, EINA_TRUE);
177
178 // TODO 6
179 elm_toolbar_item_append(toolbar, NULL, "Guide", toolbar_it_cb, layout);
180 elm_toolbar_item_append(toolbar, NULL, "Time Line View", toolbar_it_cb, layout);
181 elm_toolbar_item_append(toolbar, NULL, "Recorded TV", toolbar_it_cb, layout);
182 elm_toolbar_item_append(toolbar, NULL, "Downloads", toolbar_it_cb, layout);
183 elm_toolbar_item_append(toolbar, NULL, "Favorites", toolbar_it_cb, layout);
184 elm_toolbar_item_append(toolbar, NULL, "YouTube", toolbar_it_cb, layout);
185
186 elm_layout_content_set(layout, "elm.swallow.bottom", toolbar);
187 evas_object_show(toolbar);
188}
189
190void
191init(void)
192{
193 Evas_Object *win = NULL, *layout = NULL;
194
195 //Create a Window
196 win = create_win();
197
198 //Create a Layout
199 layout = create_layout(win);
200
201 //Create Top Contents
202 create_top_contents(layout);
203
204 //Create Middle Contents
205 create_middle_contents(layout);
206
207 //Create Arrows
208 create_arrows(layout);
209
210 //Create Bottom Contents
211 create_bottom_contents(layout);
212}
213
214Evas_Object *
215create_button(Evas_Object *parent)
216{
217 Evas_Object *btn = NULL;
218
219 btn = elm_button_add(parent);
220 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
221 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
222 evas_object_show(btn);
223
224 return btn;
225}
226
227Evas_Object *
228create_image(Evas_Object *parent, char *path, char *group)
229{
230 Evas_Object *img = NULL;
231
232 img = elm_image_add(parent);
233 elm_image_file_set(img, path, group);
234 evas_object_show(img);
235
236 return img;
237}
238
239void
240btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
241{
242 _btn_effect(obj);
243}
244
245void
246btn_clicked(void *data, Evas_Object *obj, void *event_info)
247{
248 _btn_effect(obj);
249}
250
251Eina_Bool
252_left_arrow_timer_cb(void *data)
253{
254 Evas_Object *layout = data;
255 if (!data) return ECORE_CALLBACK_CANCEL;
256 // TODO 11
257 //elm_layout_signal_emit(layout, ** , **);
258
259 // TODO 11
260 //return ECORE_CALLBACK_**;
261}
262
263// TODO 10
264void
265_left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
266{
267 Evas_Object *layout = data;
268 if (!layout) return;
269 // TODO 10
270 //elm_layout_signal_emit(layout, **, **);
271
272 // TODO 11
273 //ecore_timer_add(**, _left_arrow_timer_cb, layout);
274}
275
276// TODO 10
277void
278_right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
279{
280 Evas_Object *layout = data;
281 if (!layout) return;
282 elm_exit();
283}
284
285void
286_btn_effect(Evas_Object *obj)
287{
288 evas_object_raise(obj);
289
290 Elm_Transit *transit = elm_transit_add();
291 elm_transit_object_add(transit, obj);
292 elm_transit_duration_set(transit, 0.25);
293 // TODO 8
294 //elm_transit_**_set(transit, EINA_TRUE);
295 elm_transit_effect_zoom_add(transit, 1.0, 1.25);
296 elm_transit_smooth_set(transit, EINA_FALSE);
297 elm_transit_go(transit);
298}
299
300EAPI_MAIN int
301elm_main(int argc, char **argv)
302{
303 //Set App Directory
304 // TODO 2
305 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
306 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
307 elm_app_info_set(elm_main, "sample", "images/bg.jpg");
308
309 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
310
311 init();
312
313 elm_run();
314
315 elm_shutdown();
316
317 return 0;
318}
319ELM_MAIN()
diff --git a/source/2-step/9-free/main.c b/source/2-step/9-free/main.c
new file mode 100644
index 0000000..7857c3b
--- /dev/null
+++ b/source/2-step/9-free/main.c
@@ -0,0 +1,319 @@
1#include <Elementary.h>
2
3#define PACKAGE_BIN_DIR "/usr/local/bin"
4#define PACKAGE_DATA_DIR "/usr/local/share/sample"
5
6Evas_Object *create_button(Evas_Object *parent);
7Evas_Object *create_image(Evas_Object *parent, char *path, char *group);
8void btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
9void btn_clicked(void *data, Evas_Object *obj, void *event_info);
10void _left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
11void _right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info);
12void _btn_effect(Evas_Object *obj);
13
14Evas_Object *
15create_win()
16{
17 Evas_Object *win = NULL;
18
19 // TODO 2
20 win = elm_win_util_standard_add(elm_app_name_get(), elm_app_name_get());
21 // TODO 7
22 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
23 elm_win_autodel_set(win, EINA_TRUE);
24 evas_object_resize(win, 720, 400);
25 evas_object_show(win);
26
27 return win;
28}
29
30Evas_Object *
31create_layout(Evas_Object *win)
32{
33 Evas_Object *layout = NULL;
34 char buf[PATH_MAX];
35
36 layout = elm_layout_add(win);
37 // TODO 2
38 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
39 // TODO 2
40 elm_layout_file_set(layout, buf, "main");
41 // TODO 2
42 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
43 elm_win_resize_object_add(win, layout);
44 evas_object_show(layout);
45
46 return layout;
47}
48
49void
50create_top_contents(Evas_Object *layout)
51{
52 Evas_Object *table = NULL, *btn = NULL, *img = NULL, *label = NULL;
53 int i =0;
54 char buf[PATH_MAX], buf2[PATH_MAX];
55
56 // TODO 3
57 table = elm_table_add(layout);
58
59 for (i = 0; i < 5; i++)
60 {
61 btn = create_button(table);
62 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
63 snprintf(buf2, sizeof(buf2), "icon%d", i);
64 img = create_image(btn, buf, buf2);
65 // TODO 3
66 elm_object_content_set(btn, img);
67
68 elm_table_pack(table, btn, i, 0, 1, 1);
69
70 label = elm_label_add(table);
71 snprintf(buf2, sizeof(buf2), "<color=#ffffff>item%d</color>", i);
72 // TODO 3
73 elm_object_text_set(label, buf2);
74 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
75 evas_object_show(label);
76
77 elm_table_pack(table, label, i, 1, 1, 1);
78 }
79
80 elm_layout_content_set(layout, "elm.swallow.top", table);
81 evas_object_show(table);
82
83}
84
85void
86create_middle_contents(Evas_Object *layout)
87{
88 Evas_Object *table = NULL, *btn = NULL, *img = NULL;
89 Evas_Coord padding_size = 0;
90 int i = 0, j = 0;
91 char buf[PATH_MAX];
92
93 table = elm_table_add(layout);
94 // TODO 4
95 padding_size = 7 * elm_config_scale_get();
96 elm_table_padding_set(table, padding_size, padding_size);
97
98 for (i = 0; i < 3; i++)
99 {
100 for (j = 0; j < 6; j++)
101 {
102 btn = create_button(table);
103
104 // TODO 10
105 // elm_button "clicked" smart callback
106 //evas_object_**(**, **, btn_clicked, NULL);
107
108 // TODO 10
109 // evas object mouse in callback
110 //evas_object_**(**, **, btn_mouse_in, NULL);
111
112 snprintf(buf, sizeof(buf), "%s/images/%d.jpg", elm_app_data_dir_get(), ((i * 6) + j));
113 img = create_image(btn, buf, NULL);
114 elm_object_content_set(btn, img);
115 // TODO 4
116 elm_table_pack(table, btn, j, i, 1, 1);
117 }
118 }
119
120 // TODO 4
121 elm_layout_content_set(layout, "elm.swallow.middle", table);
122 evas_object_show(table);
123}
124
125void
126create_arrows(Evas_Object *layout)
127{
128 Evas_Object *btn = NULL, *img = NULL;
129 char buf[PATH_MAX];
130
131 //Create a Left arrow
132 btn = create_button(layout);
133 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
134 // TODO 5
135 img = create_image(btn, buf, "left_arrow");
136 elm_object_content_set(btn, img);
137 // TODO 5
138 elm_layout_content_set(layout, "elm.swallow.left_arrow", btn);
139 evas_object_show(btn);
140 // TODO 10
141 //evas_object_smart_callback_add(btn, **, _left_arrow_clicked_cb, layout);
142
143 //Create a Right arrow
144 btn = create_button(layout);
145 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
146 // TODO 5
147 img = create_image(btn, buf, "right_arrow");
148 elm_object_content_set(btn, img);
149 // TODO 5
150 elm_layout_content_set(layout, "elm.swallow.right_arrow", btn);
151 evas_object_show(btn);
152 // TODO 10
153 //evas_object_smart_callback_add(btn, **, _right_arrow_clicked_cb, layout);
154}
155
156void
157toolbar_it_cb(void *data, Evas_Object *obj, void *event_info)
158{
159 Elm_Object_Item *it = event_info;
160 printf("%s\n", elm_object_item_text_get(it));
161 Evas_Object *layout = data;
162 if (!layout) return;
163 // TODO 6
164 elm_layout_text_set(layout, "elm.text.news", elm_object_item_text_get(it));
165}
166
167void
168create_bottom_contents(Evas_Object *layout)
169{
170 Evas_Object *toolbar = NULL;
171
172 // TODO 6
173 toolbar = elm_toolbar_add(layout);
174 elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);
175 elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE);
176 elm_toolbar_homogeneous_set(toolbar, EINA_TRUE);
177
178 // TODO 6
179 elm_toolbar_item_append(toolbar, NULL, "Guide", toolbar_it_cb, layout);
180 elm_toolbar_item_append(toolbar, NULL, "Time Line View", toolbar_it_cb, layout);
181 elm_toolbar_item_append(toolbar, NULL, "Recorded TV", toolbar_it_cb, layout);
182 elm_toolbar_item_append(toolbar, NULL, "Downloads", toolbar_it_cb, layout);
183 elm_toolbar_item_append(toolbar, NULL, "Favorites", toolbar_it_cb, layout);
184 elm_toolbar_item_append(toolbar, NULL, "YouTube", toolbar_it_cb, layout);
185
186 elm_layout_content_set(layout, "elm.swallow.bottom", toolbar);
187 evas_object_show(toolbar);
188}
189
190void
191init(void)
192{
193 Evas_Object *win = NULL, *layout = NULL;
194
195 //Create a Window
196 win = create_win();
197
198 //Create a Layout
199 layout = create_layout(win);
200
201 //Create Top Contents
202 create_top_contents(layout);
203
204 //Create Middle Contents
205 create_middle_contents(layout);
206
207 //Create Arrows
208 create_arrows(layout);
209
210 //Create Bottom Contents
211 create_bottom_contents(layout);
212}
213
214Evas_Object *
215create_button(Evas_Object *parent)
216{
217 Evas_Object *btn = NULL;
218
219 btn = elm_button_add(parent);
220 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
221 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
222 evas_object_show(btn);
223
224 return btn;
225}
226
227Evas_Object *
228create_image(Evas_Object *parent, char *path, char *group)
229{
230 Evas_Object *img = NULL;
231
232 img = elm_image_add(parent);
233 elm_image_file_set(img, path, group);
234 evas_object_show(img);
235
236 return img;
237}
238
239void
240btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
241{
242 _btn_effect(obj);
243}
244
245void
246btn_clicked(void *data, Evas_Object *obj, void *event_info)
247{
248 _btn_effect(obj);
249}
250
251Eina_Bool
252_left_arrow_timer_cb(void *data)
253{
254 Evas_Object *layout = data;
255 if (!data) return ECORE_CALLBACK_CANCEL;
256 // TODO 11
257 //elm_layout_signal_emit(layout, ** , **);
258
259 // TODO 11
260 //return ECORE_CALLBACK_**;
261}
262
263// TODO 10
264void
265_left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
266{
267 Evas_Object *layout = data;
268 if (!layout) return;
269 // TODO 10
270 //elm_layout_signal_emit(layout, **, **);
271
272 // TODO 11
273 //ecore_timer_add(**, _left_arrow_timer_cb, layout);
274}
275
276// TODO 10
277void
278_right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
279{
280 Evas_Object *layout = data;
281 if (!layout) return;
282 elm_exit();
283}
284
285void
286_btn_effect(Evas_Object *obj)
287{
288 evas_object_raise(obj);
289
290 Elm_Transit *transit = elm_transit_add();
291 elm_transit_object_add(transit, obj);
292 elm_transit_duration_set(transit, 0.25);
293 // TODO 8
294 elm_transit_auto_reverse_set(transit, EINA_TRUE);
295 elm_transit_effect_zoom_add(transit, 1.0, 1.25);
296 elm_transit_smooth_set(transit, EINA_FALSE);
297 elm_transit_go(transit);
298}
299
300EAPI_MAIN int
301elm_main(int argc, char **argv)
302{
303 //Set App Directory
304 // TODO 2
305 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
306 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
307 elm_app_info_set(elm_main, "sample", "images/bg.jpg");
308
309 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
310
311 init();
312
313 elm_run();
314
315 elm_shutdown();
316
317 return 0;
318}
319ELM_MAIN()
diff --git a/source/3-final/src/main.c b/source/3-final/src/main.c
index d114ccb..9456e6a 100644
--- a/source/3-final/src/main.c
+++ b/source/3-final/src/main.c
@@ -16,7 +16,9 @@ create_win()
16{ 16{
17 Evas_Object *win = NULL; 17 Evas_Object *win = NULL;
18 18
19 // TODO 2
19 win = elm_win_util_standard_add(elm_app_name_get(), elm_app_name_get()); 20 win = elm_win_util_standard_add(elm_app_name_get(), elm_app_name_get());
21 // TODO 7
20 elm_win_focus_highlight_enabled_set(win, EINA_TRUE); 22 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
21 elm_win_autodel_set(win, EINA_TRUE); 23 elm_win_autodel_set(win, EINA_TRUE);
22 evas_object_resize(win, 720, 400); 24 evas_object_resize(win, 720, 400);
@@ -32,8 +34,11 @@ create_layout(Evas_Object *win)
32 char buf[PATH_MAX]; 34 char buf[PATH_MAX];
33 35
34 layout = elm_layout_add(win); 36 layout = elm_layout_add(win);
37 // TODO 2
35 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get()); 38 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
39 // TODO 2
36 elm_layout_file_set(layout, buf, "main"); 40 elm_layout_file_set(layout, buf, "main");
41 // TODO 2
37 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 42 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
38 elm_win_resize_object_add(win, layout); 43 elm_win_resize_object_add(win, layout);
39 evas_object_show(layout); 44 evas_object_show(layout);
@@ -48,6 +53,7 @@ create_top_contents(Evas_Object *layout)
48 int i =0; 53 int i =0;
49 char buf[PATH_MAX], buf2[PATH_MAX]; 54 char buf[PATH_MAX], buf2[PATH_MAX];
50 55
56 // TODO 3
51 table = elm_table_add(layout); 57 table = elm_table_add(layout);
52 58
53 for (i = 0; i < 5; i++) 59 for (i = 0; i < 5; i++)
@@ -56,15 +62,16 @@ create_top_contents(Evas_Object *layout)
56 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get()); 62 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
57 snprintf(buf2, sizeof(buf2), "icon%d", i); 63 snprintf(buf2, sizeof(buf2), "icon%d", i);
58 img = create_image(btn, buf, buf2); 64 img = create_image(btn, buf, buf2);
65 // TODO 3
59 elm_object_content_set(btn, img); 66 elm_object_content_set(btn, img);
60 67
61 elm_table_pack(table, btn, i, 0, 1, 1); 68 elm_table_pack(table, btn, i, 0, 1, 1);
62 69
63 label = elm_label_add(table); 70 label = elm_label_add(table);
64 snprintf(buf2, sizeof(buf2), "<color=#ffffff>item%d</color>", i); 71 snprintf(buf2, sizeof(buf2), "<color=#ffffff>item%d</color>", i);
72 // TODO 3
65 elm_object_text_set(label, buf2); 73 elm_object_text_set(label, buf2);
66 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 74 evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
67 evas_object_size_hint_align_set(label, 0.5, 0.5);
68 evas_object_show(label); 75 evas_object_show(label);
69 76
70 elm_table_pack(table, label, i, 1, 1, 1); 77 elm_table_pack(table, label, i, 1, 1, 1);
@@ -84,6 +91,7 @@ create_middle_contents(Evas_Object *layout)
84 char buf[PATH_MAX]; 91 char buf[PATH_MAX];
85 92
86 table = elm_table_add(layout); 93 table = elm_table_add(layout);
94 // TODO 4
87 padding_size = 7 * elm_config_scale_get(); 95 padding_size = 7 * elm_config_scale_get();
88 elm_table_padding_set(table, padding_size, padding_size); 96 elm_table_padding_set(table, padding_size, padding_size);
89 97
@@ -93,18 +101,23 @@ create_middle_contents(Evas_Object *layout)
93 { 101 {
94 btn = create_button(table); 102 btn = create_button(table);
95 103
104 // TODO 10
96 // elm_button "clicked" smart callback 105 // elm_button "clicked" smart callback
97 //evas_object_smart_callback_add(btn, "clicked", btn_clicked, NULL); 106 //evas_object_smart_callback_add(btn, "clicked", btn_clicked, NULL);
98 107
108 // TODO 10
99 // evas object mouse in callback 109 // evas object mouse in callback
100 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, btn_mouse_in, NULL); 110 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, btn_mouse_in, NULL);
111
101 snprintf(buf, sizeof(buf), "%s/images/%d.jpg", elm_app_data_dir_get(), ((i * 6) + j)); 112 snprintf(buf, sizeof(buf), "%s/images/%d.jpg", elm_app_data_dir_get(), ((i * 6) + j));
102 img = create_image(btn, buf, NULL); 113 img = create_image(btn, buf, NULL);
103 elm_object_content_set(btn, img); 114 elm_object_content_set(btn, img);
115 // TODO 4
104 elm_table_pack(table, btn, j, i, 1, 1); 116 elm_table_pack(table, btn, j, i, 1, 1);
105 } 117 }
106 } 118 }
107 119
120 // TODO 4
108 elm_layout_content_set(layout, "elm.swallow.middle", table); 121 elm_layout_content_set(layout, "elm.swallow.middle", table);
109 evas_object_show(table); 122 evas_object_show(table);
110} 123}
@@ -118,19 +131,25 @@ create_arrows(Evas_Object *layout)
118 //Create a Left arrow 131 //Create a Left arrow
119 btn = create_button(layout); 132 btn = create_button(layout);
120 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get()); 133 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
134 // TODO 5
121 img = create_image(btn, buf, "left_arrow"); 135 img = create_image(btn, buf, "left_arrow");
122 elm_object_content_set(btn, img); 136 elm_object_content_set(btn, img);
137 // TODO 5
123 elm_layout_content_set(layout, "elm.swallow.left_arrow", btn); 138 elm_layout_content_set(layout, "elm.swallow.left_arrow", btn);
124 evas_object_show(btn); 139 evas_object_show(btn);
140 // TODO 10
125 evas_object_smart_callback_add(btn, "clicked", _left_arrow_clicked_cb, layout); 141 evas_object_smart_callback_add(btn, "clicked", _left_arrow_clicked_cb, layout);
126 142
127 //Create a Right arrow 143 //Create a Right arrow
128 btn = create_button(layout); 144 btn = create_button(layout);
129 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get()); 145 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
146 // TODO 5
130 img = create_image(btn, buf, "right_arrow"); 147 img = create_image(btn, buf, "right_arrow");
131 elm_object_content_set(btn, img); 148 elm_object_content_set(btn, img);
149 // TODO 5
132 elm_layout_content_set(layout, "elm.swallow.right_arrow", btn); 150 elm_layout_content_set(layout, "elm.swallow.right_arrow", btn);
133 evas_object_show(btn); 151 evas_object_show(btn);
152 // TODO 10
134 evas_object_smart_callback_add(btn, "clicked", _right_arrow_clicked_cb, layout); 153 evas_object_smart_callback_add(btn, "clicked", _right_arrow_clicked_cb, layout);
135} 154}
136 155
@@ -141,6 +160,7 @@ toolbar_it_cb(void *data, Evas_Object *obj, void *event_info)
141 printf("%s\n", elm_object_item_text_get(it)); 160 printf("%s\n", elm_object_item_text_get(it));
142 Evas_Object *layout = data; 161 Evas_Object *layout = data;
143 if (!layout) return; 162 if (!layout) return;
163 // TODO 6
144 elm_layout_text_set(layout, "elm.text.news", elm_object_item_text_get(it)); 164 elm_layout_text_set(layout, "elm.text.news", elm_object_item_text_get(it));
145} 165}
146 166
@@ -149,11 +169,13 @@ create_bottom_contents(Evas_Object *layout)
149{ 169{
150 Evas_Object *toolbar = NULL; 170 Evas_Object *toolbar = NULL;
151 171
172 // TODO 6
152 toolbar = elm_toolbar_add(layout); 173 toolbar = elm_toolbar_add(layout);
153 elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS); 174 elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);
154 //elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE); // EFL 1.8 175 elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE);
155 elm_toolbar_homogeneous_set(toolbar, EINA_TRUE); 176 elm_toolbar_homogeneous_set(toolbar, EINA_TRUE);
156 177
178 // TODO 6
157 elm_toolbar_item_append(toolbar, NULL, "Guide", toolbar_it_cb, layout); 179 elm_toolbar_item_append(toolbar, NULL, "Guide", toolbar_it_cb, layout);
158 elm_toolbar_item_append(toolbar, NULL, "Time Line View", toolbar_it_cb, layout); 180 elm_toolbar_item_append(toolbar, NULL, "Time Line View", toolbar_it_cb, layout);
159 elm_toolbar_item_append(toolbar, NULL, "Recorded TV", toolbar_it_cb, layout); 181 elm_toolbar_item_append(toolbar, NULL, "Recorded TV", toolbar_it_cb, layout);
@@ -226,20 +248,37 @@ btn_clicked(void *data, Evas_Object *obj, void *event_info)
226 _btn_effect(obj); 248 _btn_effect(obj);
227} 249}
228 250
251Eina_Bool
252_left_arrow_timer_cb(void *data)
253{
254 Evas_Object *layout = data;
255 if (!data) return ECORE_CALLBACK_CANCEL;
256 // TODO 11
257 elm_layout_signal_emit(layout, "elm,state,arrow,show", "elm");
258
259 // TODO 11
260 return ECORE_CALLBACK_CANCEL;
261}
262
263// TODO 10
229void 264void
230_left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info) 265_left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
231{ 266{
232 Evas_Object *layout = data; 267 Evas_Object *layout = data;
233 if (!layout) return; 268 if (!layout) return;
234 elm_layout_signal_emit(layout, "elm,state,arrow,hide" , "elm"); 269 elm_layout_signal_emit(layout, "elm,state,arrow,hide" , "elm");
270
271 // TODO 11
272 ecore_timer_add(1.0, _left_arrow_timer_cb, layout);
235} 273}
236 274
275// TODO 10
237void 276void
238_right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info) 277_right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
239{ 278{
240 Evas_Object *layout = data; 279 Evas_Object *layout = data;
241 if (!layout) return; 280 if (!layout) return;
242 elm_layout_signal_emit(layout, "elm,state,arrow,show" , "elm"); 281 elm_exit();
243} 282}
244 283
245void 284void
@@ -250,6 +289,7 @@ _btn_effect(Evas_Object *obj)
250 Elm_Transit *transit = elm_transit_add(); 289 Elm_Transit *transit = elm_transit_add();
251 elm_transit_object_add(transit, obj); 290 elm_transit_object_add(transit, obj);
252 elm_transit_duration_set(transit, 0.25); 291 elm_transit_duration_set(transit, 0.25);
292 // TODO 8
253 elm_transit_auto_reverse_set(transit, EINA_TRUE); 293 elm_transit_auto_reverse_set(transit, EINA_TRUE);
254 elm_transit_effect_zoom_add(transit, 1.0, 1.25); 294 elm_transit_effect_zoom_add(transit, 1.0, 1.25);
255 elm_transit_smooth_set(transit, EINA_FALSE); 295 elm_transit_smooth_set(transit, EINA_FALSE);
@@ -260,6 +300,7 @@ EAPI_MAIN int
260elm_main(int argc, char **argv) 300elm_main(int argc, char **argv)
261{ 301{
262 //Set App Directory 302 //Set App Directory
303 // TODO 2
263 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR); 304 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
264 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR); 305 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
265 elm_app_info_set(elm_main, "sample", "images/bg.jpg"); 306 elm_app_info_set(elm_main, "sample", "images/bg.jpg");