diff --git a/legacy/elementary/data/themes/Makefile.am b/legacy/elementary/data/themes/Makefile.am index 20120f6d80..4e36cc0c9b 100644 --- a/legacy/elementary/data/themes/Makefile.am +++ b/legacy/elementary/data/themes/Makefile.am @@ -216,7 +216,8 @@ icon_arrow_down_left.png \ icon_arrow_down_right.png \ icon_arrow_up_left.png \ icon_arrow_up_right.png \ -thumb_shadow.png +thumb_shadow.png \ +group_index.png default.edj: Makefile $(EXTRA_DIST) $(EDJE_CC) $(EDJE_FLAGS) \ diff --git a/legacy/elementary/data/themes/default.edc b/legacy/elementary/data/themes/default.edc index 1708c6c307..893476e7a9 100644 --- a/legacy/elementary/data/themes/default.edc +++ b/legacy/elementary/data/themes/default.edc @@ -16521,6 +16521,282 @@ collections { } } } + group { name: "elm/genlist/item/group_index/default"; + alias: "elm/genlist/item_odd/group_index/default"; + data.item: "stacking" "above"; + data.item: "selectraise" "on"; + data.item: "labels" "elm.text"; + data.item: "icons" "elm.swallow.icon elm.swallow.end"; + data.item: "treesize" "20"; +// data.item: "states" ""; + images { + image: "bt_sm_base1.png" COMP; + image: "bt_sm_shine.png" COMP; + image: "bt_sm_hilight.png" COMP; + image: "ilist_item_shadow.png" COMP; + image: "group_index.png" COMP; + } + parts { + part { + name: "event"; + type: RECT; + repeat_events: 0; + description { + state: "default" 0.0; + color: 0 0 0 0; + } + } + part { + name: "base_sh"; + mouse_events: 0; + description { + state: "default" 0.0; + align: 0.0 0.0; + min: 0 10; + fixed: 1 1; + rel1 { + to: "base"; + relative: 0.0 1.0; + offset: 0 0; + } + rel2 { + to: "base"; + relative: 1.0 1.0; + offset: -1 0; + } + image { + normal: "ilist_item_shadow.png"; + } + fill.smooth: 0; + } + } + part { + name: "base"; + mouse_events: 0; + description { + state: "default" 0.0; + image { + normal: "group_index.png"; + border: 2 2 2 2; + } + fill.smooth: 0; + } + } + part { name: "bg"; + clip_to: "disclip"; + mouse_events: 0; + description { state: "default" 0.0; + visible: 0; + color: 255 255 255 0; + rel1 { + relative: 0.0 0.0; + offset: -5 -5; + } + rel2 { + relative: 1.0 1.0; + offset: 4 4; + } + image { + normal: "bt_sm_base1.png"; + border: 6 6 6 6; + } + image.middle: SOLID; + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + visible: 1; + color: 255 255 255 255; + rel1 { + relative: 0.0 0.0; + offset: -2 -2; + } + rel2 { + relative: 1.0 1.0; + offset: 1 1; + } + } + } + part { name: "elm.swallow.pad"; + type: SWALLOW; + description { state: "default" 0.0; + fixed: 1 0; + align: 0.0 0.5; + rel1 { + relative: 0.0 0.0; + offset: 4 4; + } + rel2 { + relative: 0.0 1.0; + offset: 4 -5; + } + } + } + part { name: "elm.swallow.icon"; + clip_to: "disclip"; + type: SWALLOW; + description { state: "default" 0.0; + fixed: 1 0; + align: 0.0 0.5; + rel1 { + to_x: "elm.swallow.pad"; + relative: 1.0 0.0; + offset: -1 4; + } + rel2 { + to_x: "elm.swallow.pad"; + relative: 1.0 1.0; + offset: -1 -5; + } + } + } + part { name: "elm.swallow.end"; + clip_to: "disclip"; + type: SWALLOW; + description { state: "default" 0.0; + fixed: 1 0; + align: 1.0 0.5; + aspect: 1.0 1.0; + aspect_preference: VERTICAL; + rel1 { + relative: 1.0 0.0; + offset: -5 4; + } + rel2 { + relative: 1.0 1.0; + offset: -5 -5; + } + } + } + part { name: "elm.text"; + clip_to: "disclip"; + type: TEXT; + effect: SOFT_SHADOW; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; +// min: 16 16; + rel1 { + to_x: "elm.swallow.icon"; + relative: 1.0 0.0; + offset: 0 4; + } + rel2 { + to_x: "elm.swallow.end"; + relative: 0.0 1.0; + offset: -1 -5; + } + color: 0 0 0 255; + color3: 0 0 0 0; + text { + font: "Sans"; + size: 10; + min: 1 1; +// min: 0 1; + align: 0.0 0.5; + text_class: "list_item"; + } + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + color: 224 224 224 255; + color3: 0 0 0 64; + } + } + part { name: "fg1"; + clip_to: "disclip"; + mouse_events: 0; + description { state: "default" 0.0; + visible: 0; + color: 255 255 255 0; + rel1.to: "bg"; + rel2.relative: 1.0 0.5; + rel2.to: "bg"; + image { + normal: "bt_sm_hilight.png"; + border: 6 6 6 0; + } + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + visible: 1; + color: 255 255 255 255; + } + } + part { name: "fg2"; + clip_to: "disclip"; + mouse_events: 0; + description { state: "default" 0.0; + visible: 0; + color: 255 255 255 0; + rel1.to: "bg"; + rel2.to: "bg"; + image { + normal: "bt_sm_shine.png"; + border: 6 6 6 0; + } + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + visible: 1; + color: 255 255 255 255; + } + } + part { name: "disclip"; + type: RECT; + description { state: "default" 0.0; + rel1.to: "bg"; + rel2.to: "bg"; + } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + color: 255 255 255 64; + } + } + } + programs { + // signal: elm,state,%s,active + // a "check" item named %s went active + // signal: elm,state,%s,passive + // a "check" item named %s went passive + // default is passive + program { + name: "go_active"; + signal: "elm,state,selected"; + source: "elm"; + action: STATE_SET "selected" 0.0; + target: "bg"; + target: "fg1"; + target: "fg2"; + target: "elm.text"; + } + program { + name: "go_passive"; + signal: "elm,state,unselected"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "bg"; + target: "fg1"; + target: "fg2"; + target: "elm.text"; + transition: LINEAR 0.1; + } + program { + name: "go_disabled"; + signal: "elm,state,disabled"; + source: "elm"; + action: STATE_SET "disabled" 0.0; + target: "disclip"; + } + program { + name: "go_enabled"; + signal: "elm,state,enabled"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "disclip"; + } + } + } group { name: "elm/genlist/item_compress/message/default"; data.item: "stacking" "above"; data.item: "selectraise" "on"; diff --git a/legacy/elementary/data/themes/group_index.png b/legacy/elementary/data/themes/group_index.png new file mode 100644 index 0000000000..7df068040c Binary files /dev/null and b/legacy/elementary/data/themes/group_index.png differ diff --git a/legacy/elementary/src/bin/test.c b/legacy/elementary/src/bin/test.c index b0c208e6c9..e195fbe9b0 100644 --- a/legacy/elementary/src/bin/test.c +++ b/legacy/elementary/src/bin/test.c @@ -65,6 +65,8 @@ void test_genlist4(void *data, Evas_Object *obj, void *event_info); void test_genlist5(void *data, Evas_Object *obj, void *event_info); void test_genlist6(void *data, Evas_Object *obj, void *event_info); void test_genlist7(void *data, Evas_Object *obj, void *event_info); +void test_genlist8(void *data, Evas_Object *obj, void *event_info); +void test_genlist9(void *data, Evas_Object *obj, void *event_info); void test_table(void *data, Evas_Object *obj, void *event_info); void test_gengrid(void *data, Evas_Object *obj, void *event_info); void test_gengrid2(void *data, Evas_Object *obj, void *event_info); @@ -299,6 +301,8 @@ my_win_main(char *autorun) ADD_TEST("Genlist 5", test_genlist5); ADD_TEST("Genlist 7", test_genlist7); ADD_TEST("Genlist Tree", test_genlist6); + ADD_TEST("Genlist Group", test_genlist8); + ADD_TEST("Genlist Group Tree", test_genlist9); ADD_TEST("GenGrid", test_gengrid); ADD_TEST("GenGrid 2", test_gengrid2); ADD_TEST("Checks", test_check); diff --git a/legacy/elementary/src/bin/test_genlist.c b/legacy/elementary/src/bin/test_genlist.c index d2147b1542..5766086d32 100644 --- a/legacy/elementary/src/bin/test_genlist.c +++ b/legacy/elementary/src/bin/test_genlist.c @@ -1313,4 +1313,316 @@ test_genlist7(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_in evas_object_resize(win, 320, 320); evas_object_show(win); } + +/*************/ + +static Elm_Genlist_Item_Class itc_group; +char *gl8_label_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__) +{ + char buf[256]; + snprintf(buf, sizeof(buf), "Group Index # %i (Item # %i)", (int)((long)data / 10), (int)(long)data); + return strdup(buf); +} + +static void +_bt_show_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + elm_genlist_item_top_show(data); + //elm_genlist_item_show(data); + //elm_genlist_item_middle_show(data); +} +static void +_bt_bring_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + elm_genlist_item_top_bring_in(data); + //elm_genlist_item_bring_in(data); + //elm_genlist_item_middle_bring_in(data); +} + +void +test_genlist8(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + Evas_Object *win, *bg, *gl, *bt[8], *bx, *bx2, *bx3; + Elm_Genlist_Item *gli = NULL, *git = NULL; + int i, bt_count, bt_num; + + win = elm_win_add(NULL, "genlist-group", ELM_WIN_BASIC); + elm_win_title_set(win, "Genlist Group"); + elm_win_autodel_set(win, 1); + + bg = elm_bg_add(win); + elm_win_resize_object_add(win, bg); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(bg); + + bx = elm_box_add(win); + evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(win, bx); + evas_object_show(bx); + + gl = elm_genlist_add(win); + evas_object_smart_callback_add(gl, "selected", _gl_selected, NULL); + evas_object_smart_callback_add(gl, "clicked", _gl_clicked, NULL); + evas_object_smart_callback_add(gl, "longpressed", _gl_longpress, NULL); + evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(bx, gl); + evas_object_show(gl); + + itc1.item_style = "default"; + itc1.func.label_get = gl_label_get; + itc1.func.icon_get = gl_icon_get; + itc1.func.state_get = gl_state_get; + itc1.func.del = gl_del; + + itc_group.item_style = "group_index"; + itc_group.func.label_get = gl8_label_get; + itc_group.func.icon_get = NULL; + itc_group.func.state_get = NULL; + itc_group.func.del = gl_del; + + bx2 = elm_box_add(win); + elm_box_horizontal_set(bx2, EINA_TRUE); + elm_box_homogenous_set(bx2, EINA_TRUE); + evas_object_size_hint_weight_set(bx2, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(bx2, EVAS_HINT_FILL, EVAS_HINT_FILL); + + bt_num = 0; + bt[bt_num] = elm_button_add(win); + elm_button_label_set(bt[bt_num], "Show 0"); + evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0); + evas_object_show(bt[bt_num]); + elm_box_pack_end(bx2, bt[bt_num]); + + bt[++bt_num] = elm_button_add(win); + elm_button_label_set(bt[bt_num], "Show 26"); + evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0); + evas_object_show(bt[bt_num]); + elm_box_pack_end(bx2, bt[bt_num]); + + bt[++bt_num] = elm_button_add(win); + elm_button_label_set(bt[bt_num], "Show 101"); + evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0); + evas_object_show(bt[bt_num]); + elm_box_pack_end(bx2, bt[bt_num]); + + bt[++bt_num] = elm_button_add(win); + elm_button_label_set(bt[bt_num], "Show 480"); + evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0); + evas_object_show(bt[bt_num]); + elm_box_pack_end(bx2, bt[bt_num]); + + elm_box_pack_end(bx, bx2); + evas_object_show(bx2); + + bx3 = elm_box_add(win); + elm_box_horizontal_set(bx3, EINA_TRUE); + elm_box_homogenous_set(bx3, EINA_TRUE); + evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL, EVAS_HINT_FILL); + + bt[++bt_num] = elm_button_add(win); + elm_button_label_set(bt[bt_num], "Bring top 0"); + evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0); + evas_object_show(bt[bt_num]); + elm_box_pack_end(bx3, bt[bt_num]); + + bt[++bt_num] = elm_button_add(win); + elm_button_label_set(bt[bt_num], "Bring top 31"); + evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0); + evas_object_show(bt[bt_num]); + elm_box_pack_end(bx3, bt[bt_num]); + + bt[++bt_num] = elm_button_add(win); + elm_button_label_set(bt[bt_num], "Bring top 239"); + evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0); + evas_object_show(bt[bt_num]); + elm_box_pack_end(bx3, bt[bt_num]); + + bt[++bt_num] = elm_button_add(win); + elm_button_label_set(bt[bt_num], "Bring top 477"); + evas_object_size_hint_align_set(bt[bt_num], EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(bt[bt_num], EVAS_HINT_EXPAND, 0.0); + evas_object_show(bt[bt_num]); + elm_box_pack_end(bx3, bt[bt_num]); + + elm_box_pack_end(bx, bx3); + evas_object_show(bx3); + + bt_count = 0; + for (i = 0; i < 500; i++) + { + if (!(i % 10)) + { + gli = git = elm_genlist_item_append(gl, &itc_group, + (void *)(long)i/* item data */, + NULL/* parent */, + ELM_GENLIST_ITEM_GROUP, + gl_sel/* func */, + (void *)(long)(i * 10)/* func data */); + } + else if (git) + { + gli = elm_genlist_item_append(gl, &itc1, + (void *)(long)i/* item data */, + git/* parent */, + ELM_GENLIST_ITEM_NONE, + gl_sel/* func */, + (void *)(long)(i * 10)/* func data */); + } + //elm_genlist_item_display_only_set(gli, EINA_TRUE); + switch (i) + { + case 0: + evas_object_smart_callback_add(bt[0], "clicked", _bt_show_cb, gli); + evas_object_smart_callback_add(bt[4], "clicked", _bt_bring_cb, gli); + break; + case 26: + evas_object_smart_callback_add(bt[1], "clicked", _bt_show_cb, gli); + break; + case 31: + evas_object_smart_callback_add(bt[5], "clicked", _bt_bring_cb, gli); + break; + case 101: + evas_object_smart_callback_add(bt[2], "clicked", _bt_show_cb, gli); + break; + case 239: + evas_object_smart_callback_add(bt[6], "clicked", _bt_bring_cb, gli); + break; + case 477: + evas_object_smart_callback_add(bt[7], "clicked", _bt_bring_cb, gli); + break; + case 480: + evas_object_smart_callback_add(bt[3], "clicked", _bt_show_cb, gli); + break; + } + } + + evas_object_resize(win, 480, 800); + evas_object_show(win); +} + +/*************/ + +static void +gl9_exp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Elm_Genlist_Item *it = event_info; + Evas_Object *gl = elm_genlist_item_genlist_get(it); + int val = (int)(long)elm_genlist_item_data_get(it); + val *= 10; + elm_genlist_item_append(gl, &itc1, + (void *)(long)(val + 1)/* item data */, it/* parent */, + ELM_GENLIST_ITEM_NONE, gl4_sel/* func */, + NULL/* func data */); + elm_genlist_item_append(gl, &itc1, + (void *)(long)(val + 2)/* item data */, it/* parent */, + ELM_GENLIST_ITEM_NONE, gl4_sel/* func */, + NULL/* func data */); + elm_genlist_item_append(gl, &itc1, + (void *)(long)(val + 3)/* item data */, it/* parent */, + ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */, + NULL/* func data */); +} +static void +gl9_con(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Elm_Genlist_Item *it = event_info; + elm_genlist_item_subitems_clear(it); +} + +static void +gl9_exp_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Elm_Genlist_Item *it = event_info; + elm_genlist_item_expanded_set(it, EINA_TRUE); +} +static void +gl9_con_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) +{ + Elm_Genlist_Item *it = event_info; + elm_genlist_item_expanded_set(it, EINA_FALSE); +} + +void +test_genlist9(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +{ + Evas_Object *win, *bg, *gl, *bx; + Elm_Genlist_Item *git; + + win = elm_win_add(NULL, "genlist-group-tree", ELM_WIN_BASIC); + elm_win_title_set(win, "Genlist Group Tree"); + elm_win_autodel_set(win, 1); + + bg = elm_bg_add(win); + elm_win_resize_object_add(win, bg); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(bg); + + bx = elm_box_add(win); + evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(win, bx); + evas_object_show(bx); + + gl = elm_genlist_add(win); + evas_object_smart_callback_add(gl, "selected", _gl_selected, NULL); + evas_object_smart_callback_add(gl, "clicked", _gl_clicked, NULL); + evas_object_smart_callback_add(gl, "longpressed", _gl_longpress, NULL); + evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(bx, gl); + evas_object_show(gl); + + itc1.item_style = "default"; + itc1.func.label_get = gl_label_get; + itc1.func.icon_get = gl_icon_get; + itc1.func.state_get = gl_state_get; + itc1.func.del = gl_del; + + itc_group.item_style = "group_index"; + itc_group.func.label_get = gl8_label_get; + itc_group.func.icon_get = NULL; + itc_group.func.state_get = NULL; + itc_group.func.del = gl_del; + + git = elm_genlist_item_append(gl, &itc_group, + (void *)0/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_GROUP, gl4_sel/* func */, + NULL/* func data */); + elm_genlist_item_append(gl, &itc1, + (void *)1/* item data */, git/* parent */, ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */, + NULL/* func data */); + elm_genlist_item_append(gl, &itc1, + (void *)2/* item data */, git/* parent */, ELM_GENLIST_ITEM_NONE, gl4_sel/* func */, + NULL/* func data */); + elm_genlist_item_append(gl, &itc1, + (void *)3/* item data */, git/* parent */, ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */, + NULL/* func data */); + git = elm_genlist_item_append(gl, &itc_group, + (void *)4/* item data */, NULL/* parent */, ELM_GENLIST_ITEM_GROUP, gl4_sel/* func */, + NULL/* func data */); + elm_genlist_item_append(gl, &itc1, + (void *)5/* item data */, git/* parent */, ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */, + NULL/* func data */); + elm_genlist_item_append(gl, &itc1, + (void *)6/* item data */, git/* parent */, ELM_GENLIST_ITEM_NONE, gl4_sel/* func */, + NULL/* func data */); + elm_genlist_item_append(gl, &itc1, + (void *)7/* item data */, git/* parent */, ELM_GENLIST_ITEM_SUBITEMS, gl4_sel/* func */, + NULL/* func data */); + + evas_object_smart_callback_add(gl, "expand,request", gl9_exp_req, gl); + evas_object_smart_callback_add(gl, "contract,request", gl9_con_req, gl); + evas_object_smart_callback_add(gl, "expanded", gl9_exp, gl); + evas_object_smart_callback_add(gl, "contracted", gl9_con, gl); + + evas_object_resize(win, 480, 800); + evas_object_show(win); +} #endif diff --git a/legacy/elementary/src/lib/Elementary.h.in b/legacy/elementary/src/lib/Elementary.h.in index 0e1c218731..f546fc177a 100644 --- a/legacy/elementary/src/lib/Elementary.h.in +++ b/legacy/elementary/src/lib/Elementary.h.in @@ -1684,7 +1684,8 @@ extern "C" { typedef enum _Elm_Genlist_Item_Flags { ELM_GENLIST_ITEM_NONE = 0, - ELM_GENLIST_ITEM_SUBITEMS = (1 << 0) + ELM_GENLIST_ITEM_SUBITEMS = (1 << 0), + ELM_GENLIST_ITEM_GROUP = (1 << 1) } Elm_Genlist_Item_Flags; typedef struct _Elm_Genlist_Item_Class Elm_Genlist_Item_Class; typedef struct _Elm_Genlist_Item Elm_Genlist_Item; /**< Item of Elm_Genlist. Sub-type of Elm_Widget_Item */ diff --git a/legacy/elementary/src/lib/elm_genlist.c b/legacy/elementary/src/lib/elm_genlist.c index 4184208a76..658572a7bc 100644 --- a/legacy/elementary/src/lib/elm_genlist.c +++ b/legacy/elementary/src/lib/elm_genlist.c @@ -289,6 +289,7 @@ struct _Widget_Data { Evas_Object *obj, *scr, *pan_smart; Eina_Inlist *items, *blocks; + Eina_List *group_items; Pan *pan; Evas_Coord pan_x, pan_y, w, h, minw, minh, realminw, prev_viewport_w; Ecore_Job *calc_job, *update_job; @@ -361,6 +362,7 @@ struct _Elm_Genlist_Item Evas_Coord x, y, w, h, minw, minh; const Elm_Genlist_Item_Class *itc; Elm_Genlist_Item *parent; + Elm_Genlist_Item *group_item; Elm_Genlist_Item_Flags flags; struct { @@ -373,6 +375,7 @@ struct _Elm_Genlist_Item Ecore_Timer *long_timer; Ecore_Timer *swipe_timer; Evas_Coord dx, dy; + Evas_Coord scrl_x, scrl_y; Elm_Genlist_Item *rel; @@ -394,6 +397,7 @@ struct _Elm_Genlist_Item Eina_Bool before : 1; Eina_Bool want_unrealize : 1; + Eina_Bool want_realize : 1; Eina_Bool realized : 1; Eina_Bool selected : 1; Eina_Bool hilighted : 1; @@ -817,7 +821,11 @@ _item_hilight(Elm_Genlist_Item *it) edje_object_signal_emit(it->base.view, "elm,state,selected", "elm"); selectraise = edje_object_data_get(it->base.view, "selectraise"); if ((selectraise) && (!strcmp(selectraise, "on"))) - evas_object_raise(it->base.view); + { + evas_object_raise(it->base.view); + if ((it->group_item) && (it->group_item->realized)) + evas_object_raise(it->group_item->base.view); + } it->hilighted = EINA_TRUE; } @@ -1636,7 +1644,10 @@ _item_realize(Elm_Genlist_Item *it, evas_object_color_set(it->spacer, 0, 0, 0, 0); elm_widget_sub_object_add(it->base.widget, it->spacer); } - for (it2 = it, depth = 0; it2->parent; it2 = it2->parent) depth += 1; + for (it2 = it, depth = 0; it2->parent; it2 = it2->parent) + { + if (it2->parent->flags != ELM_GENLIST_ITEM_GROUP) depth += 1; + } it->expanded_depth = depth; treesize = edje_object_data_get(it->base.view, "treesize"); if (treesize) tsize = atoi(treesize); @@ -1938,13 +1949,16 @@ _item_block_unrealize(Item_Block *itb) if (!itb->realized) return; EINA_LIST_FOREACH(itb->items, l, it) { - if (it->dragging) + if (it->flags != ELM_GENLIST_ITEM_GROUP) { - dragging = EINA_TRUE; - it->want_unrealize = EINA_TRUE; + if (it->dragging) + { + dragging = EINA_TRUE; + it->want_unrealize = EINA_TRUE; + } + else + _item_unrealize(it); } - else - _item_unrealize(it); } if (!dragging) { @@ -1961,6 +1975,7 @@ _item_block_position(Item_Block *itb, { const Eina_List *l; Elm_Genlist_Item *it; + Elm_Genlist_Item *git; Evas_Coord y = 0, ox, oy, ow, oh, cvx, cvy, cvw, cvh; int vis; @@ -1973,31 +1988,69 @@ _item_block_position(Item_Block *itb, it->x = 0; it->y = y; it->w = itb->w; - vis = (ELM_RECTS_INTERSECT(itb->x + it->x - it->wd->pan_x + ox, - itb->y + it->y - it->wd->pan_y + oy, - it->w, it->h, - cvx, cvy, cvw, cvh)); - if ((itb->realized) && (!it->realized)) + it->scrl_x = itb->x + it->x - it->wd->pan_x + ox; + it->scrl_y = itb->y + it->y - it->wd->pan_y + oy; + + if (it->flags != ELM_GENLIST_ITEM_GROUP) { - if (vis) _item_realize(it, in, 0); - } - if (it->realized) - { - if (vis) + vis = (ELM_RECTS_INTERSECT(it->scrl_x, it->scrl_y, it->w, it->h, + cvx, cvy, cvw, cvh)); + if ((itb->realized) && (!it->realized)) { - evas_object_resize(it->base.view, it->w, it->h); - evas_object_move(it->base.view, - ox + itb->x + it->x - itb->wd->pan_x, - oy + itb->y + it->y - itb->wd->pan_y); - evas_object_show(it->base.view); + if (vis) _item_realize(it, in, 0); } - else + if (it->realized) { - if (!it->dragging) _item_unrealize(it); + if (vis) + { + git = it->group_item; + if (git) + { + if (git->scrl_y < oy) + git->scrl_y = oy; + if ((git->scrl_y + git->h) > (it->scrl_y + it->h)) + git->scrl_y = (it->scrl_y + it->h) - git->minh; + git->want_realize = EINA_TRUE; + } + evas_object_resize(it->base.view, it->w, it->h); + evas_object_move(it->base.view, + it->scrl_x, it->scrl_y); + evas_object_show(it->base.view); + } + else + { + if (!it->dragging) _item_unrealize(it); + } } + in++; } y += it->h; - in++; + } +} + +static void +_group_items_recalc(void *data) +{ + Widget_Data *wd = data; + Eina_List *l; + Elm_Genlist_Item *git; + + EINA_LIST_FOREACH(wd->group_items, l, git) + { + if (git->want_realize) + { + if (!git->realized) + _item_realize(git, 0, 0); + evas_object_resize(git->base.view, wd->minw, git->h); + evas_object_move(git->base.view, git->scrl_x, git->scrl_y); + evas_object_show(git->base.view); + evas_object_raise(git->base.view); + } + else if (!git->want_realize && git->realized) + { + if (!git->dragging) + _item_unrealize(git); + } } } @@ -2360,9 +2413,15 @@ _pan_calculate(Evas_Object *obj) Item_Block *itb; Evas_Coord ox, oy, ow, oh, cvx, cvy, cvw, cvh; int in = 0; + Elm_Genlist_Item *git; + Eina_List *l; evas_object_geometry_get(obj, &ox, &oy, &ow, &oh); evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh); + EINA_LIST_FOREACH(sd->wd->group_items, l, git) + { + git->want_realize = EINA_FALSE; + } EINA_INLIST_FOREACH(sd->wd->blocks, itb) { itb->w = sd->wd->minw; @@ -2381,6 +2440,7 @@ _pan_calculate(Evas_Object *obj) } in += itb->count; } + _group_items_recalc(sd->wd); } static void @@ -2843,6 +2903,8 @@ elm_genlist_item_append(Evas_Object *obj, if (!it) return NULL; if (!it->parent) { + if (flags & ELM_GENLIST_ITEM_GROUP) + wd->group_items = eina_list_append(wd->group_items, it); wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it)); it->rel = NULL; } @@ -2858,6 +2920,11 @@ elm_genlist_item_append(Evas_Object *obj, EINA_INLIST_GET(it2)); it->rel = it2; it->rel->relcount++; + + if (it->parent->flags & ELM_GENLIST_ITEM_GROUP) + it->group_item = parent; + else if (it->parent->group_item) + it->group_item = it->parent->group_item; } it->before = EINA_FALSE; _item_queue(wd, it); @@ -2898,6 +2965,8 @@ elm_genlist_item_prepend(Evas_Object *obj, if (!it) return NULL; if (!it->parent) { + if (flags & ELM_GENLIST_ITEM_GROUP) + wd->group_items = eina_list_prepend(wd->group_items, it); wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it)); it->rel = NULL; } @@ -3682,6 +3751,7 @@ EAPI void elm_genlist_item_show(Elm_Genlist_Item *it) { ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it); + Evas_Coord gith = 0; if (it->delete_me) return; if ((it->queued) || (!it->mincalcd)) { @@ -3695,6 +3765,8 @@ elm_genlist_item_show(Elm_Genlist_Item *it) it->wd->show_item->showme = EINA_FALSE; it->wd->show_item = NULL; } + if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y))) + gith = it->group_item->h; elm_smart_scroller_child_region_show(it->wd->scr, it->x + it->block->x, it->y + it->block->y, @@ -3716,6 +3788,7 @@ EAPI void elm_genlist_item_bring_in(Elm_Genlist_Item *it) { ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it); + Evas_Coord gith = 0; if (it->delete_me) return; if ((it->queued) || (!it->mincalcd)) { @@ -3729,9 +3802,11 @@ elm_genlist_item_bring_in(Elm_Genlist_Item *it) it->wd->show_item->showme = EINA_FALSE; it->wd->show_item = NULL; } + if ((it->group_item) && (it->wd->pan_y > (it->y + it->block->y))) + gith = it->group_item->h; elm_smart_scroller_region_bring_in(it->wd->scr, it->x + it->block->x, - it->y + it->block->y, + it->y + it->block->y - gith, it->block->w, it->h); } @@ -3750,6 +3825,7 @@ elm_genlist_item_top_show(Elm_Genlist_Item *it) { ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it); Evas_Coord ow, oh; + Evas_Coord gith = 0; if (it->delete_me) return; if ((it->queued) || (!it->mincalcd)) @@ -3765,9 +3841,10 @@ elm_genlist_item_top_show(Elm_Genlist_Item *it) it->wd->show_item = NULL; } evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh); + if (it->group_item) gith = it->group_item->h; elm_smart_scroller_child_region_show(it->wd->scr, it->x + it->block->x, - it->y + it->block->y, + it->y + it->block->y - gith, it->block->w, oh); } @@ -3787,6 +3864,7 @@ elm_genlist_item_top_bring_in(Elm_Genlist_Item *it) { ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it); Evas_Coord ow, oh; + Evas_Coord gith = 0; if (it->delete_me) return; if ((it->queued) || (!it->mincalcd)) @@ -3802,9 +3880,10 @@ elm_genlist_item_top_bring_in(Elm_Genlist_Item *it) it->wd->show_item = NULL; } evas_object_geometry_get(it->wd->pan_smart, NULL, NULL, &ow, &oh); + if (it->group_item) gith = it->group_item->h; elm_smart_scroller_region_bring_in(it->wd->scr, it->x + it->block->x, - it->y + it->block->y, + it->y + it->block->y - gith, it->block->w, oh); }