forked from enlightenment/efl
Change Ecore_Evas to work with Evas_Object as cursor.
WARNING: this breaks the API, if you rely on ecore_evas_cursor_get(), you need to get the "Evas_Object *" instead of the filename. Now the code is smaller and we can handle any object, including Edje. Patch by Cedric BAIL. SVN revision: 31818
This commit is contained in:
parent
7468078e12
commit
e04b782d50
|
@ -201,7 +201,8 @@ EAPI void ecore_evas_size_base_get(Ecore_Evas *ee, int *w, int *h);
|
|||
EAPI void ecore_evas_size_step_set(Ecore_Evas *ee, int w, int h);
|
||||
EAPI void ecore_evas_size_step_get(Ecore_Evas *ee, int *w, int *h);
|
||||
EAPI void ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y);
|
||||
EAPI void ecore_evas_cursor_get(Ecore_Evas *ee, char **file, int *layer, int *hot_x, int *hot_y);
|
||||
EAPI void ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y);
|
||||
EAPI void ecore_evas_cursor_get(Ecore_Evas *ee, Evas_Object **obj, int *layer, int *hot_x, int *hot_y);
|
||||
EAPI void ecore_evas_layer_set(Ecore_Evas *ee, int layer);
|
||||
EAPI int ecore_evas_layer_get(Ecore_Evas *ee);
|
||||
EAPI void ecore_evas_focus_set(Ecore_Evas *ee, int on);
|
||||
|
|
|
@ -1269,20 +1269,60 @@ ecore_evas_size_step_get(Ecore_Evas *ee, int *w, int *h)
|
|||
EAPI void
|
||||
ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y)
|
||||
{
|
||||
Evas_Object *obj = NULL;
|
||||
|
||||
if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
|
||||
{
|
||||
ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
|
||||
"ecore_evas_cursor_set");
|
||||
return;
|
||||
}
|
||||
IFC(ee, fn_cursor_set) (ee, file, layer, hot_x, hot_y);
|
||||
|
||||
if (file)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
obj = evas_object_image_add(ee->evas);
|
||||
evas_object_image_file_set(obj, file, NULL);
|
||||
evas_object_image_size_get(obj, &x, &y);
|
||||
evas_object_resize(obj, x, y);
|
||||
evas_object_image_fill_set(obj, 0, 0, x, y);
|
||||
}
|
||||
|
||||
IFC(ee, fn_object_cursor_set) (ee, obj, layer, hot_x, hot_y);
|
||||
IFE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cursor of an Ecore_Evas
|
||||
* @param ee The Ecore_Evas
|
||||
* @param obj The Evas_Object for the cursor
|
||||
* @param layer
|
||||
* @param hot_x The x coordinate of the cursor's hot spot
|
||||
* @param hot_y The y coordinate of the cursor's hot spot
|
||||
*
|
||||
* This function makes the mouse cursor over @p ee be the image specified by
|
||||
* @p file. The actual point within the image that the mouse is at is specified
|
||||
* by @p hot_x and @p hot_y, which are coordinates with respect to the top left
|
||||
* corner of the cursor image.
|
||||
*/
|
||||
EAPI void
|
||||
ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
|
||||
{
|
||||
if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
|
||||
{
|
||||
ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS,
|
||||
"ecore_evas_cursor_set");
|
||||
return;
|
||||
}
|
||||
IFC(ee, fn_object_cursor_set) (ee, obj, layer, hot_x, hot_y);
|
||||
IFE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about an Ecore_Evas' cursor
|
||||
* @param ee The Ecore_Evas to set
|
||||
* @param file A pointer to a string to place the cursor file name in.
|
||||
* @param obj A pointer to an Evas_Object to place the cursor Evas_Object.
|
||||
* @param layer A pointer to an int to place the cursor's layer in..
|
||||
* @param hot_x A pointer to an int to place the cursor's hot_x coordinate in.
|
||||
* @param hot_y A pointer to an int to place the cursor's hot_y coordinate in.
|
||||
|
@ -1290,7 +1330,7 @@ ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, in
|
|||
* This function queries information about an Ecore_Evas' cursor.
|
||||
*/
|
||||
EAPI void
|
||||
ecore_evas_cursor_get(Ecore_Evas *ee, char **file, int *layer, int *hot_x, int *hot_y)
|
||||
ecore_evas_cursor_get(Ecore_Evas *ee, Evas_Object **obj, int *layer, int *hot_x, int *hot_y)
|
||||
{
|
||||
if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS))
|
||||
{
|
||||
|
@ -1298,7 +1338,7 @@ ecore_evas_cursor_get(Ecore_Evas *ee, char **file, int *layer, int *hot_x, int *
|
|||
"ecore_evas_cursor_get");
|
||||
return;
|
||||
}
|
||||
if (file) *file = ee->prop.cursor.file;
|
||||
if (obj) *obj = ee->prop.cursor.object;
|
||||
if (layer) *layer = ee->prop.cursor.layer;
|
||||
if (hot_x) *hot_x = ee->prop.cursor.hot.x;
|
||||
if (hot_y) *hot_y = ee->prop.cursor.hot.y;
|
||||
|
@ -1821,7 +1861,6 @@ _ecore_evas_free(Ecore_Evas *ee)
|
|||
if (ee->prop.title) free(ee->prop.title);
|
||||
if (ee->prop.name) free(ee->prop.name);
|
||||
if (ee->prop.clas) free(ee->prop.clas);
|
||||
if (ee->prop.cursor.file) free(ee->prop.cursor.file);
|
||||
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
|
||||
if (ee->evas) evas_free(ee->evas);
|
||||
ee->data = NULL;
|
||||
|
@ -1830,7 +1869,6 @@ _ecore_evas_free(Ecore_Evas *ee)
|
|||
ee->prop.title = NULL;
|
||||
ee->prop.name = NULL;
|
||||
ee->prop.clas = NULL;
|
||||
ee->prop.cursor.file = NULL;
|
||||
ee->prop.cursor.object = NULL;
|
||||
ee->evas = NULL;
|
||||
if (ee->engine.idle_flush_timer)
|
||||
|
|
|
@ -420,16 +420,15 @@ _ecore_evas_directfb_shaped_set(Ecore_Evas *ee, int shaped)
|
|||
}
|
||||
|
||||
static void
|
||||
_ecore_evas_directfb_cursor_set(Ecore_Evas *ee, const char *file, int layer __UNUSED__, int hot_x, int hot_y)
|
||||
_ecore_evas_directfb_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
if (!file)
|
||||
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
|
||||
|
||||
if (obj == NULL)
|
||||
{
|
||||
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
|
||||
if (ee->prop.cursor.file) free(ee->prop.cursor.file);
|
||||
ee->prop.cursor.object = NULL;
|
||||
ee->prop.cursor.file = NULL;
|
||||
ee->prop.cursor.layer = 0;
|
||||
ee->prop.cursor.hot.x = 0;
|
||||
ee->prop.cursor.hot.y = 0;
|
||||
|
@ -437,21 +436,18 @@ _ecore_evas_directfb_cursor_set(Ecore_Evas *ee, const char *file, int layer __UN
|
|||
return;
|
||||
|
||||
}
|
||||
ecore_directfb_window_cursor_show(ee->engine.directfb.window, 0);
|
||||
if (!ee->prop.cursor.object) ee->prop.cursor.object = evas_object_image_add(ee->evas);
|
||||
if (ee->prop.cursor.file) free(ee->prop.cursor.file);
|
||||
ee->prop.cursor.file = strdup(file);
|
||||
|
||||
ee->prop.cursor.object = obj;
|
||||
ee->prop.cursor.layer = layer;
|
||||
ee->prop.cursor.hot.x = hot_x;
|
||||
ee->prop.cursor.hot.y = hot_y;
|
||||
|
||||
ecore_directfb_window_cursor_show(ee->engine.directfb.window, 0);
|
||||
|
||||
evas_pointer_output_xy_get(ee->evas, &x, &y);
|
||||
evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
|
||||
evas_object_color_set(ee->prop.cursor.object, 255, 255, 255, 255);
|
||||
evas_object_move(ee->prop.cursor.object,x - ee->prop.cursor.hot.x,y - ee->prop.cursor.hot.y);
|
||||
evas_object_image_file_set(ee->prop.cursor.object, ee->prop.cursor.file, NULL);
|
||||
evas_object_image_size_get(ee->prop.cursor.object, &x, &y);
|
||||
evas_object_resize(ee->prop.cursor.object, x, y);
|
||||
evas_object_image_fill_set(ee->prop.cursor.object, 0, 0, x, y);
|
||||
evas_object_pass_events_set(ee->prop.cursor.object, 1);
|
||||
if (evas_pointer_inside_get(ee->evas))
|
||||
evas_object_show(ee->prop.cursor.object);
|
||||
|
@ -537,7 +533,7 @@ static const Ecore_Evas_Engine_Func _ecore_directfb_engine_func =
|
|||
NULL, /* size max */
|
||||
NULL, /* size base */
|
||||
NULL, /* size step */
|
||||
_ecore_evas_directfb_cursor_set, /* cursor set */
|
||||
_ecore_evas_directfb_object_cursor_set, /* set cursor to an evas object */
|
||||
NULL, /* layer set */
|
||||
_ecore_evas_directfb_focus_set, /* focus */
|
||||
NULL, /* iconified */
|
||||
|
|
|
@ -408,24 +408,22 @@ _ecore_evas_rotation_set(Ecore_Evas *ee, int rotation)
|
|||
}
|
||||
|
||||
static void
|
||||
_ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y)
|
||||
_ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
if (!file)
|
||||
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
|
||||
|
||||
if (obj == NULL)
|
||||
{
|
||||
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
|
||||
if (ee->prop.cursor.file) free(ee->prop.cursor.file);
|
||||
ee->prop.cursor.object = NULL;
|
||||
ee->prop.cursor.file = NULL;
|
||||
ee->prop.cursor.layer = 0;
|
||||
ee->prop.cursor.hot.x = 0;
|
||||
ee->prop.cursor.hot.y = 0;
|
||||
return;
|
||||
}
|
||||
if (!ee->prop.cursor.object) ee->prop.cursor.object = evas_object_image_add(ee->evas);
|
||||
if (ee->prop.cursor.file) free(ee->prop.cursor.file);
|
||||
ee->prop.cursor.file = strdup(file);
|
||||
|
||||
ee->prop.cursor.object = obj;
|
||||
ee->prop.cursor.layer = layer;
|
||||
ee->prop.cursor.hot.x = hot_x;
|
||||
ee->prop.cursor.hot.y = hot_y;
|
||||
|
@ -435,10 +433,6 @@ _ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, i
|
|||
evas_object_move(ee->prop.cursor.object,
|
||||
x - ee->prop.cursor.hot.x,
|
||||
y - ee->prop.cursor.hot.y);
|
||||
evas_object_image_file_set(ee->prop.cursor.object, ee->prop.cursor.file, NULL);
|
||||
evas_object_image_size_get(ee->prop.cursor.object, &x, &y);
|
||||
evas_object_resize(ee->prop.cursor.object, x, y);
|
||||
evas_object_image_fill_set(ee->prop.cursor.object, 0, 0, x, y);
|
||||
evas_object_pass_events_set(ee->prop.cursor.object, 1);
|
||||
if (evas_pointer_inside_get(ee->evas))
|
||||
evas_object_show(ee->prop.cursor.object);
|
||||
|
@ -551,7 +545,7 @@ static const Ecore_Evas_Engine_Func _ecore_fb_engine_func =
|
|||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
_ecore_evas_cursor_set,
|
||||
_ecore_evas_object_cursor_set,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
|
|
@ -111,7 +111,7 @@ struct _Ecore_Evas_Engine_Func
|
|||
void (*fn_size_max_set) (Ecore_Evas *ee, int w, int h);
|
||||
void (*fn_size_base_set) (Ecore_Evas *ee, int w, int h);
|
||||
void (*fn_size_step_set) (Ecore_Evas *ee, int w, int h);
|
||||
void (*fn_cursor_set) (Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y);
|
||||
void (*fn_object_cursor_set) (Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y);
|
||||
void (*fn_layer_set) (Ecore_Evas *ee, int layer);
|
||||
void (*fn_focus_set) (Ecore_Evas *ee, int on);
|
||||
void (*fn_iconified_set) (Ecore_Evas *ee, int on);
|
||||
|
@ -227,7 +227,6 @@ struct _Ecore_Evas
|
|||
step;
|
||||
struct {
|
||||
Evas_Object *object;
|
||||
char *file;
|
||||
int layer;
|
||||
struct {
|
||||
int x, y;
|
||||
|
|
|
@ -347,24 +347,22 @@ _ecore_evas_move_resize(Ecore_Evas *ee, int x __UNUSED__, int y __UNUSED__, int
|
|||
}
|
||||
|
||||
static void
|
||||
_ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y)
|
||||
_ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
if (!file)
|
||||
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
|
||||
|
||||
if (obj == NULL)
|
||||
{
|
||||
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
|
||||
if (ee->prop.cursor.file) free(ee->prop.cursor.file);
|
||||
ee->prop.cursor.object = NULL;
|
||||
ee->prop.cursor.file = NULL;
|
||||
ee->prop.cursor.layer = 0;
|
||||
ee->prop.cursor.hot.x = 0;
|
||||
ee->prop.cursor.hot.y = 0;
|
||||
return;
|
||||
}
|
||||
if (!ee->prop.cursor.object) ee->prop.cursor.object = evas_object_image_add(ee->evas);
|
||||
if (ee->prop.cursor.file) free(ee->prop.cursor.file);
|
||||
ee->prop.cursor.file = strdup(file);
|
||||
|
||||
ee->prop.cursor.object = obj;
|
||||
ee->prop.cursor.layer = layer;
|
||||
ee->prop.cursor.hot.x = hot_x;
|
||||
ee->prop.cursor.hot.y = hot_y;
|
||||
|
@ -374,10 +372,6 @@ _ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, i
|
|||
evas_object_move(ee->prop.cursor.object,
|
||||
x - ee->prop.cursor.hot.x,
|
||||
y - ee->prop.cursor.hot.y);
|
||||
evas_object_image_file_set(ee->prop.cursor.object, ee->prop.cursor.file, NULL);
|
||||
evas_object_image_size_get(ee->prop.cursor.object, &x, &y);
|
||||
evas_object_resize(ee->prop.cursor.object, x, y);
|
||||
evas_object_image_fill_set(ee->prop.cursor.object, 0, 0, x, y);
|
||||
evas_object_pass_events_set(ee->prop.cursor.object, 1);
|
||||
if (evas_pointer_inside_get(ee->evas))
|
||||
evas_object_show(ee->prop.cursor.object);
|
||||
|
@ -416,7 +410,7 @@ static const Ecore_Evas_Engine_Func _ecore_sdl_engine_func =
|
|||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
_ecore_evas_cursor_set,
|
||||
_ecore_evas_object_cursor_set,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -442,7 +436,6 @@ ecore_evas_sdl_new(const char* name, int w, int h, int fullscreen, int hwsurface
|
|||
name = ecore_evas_sdl_default;
|
||||
|
||||
rmethod = evas_render_method_lookup("software_sdl");
|
||||
fprintf(stderr, "rmethod: %i\n", rmethod);
|
||||
if (!rmethod) return NULL;
|
||||
|
||||
if (!ecore_sdl_init(name)) return NULL;
|
||||
|
|
|
@ -2086,39 +2086,35 @@ _ecore_evas_x_size_step_set(Ecore_Evas *ee, int w, int h)
|
|||
}
|
||||
|
||||
static void
|
||||
_ecore_evas_x_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, int hot_y)
|
||||
_ecore_evas_x_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
if (!file)
|
||||
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
|
||||
|
||||
if (obj == NULL)
|
||||
{
|
||||
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
|
||||
if (ee->prop.cursor.file) free(ee->prop.cursor.file);
|
||||
ee->prop.cursor.object = NULL;
|
||||
ee->prop.cursor.file = NULL;
|
||||
ee->prop.cursor.layer = 0;
|
||||
ee->prop.cursor.hot.x = 0;
|
||||
ee->prop.cursor.hot.y = 0;
|
||||
ecore_x_window_cursor_show(ee->engine.x.win, 1);
|
||||
return;
|
||||
}
|
||||
ecore_x_window_cursor_show(ee->engine.x.win, 0);
|
||||
if (!ee->prop.cursor.object) ee->prop.cursor.object = evas_object_image_add(ee->evas);
|
||||
if (ee->prop.cursor.file) free(ee->prop.cursor.file);
|
||||
ee->prop.cursor.file = strdup(file);
|
||||
|
||||
ee->prop.cursor.object = obj;
|
||||
ee->prop.cursor.layer = layer;
|
||||
ee->prop.cursor.hot.x = hot_x;
|
||||
ee->prop.cursor.hot.y = hot_y;
|
||||
|
||||
ecore_x_window_cursor_show(ee->engine.x.win, 0);
|
||||
|
||||
evas_pointer_output_xy_get(ee->evas, &x, &y);
|
||||
evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
|
||||
evas_object_color_set(ee->prop.cursor.object, 255, 255, 255, 255);
|
||||
evas_object_move(ee->prop.cursor.object,
|
||||
x - ee->prop.cursor.hot.x,
|
||||
y - ee->prop.cursor.hot.y);
|
||||
evas_object_image_file_set(ee->prop.cursor.object, ee->prop.cursor.file, NULL);
|
||||
evas_object_image_size_get(ee->prop.cursor.object, &x, &y);
|
||||
evas_object_resize(ee->prop.cursor.object, x, y);
|
||||
evas_object_image_fill_set(ee->prop.cursor.object, 0, 0, x, y);
|
||||
evas_object_pass_events_set(ee->prop.cursor.object, 1);
|
||||
if (evas_pointer_inside_get(ee->evas))
|
||||
evas_object_show(ee->prop.cursor.object);
|
||||
|
@ -2489,7 +2485,7 @@ static const Ecore_Evas_Engine_Func _ecore_x_engine_func =
|
|||
_ecore_evas_x_size_max_set,
|
||||
_ecore_evas_x_size_base_set,
|
||||
_ecore_evas_x_size_step_set,
|
||||
_ecore_evas_x_cursor_set,
|
||||
_ecore_evas_x_object_cursor_set,
|
||||
_ecore_evas_x_layer_set,
|
||||
_ecore_evas_x_focus_set,
|
||||
_ecore_evas_x_iconified_set,
|
||||
|
|
Loading…
Reference in New Issue