Enlightenment CVS committal

Author  : barbieri
Project : e17
Module  : libs/ecore

Dir     : e17/libs/ecore/src/lib/ecore_evas


Modified Files:
        Ecore_Evas.h ecore_evas.c ecore_evas_directfb.c 
        ecore_evas_fb.c ecore_evas_private.h ecore_evas_sdl.c 
        ecore_evas_x.c 


Log Message:
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.

===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_evas/Ecore_Evas.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -3 -r1.31 -r1.32
--- Ecore_Evas.h        23 Sep 2007 11:57:34 -0000      1.31
+++ Ecore_Evas.h        26 Sep 2007 14:40:02 -0000      1.32
@@ -201,7 +201,8 @@
 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);
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_evas/ecore_evas.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -3 -r1.39 -r1.40
--- ecore_evas.c        27 Aug 2007 10:20:12 -0000      1.39
+++ ecore_evas.c        26 Sep 2007 14:40:02 -0000      1.40
@@ -1269,20 +1269,60 @@
 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;
+     }
+
+   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_cursor_set) (ee, file, layer, hot_x, hot_y);
+   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 @@
  * 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");
        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 @@
    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 @@
    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)
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_evas/ecore_evas_directfb.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- ecore_evas_directfb.c       17 Jun 2007 03:41:43 -0000      1.10
+++ ecore_evas_directfb.c       26 Sep 2007 14:40:02 -0000      1.11
@@ -420,16 +420,15 @@
 }
 
 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 @@
        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 @@
      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 */
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_evas/ecore_evas_fb.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -3 -r1.27 -r1.28
--- ecore_evas_fb.c     25 Jul 2007 17:00:55 -0000      1.27
+++ ecore_evas_fb.c     26 Sep 2007 14:40:02 -0000      1.28
@@ -408,24 +408,22 @@
 }
 
 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 @@
    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 @@
      NULL,
      NULL,
      NULL,
-     _ecore_evas_cursor_set,
+     _ecore_evas_object_cursor_set,
      NULL,
      NULL,
      NULL,
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_evas/ecore_evas_private.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -3 -r1.31 -r1.32
--- ecore_evas_private.h        23 Sep 2007 11:57:34 -0000      1.31
+++ ecore_evas_private.h        26 Sep 2007 14:40:02 -0000      1.32
@@ -111,7 +111,7 @@
    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 @@
        step;
       struct {
         Evas_Object *object;
-        char        *file;
         int          layer;
         struct {
            int       x, y;
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_evas/ecore_evas_sdl.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- ecore_evas_sdl.c    26 Aug 2007 11:17:21 -0000      1.2
+++ ecore_evas_sdl.c    26 Sep 2007 14:40:02 -0000      1.3
@@ -347,24 +347,22 @@
 }
 
 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 @@
    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 @@
    NULL,
    NULL,
    NULL,
-   _ecore_evas_cursor_set,
+   _ecore_evas_object_cursor_set,
    NULL,
    NULL,
    NULL,
@@ -442,7 +436,6 @@
      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;
===================================================================
RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_evas/ecore_evas_x.c,v
retrieving revision 1.107
retrieving revision 1.108
diff -u -3 -r1.107 -r1.108
--- ecore_evas_x.c      8 Sep 2007 04:51:16 -0000       1.107
+++ ecore_evas_x.c      26 Sep 2007 14:40:02 -0000      1.108
@@ -2086,39 +2086,35 @@
 }
 
 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 @@
      _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,



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to