struct _Elm_Cursor
{
- Evas_Object *obj;
+ Evas_Object *obj, *hotobj;
Evas_Object *eventarea, *owner;
const char *style, *cursor_name;
int hot_x, hot_y;
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)
{
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"))
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)
{
if (cur->visible) return;
{
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,