summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2014-12-06 00:07:20 +0100
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2014-12-06 00:07:20 +0100
commit7527590f1c265d49a9c7a38a9f8e8f6b47d7a645 (patch)
tree99742e4e488a428557c2e9d9cb4eec10564bc07b
parentc9f5d12645e4f5418d375b1d3d4f358d14430628 (diff)
Rewrote the stack.
The Stack is now focused on having multiple panels above each other. The Stack is filled with Stack Items. A stack item has a internal pointer to the start and to the current node. each current node is a child of the start. If somehow a new item gets focues via a api call, A new stackitem will be pushed to the stack.
-rw-r--r--src/elm_settingspane.c254
1 files changed, 171 insertions, 83 deletions
diff --git a/src/elm_settingspane.c b/src/elm_settingspane.c
index aa010ad..d1282b3 100644
--- a/src/elm_settingspane.c
+++ b/src/elm_settingspane.c
@@ -23,9 +23,9 @@ typedef struct
23{ 23{
24 Elm_Settingspane_Item *zero; 24 Elm_Settingspane_Item *zero;
25 25
26 // List of Stack_Item s
26 Eina_List *stack; 27 Eina_List *stack;
27 28
28 Eina_List *item_cache; /* all items which are in the widget, for the searchbar */
29 Elm_Genlist_Item_Class *itcc; // , *itci; 29 Elm_Genlist_Item_Class *itcc; // , *itci;
30} Elm_Settingspane_Data; 30} Elm_Settingspane_Data;
31 31
@@ -55,6 +55,12 @@ typedef struct
55 } panel; 55 } panel;
56} Elm_Settingspane_Item_Data; 56} Elm_Settingspane_Item_Data;
57 57
58typedef struct _Stack_Item
59{
60 Elm_Object_Item *start;
61 Elm_Object_Item *current;
62} Stack_Item;
63
58static void _item_sel_cb(void *data, Evas_Object *obj, void *event_info); 64static void _item_sel_cb(void *data, Evas_Object *obj, void *event_info);
59static void _item_stack_pop(Elm_Settingspane *pane); 65static void _item_stack_pop(Elm_Settingspane *pane);
60static void _item_stack_remove(Elm_Settingspane_Item *del); 66static void _item_stack_remove(Elm_Settingspane_Item *del);
@@ -148,7 +154,7 @@ _title_bar_refresh(Evas_Object *w)
148 Evas_Object *bx; 154 Evas_Object *bx;
149 Eina_List *node; 155 Eina_List *node;
150 Elm_Settingspane_Data *wd = eo_data_scope_get(w, ELM_SETTINGSPANE_CLASS); 156 Elm_Settingspane_Data *wd = eo_data_scope_get(w, ELM_SETTINGSPANE_CLASS);
151 Elm_Settingspane_Item *item; 157 Stack_Item *item;
152 158
153 bx = evas_object_data_get(w, DK_MAIN_TITLE_BOX); 159 bx = evas_object_data_get(w, DK_MAIN_TITLE_BOX);
154 160
@@ -156,7 +162,7 @@ _title_bar_refresh(Evas_Object *w)
156 162
157 EINA_LIST_FOREACH(wd->stack, node, item) 163 EINA_LIST_FOREACH(wd->stack, node, item)
158 { 164 {
159 _title_bar_append(w, item); 165 _title_bar_append(w, item->current);
160 } 166 }
161} 167}
162 168
@@ -329,7 +335,6 @@ _content_layout_content_hide(Evas_Object *w)
329 Evas_Object *shown = evas_object_data_get(w, DK_MAIN_PANEL_SHOWED); 335 Evas_Object *shown = evas_object_data_get(w, DK_MAIN_PANEL_SHOWED);
330 336
331 elm_widget_signal_emit(shown, EMIT_CONTENT_DEFAULT); 337 elm_widget_signal_emit(shown, EMIT_CONTENT_DEFAULT);
332 evas_object_data_del(shown, DK_PANEL_ITEM_SHOWN);
333} 338}
334 339
335static void 340static void
@@ -447,11 +452,12 @@ _list_fill(Evas_Object *list, Elm_Settingspane_Item *item)
447} 452}
448 453
449static void 454static void
450_menu_layout_show(Evas_Object *w, Elm_Settingspane_Item *item, Eina_Bool zero) 455_menu_layout_show(Evas_Object *w, Elm_Settingspane_Item *item, Elm_Settingspane_Item *item_h)
451{ 456{
452 Evas_Object *shown = evas_object_data_get(w, DK_MAIN_MENU_SHOWED); 457 Evas_Object *shown = evas_object_data_get(w, DK_MAIN_MENU_SHOWED);
453 Evas_Object *hidden = evas_object_data_get(w, DK_MAIN_MENU_HIDDEN); 458 Evas_Object *hidden = evas_object_data_get(w, DK_MAIN_MENU_HIDDEN);
454 Evas_Object *behind = evas_object_data_get(w, DK_MAIN_MENU_BEHIND); 459 Evas_Object *behind = evas_object_data_get(w, DK_MAIN_MENU_BEHIND);
460 Evas_Object *shownlist = evas_object_data_get(shown, DK_MENU_GENLIST);
455 Evas_Object *behindlist = evas_object_data_get(behind, DK_MENU_GENLIST); 461 Evas_Object *behindlist = evas_object_data_get(behind, DK_MENU_GENLIST);
456 462
457 _list_fill(behindlist, item); 463 _list_fill(behindlist, item);
@@ -459,10 +465,13 @@ _menu_layout_show(Evas_Object *w, Elm_Settingspane_Item *item, Eina_Bool zero)
459 evas_object_data_set(behind, DK_MENU_ITEM_SHOWN, item); 465 evas_object_data_set(behind, DK_MENU_ITEM_SHOWN, item);
460 466
461 //showed item has not changed 467 //showed item has not changed
462 if (zero) 468 if (!item_h)
463 elm_widget_signal_emit(shown, EMIT_MENU_DEFAULT); 469 elm_widget_signal_emit(shown, EMIT_MENU_DEFAULT);
464 else 470 else
465 elm_widget_signal_emit(shown, EMIT_MENU_HIDDEN); 471 {
472 _list_fill(shownlist, item_h);
473 elm_widget_signal_emit(shown, EMIT_MENU_HIDDEN);
474 }
466 evas_object_raise(shown); 475 evas_object_raise(shown);
467 476
468 evas_object_stack_below(hidden, behind); 477 evas_object_stack_below(hidden, behind);
@@ -475,7 +484,6 @@ _menu_layout_show(Evas_Object *w, Elm_Settingspane_Item *item, Eina_Bool zero)
475 evas_object_data_set(w, DK_MAIN_MENU_BEHIND, hidden); 484 evas_object_data_set(w, DK_MAIN_MENU_BEHIND, hidden);
476 _menu_layout_resize(w); 485 _menu_layout_resize(w);
477} 486}
478
479static void 487static void
480_menu_layout_refresh(Evas_Object *w) 488_menu_layout_refresh(Evas_Object *w)
481{ 489{
@@ -523,9 +531,9 @@ _menu_layout_hide(Evas_Object *w)
523 Evas_Object *behind = evas_object_data_get(w, DK_MAIN_MENU_BEHIND); 531 Evas_Object *behind = evas_object_data_get(w, DK_MAIN_MENU_BEHIND);
524 532
525 elm_widget_signal_emit(hidden, EMIT_MENU_DEFAULT); 533 elm_widget_signal_emit(hidden, EMIT_MENU_DEFAULT);
526 elm_widget_signal_emit(shown, EMIT_MENU_HIDDEN); 534 elm_widget_signal_emit(shown, EMIT_MENU_DEFAULT);
527 elm_widget_signal_emit(behind, EMIT_MENU_DEFAULT); 535 elm_widget_signal_emit(behind, EMIT_MENU_DEFAULT);
528 _menu_layout_resize(w); 536 _content_layout_offset_set(w, -1);
529} 537}
530 538
531static void 539static void
@@ -649,105 +657,186 @@ _item_stack_dump(Elm_Settingspane_Data *wd)
649}*/ 657}*/
650 658
651static void 659static void
652_item_stack_push(Evas_Object *obj, Elm_Settingspane_Item *item) 660_stack_item_new(Elm_Settingspane_Item *item)
653{ 661{
654 Elm_Settingspane_Item_Data *idl, *id = eo_data_scope_get(item, ELM_SETTINGSPANE_ITEM_CLASS); 662 Elm_Settingspane_Item_Data *id = eo_data_scope_get(item, ELM_SETTINGSPANE_ITEM_CLASS);
655 Elm_Settingspane_Data *wd = eo_data_scope_get(id->sw, ELM_SETTINGSPANE_CLASS); 663 Elm_Settingspane_Data *wd = eo_data_scope_get(id->sw, ELM_SETTINGSPANE_CLASS);
656 Eina_List *pfirst; 664 Stack_Item *it = calloc(1, sizeof(Stack_Item));
665 it->start = it->current = item;
666 wd->stack = eina_list_append(wd->stack, it);
667}
668static void
669_stack_item_remove(Evas_Object *w)
670{
671 Elm_Settingspane_Data *wd = eo_data_scope_get(w, ELM_SETTINGSPANE_CLASS);
672 Stack_Item *it = eina_list_data_get(eina_list_last(wd->stack));
657 673
658 /* this is the "top" item, we do not do anything. */ 674 wd->stack = eina_list_remove(wd->stack, it);
675}
659 676
660 if (eina_list_data_get(eina_list_last(wd->stack)) == item)
661 return;
662 677
663 if (!HAS_PANEL(id) && (!id->childs) && (id->par)) 678static void
664 return; 679_stack_item_push(Elm_Settingspane_Item *item)
680{
681 Elm_Settingspane_Item_Data *id = eo_data_scope_get(item, ELM_SETTINGSPANE_ITEM_CLASS);
682 Elm_Settingspane_Data *wd = eo_data_scope_get(id->sw, ELM_SETTINGSPANE_CLASS);
683 Stack_Item *it = eina_list_data_get(eina_list_last(wd->stack));
684 it->current = item;
685}
686
687static void
688_stack_item_pop(Evas_Object *w)
689{
690 Elm_Settingspane_Data *wd = eo_data_scope_get(w, ELM_SETTINGSPANE_CLASS);
691 Stack_Item *it = eina_list_data_get(eina_list_last(wd->stack));
692 Elm_Settingspane_Item_Data *id = eo_data_scope_get(it->current, ELM_SETTINGSPANE_ITEM_CLASS);
665 693
666 //we dont want to have a item twice on the stack, so remove the item from the stack! 694 it->current = id->par;
667 _item_stack_remove(item); 695}
668 696
669 pfirst = eina_list_last(wd->stack); 697static Eina_Bool
698_stack_item_pop_end(Evas_Object *w)
699{
700 Elm_Settingspane_Data *wd = eo_data_scope_get(w, ELM_SETTINGSPANE_CLASS);
701 Stack_Item *it = eina_list_data_get(eina_list_last(wd->stack));
670 702
671 wd->stack = eina_list_append(wd->stack, item); 703 if (it->current == it->start)
704 return EINA_TRUE;
705 return EINA_FALSE;
706}
672 707
673 /* 708static Elm_Settingspane_Item*
674 * Enable/Disable the back button 709_stack_item_current_get(Evas_Object *w)
675 */ 710{
676 if (eina_list_count(wd->stack) > 1) 711 Elm_Settingspane_Data *wd = eo_data_scope_get(w, ELM_SETTINGSPANE_CLASS);
677 elm_widget_signal_emit(id->sw, EMIT_BACK_ENABLE); 712 Stack_Item *it = eina_list_data_get(eina_list_last(wd->stack));
713 return it->current;
714}
678 715
679 /* 716static void
680 * If pfirst has a panel we have panel above panel, so we should hide the menu, 717_item_stack_push_to_item(Evas_Object *obj, Elm_Settingspane_Item *item)
681 * otherwise it could confuse the user. 718{
682 */ 719 Elm_Settingspane_Item *ido;
683 if (pfirst) 720 Elm_Settingspane_Item_Data *id = eo_data_scope_get(item, ELM_SETTINGSPANE_ITEM_CLASS);
684 { 721 Elm_Settingspane_Data *wd = eo_data_scope_get(obj, ELM_SETTINGSPANE_CLASS);
685 Elm_Settingspane_Item *it; 722
686 it = eina_list_data_get(pfirst); 723 if ((wd->stack) && (_stack_item_current_get(obj) == item))
687 idl = eo_data_scope_get(it, ELM_SETTINGSPANE_ITEM_CLASS); 724 return;
688 if (HAS_PANEL(idl)) 725
689 _menu_layout_hide(id->sw); 726 ido = _stack_item_current_get(obj);
690 } 727
728 _stack_item_push(item);
729
730 if (eina_list_count(wd->stack) > 1 || !_stack_item_pop_end(obj))
731 elm_widget_signal_emit(obj, EMIT_BACK_ENABLE);
732
733 if (!HAS_PANEL(id) && (!id->childs) && (id->par))
734 return;
691 735
692 if (HAS_PANEL(id)) 736 if (HAS_PANEL(id))
693 _content_layout_content_set(obj, item); 737 _content_layout_content_set(obj, item);
694 else 738 else
695 _menu_layout_show(obj, item, id->par ? EINA_FALSE : EINA_TRUE); 739 _menu_layout_show(obj, item, ido);
696 _title_bar_refresh(id->sw); 740 _title_bar_refresh(obj);
697} 741}
698 742
699static Elm_Settingspane_Item* 743static Eina_Bool
700_item_stack_pop_raw(Evas_Object *obj) 744stack_item_raise(Elm_Settingspane_Item *item)
745{
746 Elm_Settingspane_Item_Data *id = eo_data_scope_get(item, ELM_SETTINGSPANE_ITEM_CLASS);
747 Elm_Settingspane_Data *wd = eo_data_scope_get(id->sw, ELM_SETTINGSPANE_CLASS);
748 Stack_Item *it;
749 Eina_List *node;
750
751 EINA_LIST_FOREACH(wd->stack, node, it)
752 {
753 if (it->start == item)
754 {
755 //TODO raise this item
756 return EINA_TRUE;
757 }
758 }
759 return EINA_FALSE;
760}
761
762static void
763_item_stack_push(Evas_Object *obj, Elm_Settingspane_Item *item)
701{ 764{
702 Elm_Settingspane_Data *wd = eo_data_scope_get(obj, ELM_SETTINGSPANE_CLASS); 765 Elm_Settingspane_Data *wd = eo_data_scope_get(obj, ELM_SETTINGSPANE_CLASS);
703 if (eina_list_count(wd->stack) < 1) 766 Elm_Settingspane_Item_Data *id = eo_data_scope_get(item, ELM_SETTINGSPANE_ITEM_CLASS);
704 return NULL; //trololol lets pop item zero 767 Elm_Settingspane_Item *it;
768 if ((wd->stack) && (_stack_item_current_get(obj) == item))
769 return;
705 770
706 Elm_Settingspane_Item *old = eina_list_data_get(eina_list_last(wd->stack)); 771 if (wd->stack)
707 Elm_Settingspane_Item_Data *id = eo_data_scope_get(old, ELM_SETTINGSPANE_ITEM_CLASS); 772 {
773 it = _stack_item_current_get(obj);
774 _content_layout_content_hide(obj);
775 _menu_layout_hide(obj);
776 }
708 777
709 if (id->changed) 778
779 if (!stack_item_raise(item))
710 { 780 {
711 Evas_Object *l = evas_object_data_get(obj, DK_MAIN_PANEL_SHOWED); 781 _stack_item_new(item);
712 _item_highlight(l);
713 return NULL;
714 } 782 }
783 if (eina_list_count(wd->stack) > 1 || !_stack_item_pop_end(obj))
784 elm_widget_signal_emit(obj, EMIT_BACK_ENABLE);
715 785
716 if (_item_has_panel(old)) 786 if (!HAS_PANEL(id) && (!id->childs) && (id->par))
717 _content_layout_content_del(obj); 787 return;
718 788
719 wd->stack = eina_list_remove(wd->stack, old); 789 if (HAS_PANEL(id))
720 _title_bar_refresh(obj); 790 _content_layout_content_set(obj, item);
721 return old; 791 else
792 _menu_layout_show(obj, item, NULL); //this is our item zero
793 _title_bar_refresh(id->sw);
722} 794}
723 795
724static void 796static void
725_item_stack_pop(Evas_Object *obj) 797_item_stack_pop(Evas_Object *obj)
726{ 798{
799 Elm_Settingspane_Item *it, *it_o;
727 Elm_Settingspane_Data *wd = eo_data_scope_get(obj, ELM_SETTINGSPANE_CLASS); 800 Elm_Settingspane_Data *wd = eo_data_scope_get(obj, ELM_SETTINGSPANE_CLASS);
728 Elm_Settingspane_Item *old = _item_stack_pop_raw(obj); 801 Elm_Settingspane_Item_Data *id;
729
730 if (!old)
731 return;
732 802
733 Eina_List *new_node = eina_list_last(wd->stack); 803 it_o = _stack_item_current_get(obj);
734 Elm_Settingspane_Item *new = eina_list_data_get(new_node);
735 Elm_Settingspane_Item *lower_new = eina_list_data_get(eina_list_prev(new_node));
736 804
737 if (!_item_has_panel(new) && !_item_has_panel(old)) 805 if (_stack_item_pop_end(obj))
738 _menu_layout_hidden_to_show(obj, new, lower_new);
739 else if (!_item_has_panel(new) && _item_has_panel(old))
740 _content_layout_content_hide(obj);
741 else if (_item_has_panel(new))
742 { 806 {
743 _content_layout_content_set(obj, new); 807 _stack_item_remove(obj);
808 }
809 else
810 _stack_item_pop(obj);
811
812 it = _stack_item_current_get(obj);
813 id = eo_data_scope_get(it, ELM_SETTINGSPANE_ITEM_CLASS);
744 814
745 if (!_item_has_panel(lower_new)) 815 if (!_item_has_panel(it_o) && !_item_has_panel(it))
746 _menu_layout_restore(obj); 816 {
817 _menu_layout_hidden_to_show(obj, it, id->par);
818 }
819 else if (_item_has_panel(it_o) && !_item_has_panel(it))
820 {
821 _content_layout_content_hide(obj);
822 _content_layout_content_del(obj);
823// _menu_layout_show(obj, it, _stack_item_pop_end(obj));
824 }
825 else if (_item_has_panel(it_o) && _item_has_panel(it))
826 {
827 _content_layout_content_del(obj);
828 _content_layout_content_set(obj, it);
829 if (id->par)
830 {
831 Elm_Settingspane_Item_Data *pard = eo_data_scope_get(id->par, ELM_SETTINGSPANE_ITEM_CLASS);
832 _menu_layout_show(obj, id->par, pard->par);
833 }
747 } 834 }
748 835
749 if (eina_list_count(wd->stack) < 2) 836 if (eina_list_count(wd->stack) == 1 && _stack_item_pop_end(obj))
750 elm_widget_signal_emit(obj, EMIT_BACK_DISABLE); 837 elm_widget_signal_emit(obj, EMIT_BACK_DISABLE);
838
839 _title_bar_refresh(obj);
751} 840}
752 841
753static void 842static void
@@ -769,10 +858,9 @@ static void
769_item_append(Elm_Settingspane_Item *root, Elm_Settingspane_Item *toadd, Elm_Settingspane_Item *rel) 858_item_append(Elm_Settingspane_Item *root, Elm_Settingspane_Item *toadd, Elm_Settingspane_Item *rel)
770{ 859{
771 Elm_Settingspane_Item_Data *id = eo_data_scope_get(root, ELM_SETTINGSPANE_ITEM_CLASS); 860 Elm_Settingspane_Item_Data *id = eo_data_scope_get(root, ELM_SETTINGSPANE_ITEM_CLASS);
772 Elm_Settingspane_Data *wd = eo_data_scope_get(id->sw, ELM_SETTINGSPANE_CLASS);
773 id->childs = eina_list_append_relative(id->childs, toadd, rel); 861 id->childs = eina_list_append_relative(id->childs, toadd, rel);
774 862
775 if (eina_list_data_get(eina_list_last(wd->stack)) == root) 863 if (_stack_item_current_get(id->sw) == root)
776 _menu_layout_refresh(id->sw); 864 _menu_layout_refresh(id->sw);
777} 865}
778 866
@@ -820,17 +908,17 @@ _item_del(Elm_Settingspane_Item *del, Eina_Bool full)
820static void 908static void
821_item_sel_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 909_item_sel_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
822{ 910{
823 Elm_Settingspane_Item *selected = data; 911 Elm_Settingspane_Item *curr, *selected = data;
824 Elm_Settingspane_Item_Data *id = eo_data_scope_get(selected, ELM_SETTINGSPANE_ITEM_CLASS); 912 Elm_Settingspane_Item_Data *id = eo_data_scope_get(selected, ELM_SETTINGSPANE_ITEM_CLASS);
825 Elm_Settingspane_Data *wd = eo_data_scope_get(id->sw, ELM_SETTINGSPANE_CLASS);
826 913
827 if (eina_list_data_get(eina_list_last(wd->stack)) == selected) 914 curr = _stack_item_current_get(id->sw);
828 return; 915
916 if (curr == selected)
917 return;
829 918
830 if (_item_has_panel(eina_list_data_get(eina_list_last(wd->stack)))) 919 if (_item_has_panel(curr))
831 if (!_item_stack_pop_raw(id->sw)) 920 _item_stack_pop(id->sw);
832 return; 921 _item_stack_push_to_item(id->sw, selected);
833 _item_stack_push(id->sw, selected);
834} 922}
835 923
836EOLIAN static void 924EOLIAN static void
@@ -1081,7 +1169,7 @@ _item_search(Elm_Settingspane_Item *it, char **string, int lvl)
1081} 1169}
1082 1170
1083EOLIAN static Elm_Settingspane_Item * 1171EOLIAN static Elm_Settingspane_Item *
1084_elm_settingspane_item_get(Eo *obj, Elm_Settingspane_Data *pd, const char *paths) 1172_elm_settingspane_item_get(Eo *obj EINA_UNUSED, Elm_Settingspane_Data *pd, const char *paths)
1085{ 1173{
1086 char **string = eina_str_split(paths, "/", 0); 1174 char **string = eina_str_split(paths, "/", 0);
1087 return _item_search(pd->zero, string, 0); 1175 return _item_search(pd->zero, string, 0);