summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-11-14 14:57:36 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2013-11-14 14:57:36 +0100
commitff86fc7bd7fff94af66d5b758b9e7bf6f7a61bf6 (patch)
tree033ffc477f77fcc57c5fe2a16fd50366877d8876
parent1241760d00758c85cbef2f12e37477099dc02f17 (diff)
app: improve naviframe infrastructure
-rw-r--r--app/src/bin/app.h19
-rw-r--r--app/src/bin/gui.c81
2 files changed, 69 insertions, 31 deletions
diff --git a/app/src/bin/app.h b/app/src/bin/app.h
index 71e5fc9..9983152 100644
--- a/app/src/bin/app.h
+++ b/app/src/bin/app.h
@@ -38,6 +38,21 @@ extern int _elm_skel_log_dom;
38#endif 38#endif
39#define DBG(...) EINA_LOG_DOM_DBG(_elm_skel_log_dom, __VA_ARGS__) 39#define DBG(...) EINA_LOG_DOM_DBG(_elm_skel_log_dom, __VA_ARGS__)
40 40
41typedef enum _App_Frames
42{
43 FRAME_MAIN = 0,
44 FRAME_TUNNEL,
45 MAX_FRAMES
46} App_Frame;
47
48typedef struct _Gui_Frame
49{
50 const char *name;
51 Evas_Smart_Cb create_cb;
52 Elm_Naviframe_Item_Pop_Cb pop_cb;
53 Elm_Object_Item_Signal_Cb update_cb;
54} Gui_Frame;
55
41typedef struct _app { 56typedef struct _app {
42 Eina_Bool init_done; 57 Eina_Bool init_done;
43 const char *theme_path; 58 const char *theme_path;
@@ -46,6 +61,7 @@ typedef struct _app {
46 Evas_Object *win; 61 Evas_Object *win;
47 Evas_Object *popup; 62 Evas_Object *popup;
48 Evas_Object *nf; 63 Evas_Object *nf;
64 Gui_Frame frames[MAX_FRAMES];
49 } gui; 65 } gui;
50} App; 66} App;
51 67
@@ -71,9 +87,6 @@ Evas_Object*
71app_gui_create(App *app, Eina_Bool fullscreen, Eina_Rectangle geometry); 87app_gui_create(App *app, Eina_Bool fullscreen, Eina_Rectangle geometry);
72 88
73void 89void
74app_gui_push_first_frame(App *app);
75
76void
77app_gui_notify(App *app, const char *msg); 90app_gui_notify(App *app, const char *msg);
78 91
79void 92void
diff --git a/app/src/bin/gui.c b/app/src/bin/gui.c
index 5f1f3c7..9e346ae 100644
--- a/app/src/bin/gui.c
+++ b/app/src/bin/gui.c
@@ -33,12 +33,11 @@ _on_tunnel_signal(void *data, Evas_Object *obj, const char *sig, const char *src
33{ 33{
34 App *app = (App *) data; 34 App *app = (App *) data;
35 35
36 if (!strcmp(sig, "mouse,move"))
37 return;
38
39 INF("recv theme sig : %s - %s (%p)", sig, src, obj);
40 if (!strcmp(sig, "tunnel,exit")) 36 if (!strcmp(sig, "tunnel,exit"))
41 _app_exit(app); 37 {
38 INF("recv theme sig : %s - %s (%p)", sig, src, obj);
39 _app_exit(app);
40 }
42} 41}
43 42
44/* NAVIFRAME */ 43/* NAVIFRAME */
@@ -80,12 +79,46 @@ _naviframe_right_button_create(App *app, const char *name, Evas_Smart_Cb cb)
80} 79}
81 80
82static void 81static void
83_frame_tunnel_update(void *data, Elm_Object_Item *it, const char *sig EINA_UNUSED, const char *src EINA_UNUSED) 82_naviframe_content_set(App *app, Evas_Object *content, App_Frame cur, App_Frame next)
83{
84 Gui_Frame *frame;
85 Elm_Object_Item *it;
86 Evas_Object *btn = NULL;
87
88 if (next < MAX_FRAMES)
89 {
90 frame = &app->gui.frames[next];
91 btn = _naviframe_right_button_create(app, frame->name, frame->create_cb);
92 }
93
94 frame = &app->gui.frames[cur];
95 it = elm_naviframe_item_push(app->gui.nf, frame->name, NULL, btn, content, NULL);
96 elm_object_item_signal_callback_add(it, "elm,state,prev,popped", "elm", frame->update_cb, app);
97 elm_naviframe_item_pop_cb_set(it, frame->pop_cb, app);
98
99 INF("frame push %s", elm_object_item_part_text_get(it, "elm.text.title"));
100}
101
102static Eina_Bool
103_frame_common_delete(void *data, Elm_Object_Item *it)
84{ 104{
85 App *app = (App *) data; 105 App *app = (App *) data;
86 Evas_Object *edj = _naviframe_item_edje_get(it); 106 Evas_Object *edj = _naviframe_item_edje_get(it);
87 107
88 INF("update tunnel frame %p", edj); 108 INF("frame delete %s %p", elm_object_item_part_text_get(it, "elm.text.title"), edj);
109
110 (void) app;
111
112 return EINA_TRUE;
113}
114
115static void
116_frame_common_update(void *data, Elm_Object_Item *it, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
117{
118 App *app = (App *) data;
119 Evas_Object *edj = _naviframe_item_edje_get(it);
120
121 INF("frame update %s %p", elm_object_item_part_text_get(it, "elm.text.title"), edj);
89 122
90 (void) app; 123 (void) app;
91} 124}
@@ -94,7 +127,6 @@ static void
94_frame_tunnel_create(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 127_frame_tunnel_create(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
95{ 128{
96 App *app = (App *) data; 129 App *app = (App *) data;
97 Elm_Object_Item *it;
98 Evas_Object *layout; 130 Evas_Object *layout;
99 131
100 // load and add the elm layout 132 // load and add the elm layout
@@ -105,9 +137,7 @@ _frame_tunnel_create(void *data, Evas_Object *obj EINA_UNUSED, void *event_info
105 137
106 elm_object_signal_callback_add(layout, "*", "*", _on_tunnel_signal, app); 138 elm_object_signal_callback_add(layout, "*", "*", _on_tunnel_signal, app);
107 139
108 it = elm_naviframe_item_push(app->gui.nf, "Tunnel", NULL, NULL, layout, NULL); 140 _naviframe_content_set(app, layout, FRAME_TUNNEL, MAX_FRAMES);
109 evas_object_data_set(app->gui.nf, "page2", it);
110 elm_object_item_signal_callback_add(it, "elm,state,prev,popped", "elm", _frame_tunnel_update, app);
111} 141}
112 142
113static void 143static void
@@ -120,22 +150,10 @@ _frame_main_btn_click(void *data, Evas_Object *obj EINA_UNUSED, void *evt_inf EI
120} 150}
121 151
122static void 152static void
123_frame_main_update(void *data, Elm_Object_Item *it, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
124{
125 App *app = (App *) data;
126 Evas_Object *edj = _naviframe_item_edje_get(it);
127
128 INF("update main frame %p", edj);
129
130 (void) app;
131}
132
133static void
134_frame_main_create(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 153_frame_main_create(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
135{ 154{
136 App *app = (App *) data; 155 App *app = (App *) data;
137 156
138 Elm_Object_Item *it;
139 Evas_Object *box, *lab, *btn; 157 Evas_Object *box, *lab, *btn;
140 158
141 // add a vertical box as a resize object for the window 159 // add a vertical box as a resize object for the window
@@ -169,10 +187,7 @@ _frame_main_create(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EI
169 elm_object_focus_set(btn, EINA_TRUE); 187 elm_object_focus_set(btn, EINA_TRUE);
170 evas_object_show(btn); 188 evas_object_show(btn);
171 189
172 btn = _naviframe_right_button_create(app, "Tunnel", _frame_tunnel_create); 190 _naviframe_content_set(app, box, FRAME_MAIN, FRAME_TUNNEL);
173
174 it = elm_naviframe_item_push(app->gui.nf, "Main", NULL, btn, box, NULL);
175 elm_object_item_signal_callback_add(it, "elm,state,prev,popped", "elm", _frame_main_update, app);
176} 191}
177 192
178static Evas_Object * 193static Evas_Object *
@@ -185,7 +200,6 @@ _create_naviframe(App *app, Evas_Object *parent)
185 elm_win_resize_object_add(parent, nf); 200 elm_win_resize_object_add(parent, nf);
186 evas_object_show(nf); 201 evas_object_show(nf);
187 evas_object_smart_callback_add(nf, "title,clicked", _naviframe_title_clicked, app); 202 evas_object_smart_callback_add(nf, "title,clicked", _naviframe_title_clicked, app);
188 _frame_main_create(app, NULL, NULL);
189 203
190 return nf; 204 return nf;
191} 205}
@@ -265,7 +279,18 @@ app_gui_create(App *app, Eina_Bool fullscreen, Eina_Rectangle geometry)
265 /* elm_win_focus_highlight_enabled_set(win, EINA_TRUE); */ 279 /* elm_win_focus_highlight_enabled_set(win, EINA_TRUE); */
266 evas_object_show(win); 280 evas_object_show(win);
267 281
282 /* setup naviframes */
283 app->gui.frames[FRAME_MAIN].name = "Main";
284 app->gui.frames[FRAME_MAIN].create_cb = _frame_main_create;
285 app->gui.frames[FRAME_MAIN].pop_cb = _frame_common_delete;
286 app->gui.frames[FRAME_MAIN].update_cb = _frame_common_update;
287 app->gui.frames[FRAME_TUNNEL].name = "Tunnel";
288 app->gui.frames[FRAME_TUNNEL].create_cb = _frame_tunnel_create;
289 app->gui.frames[FRAME_TUNNEL].pop_cb = _frame_common_delete;
290 app->gui.frames[FRAME_TUNNEL].update_cb = _frame_common_update;
291
268 _create_naviframe(app, win); 292 _create_naviframe(app, win);
293 app->gui.frames[FRAME_MAIN].create_cb(app, NULL, NULL);
269 294
270 // set position and size according to parameters 295 // set position and size according to parameters
271 if(fullscreen) 296 if(fullscreen)