forked from enlightenment/efl
Immediatly change the cursor if changed from inside the widget
@fix elm_object_cursor_set() to work also when used with the mouse pointer yet inside the widget, otherwise you need to mouseout/mousein to actually see the new setted cursor. Please give a short review on this one, maybe there is a simpler way to check if the pointer is inside the widget... Also added a button in the cursor test for this use case
This commit is contained in:
parent
3a2e56614c
commit
b735386a45
|
@ -15,6 +15,7 @@ typedef struct _Testitem
|
|||
} Testitem;
|
||||
|
||||
static Elm_Gengrid_Item_Class gic;
|
||||
static Eina_Bool cursor_setted = EINA_FALSE;
|
||||
|
||||
char *
|
||||
grd_lbl_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
|
||||
|
@ -94,6 +95,23 @@ glt_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNU
|
|||
return strdup(buf);
|
||||
}
|
||||
|
||||
static void
|
||||
bt_clicked(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
if (cursor_setted)
|
||||
{
|
||||
elm_object_cursor_unset(obj);
|
||||
cursor_setted = EINA_FALSE;
|
||||
elm_object_text_set(obj, "Cursor set on click");
|
||||
}
|
||||
else
|
||||
{
|
||||
elm_object_cursor_set(obj, ELM_CURSOR_HAND1);
|
||||
cursor_setted = EINA_TRUE;
|
||||
elm_object_text_set(obj, "Cursor unset on click");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
test_cursor(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
|
@ -133,6 +151,12 @@ test_cursor(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_in
|
|||
elm_box_pack_end(bx, bt);
|
||||
evas_object_show(bt);
|
||||
|
||||
bt = elm_button_add(win);
|
||||
elm_object_text_set(bt, "Cursor set on click");
|
||||
evas_object_smart_callback_add(bt, "clicked", bt_clicked, NULL);
|
||||
elm_box_pack_end(bx, bt);
|
||||
evas_object_show(bt);
|
||||
|
||||
list = elm_list_add(win);
|
||||
elm_box_pack_end(bx, list);
|
||||
evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
|
|
|
@ -164,6 +164,10 @@ extern const char *_elm_engines[];
|
|||
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
||||
#undef CEIL
|
||||
#define CEIL(a) (((a) % 2 != 0) ? ((a) / 2 + 1) : ((a) / 2))
|
||||
#undef IS_INSIDE
|
||||
#define IS_INSIDE(x, y, xx, yy, ww, hh) \
|
||||
(((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && \
|
||||
((x) >= (xx)) && ((y) >= (yy)))
|
||||
|
||||
|
||||
#define ELM_SAFE_FREE(_h, _fn) do { _fn((void*)_h); _h = NULL; } while (0)
|
||||
|
|
|
@ -406,6 +406,12 @@ _elm_cursor_cur_set(Elm_Cursor *cur)
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Evas_Coord x, y, w, h, px, py;
|
||||
evas_object_geometry_get(cur->eventarea, &x, &y, &w, &h);
|
||||
evas_pointer_canvas_xy_get(cur->evas, &px, &py);
|
||||
if (IS_INSIDE(px, py, x, y, w, h))
|
||||
_elm_cursor_set(cur);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue