diff --git a/legacy/elementary/data/themes/Makefile.am b/legacy/elementary/data/themes/Makefile.am index 2139b9b84a..444ea8320c 100644 --- a/legacy/elementary/data/themes/Makefile.am +++ b/legacy/elementary/data/themes/Makefile.am @@ -103,6 +103,7 @@ edc/elm/clock.edc \ edc/elm/colorsel.edc \ edc/elm/conform.edc \ edc/elm/ctxpopup.edc \ +edc/elm/cursor.edc \ edc/elm/datetime.edc \ edc/elm/dayselector.edc \ edc/elm/diskselector.edc \ @@ -508,6 +509,7 @@ img/pointer_entry_bar.png \ img/pointer_glow.png \ img/pointer_mono.png \ img/pointer.png \ +img/pointer_hand1.png \ img/ring_shadow.png \ img/ring_white_blue_glow.png \ img/ring_white_middle.png \ diff --git a/legacy/elementary/data/themes/default.edc b/legacy/elementary/data/themes/default.edc index 09a26c5e9c..953de8b401 100644 --- a/legacy/elementary/data/themes/default.edc +++ b/legacy/elementary/data/themes/default.edc @@ -68,6 +68,7 @@ collections { #include "edc/elm/clock.edc" #include "edc/elm/gengrid.edc" #include "edc/elm/hover.edc" +#include "edc/elm/cursor.edc" // desktop in general #include "edc/wallpaper.edc" diff --git a/legacy/elementary/data/themes/edc/elm/cursor.edc b/legacy/elementary/data/themes/edc/elm/cursor.edc new file mode 100644 index 0000000000..ea7bc111a1 --- /dev/null +++ b/legacy/elementary/data/themes/edc/elm/cursor.edc @@ -0,0 +1,101 @@ +// cursors available: +// +// "x" +// "arrow" +// "based_arrow_down" +// "based_arrow_up" +// "boat" +// "bogosity" +// "bottom_left_corner" +// "bottom_right_corner" +// "bottom_side" +// "bottom_tee" +// "box_spiral" +// "center_ptr" +// "circle" +// "clock" +// "coffee_mug" +// "cross" +// "cross_reverse" +// "crosshair" +// "diamond_cross" +// "dot" +// "dot_box_mask" +// "double_arrow" +// "draft_large" +// "draft_small" +// "draped_box" +// "exchange" +// "fleur" +// "gobbler" +// "gumby" +// "hand1" *DONE* +// "hand2" +// "heart" +// "icon" +// "iron_cross" +// "left_ptr" +// "left_side" +// "left_tee" +// "leftbutton" +// "ll_angle" +// "lr_angle" +// "man" +// "middlebutton" +// "mouse" +// "pencil" +// "pirate" +// "plus" +// "question_arrow" +// "right_ptr" +// "right_side" +// "right_tee" +// "rightbutton" +// "rtl_logo" +// "sailboat" +// "sb_down_arrow" +// "sb_h_double_arrow" +// "sb_left_arrow" +// "sb_right_arrow" +// "sb_up_arrow" +// "sb_v_double_arrow" +// "shuttle" +// "sizing" +// "spider" +// "spraycan" +// "star" +// "target" +// "tcross" +// "top_left_arrow" +// "top_left_corner" +// "top_right_corner" +// "top_side" +// "top_tee" +// "trek" +// "ul_angle" +// "umbrella" +// "ur_angle" +// "watch" +// "xterm" + +group { name: "elm/cursor/hand1/default"; + images.image: "pointer_hand1.png" COMP; + parts { + part { name: "base"; mouse_events: 0; scale: 1; + description { state: "default" 0.0; + FIXED_SIZE(32, 32) + image.normal: "pointer_hand1.png"; + } + } + part { name: "elm.content.hotspot"; type: SWALLOW; + description { state: "default" 0.0; + visible: 0; + rel1.relative: (26/32) (9/32); + rel1.to: "base"; + rel2.to: "base"; + rel2.relative: (26/32) (9/32); + rel2.offset: 0 0; + } + } + } +} diff --git a/legacy/elementary/data/themes/img/pointer_hand1.png b/legacy/elementary/data/themes/img/pointer_hand1.png new file mode 100644 index 0000000000..68f356d069 Binary files /dev/null and b/legacy/elementary/data/themes/img/pointer_hand1.png differ diff --git a/legacy/elementary/src/bin/test_cursor.c b/legacy/elementary/src/bin/test_cursor.c index afd86594a2..499e9d5250 100644 --- a/legacy/elementary/src/bin/test_cursor.c +++ b/legacy/elementary/src/bin/test_cursor.c @@ -299,7 +299,7 @@ test_cursor3(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_i o = elm_button_add(win); elm_object_cursor_set(o, ELM_CURSOR_HAND1); -// elm_object_cursor_theme_search_enabled_set(o, EINA_TRUE); + elm_object_cursor_theme_search_enabled_set(o, EINA_TRUE); elm_object_text_set(o, "hand1"); elm_box_pack_end(bx, o); evas_object_show(o); diff --git a/legacy/elementary/src/lib/els_cursor.c b/legacy/elementary/src/lib/els_cursor.c index ab778538d3..da74f10540 100644 --- a/legacy/elementary/src/lib/els_cursor.c +++ b/legacy/elementary/src/lib/els_cursor.c @@ -133,7 +133,7 @@ static const int _cursors_count = sizeof(_cursors)/sizeof(struct _Cursor_Id); struct _Elm_Cursor { - Evas_Object *obj; + Evas_Object *obj, *hotobj; Evas_Object *eventarea, *owner; const char *style, *cursor_name; int hot_x, hot_y; @@ -166,9 +166,41 @@ _elm_cursor_obj_del(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UN evas_object_event_callback_del_full(cur->obj, EVAS_CALLBACK_DEL, _elm_cursor_obj_del, cur); cur->obj = NULL; + ELM_SAFE_FREE(cur->hotobj, evas_object_del); } } +static void +_elm_cursor_set_hot_spots(Elm_Cursor *cur) +{ + const char *str; + Evas_Coord cx, cy, x, y, w, h; + int prev_hot_x, prev_hot_y; + + prev_hot_x = cur->hot_x; + prev_hot_y = cur->hot_y; + + evas_object_geometry_get(cur->obj, &cx, &cy, NULL, NULL); + evas_object_geometry_get(cur->hotobj, &x, &y, &w, &h); + cur->hot_x = (x + (w / 2)) - cx; + cur->hot_y = (y + (h / 2)) - cy; + + str = edje_object_data_get(cur->obj, "hot_x"); + if (str) cur->hot_x = atoi(str); + str = edje_object_data_get(cur->obj, "hot_y"); + if (str) cur->hot_y = atoi(str); + + if ((prev_hot_x != cur->hot_x) || (prev_hot_y != cur->hot_y)) + ecore_evas_object_cursor_set(cur->ee, cur->obj, ELM_OBJECT_LAYER_CURSOR, + cur->hot_x, cur->hot_y); +} + +static void +_elm_cursor_hot_change(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +{ + _elm_cursor_set_hot_spots(data); +} + static Eina_Bool _elm_cursor_obj_add(Evas_Object *obj, Elm_Cursor *cur) { @@ -176,8 +208,7 @@ _elm_cursor_obj_add(Evas_Object *obj, Elm_Cursor *cur) cur->obj = edje_object_add(cur->evas); - if (!cur->obj) - return EINA_FALSE; + if (!cur->obj) return EINA_FALSE; if (!_elm_theme_object_set(obj, cur->obj, "cursor", cur->cursor_name, cur->style ? cur->style : "default")) @@ -185,29 +216,22 @@ _elm_cursor_obj_add(Evas_Object *obj, Elm_Cursor *cur) ELM_SAFE_FREE(cur->obj, evas_object_del); return EINA_FALSE; } + cur->hotobj = evas_object_rectangle_add(cur->evas); + evas_object_color_set(cur->hotobj, 0, 0, 0, 0); + edje_object_part_swallow(cur->obj, "elm.content.hotspot", cur->hotobj); + evas_object_event_callback_add(cur->obj, EVAS_CALLBACK_MOVE, + _elm_cursor_hot_change, cur); + evas_object_event_callback_add(cur->obj, EVAS_CALLBACK_RESIZE, + _elm_cursor_hot_change, cur); evas_object_event_callback_add(cur->obj, EVAS_CALLBACK_DEL, _elm_cursor_obj_del, cur); - edje_object_size_min_get(cur->obj, &x, &y); + edje_object_size_min_restricted_calc(cur->obj, &x, &y, x, y); evas_object_resize(cur->obj, x, y); return EINA_TRUE; } -static void -_elm_cursor_set_hot_spots(Elm_Cursor *cur) -{ - const char *str; - - str = edje_object_data_get(cur->obj, "hot_x"); - if (str) cur->hot_x = atoi(str); - else cur->hot_x = 0; - - str = edje_object_data_get(cur->obj, "hot_y"); - if (str) cur->hot_y = atoi(str); - else cur->hot_y = 0; -} - static void _elm_cursor_set(Elm_Cursor *cur) { @@ -229,6 +253,7 @@ _elm_cursor_set(Elm_Cursor *cur) { evas_object_del(cur->obj); cur->obj = NULL; + ELM_SAFE_FREE(cur->hotobj, evas_object_del); } ecore_evas_object_cursor_set(cur->ee, NULL, ELM_OBJECT_LAYER_CURSOR, cur->hot_x,