diff --git a/src/bin/empc.c b/src/bin/empc.c index 8ec1d22..864062d 100644 --- a/src/bin/empc.c +++ b/src/bin/empc.c @@ -2818,6 +2818,63 @@ slider_seek(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUS empd_empdd_seek_call(empd_proxy, empd_songid, lround(val * empd_song_length)); } +static int +mouse_wheel(void *data EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Mouse_Wheel *ev) +{ + if (!queue_list_state) return ECORE_CALLBACK_RENEW; + if (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) + { + Elm_Object_Item *it, *pit, *pick; + int w; + + elm_scroller_region_get(queue_list, NULL, NULL, &w, NULL); + /* FIXME: this should actually calc the height of an item for y */ + it = elm_genlist_at_xy_item_get(queue_list, w / 2, 5, NULL); + if (!it) return ECORE_CALLBACK_RENEW; + pit = elm_genlist_item_parent_get(it); + if (!pit) pit = it; //already parent + if (!ev->z) return ECORE_CALLBACK_RENEW; + if (ev->z < 0) //up + { + if (pit != it) pick = pit; + else + { + pick = elm_genlist_item_prev_get(pit); + do + { + if (elm_genlist_item_parent_get(pick) != pit) break; + pick = elm_genlist_item_prev_get(pick); + } while (pick); + if (!pick) + pick = elm_genlist_first_item_get(queue_list); + } + } + else if (ev->z > 0) + { + if (pit != it) + { + pick = elm_genlist_item_next_get(pit); + if (pick) + pick = elm_genlist_item_parent_get(pick); + } + else + { + pick = elm_genlist_item_next_get(pit); + do + { + if (elm_genlist_item_parent_get(pick) != pit) break; + pick = elm_genlist_item_next_get(pick); + } while (pick); + } + if (!pick) + pick = elm_genlist_last_item_get(queue_list); + } + elm_genlist_item_bring_in(pick, ELM_GENLIST_ITEM_SCROLLTO_TOP); + return ECORE_CALLBACK_CANCEL; + } + return ECORE_CALLBACK_RENEW; +} + static int mouse_down(void *data EINA_UNUSED, int t EINA_UNUSED, Ecore_Event_Key *ev EINA_UNUSED) { @@ -3337,6 +3394,7 @@ main(int argc, char *argv[]) ecore_event_init(); E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_KEY_DOWN, key_down, NULL); E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_BUTTON_DOWN, mouse_down, NULL); + E_LIST_HANDLER_APPEND(handlers, ECORE_EVENT_MOUSE_WHEEL, mouse_wheel, NULL); elm_init(argc, argv); elm_config_scale_set(1.3);