summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung2@gmailcom>2013-05-15 07:19:14 +0530
committerDaniel Juyung Seo <seojuyung2@gmailcom>2013-05-15 07:19:14 +0530
commitcdc1b7bc3d36fc30085248c887fc2c7582e403e7 (patch)
treecbb0185dd620e4d2d6a2784acca6d5e40d075185
parent0e3086e6b77107c1580abca410618cb395e84ef7 (diff)
template-final: fixed some code for a practice session.
-rw-r--r--sample/template-final/data/edc/layout.edc24
-rw-r--r--sample/template-final/src/main.c61
2 files changed, 66 insertions, 19 deletions
diff --git a/sample/template-final/data/edc/layout.edc b/sample/template-final/data/edc/layout.edc
index a110c2a..a10af9a 100644
--- a/sample/template-final/data/edc/layout.edc
+++ b/sample/template-final/data/edc/layout.edc
@@ -24,6 +24,7 @@ collections {
24 rel2.relative: 0.65 0.15; 24 rel2.relative: 0.65 0.15;
25 } 25 }
26 } 26 }
27 // TODO 7
27 part { name: "elm.text.news"; 28 part { name: "elm.text.news";
28 type: TEXT; 29 type: TEXT;
29 scale: 1; 30 scale: 1;
@@ -35,9 +36,6 @@ collections {
35 text { font: "Sans:style=Bold"; 36 text { font: "Sans:style=Bold";
36 size: 12; 37 size: 12;
37 min: 0 0; 38 min: 0 0;
38 max: 1 0;
39 align: 0.5 0.5;
40 ellipsis: 0.0;
41 text: "News"; 39 text: "News";
42 } 40 }
43 } 41 }
@@ -66,6 +64,11 @@ collections {
66 fixed: 1 1; 64 fixed: 1 1;
67 align: 0.0 0.5; 65 align: 0.0 0.5;
68 } 66 }
67 // TODO 9
68 description { state: "visible" 0.0;
69 inherit: "default" 0.0;
70 visible: 0;
71 }
69 } 72 }
70 part { name: "elm.swallow.right_arrow"; 73 part { name: "elm.swallow.right_arrow";
71 type: SWALLOW; 74 type: SWALLOW;
@@ -79,6 +82,21 @@ collections {
79 } 82 }
80 } 83 }
81 } 84 }
85 programs {
86 // TODO 9
87 program { name: "hide-arrow-left";
88 signal: "elm,state,arrow,hide";
89 source: "elm";
90 action: STATE_SET "visible" 0.0;
91 target: "elm.swallow.left_arrow";
92 }
93 program { name: "show-arrow-left";
94 signal: "elm,state,arrow,show";
95 source: "elm";
96 action: STATE_SET "default" 0.0;
97 target: "elm.swallow.left_arrow";
98 }
99 }
82 } 100 }
83 group { name:"left_arrow"; 101 group { name:"left_arrow";
84 parts { 102 parts {
diff --git a/sample/template-final/src/main.c b/sample/template-final/src/main.c
index 575bb8e..784ea3b 100644
--- a/sample/template-final/src/main.c
+++ b/sample/template-final/src/main.c
@@ -35,7 +35,7 @@ btn_clicked(void *data, Evas_Object *obj, void *event_info)
35 elm_transit_object_add(transit, obj); 35 elm_transit_object_add(transit, obj);
36 elm_transit_duration_set(transit, 0.25); 36 elm_transit_duration_set(transit, 0.25);
37 elm_transit_auto_reverse_set(transit, EINA_TRUE); 37 elm_transit_auto_reverse_set(transit, EINA_TRUE);
38 elm_transit_effect_zoom_add(transit, 1.0, 1.25); 38 // TODO 6 - add a zoom transit effect
39 elm_transit_smooth_set(transit, EINA_FALSE); 39 elm_transit_smooth_set(transit, EINA_FALSE);
40 elm_transit_go(transit); 40 elm_transit_go(transit);
41} 41}
@@ -44,7 +44,30 @@ void
44toolbar_it_cb(void *data, Evas_Object *obj, void *event_info) 44toolbar_it_cb(void *data, Evas_Object *obj, void *event_info)
45{ 45{
46 Elm_Object_Item *it = event_info; 46 Elm_Object_Item *it = event_info;
47 Evas_Object *layout = data;
47 printf("%s\n", elm_object_item_text_get(it)); 48 printf("%s\n", elm_object_item_text_get(it));
49 if (!layout) return;
50 // TODO 8 - set layout's "elm.text.news" part text as toolbar item's text (elm_layout)
51}
52
53void
54_left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
55{
56 Evas_Object *layout = data;
57 if (!layout) return;
58 // TODO 9 - emit "elm,state,arrow,hide" signal to layout
59 // fill in xxx
60 // elm_layout_signal_emit(layout, xxx, "elm");
61}
62
63void
64_right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
65{
66 Evas_Object *layout = data;
67 if (!layout) return;
68 // TODO 9 - emit "elm,state,arrow,show" signal to layout
69 // fill in xxx
70 // elm_layout_signal_emit(layout, xxx, "elm");
48} 71}
49 72
50void 73void
@@ -57,28 +80,31 @@ init()
57 80
58 //Create a Window 81 //Create a Window
59 win = elm_win_util_standard_add(elm_app_name_get(), elm_app_name_get()); 82 win = elm_win_util_standard_add(elm_app_name_get(), elm_app_name_get());
60 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
61 elm_win_autodel_set(win, EINA_TRUE); 83 elm_win_autodel_set(win, EINA_TRUE);
62 evas_object_resize(win, 720, 400); 84 evas_object_resize(win, 720, 400);
63 evas_object_show(win); 85 evas_object_show(win);
64 86
87 // TODO 5 - enable the focus highlight mode (elm_win)
88
65 //Create a Layout 89 //Create a Layout
66 layout = elm_layout_add(win); 90 layout = elm_layout_add(win);
67 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", PACKAGE_DATA_DIR); 91 // TODO 1
92 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
68 elm_layout_file_set(layout, buf, "main"); 93 elm_layout_file_set(layout, buf, "main");
69 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 94 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
70 elm_win_resize_object_add(win, layout); 95 elm_win_resize_object_add(win, layout);
71 evas_object_show(layout); 96 evas_object_show(layout);
72 97
73 //Create Top Contents 98 //Create Top Contents
99 // TODO 2
74 table = elm_table_add(layout); 100 table = elm_table_add(layout);
75 101
76 for (i = 0; i < 5; i++) 102 for (i = 0; i < 5; i++)
77 { 103 {
78 btn = create_button(table); 104 btn = create_button(table);
79 105 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
80 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", PACKAGE_DATA_DIR);
81 snprintf(buf2, sizeof(buf2), "icon%d", i); 106 snprintf(buf2, sizeof(buf2), "icon%d", i);
107 // TODO 3
82 img = create_image(btn, buf, buf2); 108 img = create_image(btn, buf, buf2);
83 elm_object_content_set(btn, img); 109 elm_object_content_set(btn, img);
84 110
@@ -107,8 +133,9 @@ init()
107 for (j = 0; j < 6; j++) 133 for (j = 0; j < 6; j++)
108 { 134 {
109 btn = create_button(table); 135 btn = create_button(table);
136 // TODO 6
110 evas_object_smart_callback_add(btn, "clicked", btn_clicked, NULL); 137 evas_object_smart_callback_add(btn, "clicked", btn_clicked, NULL);
111 snprintf(buf, sizeof(buf), "%s/images/%d.jpg", PACKAGE_DATA_DIR, ((i * 6) + j)); 138 snprintf(buf, sizeof(buf), "%s/images/%d.jpg", elm_app_data_dir_get(), ((i * 6) + j));
112 img = create_image(btn, buf, NULL); 139 img = create_image(btn, buf, NULL);
113 elm_object_content_set(btn, img); 140 elm_object_content_set(btn, img);
114 elm_table_pack(table, btn, j, i, 1, 1); 141 elm_table_pack(table, btn, j, i, 1, 1);
@@ -120,34 +147,35 @@ init()
120 147
121 //Create a Left arrow 148 //Create a Left arrow
122 btn = create_button(table); 149 btn = create_button(table);
123 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", PACKAGE_DATA_DIR); 150 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
124 img = create_image(btn, buf, "left_arrow"); 151 img = create_image(btn, buf, "left_arrow");
125 elm_object_content_set(btn, img); 152 elm_object_content_set(btn, img);
126 elm_object_part_content_set(layout, "elm.swallow.left_arrow", btn); 153 elm_object_part_content_set(layout, "elm.swallow.left_arrow", btn);
127 evas_object_show(btn); 154 evas_object_show(btn);
155 evas_object_smart_callback_add(btn, "clicked", _left_arrow_clicked_cb, layout);
128 156
129 //Create a Right arrow 157 //Create a Right arrow
130 btn = create_button(table); 158 btn = create_button(table);
131 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", PACKAGE_DATA_DIR); 159 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
132 img = create_image(btn, buf, "right_arrow"); 160 img = create_image(btn, buf, "right_arrow");
133 elm_object_content_set(btn, img); 161 elm_object_content_set(btn, img);
134 elm_object_part_content_set(layout, "elm.swallow.right_arrow", btn); 162 elm_object_part_content_set(layout, "elm.swallow.right_arrow", btn);
135 evas_object_show(btn); 163 evas_object_show(btn);
164 evas_object_smart_callback_add(btn, "clicked", _right_arrow_clicked_cb, layout);
136 165
166 // TODO 4
137 //Create Bottom Contents 167 //Create Bottom Contents
138 toolbar = elm_toolbar_add(layout); 168 toolbar = elm_toolbar_add(layout);
139 elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS); 169 elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);
140 elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE); 170 elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE);
141 elm_toolbar_homogeneous_set(toolbar, EINA_TRUE); 171 elm_toolbar_homogeneous_set(toolbar, EINA_TRUE);
142 evas_object_size_hint_weight_set(toolbar, EVAS_HINT_EXPAND, 0);
143 evas_object_size_hint_align_set(toolbar, EVAS_HINT_FILL, 0);
144 172
145 elm_toolbar_item_append(toolbar, NULL, "Guide", toolbar_it_cb, NULL); 173 elm_toolbar_item_append(toolbar, NULL, "Guide", toolbar_it_cb, layout);
146 elm_toolbar_item_append(toolbar, NULL, "Time Line View", toolbar_it_cb, NULL); 174 elm_toolbar_item_append(toolbar, NULL, "Time Line View", toolbar_it_cb, layout);
147 elm_toolbar_item_append(toolbar, NULL, "Recorded TV", toolbar_it_cb, NULL); 175 elm_toolbar_item_append(toolbar, NULL, "Recorded TV", toolbar_it_cb, layout);
148 elm_toolbar_item_append(toolbar, NULL, "Downloads", toolbar_it_cb, NULL); 176 elm_toolbar_item_append(toolbar, NULL, "Downloads", toolbar_it_cb, layout);
149 elm_toolbar_item_append(toolbar, NULL, "Favorites", toolbar_it_cb, NULL); 177 elm_toolbar_item_append(toolbar, NULL, "Favorites", toolbar_it_cb, layout);
150 elm_toolbar_item_append(toolbar, NULL, "YouTube", toolbar_it_cb, NULL); 178 elm_toolbar_item_append(toolbar, NULL, "YouTube", toolbar_it_cb, layout);
151 179
152 elm_object_part_content_set(layout, "elm.swallow.bottom", toolbar); 180 elm_object_part_content_set(layout, "elm.swallow.bottom", toolbar);
153 evas_object_show(toolbar); 181 evas_object_show(toolbar);
@@ -156,6 +184,7 @@ init()
156EAPI_MAIN int 184EAPI_MAIN int
157elm_main(int argc, char **argv) 185elm_main(int argc, char **argv)
158{ 186{
187 // TODO 1
159 //Set App Directory 188 //Set App Directory
160 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR); 189 elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
161 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR); 190 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);