summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2015-03-22 00:23:04 +0100
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2015-10-05 12:56:26 +0200
commitef670bdcefe35d7108bcbadae830a46ee8a1eca7 (patch)
treea001982e52bda12593a129797dca4aeacf71271c
parent7e4c3ca6662f647b08885e2f3b11d50389d26cac (diff)
settingspanel: refactored realizing code
item calls to realize and unrealizing are showing or unshowing the item, which reduces the number of lines and makes the code much more readable.
-rw-r--r--data/themes/edc/elm/settingspane.edc25
-rw-r--r--src/bin/test_settingspane.c18
-rw-r--r--src/lib/elc_settingspane.c979
-rw-r--r--src/lib/elm_settingspane.eo1
-rw-r--r--src/lib/elm_settingspane_item.eo12
5 files changed, 388 insertions, 647 deletions
diff --git a/data/themes/edc/elm/settingspane.edc b/data/themes/edc/elm/settingspane.edc
index f4988cc80..1a43ddc97 100644
--- a/data/themes/edc/elm/settingspane.edc
+++ b/data/themes/edc/elm/settingspane.edc
@@ -314,14 +314,6 @@ group { name: "elm/settingspane/base/default";
314 } 314 }
315 part { name: "elm.swallow.content"; type: SWALLOW; 315 part { name: "elm.swallow.content"; type: SWALLOW;
316 description { state: "default" 0.0; 316 description { state: "default" 0.0;
317 rel1.relative: 0.0 0.0;
318 rel2.relative: 0.0 1.0;
319 align: 1.0 0.0;
320 fixed: 1 1;
321 }
322 /* Only visible without display hidden */
323 description { state: "visible" 0.0;
324 inherit: "default" 0.0;
325 rel1.offset: 0 0; 317 rel1.offset: 0 0;
326 rel2.offset: -1 -1; 318 rel2.offset: -1 -1;
327 rel2.relative: 1.0 1.0; 319 rel2.relative: 1.0 1.0;
@@ -330,15 +322,15 @@ group { name: "elm/settingspane/base/default";
330 /* part gets this state when there is hidden */ 322 /* part gets this state when there is hidden */
331 /* otherwise it will overlap the hidden part */ 323 /* otherwise it will overlap the hidden part */
332 description { state: "visible_hidden" 0.0; 324 description { state: "visible_hidden" 0.0;
333 inherit: "visible" 0.0; 325 inherit: "default" 0.0;
334 rel1.offset: 15 0; 326 rel1.offset: 15 0;
335 rel2.offset: 0 -1; 327 rel2.offset: 0 -1;
336 align: 0.0 0.0; 328 align: 1.0 0.0;
337 } 329 }
338 /* just a tiny bit on the left side from the old list */ 330 /* just a tiny bit on the left side from the old list */
339 description { state: "hidden" 0.0; 331 description { state: "hidden" 0.0;
340 inherit: "visible" 0.0; 332 inherit: "default" 0.0;
341 rel1.offset: 0 0; 333 rel1.offset: -135 0;
342 rel2.offset: 15 -1; 334 rel2.offset: 15 -1;
343 rel2.relative: 0.0 1.0; 335 rel2.relative: 0.0 1.0;
344 align: 1.0 0.0; 336 align: 1.0 0.0;
@@ -373,7 +365,7 @@ group { name: "elm/settingspane/base/default";
373 programs { 365 programs {
374 program { 366 program {
375 signal: "elm,state,visible"; source: "elm"; 367 signal: "elm,state,visible"; source: "elm";
376 action: STATE_SET "visible" 0.0; 368 action: STATE_SET "default" 0.0;
377 transition: DECELERATE 0.4; 369 transition: DECELERATE 0.4;
378 target: "elm.swallow.content"; 370 target: "elm.swallow.content";
379 target: "back_cover"; 371 target: "back_cover";
@@ -393,13 +385,6 @@ group { name: "elm/settingspane/base/default";
393 target: "back_cover"; 385 target: "back_cover";
394 } 386 }
395 program { 387 program {
396 signal: "elm,state,default"; source: "elm";
397 action: STATE_SET "default" 0.0;
398 transition: DECELERATE 0.2;
399 target: "elm.swallow.content";
400 target: "back_cover";
401 }
402 program {
403 signal: "mouse,clicked,1"; source: "back_cover"; 388 signal: "mouse,clicked,1"; source: "back_cover";
404 action: SIGNAL_EMIT "action,back" "conf"; 389 action: SIGNAL_EMIT "action,back" "conf";
405 } 390 }
diff --git a/src/bin/test_settingspane.c b/src/bin/test_settingspane.c
index 9edab693c..d3c554401 100644
--- a/src/bin/test_settingspane.c
+++ b/src/bin/test_settingspane.c
@@ -204,16 +204,6 @@ del_focused_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_U
204 elm_settingspane_item_delete(item); 204 elm_settingspane_item_delete(item);
205} 205}
206 206
207static void
208recreate_focused_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
209{
210 Elm_Settingspane_Item *item;
211
212 item = elm_settingspane_focused_get(data);
213
214 elm_settingspane_item_recreate(item);
215}
216
217void 207void
218test_settingspane(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 208test_settingspane(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
219{ 209{
@@ -301,14 +291,6 @@ test_settingspane(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
301 elm_box_pack_end(btnbox, o); 291 elm_box_pack_end(btnbox, o);
302 evas_object_show(o); 292 evas_object_show(o);
303 293
304 o = elm_button_add(win);
305 elm_object_text_set(o, "recreate current item");
306 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
307 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
308 evas_object_smart_callback_add(o, "clicked", recreate_focused_cb, sw);
309 elm_box_pack_end(btnbox, o);
310 evas_object_show(o);
311
312 evas_object_show(win); 294 evas_object_show(win);
313 evas_object_resize(win, 500, 500); 295 evas_object_resize(win, 500, 500);
314} 296}
diff --git a/src/lib/elc_settingspane.c b/src/lib/elc_settingspane.c
index 95f294995..92cd2a858 100644
--- a/src/lib/elc_settingspane.c
+++ b/src/lib/elc_settingspane.c
@@ -26,11 +26,21 @@
26 26
27typedef struct 27typedef struct
28{ 28{
29 Evas_Object *o; 29 Evas_Object *list; //the genlist
30 Evas_Object *layout;
31 Eina_Bool visible_hidden; //the menu is there but hidden
30} Menu; 32} Menu;
31 33
32typedef struct 34typedef struct
33{ 35{
36 Evas_Object *apply; //< apply button
37 Evas_Object *reset; //< reset button
38 Evas_Object *layout; //< The layout where everything is displayed
39 Eina_Bool hidden; //< true if it is realized but hidden
40} Panel;
41
42typedef struct
43{
34 Elm_Settingspane_Item *zero; 44 Elm_Settingspane_Item *zero;
35 45
36 // list of all Elm_Item_Object 46 // list of all Elm_Item_Object
@@ -43,12 +53,16 @@ typedef struct
43 { 53 {
44 Eina_Bool on; 54 Eina_Bool on;
45 Evas_Object *display, *grid, *obj; 55 Evas_Object *display, *grid, *obj;
56 Panel *p;
46 Ecore_Thread *run; 57 Ecore_Thread *run;
47 const char* keyword; 58 const char* keyword;
48 } search; 59 } search;
49 Evas_Object *title_box, *search_label, *search_results, *unsaved_opened; 60 Evas_Object *title_box, *search_label, *search_results, *unsaved_opened;
50 Evas_Object *table_panel; 61 Evas_Object *table_panel;
51 Evas_Object *table_menu; 62 Evas_Object *table_menu;
63 Elm_Settingspane_Item *menu_hidden;
64 Elm_Settingspane_Item *menu_visible;
65 Elm_Settingspane_Item *panel_visible;
52} Elm_Settingspane_Data; 66} Elm_Settingspane_Data;
53 67
54typedef struct 68typedef struct
@@ -64,7 +78,7 @@ typedef struct
64 const char *description; 78 const char *description;
65 void *data; 79 void *data;
66 80
67 Evas_Object *sw; 81 Evas_Object *sw; //< widget where this is created
68 Eina_Bool changed; 82 Eina_Bool changed;
69 83
70 Elm_Widget_Item *it; 84 Elm_Widget_Item *it;
@@ -72,14 +86,12 @@ typedef struct
72 86
73 struct 87 struct
74 { 88 {
75 Evas_Object *tmp_content; //obejct of a hiden content will be held here.
76
77 Evas_Smart_Cb apply; 89 Evas_Smart_Cb apply;
78 Evas_Smart_Cb reset; 90 Evas_Smart_Cb reset;
79 Content_Get_Cb content_get; 91 Content_Get_Cb content_get;
80 } panel; 92 } event;
81 Eina_Bool keep; 93 Panel *panel; //< if this item is realized its not NULL
82 Eina_Bool scheduled; 94 Menu *menu;
83} Elm_Settingspane_Item_Data; 95} Elm_Settingspane_Item_Data;
84 96
85typedef struct _Search_Run 97typedef struct _Search_Run
@@ -89,6 +101,9 @@ typedef struct _Search_Run
89 const char *keyword; 101 const char *keyword;
90} Search_Run; 102} Search_Run;
91 103
104
105static void _item_menu_refresh(Eo *obj, Elm_Settingspane_Item_Data *pd);
106
92static void _unsaved_changes_add(Evas_Object *w, Elm_Object_Item *item); 107static void _unsaved_changes_add(Evas_Object *w, Elm_Object_Item *item);
93static void _unsaved_changes_remove(Evas_Object *w, Elm_Object_Item *item); 108static void _unsaved_changes_remove(Evas_Object *w, Elm_Object_Item *item);
94 109
@@ -101,20 +116,13 @@ static void _history_stack_remove(Evas_Object *w, Elm_Object_Item *it);
101static void _item_sel_cb(void *data, Evas_Object *obj, void *event_info); 116static void _item_sel_cb(void *data, Evas_Object *obj, void *event_info);
102static void _search_panel_stop(Evas_Object *w); 117static void _search_panel_stop(Evas_Object *w);
103 118
104#define HAS_PANEL(id) (id->panel.content_get) 119#define HAS_PANEL(id) (id->event.content_get)
105/* Data Keys in the layouts, DK = Data Key */ 120/* Data Keys in the layouts, DK = Data Key */
106 121
107#define DK_MAIN_MENU_SHOWED "__menu_layout_show" 122#define DK_MAIN_MENU_SHOWED "__menu_layout_show"
108#define DK_MAIN_MENU_HIDDEN "__menu_layout_hidden" 123#define DK_MAIN_MENU_HIDDEN "__menu_layout_hidden"
109#define DK_MAIN_MENU_BEHIND "__menu_layout_behind" 124#define DK_MAIN_MENU_BEHIND "__menu_layout_behind"
110 125
111#define DK_MAIN_PANEL_SHOWED "__panel_layout_show"
112#define DK_MAIN_PANEL_HIDDEN "__panel_layout_hidden"
113
114#define DK_PANEL_APPLY_BUTTON "__apply_btn"
115#define DK_PANEL_RESET_BUTTON "__reset_btn"
116#define DK_PANEL_ITEM_SHOWN "__showed_item"
117
118#define DK_MENU_GENLIST "__menu_genlist" 126#define DK_MENU_GENLIST "__menu_genlist"
119#define DK_MENU_ITEM_SHOWN "__showed_item" 127#define DK_MENU_ITEM_SHOWN "__showed_item"
120 128
@@ -158,6 +166,8 @@ static void _search_panel_stop(Evas_Object *w);
158#define IC_DATA_L(v) eo_data_scope_get(v, ELM_SETTINGSPANE_ITEM_CLASS) 166#define IC_DATA_L(v) eo_data_scope_get(v, ELM_SETTINGSPANE_ITEM_CLASS)
159#define C_DATA(v) Elm_Settingspane_Data *wd = eo_data_scope_get(v, ELM_SETTINGSPANE_CLASS) 167#define C_DATA(v) Elm_Settingspane_Data *wd = eo_data_scope_get(v, ELM_SETTINGSPANE_CLASS)
160 168
169static Panel* _item_panel_realize(Eo *obj, Evas_Object *w, Evas_Object *content);
170
161static const Elm_Layout_Part_Alias_Description _content_aliases[] = 171static const Elm_Layout_Part_Alias_Description _content_aliases[] =
162{ 172{
163 {"options", "elm.swallow.options"}, 173 {"options", "elm.swallow.options"},
@@ -180,7 +190,9 @@ conf_menu_back_cb(void *data EINA_UNUSED, Evas_Object *obj, const char *emission
180} 190}
181 191
182/* 192/*
183 * Titlebar stuff 193 * =================================
194 * Titlebar stuff
195 * =================================
184 */ 196 */
185static void 197static void
186_title_bar_refresh(Evas_Object *w) 198_title_bar_refresh(Evas_Object *w)
@@ -208,16 +220,19 @@ _title_bar_refresh(Evas_Object *w)
208 } while(id->par); 220 } while(id->par);
209} 221}
210 222
211/* 223/**
212 * Elm_Settingspane_Item event funktions 224 * =============================
225 * Events of a item
226 * =============================
213 */ 227 */
228
214static void 229static void
215_item_content_reset(Elm_Settingspane_Item *it) 230_item_content_reset(Elm_Settingspane_Item *it)
216{ 231{
217 IC_DATA(it); 232 IC_DATA(it);
218 233
219 if (id->panel.reset) 234 if (id->event.reset)
220 id->panel.reset(id->data, id->sw, it); 235 id->event.reset(id->data, id->sw, it);
221} 236}
222 237
223static void 238static void
@@ -225,17 +240,8 @@ _item_content_apply(Elm_Settingspane_Item *it)
225{ 240{
226 IC_DATA(it); 241 IC_DATA(it);
227 242
228 if (id->panel.apply) 243 if (id->event.apply)
229 id->panel.apply(id->data, id->sw, it); 244 id->event.apply(id->data, id->sw, it);
230}
231
232static void
233_item_content_del(Elm_Settingspane_Item *it EINA_UNUSED)
234{
235/* Elm_Settingspane_Item_Data *id = eo_data_scope_get(it,
236 ELM_SETTINGSPANE_ITEM_CLASS);
237 if (id->class->content_del)
238 id->class->content_del(id->data);*/
239} 245}
240 246
241static Evas_Object* 247static Evas_Object*
@@ -243,444 +249,29 @@ _item_content_get(Elm_Settingspane_Item *it, Evas_Object *obj)
243{ 249{
244 IC_DATA(it); 250 IC_DATA(it);
245 251
246 if (id->panel.content_get) 252 if (id->event.content_get)
247 return id->panel.content_get(obj, it, id->data); 253 return id->event.content_get(obj, it, id->data);
248 else 254 else
249 return NULL; 255 return NULL;
250} 256}
251 257
252 258
253/* 259/*
254 * content_layout section 260 * =====================================
261 * apply and reset of the items
262 * =====================================
255 */ 263 */
256 264
257static void 265static void
258_content_layout_apply_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) 266_content_layout_apply_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
259{ 267{
260 Evas_Object *l = data; 268 _item_content_apply(data);
261 Elm_Settingspane_Item *displayed = evas_object_data_get(l, DK_PANEL_ITEM_SHOWN);
262
263 if (!displayed) return;
264
265 _item_content_apply(displayed);
266} 269}
267 270
268static void 271static void
269_content_layout_reset_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED) 272_content_layout_reset_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
270{ 273{
271 Evas_Object *l = data; 274 _item_content_reset(data);
272 Elm_Settingspane_Item *displayed = evas_object_data_get(l, DK_PANEL_ITEM_SHOWN);
273
274 if (!displayed) return;
275
276 _item_content_reset(displayed);
277}
278
279static void
280_content_del(Elm_Settingspane_Item *it)
281{
282 Evas_Object *shown_content;
283 IC_DATA(it);
284
285 shown_content = id->panel.tmp_content;
286 id->panel.tmp_content = NULL;
287 eo_unref(shown_content);
288 evas_object_del(shown_content);
289 if (it)
290 _item_content_del(it);
291}
292static void
293_content_layout_hide(Evas_Object *obj, Elm_Object_Item *item)
294{
295 evas_object_data_del(obj, DK_PANEL_ITEM_SHOWN);
296 IC_DATA(item);
297
298 if (!id->keep)
299 _content_del(item);
300 else
301 {
302 Evas_Object *cnt;
303
304 cnt = elm_object_part_content_unset(obj, POS_PANEL_CONTENT);
305 evas_object_hide(cnt);
306 }
307}
308static void
309_default_reached_cb(void *data EINA_UNUSED, Evas_Object *obj, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
310{
311 Elm_Object_Item *item;
312
313 item = evas_object_data_get(obj, DK_PANEL_ITEM_SHOWN);
314 IC_DATA(item);
315
316 if (!id->scheduled)
317 return;
318
319 DBG("schedule del %s => panel %p", id->name, obj);
320 _content_layout_hide(obj, item);
321}
322
323static void
324_content_layout_content_init(Evas_Object *w)
325{
326 Evas_Object *o, *pad, *bx, *apply, *reset;
327 int i = 0;
328 C_DATA(w);
329
330
331 for (i = 0; i < 2; i++)
332 {
333 o = elm_layout_add(w);
334 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
335 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
336 elm_layout_theme_set(o, "settingspane", "panel", "default");
337 elm_layout_signal_callback_add(o, "elm,state,default,reached", EMITTER, _default_reached_cb, o);
338 evas_object_show(o);
339
340 pad = evas_object_rectangle_add(evas_object_evas_get(w));
341 evas_object_size_hint_weight_set(pad, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
342 evas_object_size_hint_align_set(pad, EVAS_HINT_FILL, EVAS_HINT_FILL);
343 elm_object_part_content_set(o, POS_PANEL_PAD, pad);
344 evas_object_show(pad);
345
346 elm_table_pack(wd->table_panel, o, 0, 0, 1, 1);
347
348 bx = elm_box_add(w);
349 evas_object_size_hint_weight_set(bx, 0, 0);
350 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
351 elm_box_horizontal_set(bx, EINA_TRUE);
352 elm_object_part_content_set(o, POS_PANEL_CONTROLS, bx);
353
354 apply = elm_button_add(w);
355 evas_object_size_hint_weight_set(apply, 0.0, 0.0);
356 evas_object_size_hint_align_set(apply, 0.0, 0.0);
357 evas_object_smart_callback_add(apply, "clicked", _content_layout_apply_cb, o);
358 elm_object_text_set(apply, "Apply");
359 evas_object_data_set(o, DK_PANEL_APPLY_BUTTON, apply);
360 elm_box_pack_end(bx, apply);
361
362 reset = elm_button_add(w);
363 evas_object_size_hint_weight_set(reset, 0, 0);
364 evas_object_size_hint_align_set(reset, 0.0, 0.0);
365 elm_object_text_set(reset, "Reset");
366 evas_object_smart_callback_add(reset, "clicked", _content_layout_reset_cb, o);
367 evas_object_data_set(o, DK_PANEL_RESET_BUTTON, reset);
368 elm_box_pack_end(bx, reset);
369
370 evas_object_show(bx);
371 evas_object_show(reset);
372 evas_object_show(apply);
373
374 if (i < 1)
375 evas_object_data_set(w, DK_MAIN_PANEL_SHOWED, o);
376 else
377 evas_object_data_set(w, DK_MAIN_PANEL_HIDDEN, o);
378 }
379}
380
381static void
382_content_layout_schedule_hide(Evas_Object *w, Eina_Bool keep)
383{
384 Evas_Object *shown = evas_object_data_get(w, DK_MAIN_PANEL_SHOWED);
385 Elm_Object_Item *item = evas_object_data_get(shown, DK_PANEL_ITEM_SHOWN);
386 IC_DATA(item);
387
388 if (!item) //nothing to hide
389 return;
390
391 id->keep = keep;
392 id->scheduled = EINA_TRUE;
393 DBG("set to true %s => panel %p", id->name, shown);
394 elm_layout_signal_emit(shown, EMIT_CONTENT_DEFAULT);
395}
396
397static void
398_content_layout_content_controls_refresh(Evas_Object *w, Elm_Settingspane_Item *it)
399{
400 IC_DATA(it);
401
402 Evas_Object *shown = evas_object_data_get(w, DK_MAIN_PANEL_SHOWED);
403 Evas_Object *apply_btn = evas_object_data_get(shown, DK_PANEL_APPLY_BUTTON);
404 Evas_Object *reset_btn = evas_object_data_get(shown, DK_PANEL_RESET_BUTTON);
405
406 if (!id->changed)
407 elm_layout_signal_emit(shown, EMIT_CONTENT_CONTROLS_HIDE);
408 else
409 elm_layout_signal_emit(shown, EMIT_CONTENT_CONTROLS_SHOW);
410
411 elm_object_disabled_set(apply_btn, !id->changed);
412 elm_object_disabled_set(reset_btn, !id->changed);
413}
414
415static void
416_content_layout_display(Evas_Object *w, Evas_Object *content)
417{
418 Evas_Object *shown = evas_object_data_get(w, DK_MAIN_PANEL_SHOWED);
419 Evas_Object *hidden = evas_object_data_get(w, DK_MAIN_PANEL_HIDDEN);
420
421 elm_layout_content_unset(hidden, POS_PANEL_CONTENT);
422 elm_object_part_content_set(hidden, POS_PANEL_CONTENT, content);
423
424 elm_layout_signal_emit(hidden, EMIT_CONTENT_VISIBLE);
425
426 evas_object_data_set(w, DK_MAIN_PANEL_SHOWED, hidden);
427 evas_object_raise(hidden);
428 evas_object_data_set(w, DK_MAIN_PANEL_HIDDEN, shown);
429}
430
431static void
432_content_layout_content_set(Evas_Object *w, Elm_Settingspane_Item *it)
433{
434 Elm_Object_Item *oitem;
435 IC_DATA(it);
436
437 Evas_Object *hidden = evas_object_data_get(w, DK_MAIN_PANEL_HIDDEN);
438
439 if (!id->panel.tmp_content)
440 {
441 id->panel.tmp_content = elm_scroller_add(w);
442 eo_ref(id->panel.tmp_content);
443 evas_object_size_hint_weight_set(id->panel.tmp_content,
444 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
445 evas_object_show(id->panel.tmp_content);
446 elm_object_content_set(id->panel.tmp_content, _item_content_get(it, w));
447
448 }
449 oitem = evas_object_data_get(hidden, DK_PANEL_ITEM_SHOWN);
450
451 if (oitem && oitem != it)
452 {
453 Elm_Settingspane_Item_Data *oid = IC_DATA_L(oitem);
454
455 oid->scheduled = EINA_FALSE;
456 DBG("pre del %s => panel %p", oid->name, hidden);
457 _content_layout_hide(hidden, oitem);
458 }
459
460 _content_layout_display(w, id->panel.tmp_content);
461 evas_object_data_set(hidden, DK_PANEL_ITEM_SHOWN, it);
462
463 _content_layout_content_controls_refresh(w, it);
464}
465
466/*
467 * menu_layout section
468 */
469static void
470_menu_layout_init(Evas_Object *w)
471{
472 Evas_Object *o, *list;
473 int i = 0;
474 C_DATA(w);
475
476 for (i = 0; i < 3; i++)
477 {
478 o = elm_layout_add(w);
479 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
480 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
481 elm_layout_theme_set(o, "settingspane", "menu", "default");
482// elm_layout_signal_callback_add(w, "action,back", "conf", conf_menu_back_cb, w);
483 evas_object_show(o);
484
485 list = elm_genlist_add(w);
486 elm_scroller_bounce_set(list, EINA_FALSE, EINA_FALSE);
487 elm_object_style_set(list, "flatedge");
488 evas_object_size_hint_weight_set(list, 0.0, EVAS_HINT_EXPAND);
489 evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
490 elm_genlist_mode_set(list, ELM_LIST_LIMIT);
491 evas_object_data_set(o, DK_MENU_GENLIST, list);
492 elm_object_part_content_set(o, POS_MENU_CONTENT, list);
493 evas_object_show(list);
494 elm_table_pack(wd->table_menu, o, 0, 0, 1, 1);
495
496 if (i == 0)
497 evas_object_data_set(w, DK_MAIN_MENU_HIDDEN, o);
498 else if (i == 1)
499 evas_object_data_set(w, DK_MAIN_MENU_SHOWED, o);
500 else if (i == 2)
501 evas_object_data_set(w, DK_MAIN_MENU_BEHIND, o);
502 }
503}
504
505static void
506_list_fill(Evas_Object *list, Elm_Settingspane_Item *item)
507{
508 IC_DATA(item);
509 C_DATA(id->sw);
510
511 Eina_List *node;
512 Elm_Settingspane_Item *child;
513
514 elm_genlist_clear(list);
515
516 EINA_LIST_FOREACH(id->childs, node, child)
517 {
518 Elm_Settingspane_Item_Data *cid = IC_DATA_L(child);
519 Elm_Object_Item *it;
520
521 it = elm_genlist_item_append(list, wd->itcc, child,
522 NULL, ELM_GENLIST_ITEM_NONE,
523 _item_sel_cb, child);
524 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_ALWAYS);
525 elm_genlist_item_tooltip_text_set(it, cid->description);
526 }
527}
528
529static void
530_menu_layout_show(Evas_Object *w, Elm_Settingspane_Item *item, Elm_Settingspane_Item *item_h)
531{
532 Evas_Object *shown = evas_object_data_get(w, DK_MAIN_MENU_SHOWED);
533 Evas_Object *hidden = evas_object_data_get(w, DK_MAIN_MENU_HIDDEN);
534 Evas_Object *behind = evas_object_data_get(w, DK_MAIN_MENU_BEHIND);
535 Evas_Object *shownlist = evas_object_data_get(shown, DK_MENU_GENLIST);
536 Evas_Object *behindlist = evas_object_data_get(behind, DK_MENU_GENLIST);
537 Elm_Settingspane_Item *shown_h, *shown_l;
538
539 shown_h = evas_object_data_get(hidden, DK_MENU_ITEM_SHOWN);
540 shown_l = evas_object_data_get(shown, DK_MENU_ITEM_SHOWN);
541
542 if (shown_l == item && shown_h == item_h)
543 return;
544
545 _list_fill(behindlist, item);
546 evas_object_data_set(behind, DK_MENU_ITEM_SHOWN, item);
547
548 //showed item has not changed
549 if (!item_h)
550 {
551 elm_layout_signal_emit(shown, EMIT_MENU_DEFAULT);
552 elm_layout_signal_emit(behind, EMIT_MENU_VISIBLE);
553 evas_object_data_del(shown, DK_MENU_ITEM_SHOWN);
554 }
555 else
556 {
557 _list_fill(shownlist, item_h);
558 elm_layout_signal_emit(shown, EMIT_MENU_HIDDEN);
559 elm_layout_signal_emit(behind, EMIT_MENU_VISIBLE_HIDDEN);
560 evas_object_data_set(shown, DK_MENU_ITEM_SHOWN, item_h);
561 }
562 evas_object_raise(shown);
563
564 evas_object_stack_below(hidden, behind);
565 elm_layout_signal_emit(hidden, EMIT_MENU_DEFAULT);
566 evas_object_data_del(hidden, DK_MENU_ITEM_SHOWN);
567
568 //reorder the use
569 evas_object_data_set(w, DK_MAIN_MENU_SHOWED, behind);
570 evas_object_data_set(w, DK_MAIN_MENU_HIDDEN, shown);
571 evas_object_data_set(w, DK_MAIN_MENU_BEHIND, hidden);
572}
573
574static void
575_menu_layout_del_ref(Evas_Object *w, Elm_Settingspane_Item *it_ref)
576{
577 Elm_Settingspane_Item *it;
578 Evas_Object *layouts[3];
579 int i = 0;
580
581 layouts[0] = evas_object_data_get(w, DK_MAIN_MENU_SHOWED);
582 layouts[1] = evas_object_data_get(w, DK_MAIN_MENU_HIDDEN);
583 layouts[2] = evas_object_data_get(w, DK_MAIN_MENU_BEHIND);
584
585 for (i = 0; i< 3; i++)
586 {
587 it = evas_object_data_get(layouts[i], DK_MENU_ITEM_SHOWN);
588 if (it == it_ref)
589 evas_object_data_del(layouts[i], DK_MENU_ITEM_SHOWN);
590 }
591}
592
593static void
594_menu_layout_refresh(Evas_Object *w)
595{
596 Evas_Object *layouts[3];
597 int i = 0;
598
599 layouts[0] = evas_object_data_get(w, DK_MAIN_MENU_SHOWED);
600 layouts[1] = evas_object_data_get(w, DK_MAIN_MENU_HIDDEN);
601 layouts[2] = evas_object_data_get(w, DK_MAIN_MENU_BEHIND);
602
603 for (i = 0; i< 3; i++)
604 {
605 Elm_Settingspane_Item *it;
606 Evas_Object *list;
607
608 it = evas_object_data_get(layouts[i], DK_MENU_ITEM_SHOWN);
609 if (!it)
610 continue;
611
612 list = evas_object_data_get(layouts[i], DK_MENU_GENLIST);
613
614 _list_fill(list, it);
615 }
616}
617
618static void
619_menu_layout_fill(Elm_Settingspane_Item *it)
620{
621 IC_DATA(it);
622 if (id->par)
623 _menu_layout_show(id->sw, it, id->par);
624 else
625 _menu_layout_show(id->sw, it, NULL);
626}
627
628static void
629_menu_layout_hide(Evas_Object *w)
630{
631 Evas_Object *shown = evas_object_data_get(w, DK_MAIN_MENU_SHOWED);
632 Evas_Object *hidden = evas_object_data_get(w, DK_MAIN_MENU_HIDDEN);
633 Evas_Object *behind = evas_object_data_get(w, DK_MAIN_MENU_BEHIND);
634
635 elm_layout_signal_emit(hidden, EMIT_MENU_DEFAULT);
636 evas_object_data_del(hidden, DK_MENU_ITEM_SHOWN);
637 elm_layout_signal_emit(shown, EMIT_MENU_DEFAULT);
638 evas_object_data_del(shown, DK_MENU_ITEM_SHOWN);
639 elm_layout_signal_emit(behind, EMIT_MENU_DEFAULT);
640 evas_object_data_del(behind, DK_MENU_ITEM_SHOWN);
641
642 elm_layout_signal_emit(w, EMIT_MENU_SEARCHMODE_ENABLE);
643}
644static void
645_menu_layout_restore(Evas_Object *w)
646{
647 elm_layout_signal_emit(w, EMIT_MENU_SEARCHMODE_DISABLE);
648}
649
650static void
651_menu_layout_hidden_to_show(Evas_Object *w, Elm_Settingspane_Item *new, Elm_Settingspane_Item *lower_new)
652{
653 Evas_Object *shown = evas_object_data_get(w, DK_MAIN_MENU_SHOWED);
654 Evas_Object *hidden = evas_object_data_get(w, DK_MAIN_MENU_HIDDEN);
655 Evas_Object *behind = evas_object_data_get(w, DK_MAIN_MENU_BEHIND);
656 Evas_Object *behindlist = evas_object_data_get(behind, DK_MENU_GENLIST);
657 Evas_Object *hiddenlist = evas_object_data_get(hidden, DK_MENU_GENLIST);
658
659 Elm_Settingspane_Item *item_shown = evas_object_data_get(shown, DK_MENU_ITEM_SHOWN);
660 Elm_Settingspane_Item *item_hidden = evas_object_data_get(hidden, DK_MENU_ITEM_SHOWN);
661
662 if ((item_hidden == lower_new) && (item_shown == new))
663 return;
664
665
666 if (lower_new)
667 {
668 elm_layout_signal_emit(behind, EMIT_MENU_DEFAULT);
669 _list_fill(behindlist, lower_new);
670 evas_object_raise(behind);
671 elm_layout_signal_emit(behind, EMIT_MENU_HIDDEN);
672 }
673
674 //I guess in the hidden one the items should be the correct one
675 _list_fill(hiddenlist, new);
676 elm_layout_signal_emit(hidden, EMIT_MENU_VISIBLE);
677 evas_object_stack_below(shown, hidden);
678
679 elm_layout_signal_emit(shown, EMIT_MENU_DEFAULT);
680
681 evas_object_data_set(w, DK_MAIN_MENU_SHOWED, hidden);
682 evas_object_data_set(w, DK_MAIN_MENU_HIDDEN, behind);
683 evas_object_data_set(w, DK_MAIN_MENU_BEHIND, shown);
684} 275}
685 276
686/* 277/*
@@ -739,26 +330,6 @@ _item_new(Evas_Object *obj, Elm_Settingspane_Item *par, void *usr_data, const ch
739 return item; 330 return item;
740} 331}
741 332
742static Eina_Bool
743_item_has_panel(Elm_Settingspane_Item *item)
744{
745 IC_DATA(item);
746 return HAS_PANEL(id) ? EINA_TRUE : EINA_FALSE;
747}
748
749/*static void
750_item_stack_dump(Elm_Settingspane_Data *wd)
751{
752 Eina_List *node;
753 Elm_Settingspane_Item *it;
754
755 EINA_LIST_FOREACH(wd->stack, node, it)
756 {
757 Elm_Settingspane_Item_Data *id = eo_data_scope_get(it, ELM_SETTINGSPANE_ITEM_CLASS);
758 ERR("item %p:%s", id, id->class->style);
759 }
760}*/
761
762static void 333static void
763_back_check(Evas_Object *w) 334_back_check(Evas_Object *w)
764{ 335{
@@ -802,32 +373,14 @@ _unsaved_changes_remove(Evas_Object *w, Elm_Object_Item *item)
802} 373}
803 374
804static void 375static void
805_history_stack_push(Evas_Object *w, Elm_Object_Item *it) 376_history_stack_push(Evas_Object *w, Elm_Settingspane *it)
806{ 377{
807 C_DATA(w); 378 C_DATA(w);
808 IC_DATA(it);
809 Elm_Object_Item *old;
810 Elm_Settingspane_Item_Data *ido;
811 379
812 /* we just want one item to be on the stack */ 380 /* we just want one item to be on the stack */
813 _history_stack_remove(w, it); 381 _history_stack_remove(w, it);
814 382
815 old = _history_stack_current(w);
816 ido = IC_DATA_L(old);
817 wd->history_stack = eina_list_append(wd->history_stack, it); 383 wd->history_stack = eina_list_append(wd->history_stack, it);
818
819 if (old && HAS_PANEL(ido))
820 {
821 _content_layout_schedule_hide(w, ido->changed);
822 }
823
824 if (HAS_PANEL(id))
825 {
826 _content_layout_content_set(id->sw, it);
827 }
828 else
829 _menu_layout_show(id->sw, it, old);
830
831 /* check if back is still valid */ 384 /* check if back is still valid */
832 _back_check(w); 385 _back_check(w);
833 /* refresh tiltlebar */ 386 /* refresh tiltlebar */
@@ -838,55 +391,27 @@ static Elm_Object_Item*
838_history_stack_pop(Evas_Object *w) 391_history_stack_pop(Evas_Object *w)
839{ 392{
840 C_DATA(w); 393 C_DATA(w);
841 Elm_Object_Item *current, *poped; 394 Elm_Object_Item *it;
842 Elm_Settingspane_Item_Data *poped_id;
843 Eina_Bool keep = EINA_FALSE;
844 395
845 if (_history_stack_end(w)) 396 if (_history_stack_end(w))
846 return NULL; 397 return NULL;
847 398
848 poped = _history_stack_current(w); 399 it = _history_stack_current(w);
849 poped_id = IC_DATA_L(poped); 400
401 eo_do(it, elm_obj_settingspane_item_unrealize());
850 402
851 /* check for unsaved changes */
852 if (poped_id->changed)
853 keep = EINA_TRUE;
854 /* pop the item */ 403 /* pop the item */
855 wd->history_stack = eina_list_remove(wd->history_stack, poped); 404 wd->history_stack = eina_list_remove(wd->history_stack, it);
856 /* new top item */
857 current = _history_stack_current(w);
858 405
859 /* make animations and display the new panels */ 406 /* new top item */
860 if (_item_has_panel(current) && _item_has_panel(poped)) 407 it = _history_stack_current(w);
861 { 408 eo_do(it, elm_obj_settingspane_item_realize());
862 IC_DATA(current);
863 _menu_layout_fill(id->par);
864 _content_layout_schedule_hide(w, keep);
865 _content_layout_content_set(w, current);
866 }
867 else if (_item_has_panel(current) && !_item_has_panel(poped))
868 {
869 IC_DATA(current);
870 _menu_layout_fill(id->par);
871 _content_layout_schedule_hide(w, keep);
872 _content_layout_content_set(w, current);
873 }
874 else if (!_item_has_panel(current) && _item_has_panel(poped))
875 {
876 _content_layout_schedule_hide(w, keep);
877 _menu_layout_fill(current);
878 }
879 else
880 {
881 IC_DATA(current);
882 _menu_layout_hidden_to_show(w, current, id->par);
883 }
884 409
885 /* check if back is still valid */ 410 /* check if back is still valid */
886 _back_check(w); 411 _back_check(w);
887 /* refresh tiltlebar */ 412 /* refresh tiltlebar */
888 _title_bar_refresh(w); 413 _title_bar_refresh(w);
889 return poped; 414 return it;
890} 415}
891 416
892static Elm_Object_Item* 417static Elm_Object_Item*
@@ -924,7 +449,7 @@ _item_append(Elm_Settingspane_Item *root, Elm_Settingspane_Item *toadd, Elm_Sett
924 id->childs = eina_list_append_relative(id->childs, toadd, rel); 449 id->childs = eina_list_append_relative(id->childs, toadd, rel);
925 450
926 if (_history_stack_current(id->sw) == root) 451 if (_history_stack_current(id->sw) == root)
927 _menu_layout_refresh(id->sw); 452 _item_menu_refresh(root, id);
928} 453}
929 454
930static void 455static void
@@ -935,10 +460,13 @@ _item_del(Elm_Settingspane_Item *del, Eina_Bool full)
935 Eina_List *node, *nnode; 460 Eina_List *node, *nnode;
936 Elm_Settingspane_Item *ci; 461 Elm_Settingspane_Item *ci;
937 462
463 eo_do(del, elm_obj_settingspane_item_unrealize());
464
938 if (id->changed) 465 if (id->changed)
939 { 466 {
940 ERR("This page has unsaved changes, you have lost all the data!"); 467 ERR("This page has unsaved changes, you have lost all the data!");
941 } 468 }
469
942 if (!full) 470 if (!full)
943 { 471 {
944 Elm_Settingspane_Item *top = _history_stack_current(id->sw); 472 Elm_Settingspane_Item *top = _history_stack_current(id->sw);
@@ -956,11 +484,10 @@ _item_del(Elm_Settingspane_Item *del, Eina_Bool full)
956 { 484 {
957 id_par = IC_DATA_L(id->par); 485 id_par = IC_DATA_L(id->par);
958 id_par->childs = eina_list_remove(id_par->childs, del); 486 id_par->childs = eina_list_remove(id_par->childs, del);
487 if (!full)
488 _item_menu_refresh(id->par, id_par);
959 } 489 }
960 if (!full) 490
961 _menu_layout_del_ref(id->sw, del);
962 if (!full)
963 _menu_layout_refresh(id->sw);
964 //if we have the item somewhere in the stack, remove it! 491 //if we have the item somewhere in the stack, remove it!
965 _history_stack_remove(id->sw, del); 492 _history_stack_remove(id->sw, del);
966 //unref the content, if there is one 493 //unref the content, if there is one
@@ -1012,45 +539,24 @@ _search_panel_display(Evas_Object *w)
1012 evas_object_show(g); 539 evas_object_show(g);
1013 540
1014 wd->search.obj = o; 541 wd->search.obj = o;
1015 _content_layout_schedule_hide(w, EINA_TRUE); 542 Panel *p = _item_panel_realize(NULL, w, o);
1016 _content_layout_display(w, o); 543 wd->search.p = p;
1017 _menu_layout_hide(w); 544 elm_table_pack(wd->table_panel, p->layout, 0, 0, 1, 1);
545
546 elm_layout_signal_emit(w, EMIT_MENU_SEARCHMODE_ENABLE);
547 elm_layout_signal_emit(p->layout, EMIT_CONTENT_VISIBLE);
548 evas_object_raise(p->layout);
1018} 549}
1019 550
1020static void 551static void
1021_search_panel_hide(Evas_Object *w) 552_search_panel_hide(Evas_Object *w)
1022{ 553{
1023 Elm_Settingspane_Item *item;
1024 Elm_Settingspane_Item_Data *id;
1025 Evas_Object *o;
1026 C_DATA(w); 554 C_DATA(w);
1027 555
1028 item = _history_stack_current(w); 556 elm_layout_signal_emit(wd->search.p->layout, EMIT_CONTENT_DEFAULT);
1029 id = IC_DATA_L(item); 557 elm_layout_signal_emit(w, EMIT_MENU_SEARCHMODE_DISABLE);
1030 558 free(wd->search.p);
1031 o = wd->search.obj; 559 wd->search.p = NULL;
1032 if (!o)
1033 return;
1034
1035 if (_item_has_panel(item))
1036 {
1037 _content_layout_schedule_hide(w, EINA_TRUE);
1038 _content_layout_content_set(w, item);
1039 if (id->par)
1040 {
1041 _menu_layout_restore(w);
1042 _menu_layout_fill(id->par);
1043 }
1044 }
1045 else
1046 {
1047 _content_layout_schedule_hide(w, EINA_TRUE);
1048 _menu_layout_restore(w);
1049 _menu_layout_fill(item);
1050 }
1051
1052 evas_object_del(o);
1053 wd->search.obj = NULL;
1054} 560}
1055 561
1056static void 562static void
@@ -1134,8 +640,6 @@ _search_display_items(void *data)
1134/* 640/*
1135 * !!!This code runs in a seperated thread!!! 641 * !!!This code runs in a seperated thread!!!
1136 */ 642 */
1137
1138
1139static Eina_Bool 643static Eina_Bool
1140_item_found(Elm_Settingspane_Item_Data *id, const char* keyword) 644_item_found(Elm_Settingspane_Item_Data *id, const char* keyword)
1141{ 645{
@@ -1425,14 +929,22 @@ _elm_settingspane_evas_object_smart_add(Eo *obj, Elm_Settingspane_Data *pd)
1425 evas_object_show(tb2); 929 evas_object_show(tb2);
1426 pd->table_menu = tb2; 930 pd->table_menu = tb2;
1427 931
932 pd->zero = _item_new(obj, NULL, NULL, eina_stringshare_add("root"), eina_stringshare_add(""), NULL);
933 }
1428 934
1429 _content_layout_content_init(obj); 935EOLIAN static void
1430 _menu_layout_init(obj); 936_elm_settingspane_evas_object_smart_show(Eo *obj, Elm_Settingspane_Data *pd)
937{
938 Elm_Settingspane_Item *it;
939
940 it = _history_stack_current(obj);
941 if (!it)
942 eo_do(pd->zero, elm_obj_settingspane_item_focus());
1431 943
1432 pd->zero = _item_new(obj, NULL, NULL, eina_stringshare_add("root"), eina_stringshare_add(""), NULL);
1433 _history_stack_push(obj, pd->zero);
1434 _title_bar_refresh(obj); 944 _title_bar_refresh(obj);
1435 } 945 eo_do_super(obj, ELM_SETTINGSPANE_CLASS, evas_obj_smart_show());
946}
947
1436 948
1437EOLIAN static void 949EOLIAN static void
1438_elm_settingspane_eo_base_constructor(Eo *obj, Elm_Settingspane_Data *pd) 950_elm_settingspane_eo_base_constructor(Eo *obj, Elm_Settingspane_Data *pd)
@@ -1533,9 +1045,284 @@ _elm_settingspane_item_append_relative(Eo *obj, Elm_Settingspane_Data *pd, void
1533EOLIAN static void 1045EOLIAN static void
1534_elm_settingspane_item_focus(Eo *obj, Elm_Settingspane_Item_Data *pd) 1046_elm_settingspane_item_focus(Eo *obj, Elm_Settingspane_Item_Data *pd)
1535{ 1047{
1048 eo_do(obj, elm_obj_settingspane_item_realize());
1536 _history_stack_push(pd->sw, obj); 1049 _history_stack_push(pd->sw, obj);
1537} 1050}
1538 1051
1052static void
1053_default_reached_cb(void *data, Evas_Object *obj, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
1054{
1055 Panel *p;
1056 if (!data)
1057 {
1058 evas_object_del(obj);
1059 return;
1060 }
1061
1062 IC_DATA(data);
1063 p = id->panel;
1064
1065 if (id->changed)
1066 {
1067 p->hidden = EINA_TRUE;
1068 evas_object_hide(p->layout);
1069 DBG("keep item %p", data);
1070 }
1071 else
1072 {
1073 evas_object_del(p->layout);
1074 free(p);
1075 id->panel = NULL;
1076 DBG("delete item %p", data);
1077 }
1078}
1079
1080static Panel*
1081_item_panel_realize(Eo *obj, Evas_Object *w, Evas_Object *content)
1082{
1083 Panel *p;
1084 Evas_Object *bx, *sc;
1085
1086 p = calloc(1, sizeof(Panel));
1087
1088 p->layout = elm_layout_add(w);
1089 evas_object_size_hint_weight_set(p->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1090 evas_object_size_hint_align_set(p->layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1091 elm_layout_theme_set(p->layout, "settingspane", "panel", "default");
1092 elm_layout_signal_callback_add(p->layout, "elm,state,default,reached", EMITTER, _default_reached_cb, obj);
1093
1094 bx = elm_box_add(w);
1095 evas_object_size_hint_weight_set(bx, 0, 0);
1096 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
1097 elm_box_horizontal_set(bx, EINA_TRUE);
1098 elm_object_part_content_set(p->layout, POS_PANEL_CONTROLS, bx);
1099
1100 p->apply = elm_button_add(w);
1101 evas_object_size_hint_weight_set(p->apply, 0.0, 0.0);
1102 evas_object_size_hint_align_set(p->apply, 0.0, 0.0);
1103 evas_object_smart_callback_add(p->apply, "clicked", _content_layout_apply_cb, obj);
1104 elm_object_text_set(p->apply, "Apply");
1105 elm_box_pack_end(bx, p->apply);
1106 evas_object_show(p->apply);
1107
1108 p->reset = elm_button_add(w);
1109 evas_object_size_hint_weight_set(p->reset, 0, 0);
1110 evas_object_size_hint_align_set(p->reset, 0.0, 0.0);
1111 elm_object_text_set(p->reset, "Reset");
1112 evas_object_smart_callback_add(p->reset, "clicked", _content_layout_reset_cb, obj);
1113 elm_box_pack_end(bx, p->reset);
1114 evas_object_show(p->reset);
1115
1116 sc = elm_scroller_add(w);
1117 evas_object_size_hint_weight_set(sc,
1118 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1119 elm_object_content_set(sc, content);
1120 evas_object_show(sc);
1121
1122 elm_object_part_content_set(p->layout, POS_PANEL_CONTENT, sc);
1123 return p;
1124}
1125
1126static inline void
1127_item_panel_show(Eo *obj, Elm_Settingspane_Item_Data *pd)
1128{
1129 Panel *p = pd->panel;
1130 elm_layout_signal_emit(p->layout, EMIT_CONTENT_VISIBLE);
1131 evas_object_raise(p->layout);
1132 evas_object_show(p->layout);
1133}
1134
1135static void
1136_item_menu_realize(Eo *obj, Elm_Settingspane_Item_Data *pd, Elm_Settingspane_Data *wd)
1137{
1138 Menu *m;
1139 Evas_Object *o, *list;
1140
1141 m = calloc(1, sizeof(Menu));
1142
1143 m->layout = o = elm_layout_add(pd->sw);
1144 evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1145 evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
1146 elm_layout_theme_set(o, "settingspane", "menu", "default");
1147
1148 m->list = list = elm_genlist_add(pd->sw);
1149 elm_scroller_bounce_set(list, EINA_FALSE, EINA_FALSE);
1150 elm_object_style_set(list, "flatedge");
1151 evas_object_size_hint_weight_set(list, 0.0, EVAS_HINT_EXPAND);
1152 evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
1153 elm_genlist_mode_set(list, ELM_LIST_LIMIT);
1154 evas_object_data_set(o, DK_MENU_GENLIST, list);
1155 elm_object_part_content_set(o, POS_MENU_CONTENT, list);
1156 evas_object_show(list);
1157
1158 pd->menu = m;
1159 elm_table_pack(wd->table_menu, m->layout, 0, 0, 1, 1);
1160
1161 _item_menu_refresh(obj, pd);
1162}
1163static inline void
1164_item_menu_show(Eo *obj, Elm_Settingspane_Item_Data *pd, Eina_Bool hidden)
1165{
1166 Menu *m;
1167
1168 m = pd->menu;
1169 if (hidden)
1170 elm_layout_signal_emit(m->layout, EMIT_MENU_VISIBLE_HIDDEN);
1171 else
1172 elm_layout_signal_emit(m->layout, EMIT_MENU_VISIBLE);
1173 evas_object_show(m->layout);
1174}
1175
1176static inline void
1177_item_menu_visible_hide(Eo *obj)
1178{
1179 IC_DATA(obj);
1180 Menu *m;
1181
1182 m = id->menu;
1183 if (!m) return;
1184
1185 elm_layout_signal_emit(m->layout, EMIT_MENU_HIDDEN);
1186 evas_object_raise(m->layout);
1187}
1188
1189
1190EOLIAN static void
1191_elm_settingspane_item_realize(Eo *obj, Elm_Settingspane_Item_Data *pd)
1192{
1193 C_DATA(pd->sw);
1194 DBG("realize %p", obj);
1195 if (pd->event.content_get) //this is a panel
1196 {
1197 if (!pd->panel)
1198 {
1199 Panel *p;
1200
1201 p =_item_panel_realize(obj, pd->sw, _item_content_get(obj, pd->sw));
1202 elm_table_pack(wd->table_panel, p->layout, 0, 0, 1, 1);
1203 pd->panel = p;
1204 }
1205 /* show its menu */
1206 if (pd->par)
1207 eo_do(pd->par, elm_obj_settingspane_item_realize());
1208 /* show this panel */
1209 _item_panel_show(obj, pd);
1210 /* if another one is open close it */
1211 if (wd->panel_visible)
1212 eo_do(wd->panel_visible, elm_obj_settingspane_item_unrealize());
1213 /* set us as visible */
1214 wd->panel_visible = obj;
1215 }
1216 else
1217 {
1218 /* dont do the work if this is the current menu */
1219 if (wd->menu_visible == obj)
1220 return;
1221 /* if we are realizing a menu and a panel is open, close it*/
1222 if (wd->panel_visible)
1223 eo_do(wd->panel_visible, elm_obj_settingspane_item_unrealize());
1224 /* if this is the hidden object */
1225 if (wd->menu_hidden == obj)
1226 {
1227 if (wd->menu_visible)
1228 eo_do(wd->menu_visible, elm_obj_settingspane_item_unrealize());
1229 wd->menu_hidden = NULL;
1230 if (pd->par)
1231 {
1232 Elm_Settingspane_Item_Data *ido;
1233 ido = IC_DATA_L(pd->par);
1234 _item_menu_realize(pd->par, ido, wd);
1235 wd->menu_hidden = pd->par;
1236 _item_menu_visible_hide(wd->menu_hidden);
1237 }
1238 _item_menu_show(obj, pd, (!!wd->menu_hidden));
1239 }
1240 else
1241 {
1242 /* if this is not realized realize the object */
1243 if (!pd->menu)
1244 _item_menu_realize(obj, pd, wd);
1245
1246 if (wd->menu_hidden)
1247 eo_do(wd->menu_hidden, elm_obj_settingspane_item_unrealize());
1248 if (wd->menu_visible)
1249 _item_menu_visible_hide(wd->menu_visible);
1250
1251 wd->menu_hidden = wd->menu_visible;
1252 wd->menu_visible = obj; /* show the menu */
1253 _item_menu_show(obj, pd, (!!wd->menu_hidden));
1254 }
1255 DBG("Hidden : %p visible: %p", wd->menu_hidden, wd->menu_visible);
1256 }
1257}
1258
1259static void
1260_item_panel_unrealize(Eo *obj, Elm_Settingspane_Item_Data *pd)
1261{
1262 Panel *p = pd->panel;
1263 elm_layout_signal_emit(p->layout, EMIT_CONTENT_DEFAULT);
1264}
1265
1266static void
1267_item_menu_unrealize(Eo *obj, Elm_Settingspane_Item_Data *pd)
1268{
1269 Menu *m;
1270
1271 m = pd->menu;
1272 elm_layout_signal_emit(m->layout, EMIT_CONTENT_DEFAULT);
1273 evas_object_del(m->layout);
1274 free(m);
1275 pd->menu = NULL;
1276}
1277
1278static void
1279_item_menu_refresh(Eo *obj, Elm_Settingspane_Item_Data *pd)
1280{
1281 Eina_List *node;
1282 Elm_Settingspane_Item *child;
1283 C_DATA(pd->sw);
1284
1285 if (!pd->menu) return;
1286
1287 elm_genlist_clear(pd->menu->list);
1288
1289 EINA_LIST_FOREACH(pd->childs, node, child)
1290 {
1291 Elm_Settingspane_Item_Data *cid = IC_DATA_L(child);
1292 Elm_Object_Item *it;
1293
1294 it = elm_genlist_item_append(pd->menu->list, wd->itcc, child,
1295 NULL, ELM_GENLIST_ITEM_NONE,
1296 _item_sel_cb, child);
1297 elm_genlist_item_select_mode_set(it, ELM_OBJECT_SELECT_MODE_ALWAYS);
1298 elm_genlist_item_tooltip_text_set(it, cid->description);
1299 }
1300}
1301
1302EOLIAN static void
1303_elm_settingspane_item_unrealize(Eo *obj, Elm_Settingspane_Item_Data *pd)
1304{
1305 C_DATA(pd->sw);
1306 DBG("unrealize %p", obj);
1307 if (!pd->panel && !pd->menu)
1308 return;
1309
1310 if (pd->event.content_get) //this is a panel
1311 {
1312 _item_panel_unrealize(obj, pd);
1313 if (wd->panel_visible == obj)
1314 wd->panel_visible = NULL;
1315 }
1316 else
1317 {
1318 _item_menu_unrealize(obj, pd);
1319 if (wd->menu_visible == obj)
1320 wd->menu_visible = NULL;
1321 if (wd->menu_hidden == obj)
1322 wd->menu_hidden = NULL;
1323 }
1324}
1325
1539EOLIAN static void 1326EOLIAN static void
1540_elm_settingspane_item_delete(Eo *obj, Elm_Settingspane_Item_Data *pd EINA_UNUSED) 1327_elm_settingspane_item_delete(Eo *obj, Elm_Settingspane_Item_Data *pd EINA_UNUSED)
1541{ 1328{
@@ -1552,11 +1339,19 @@ EOLIAN static void
1552_elm_settingspane_item_changed_set(Eo *obj, Elm_Settingspane_Item_Data *pd, Eina_Bool changed) 1339_elm_settingspane_item_changed_set(Eo *obj, Elm_Settingspane_Item_Data *pd, Eina_Bool changed)
1553{ 1340{
1554 pd->changed = changed; 1341 pd->changed = changed;
1342
1555 if (changed) 1343 if (changed)
1556 _unsaved_changes_add(pd->sw, obj); 1344 _unsaved_changes_add(pd->sw, obj);
1557 else 1345 else
1558 _unsaved_changes_remove(pd->sw, obj); 1346 _unsaved_changes_remove(pd->sw, obj);
1559 _content_layout_content_controls_refresh(pd->sw, obj); 1347
1348 if (!pd->panel) return;
1349
1350 if (!pd->changed)
1351 elm_layout_signal_emit(pd->panel->layout, EMIT_CONTENT_CONTROLS_HIDE);
1352 else
1353 elm_layout_signal_emit(pd->panel->layout, EMIT_CONTENT_CONTROLS_SHOW);
1354
1560} 1355}
1561 1356
1562EOLIAN static Eina_Bool 1357EOLIAN static Eina_Bool
@@ -1585,48 +1380,22 @@ _elm_settingspane_item_attach_panel(Eo *obj EINA_UNUSED, Elm_Settingspane_Item_D
1585 ERR("You cannot add a panel to a item with childs!"); 1380 ERR("You cannot add a panel to a item with childs!");
1586 return; 1381 return;
1587 } 1382 }
1588 pd->panel.content_get = content_get; 1383 pd->event.content_get = content_get;
1589 pd->panel.reset = reset; 1384 pd->event.reset = reset;
1590 pd->panel.apply = apply; 1385 pd->event.apply = apply;
1591} 1386}
1592 1387
1593EOLIAN static void 1388EOLIAN static void
1594_elm_settingspane_item_eo_base_destructor(Eo *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd) 1389_elm_settingspane_item_eo_base_destructor(Eo *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd)
1595{ 1390{
1596 if (pd->panel.tmp_content) 1391 if (pd->panel)
1597 eo_unref(pd->panel.tmp_content); 1392 eo_unref(pd->panel->layout);
1598 //unref the icon, 1393 //unref the icon,
1599 eo_unref(pd->icon); 1394 eo_unref(pd->icon);
1600 eo_do_super(obj, ELM_SETTINGSPANE_ITEM_CLASS, eo_destructor()); 1395 eo_do_super(obj, ELM_SETTINGSPANE_ITEM_CLASS, eo_destructor());
1601} 1396}
1602 1397
1603EOLIAN static void 1398EOLIAN static void
1604_elm_settingspane_item_recreate(Elm_Settingspane_Item *obj, Elm_Settingspane_Item_Data *pd)
1605{
1606 Evas_Object *shown = evas_object_data_get(pd->sw, DK_MAIN_PANEL_SHOWED);
1607 Evas_Object *tmp;
1608 Elm_Settingspane_Item *cf;
1609
1610 eo_do(pd->sw, cf = elm_obj_settingspane_focused_get());
1611
1612 if (cf != obj) return;
1613
1614 tmp = elm_scroller_add(pd->sw);
1615 eo_ref(tmp);
1616 evas_object_size_hint_weight_set(tmp, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1617 evas_object_show(tmp);
1618 elm_object_content_set(tmp, _item_content_get(obj, pd->sw));
1619
1620 elm_layout_content_unset(shown, POS_PANEL_CONTENT);
1621 elm_object_part_content_set(shown, POS_PANEL_CONTENT, tmp);
1622
1623 if (pd->panel.tmp_content)
1624 _content_del(obj);
1625
1626 pd->panel.tmp_content = tmp;
1627}
1628
1629EOLIAN static void
1630_elm_settingspane_item_keywords_set(Elm_Settingspane_Item *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd, char *v) 1399_elm_settingspane_item_keywords_set(Elm_Settingspane_Item *obj EINA_UNUSED, Elm_Settingspane_Item_Data *pd, char *v)
1631{ 1400{
1632 char **splits; 1401 char **splits;
diff --git a/src/lib/elm_settingspane.eo b/src/lib/elm_settingspane.eo
index 1efb9d820..ada8d2e72 100644
--- a/src/lib/elm_settingspane.eo
+++ b/src/lib/elm_settingspane.eo
@@ -114,6 +114,7 @@ class Elm_Settingspane(Elm_Layout)
114 Eo.Base.constructor; 114 Eo.Base.constructor;
115 Eo.Base.destructor; 115 Eo.Base.destructor;
116 Evas.Object_Smart.add; 116 Evas.Object_Smart.add;
117 Evas.Object_Smart.show;
117 Elm_Layout.content_aliases.get; 118 Elm_Layout.content_aliases.get;
118 } 119 }
119} 120}
diff --git a/src/lib/elm_settingspane_item.eo b/src/lib/elm_settingspane_item.eo
index 43e41b7d1..860e7ac4c 100644
--- a/src/lib/elm_settingspane_item.eo
+++ b/src/lib/elm_settingspane_item.eo
@@ -123,11 +123,15 @@ class Elm_Settingspane_Item(Eo.Base){
123 } 123 }
124 } 124 }
125 methods { 125 methods {
126 recreate { 126 realize {
127 /*@ 127 /*@
128 Recreates the content of a item when the item is currently displayed 128 This will realize this item, means display it if it does not exists yet, or raise it
129 @ingroup Settingspane 129 */
130 */ 130 }
131 unrealize {
132 /*@
133 Will delete or just hide this item depending if there are unsaved changes or not
134 */
131 } 135 }
132 attach_panel { 136 attach_panel {
133 /*@ 137 /*@