summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Juyung Seo <seojuyung2@gmailcom>2013-05-16 09:35:15 +0530
committerDaniel Juyung Seo <seojuyung2@gmailcom>2013-05-16 09:35:15 +0530
commit2fcede9fdc009c577c5a91d296b84ed37ccff115 (patch)
tree5a41802bec5dc7d1177be99c5a50b3f9abeee824
parentcdc1b7bc3d36fc30085248c887fc2c7582e403e7 (diff)
sample: refactoring, code cleanups and added more features that were handled during the class.
-rw-r--r--sample/2-final/data/edc/layout.edc21
-rw-r--r--sample/2-final/src/main.c76
2 files changed, 74 insertions, 23 deletions
diff --git a/sample/2-final/data/edc/layout.edc b/sample/2-final/data/edc/layout.edc
index a110c2a..1a10add 100644
--- a/sample/2-final/data/edc/layout.edc
+++ b/sample/2-final/data/edc/layout.edc
@@ -35,9 +35,6 @@ collections {
35 text { font: "Sans:style=Bold"; 35 text { font: "Sans:style=Bold";
36 size: 12; 36 size: 12;
37 min: 0 0; 37 min: 0 0;
38 max: 1 0;
39 align: 0.5 0.5;
40 ellipsis: 0.0;
41 text: "News"; 38 text: "News";
42 } 39 }
43 } 40 }
@@ -66,6 +63,10 @@ collections {
66 fixed: 1 1; 63 fixed: 1 1;
67 align: 0.0 0.5; 64 align: 0.0 0.5;
68 } 65 }
66 description { state: "visible" 0.0;
67 inherit: "default" 0.0;
68 visible: 0;
69 }
69 } 70 }
70 part { name: "elm.swallow.right_arrow"; 71 part { name: "elm.swallow.right_arrow";
71 type: SWALLOW; 72 type: SWALLOW;
@@ -79,6 +80,20 @@ collections {
79 } 80 }
80 } 81 }
81 } 82 }
83 programs {
84 program { name: "hide-arrow-left";
85 signal: "elm,state,arrow,hide";
86 source: "elm";
87 action: STATE_SET "visible" 0.0;
88 target: "elm.swallow.left_arrow";
89 }
90 program { name: "show-arrow-left";
91 signal: "elm,state,arrow,show";
92 source: "elm";
93 action: STATE_SET "default" 0.0;
94 target: "elm.swallow.left_arrow";
95 }
96 }
82 } 97 }
83 group { name:"left_arrow"; 98 group { name:"left_arrow";
84 parts { 99 parts {
diff --git a/sample/2-final/src/main.c b/sample/2-final/src/main.c
index 575bb8e..ec9edb8 100644
--- a/sample/2-final/src/main.c
+++ b/sample/2-final/src/main.c
@@ -27,7 +27,7 @@ create_image(Evas_Object *parent, char *path, char *group)
27} 27}
28 28
29void 29void
30btn_clicked(void *data, Evas_Object *obj, void *event_info) 30_btn_effect(Evas_Object *obj)
31{ 31{
32 evas_object_raise(obj); 32 evas_object_raise(obj);
33 33
@@ -36,15 +36,46 @@ btn_clicked(void *data, Evas_Object *obj, void *event_info)
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 elm_transit_effect_zoom_add(transit, 1.0, 1.25);
39 elm_transit_smooth_set(transit, EINA_FALSE); 39 //elm_transit_smooth_set(transit, EINA_FALSE); // EFL 1.8
40 elm_transit_go(transit); 40 elm_transit_go(transit);
41} 41}
42 42
43void 43void
44btn_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info)
45{
46 _btn_effect(obj);
47}
48
49void
50btn_clicked(void *data, Evas_Object *obj, void *event_info)
51{
52 _btn_effect(obj);
53}
54
55void
44toolbar_it_cb(void *data, Evas_Object *obj, void *event_info) 56toolbar_it_cb(void *data, Evas_Object *obj, void *event_info)
45{ 57{
46 Elm_Object_Item *it = event_info; 58 Elm_Object_Item *it = event_info;
47 printf("%s\n", elm_object_item_text_get(it)); 59 printf("%s\n", elm_object_item_text_get(it));
60 Evas_Object *layout = data;
61 if (!layout) return;
62 elm_layout_text_set(layout, "elm.text.news", elm_object_item_text_get(it));
63}
64
65void
66_left_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
67{
68 Evas_Object *layout = data;
69 if (!layout) return;
70 elm_layout_signal_emit(layout, "elm,state,arrow,hide" , "elm");
71}
72
73void
74_right_arrow_clicked_cb(void *data, Evas_Object *obj, void *info)
75{
76 Evas_Object *layout = data;
77 if (!layout) return;
78 elm_layout_signal_emit(layout, "elm,state,arrow,show" , "elm");
48} 79}
49 80
50void 81void
@@ -56,7 +87,8 @@ init()
56 Evas_Coord padding_size; 87 Evas_Coord padding_size;
57 88
58 //Create a Window 89 //Create a Window
59 win = elm_win_util_standard_add(elm_app_name_get(), elm_app_name_get()); 90 //win = elm_win_util_standard_add(elm_app_name_get(), elm_app_name_get()); // EFL 1.8
91 win = elm_win_util_standard_add("sample", "Sample");
60 elm_win_focus_highlight_enabled_set(win, EINA_TRUE); 92 elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
61 elm_win_autodel_set(win, EINA_TRUE); 93 elm_win_autodel_set(win, EINA_TRUE);
62 evas_object_resize(win, 720, 400); 94 evas_object_resize(win, 720, 400);
@@ -64,7 +96,7 @@ init()
64 96
65 //Create a Layout 97 //Create a Layout
66 layout = elm_layout_add(win); 98 layout = elm_layout_add(win);
67 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", PACKAGE_DATA_DIR); 99 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
68 elm_layout_file_set(layout, buf, "main"); 100 elm_layout_file_set(layout, buf, "main");
69 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 101 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
70 elm_win_resize_object_add(win, layout); 102 elm_win_resize_object_add(win, layout);
@@ -76,8 +108,7 @@ init()
76 for (i = 0; i < 5; i++) 108 for (i = 0; i < 5; i++)
77 { 109 {
78 btn = create_button(table); 110 btn = create_button(table);
79 111 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); 112 snprintf(buf2, sizeof(buf2), "icon%d", i);
82 img = create_image(btn, buf, buf2); 113 img = create_image(btn, buf, buf2);
83 elm_object_content_set(btn, img); 114 elm_object_content_set(btn, img);
@@ -107,8 +138,13 @@ init()
107 for (j = 0; j < 6; j++) 138 for (j = 0; j < 6; j++)
108 { 139 {
109 btn = create_button(table); 140 btn = create_button(table);
110 evas_object_smart_callback_add(btn, "clicked", btn_clicked, NULL); 141
111 snprintf(buf, sizeof(buf), "%s/images/%d.jpg", PACKAGE_DATA_DIR, ((i * 6) + j)); 142 // elm_button "clicked" smart callback
143 //evas_object_smart_callback_add(btn, "clicked", btn_clicked, NULL);
144
145 // evas object mouse in callback
146 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, btn_mouse_in, NULL);
147 snprintf(buf, sizeof(buf), "%s/images/%d.jpg", elm_app_data_dir_get(), ((i * 6) + j));
112 img = create_image(btn, buf, NULL); 148 img = create_image(btn, buf, NULL);
113 elm_object_content_set(btn, img); 149 elm_object_content_set(btn, img);
114 elm_table_pack(table, btn, j, i, 1, 1); 150 elm_table_pack(table, btn, j, i, 1, 1);
@@ -120,34 +156,34 @@ init()
120 156
121 //Create a Left arrow 157 //Create a Left arrow
122 btn = create_button(table); 158 btn = create_button(table);
123 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());
124 img = create_image(btn, buf, "left_arrow"); 160 img = create_image(btn, buf, "left_arrow");
125 elm_object_content_set(btn, img); 161 elm_object_content_set(btn, img);
126 elm_object_part_content_set(layout, "elm.swallow.left_arrow", btn); 162 elm_object_part_content_set(layout, "elm.swallow.left_arrow", btn);
127 evas_object_show(btn); 163 evas_object_show(btn);
164 evas_object_smart_callback_add(btn, "clicked", _left_arrow_clicked_cb, layout);
128 165
129 //Create a Right arrow 166 //Create a Right arrow
130 btn = create_button(table); 167 btn = create_button(table);
131 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", PACKAGE_DATA_DIR); 168 snprintf(buf, sizeof(buf), "%s/edj/layout.edj", elm_app_data_dir_get());
132 img = create_image(btn, buf, "right_arrow"); 169 img = create_image(btn, buf, "right_arrow");
133 elm_object_content_set(btn, img); 170 elm_object_content_set(btn, img);
134 elm_object_part_content_set(layout, "elm.swallow.right_arrow", btn); 171 elm_object_part_content_set(layout, "elm.swallow.right_arrow", btn);
135 evas_object_show(btn); 172 evas_object_show(btn);
173 evas_object_smart_callback_add(btn, "clicked", _right_arrow_clicked_cb, layout);
136 174
137 //Create Bottom Contents 175 //Create Bottom Contents
138 toolbar = elm_toolbar_add(layout); 176 toolbar = elm_toolbar_add(layout);
139 elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS); 177 elm_toolbar_select_mode_set(toolbar, ELM_OBJECT_SELECT_MODE_ALWAYS);
140 elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE); 178 //elm_toolbar_transverse_expanded_set(toolbar, EINA_TRUE); // EFL 1.8
141 elm_toolbar_homogeneous_set(toolbar, EINA_TRUE); 179 elm_toolbar_homogeneous_set(toolbar, EINA_TRUE);
142 evas_object_size_hint_weight_set(toolbar, EVAS_HINT_EXPAND, 0); 180
143 evas_object_size_hint_align_set(toolbar, EVAS_HINT_FILL, 0); 181 elm_toolbar_item_append(toolbar, NULL, "Guide", toolbar_it_cb, layout);
144 182 elm_toolbar_item_append(toolbar, NULL, "Time Line View", toolbar_it_cb, layout);
145 elm_toolbar_item_append(toolbar, NULL, "Guide", toolbar_it_cb, NULL); 183 elm_toolbar_item_append(toolbar, NULL, "Recorded TV", toolbar_it_cb, layout);
146 elm_toolbar_item_append(toolbar, NULL, "Time Line View", toolbar_it_cb, NULL); 184 elm_toolbar_item_append(toolbar, NULL, "Downloads", toolbar_it_cb, layout);
147 elm_toolbar_item_append(toolbar, NULL, "Recorded TV", toolbar_it_cb, NULL); 185 elm_toolbar_item_append(toolbar, NULL, "Favorites", toolbar_it_cb, layout);
148 elm_toolbar_item_append(toolbar, NULL, "Downloads", toolbar_it_cb, NULL); 186 elm_toolbar_item_append(toolbar, NULL, "YouTube", toolbar_it_cb, layout);
149 elm_toolbar_item_append(toolbar, NULL, "Favorites", toolbar_it_cb, NULL);
150 elm_toolbar_item_append(toolbar, NULL, "YouTube", toolbar_it_cb, NULL);
151 187
152 elm_object_part_content_set(layout, "elm.swallow.bottom", toolbar); 188 elm_object_part_content_set(layout, "elm.swallow.bottom", toolbar);
153 evas_object_show(toolbar); 189 evas_object_show(toolbar);