Enlightenment CVS committal

Author  : atmosphere
Project : e17
Module  : apps/entice

Dir     : e17/apps/entice/src/bin


Modified Files:
        entice.c image.c image.h 


Log Message:
more precise image dragging, your mouse should only drift now when it stops the image 
at the confines
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/entice.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -3 -r1.47 -r1.48
--- entice.c    8 Apr 2004 00:07:30 -0000       1.47
+++ entice.c    8 Apr 2004 18:33:41 -0000       1.48
@@ -447,6 +447,9 @@
                      evas_list_append(entice->thumb.list, o);
                   evas_object_resize(o, 48, 48);
                   hookup_entice_thumb_signals(edje, o);
+                  evas_object_layer_set(o,
+                                        evas_object_layer_get(entice->
+                                                              container));
                   edje_object_part_swallow(edje, "entice.thumb", o);
                   evas_object_show(edje);
                   evas_object_show(o);
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/image.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -3 -r1.41 -r1.42
--- image.c     8 Apr 2004 00:07:37 -0000       1.41
+++ image.c     8 Apr 2004 18:33:41 -0000       1.42
@@ -21,10 +21,18 @@
 _im_down_cb(void *data, Evas * evas, Evas_Object * obj, void *ev)
 {
    Entice_Image *im = NULL;
+   Evas_Event_Mouse_Down *e = NULL;
+   Evas_Coord ox = 0.0, oy = 0.0;
 
    if ((im = evas_object_smart_data_get((Evas_Object *) data)))
    {
-      im->dragging = 1;
+      if ((e = (Evas_Event_Mouse_Down *) ev))
+      {
+         evas_object_geometry_get(im->obj, &ox, &oy, NULL, NULL);
+         im->mouse.dragging = 1;
+         im->mouse.off_x = e->canvas.x - ox;
+         im->mouse.off_y = e->canvas.y - oy;
+      }
    }
 }
 static void
@@ -34,7 +42,8 @@
 
    if ((im = evas_object_smart_data_get((Evas_Object *) data)))
    {
-      im->dragging = 0;
+      im->mouse.dragging = 0;
+      im->mouse.off_x = im->mouse.off_y = 0.0;
    }
 }
 static void
@@ -42,28 +51,31 @@
 {
    Entice_Image *im = NULL;
    Evas_Coord dx = 0.0, dy = 0.0;
+   Evas_Coord ox = 0.0, oy = 0.0;
    Evas_Coord ww = 0.0, hh = 0.0;
+   Evas_Coord idx = 0.0, idy = 0.0;
    Evas_Event_Mouse_Move *e = NULL;
 
    if ((im = evas_object_smart_data_get((Evas_Object *) data)))
    {
-      if (im->dragging)
+      if (im->mouse.dragging)
       {
          if ((e = (Evas_Event_Mouse_Move *) ev))
          {
-            dx = e->cur.canvas.x - e->prev.canvas.x;
-            dy = e->cur.canvas.y - e->prev.canvas.y;
             ww = im->iw / im->zoom;
             hh = im->ih / im->zoom;
-            /* get the offset alignment */
-            if (ww > im->w)
-               im->align.x -= (double) dx / (double) ww;
-            else
-               im->align.x += (double) dx / (double) ww;
-            if (hh > im->h)
-               im->align.y -= (double) dy / (double) hh;
-            else
-               im->align.y += (double) dy / (double) hh;
+            evas_object_geometry_get(im->obj, &ox, &oy, NULL, NULL);
+            evas_object_move(im->obj, e->cur.canvas.x - im->mouse.off_x,
+                             e->cur.canvas.y - im->mouse.off_y);
+            evas_object_geometry_get(im->obj, &ox, &oy, NULL, NULL);
+            idx = (ww - (double) im->w);
+            idy = (hh - (double) im->h);
+            if (idx == 0.0)
+               idx = 1.0;
+            if (idy == 0.0)
+               idy = 1.0;
+            im->align.x = ((double) im->x - ox) / idx;
+            im->align.y = ((double) im->y - oy) / idy;
 
             /* keep it bounded */
             if (im->align.x < 0.0)
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/entice/src/bin/image.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -3 -r1.22 -r1.23
--- image.h     8 Apr 2004 00:07:37 -0000       1.22
+++ image.h     8 Apr 2004 18:33:42 -0000       1.23
@@ -36,8 +36,13 @@
    int fit;
    int quality;                 /* int value for saving quality */
    double zoom;                 /* the current zoom percentage */
-   int button;                  /* the drag button */
-   int dragging;                /* whether we're currently dragging */
+   struct
+   {
+      int button;               /* the drag button */
+      int dragging;             /* whether we're currently dragging */
+      Evas_Coord off_x, off_y;
+   } mouse;
+
    struct
    {
       double x, y;




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to