Enlightenment CVS committal

Author  : atmosphere
Project : e17
Module  : proto

Dir     : e17/proto/esmart/src/container/layout/engage


Modified Files:
        engage.c 


Log Message:
fix mouse grabber events, and indent
===================================================================
RCS file: 
/cvsroot/enlightenment/e17/proto/esmart/src/container/layout/engage/engage.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- engage.c    29 Apr 2004 06:18:28 -0000      1.1
+++ engage.c    29 Apr 2004 06:30:17 -0000      1.2
@@ -4,59 +4,65 @@
 #include "../../Esmart_Container.h"
 
 Evas_Object *grabber = NULL;
-int _container_scroll_timer(void *data);
+int _container_scroll_timer (void *data);
 
 void
-_engage_mouse_grabber_mouse_move_cb(void *data, Evas *evas, Evas_Object *obj, void 
*ev)
+_engage_mouse_grabber_mouse_move_cb (void *data, Evas * evas,
+                                    Evas_Object * obj, void *ev)
 {
-    fprintf(stderr, "Mouse move area\n");
+  fprintf (stderr, "Mouse move area\n");
 }
+
 void
-_engage_mouse_grabber_mouse_in_cb(void *data, Evas *evas, Evas_Object *obj, void *ev)
+_engage_mouse_grabber_mouse_in_cb (void *data, Evas * evas, Evas_Object * obj,
+                                  void *ev)
 {
-    fprintf(stderr, "Mouse in area\n");
+  fprintf (stderr, "Mouse in area\n");
 }
+
 void
-_engage_mouse_grabber_mouse_out_cb(void *data, Evas *evas, Evas_Object *obj, void *ev)
+_engage_mouse_grabber_mouse_out_cb (void *data, Evas * evas,
+                                   Evas_Object * obj, void *ev)
 {
-    fprintf(stderr, "Mouse out area\n");
+  fprintf (stderr, "Mouse out area\n");
 }
 
 void
-_engage_grabber_init(Container *cont)
+_engage_grabber_init (Container * cont)
 {
-    Evas_Object *obj = NULL;
-    obj = evas_object_rectangle_add(cont->evas);
-    evas_object_color_set(obj, 255, 255, 255, 0);
-    evas_object_layer_set(obj, 9999);
-    evas_object_repeat_events_set(obj, 1);
-    evas_object_show(obj);
-
-    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_IN,
-                               _engage_mouse_grabber_mouse_in_cb,
-                               cont);
-    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_OUT,
-                               _engage_mouse_grabber_mouse_out_cb,
-                               cont);
-    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE,
-                               _engage_mouse_grabber_mouse_move_cb,
-                               cont);
+  Evas_Object *obj = NULL;
+  obj = evas_object_rectangle_add (cont->evas);
+  evas_object_color_set (obj, 255, 255, 255, 0);
+  evas_object_layer_set (obj, 9999);
+  evas_object_repeat_events_set (obj, 1);
+  evas_object_show (obj);
+
+  evas_object_event_callback_add (obj, EVAS_CALLBACK_MOUSE_IN,
+                                 _engage_mouse_grabber_mouse_in_cb, cont);
+  evas_object_event_callback_add (obj, EVAS_CALLBACK_MOUSE_OUT,
+                                 _engage_mouse_grabber_mouse_out_cb, cont);
+  evas_object_event_callback_add (obj, EVAS_CALLBACK_MOUSE_MOVE,
+                                 _engage_mouse_grabber_mouse_move_cb, cont);
+  grabber = obj;
 }
+
 void
-_engage_layout(Container *cont)
+_engage_layout (Container * cont)
 {
   Evas_List *l;
-  double ax, ay, aw, ah; // element area geom
-  double ix, iy, iw, ih; // new x, y, w, h
-  double L; // length of all objects at original size (for nonhomog)
-  int num; // number of elements
+  double ax, ay, aw, ah;       // element area geom
+  double ix, iy, iw, ih;       // new x, y, w, h
+  double L;                    // length of all objects at original size (for 
nonhomog)
+  int num;                     // number of elements
   double error = 0;
-  int r,g,b;
+  int r, g, b;
 
   /* FIXME: add a 'changed' flag to prevent excessive recalcs */
-  if(!grabber)
-      _engage_grabber_init(cont);
-  
+  if (!grabber)
+    _engage_grabber_init (cont);
+
+  evas_object_move (grabber, cont->x, cont->y);
+  evas_object_resize (grabber, cont->w, cont->h);
 //  evas_object_geometry_get(cont->grabber, &ax, &ay, &aw, &ah);
   ax = cont->x;
   ay = cont->y;
@@ -75,228 +81,235 @@
   ix = ax;
   iy = ay;
 
-  if (cont->direction) iy += cont->scroll_offset;
-  else ix += cont->scroll_offset;
+  if (cont->direction)
+    iy += cont->scroll_offset;
+  else
+    ix += cont->scroll_offset;
 
-  L = esmart_container_elements_orig_length_get(cont->obj);
-  num = evas_list_count(cont->elements);
-  
-  
-  evas_object_color_get(cont->clipper, &r, &g, &b, NULL);
+  L = esmart_container_elements_orig_length_get (cont->obj);
+  num = evas_list_count (cont->elements);
 
-  for (l = cont->elements; l; l = l->next)
-  {
-    Container_Element *el = l->data;
-    Evas_Coord ew, eh; // old element size
 
-    if(!el)
+  evas_object_color_get (cont->clipper, &r, &g, &b, NULL);
+
+  for (l = cont->elements; l; l = l->next)
     {
-      continue;
-    }
-    evas_object_geometry_get(el->obj, NULL, NULL, &ew, &eh);
-    if (ew == 0) ew = el->orig_w;
-    if (eh == 0) eh = el->orig_h;
+      Container_Element *el = l->data;
+      Evas_Coord ew, eh;       // old element size
 
-    evas_object_resize(el->grabber, ew, eh);
+      if (!el)
+       {
+         continue;
+       }
+      evas_object_geometry_get (el->obj, NULL, NULL, &ew, &eh);
+      if (ew == 0)
+       ew = el->orig_w;
+      if (eh == 0)
+       eh = el->orig_h;
+
+      evas_object_resize (el->grabber, ew, eh);
+
+      /* vertical */
+      if (cont->direction)
+       {
+         if (cont->fill & CONTAINER_FILL_POLICY_FILL)
+           {
+             iw = aw;
+
+             if (cont->fill & CONTAINER_FILL_POLICY_HOMOGENOUS)
+               ih = (ah - cont->spacing * (num - 1)) / num;
+             else
+               ih = el->orig_h * (ah - cont->spacing * (num - 1)) / L;
+
+           }
+         else if (cont->fill & CONTAINER_FILL_POLICY_FILL_X)
+           {
+             if (cont->fill & CONTAINER_FILL_POLICY_KEEP_ASPECT)
+               {
+                 iw = aw;
+                 ih = eh * iw / ew;
+               }
+             else
+               {
+                 iw = aw;
+                 ih = eh;
+               }
+           }
+         else if (cont->fill & CONTAINER_FILL_POLICY_FILL_Y)
+           {
+             if (cont->fill & CONTAINER_FILL_POLICY_HOMOGENOUS)
+               ih = (ah - cont->spacing * (num - 1)) / num;
+             else
+               ih = el->orig_h * (ah - cont->spacing * (num - 1)) / L;
+
+             if (cont->fill & CONTAINER_FILL_POLICY_KEEP_ASPECT)
+               iw = ew * ih / eh;
+             else
+               iw = ew;
+           }
+         else
+           {
+             iw = ew;
+             ih = eh;
+           }
+
+         if (cont->align == CONTAINER_ALIGN_LEFT)
+           ix = ax;
+         else if (cont->align == CONTAINER_ALIGN_CENTER)
+           ix = ax + (aw - iw) / 2;
+         else if (cont->align == CONTAINER_ALIGN_RIGHT)
+           ix = ax + aw - iw;
+
+         evas_object_move (el->obj, ix, iy);
+         evas_object_resize (el->obj, iw, ih);
+         if (!strcmp (evas_object_type_get (el->obj), "image"))
+           {
+             evas_object_image_fill_set (el->obj, 0, 0, iw, ih);
+           }
+         evas_object_move (el->grabber, ix, iy);
+         evas_object_resize (el->grabber, iw, ih);
 
-    /* vertical */
-    if (cont->direction)
-    {
-      if (cont->fill & CONTAINER_FILL_POLICY_FILL)
-      {
-        iw = aw;
-
-        if (cont->fill & CONTAINER_FILL_POLICY_HOMOGENOUS)
-          ih = (ah - cont->spacing * (num - 1) ) / num;
-        else
-          ih = el->orig_h * (ah - cont->spacing * (num - 1) ) / L;
-          
-      }
-      else if (cont->fill & CONTAINER_FILL_POLICY_FILL_X)
-      {
-        if (cont->fill & CONTAINER_FILL_POLICY_KEEP_ASPECT)
-        {
-          iw = aw;
-          ih = eh * iw/ew;
-        }
-        else
-        {
-          iw = aw;
-          ih = eh;
-        }
-      }
-      else if (cont->fill & CONTAINER_FILL_POLICY_FILL_Y)
-      {
-        if (cont->fill & CONTAINER_FILL_POLICY_HOMOGENOUS)
-          ih = (ah - cont->spacing * (num - 1) ) / num;
-        else
-          ih = el->orig_h * (ah - cont->spacing * (num - 1) ) / L;
-
-        if (cont->fill & CONTAINER_FILL_POLICY_KEEP_ASPECT)
-          iw = ew * ih/eh;
-        else
-          iw = ew;
-      }
+         iy += ih + cont->spacing;
+       }
+
+      /* horizontal */
       else
-      {
-        iw = ew;
-        ih = eh;
-      }
-
-      if (cont->align == CONTAINER_ALIGN_LEFT)
-        ix = ax;
-      else if (cont->align == CONTAINER_ALIGN_CENTER)
-        ix = ax + (aw - iw) / 2;
-      else if (cont->align == CONTAINER_ALIGN_RIGHT)
-        ix = ax + aw - iw;
-
-      evas_object_move(el->obj, ix, iy);
-      evas_object_resize(el->obj, iw, ih);
-      if (!strcmp(evas_object_type_get(el->obj), "image"))
-      {
-        evas_object_image_fill_set(el->obj, 0, 0, iw, ih);
-      }
-      evas_object_move(el->grabber, ix, iy);
-      evas_object_resize(el->grabber, iw, ih);
+       {
+         if (cont->fill & CONTAINER_FILL_POLICY_FILL)
+           {
+             //printf("fill\n");
+             ih = ah;
+
+             if (cont->fill & CONTAINER_FILL_POLICY_HOMOGENOUS)
+               iw = (aw - cont->spacing * (num - 1)) / num;
+             else
+               {
+                 //printf("nonhomog\n");
+                 iw = el->orig_w * (aw - cont->spacing * (num - 1)) / L;
+               }
+           }
+         else if (cont->fill & CONTAINER_FILL_POLICY_FILL_X)
+           {
+             //printf("fill x\n");
+
+             if (cont->fill & CONTAINER_FILL_POLICY_HOMOGENOUS)
+               {
+                 //printf ("homog\n");
+                 iw = (aw - cont->spacing * (num - 1)) / num;
+               }
+             else
+               {
+                 //printf("nonhomog - L: %f, ew: %f\n", L, ew);
+                 iw = el->orig_w * (aw - cont->spacing * (num - 1)) / L;
+               }
+
+             if (cont->fill & CONTAINER_FILL_POLICY_KEEP_ASPECT)
+               ih = eh * iw / ew;
+             else
+               ih = eh;
+           }
+         else if (cont->fill & CONTAINER_FILL_POLICY_FILL_Y)
+           {
+             if (cont->fill & CONTAINER_FILL_POLICY_KEEP_ASPECT)
+               {
+                 ih = ah;
+                 iw = ew * ih / eh;
+               }
+             else
+               {
+                 ih = ah;
+                 iw = ew;
+               }
+           }
+         else
+           {
+             iw = ew;
+             ih = eh;
+           }
+
+         if (cont->align == CONTAINER_ALIGN_TOP)
+           iy = ay;
+         else if (cont->align == CONTAINER_ALIGN_CENTER)
+           iy = ay + (ah - ih) / 2;
+         else if (cont->align == CONTAINER_ALIGN_BOTTOM)
+           iy = ay + ah - ih;
+
+         /* make sure that the elements fill the container exactly */
+         if (error >= 1)
+           {
+             iw++;
+             error -= 1;
+           }
+         else if (error <= -1)
+           {
+             iw--;
+             error += 1;
+           }
+
+         error += iw - (int) iw;
+
+         iw = (int) iw;
+
+         evas_object_move (el->obj, ix, iy);
+         evas_object_resize (el->obj, iw, ih);
+         if (!strcmp (evas_object_type_get (el->obj), "image"))
+           {
+             evas_object_image_fill_set (el->obj, 0, 0, iw, ih);
+           }
+         evas_object_move (el->grabber, ix, iy);
+         evas_object_resize (el->grabber, iw, ih);
+         ix += iw + cont->spacing;
+       }
 
-      iy += ih + cont->spacing;
-    }
 
-    /* horizontal */
-    else
-    {
-      if (cont->fill & CONTAINER_FILL_POLICY_FILL)
-      {
-        //printf("fill\n");
-        ih = ah;
-        
-        if (cont->fill & CONTAINER_FILL_POLICY_HOMOGENOUS)
-          iw = (aw - cont->spacing * (num - 1) ) / num;
-        else
-        {
-          //printf("nonhomog\n");
-          iw = el->orig_w * (aw - cont->spacing * (num - 1) ) / L;
-        }
-      }
-      else if (cont->fill & CONTAINER_FILL_POLICY_FILL_X)
-      {
-        //printf("fill x\n");
-
-        if (cont->fill & CONTAINER_FILL_POLICY_HOMOGENOUS)
-        {
-          //printf ("homog\n");
-          iw = (aw - cont->spacing * (num - 1) ) / num;
-        }
-        else
-        {
-          //printf("nonhomog - L: %f, ew: %f\n", L, ew);
-          iw = el->orig_w * (aw - cont->spacing * (num - 1) ) / L;
-        }
-
-        if (cont->fill & CONTAINER_FILL_POLICY_KEEP_ASPECT)
-          ih = eh * iw/ew;
-        else
-          ih = eh;
-      }
-      else if (cont->fill & CONTAINER_FILL_POLICY_FILL_Y)
-      {
-        if (cont->fill & CONTAINER_FILL_POLICY_KEEP_ASPECT)
-        {
-          ih = ah;
-          iw = ew * ih/eh;
-        }
-        else
-        {
-          ih = ah;
-          iw = ew;
-        }
-      }
-      else
-      {
-        iw = ew;
-        ih = eh;
-      }
-
-      if (cont->align == CONTAINER_ALIGN_TOP)
-        iy = ay;
-      else if (cont->align == CONTAINER_ALIGN_CENTER)
-        iy = ay + (ah - ih) / 2;
-      else if (cont->align == CONTAINER_ALIGN_BOTTOM)
-        iy = ay + ah - ih;
-
-      /* make sure that the elements fill the container exactly */
-      if (error >= 1)
-      {
-        iw++;
-        error -= 1;
-      }
-      else if (error <= -1)
-      {
-        iw--;
-        error += 1;
-      }
-
-      error += iw - (int)iw; 
-
-      iw = (int)iw;
-
-      evas_object_move(el->obj, ix, iy);
-      evas_object_resize(el->obj, iw, ih);
-      if (!strcmp(evas_object_type_get(el->obj), "image"))
-      {
-        evas_object_image_fill_set(el->obj, 0, 0, iw, ih);
-      }
-      evas_object_move(el->grabber, ix, iy);
-      evas_object_resize(el->grabber, iw, ih);
-      ix += iw + cont->spacing;
+      evas_object_geometry_get (el->obj, NULL, NULL, &ew, &eh);
+      evas_object_resize (el->grabber, ew, eh);
     }
-
-   
-    evas_object_geometry_get(el->obj, NULL, NULL, &ew, &eh);
-    evas_object_resize(el->grabber, ew, eh);
-  }
 }
 
-void _engage_scroll_start(Container *cont, double velocity)
+void
+_engage_scroll_start (Container * cont, double velocity)
 {
   Scroll_Data *data;
   double length, size;
 
-  length = esmart_container_elements_length_get(cont->obj);
+  length = esmart_container_elements_length_get (cont->obj);
   size = cont->direction ? cont->h : cont->w;
 
   /* don't scroll unless the elements exceed the size of the container */
   if (length <= size)
-  {
-    printf(" length smaller than size\n");
-    return;
-  }
-  data = calloc(1, sizeof(Scroll_Data));
+    {
+      printf (" length smaller than size\n");
+      return;
+    }
+  data = calloc (1, sizeof (Scroll_Data));
   data->velocity = velocity;
-  data->start_time = ecore_time_get();
+  data->start_time = ecore_time_get ();
   data->cont = cont;
   data->length = length;
- 
-  cont->scroll_timer = ecore_timer_add(.02, _container_scroll_timer, data);
+
+  cont->scroll_timer = ecore_timer_add (.02, _container_scroll_timer, data);
 }
 
-void _engage_scroll_stop(Container *cont)
+void
+_engage_scroll_stop (Container * cont)
 {
   /* FIXME: decelerate on stop? */
   if (cont->scroll_timer)
-  {
-    ecore_timer_del(cont->scroll_timer);  
-    cont->scroll_timer = NULL;
-  }
+    {
+      ecore_timer_del (cont->scroll_timer);
+      cont->scroll_timer = NULL;
+    }
 }
 
-void _engage_scroll_to(Container *cont, Container_Element *el)
+void
+_engage_scroll_to (Container * cont, Container_Element * el)
 {
   return;
 }
 
 void
-_engage_shutdown()
+_engage_shutdown ()
 {
   return;
 }
@@ -304,33 +317,33 @@
 
 /*** internal plugin functions ***/
 int
-_container_scroll_timer(void *data)
+_container_scroll_timer (void *data)
 {
   Scroll_Data *sd = data;
   double dt, dx, size, pad, max_scroll;
- 
-  dt = ecore_time_get() - sd->start_time;
-  dx = 10 * (1 - exp(-dt)); 
+
+  dt = ecore_time_get () - sd->start_time;
+  dx = 10 * (1 - exp (-dt));
 
   sd->cont->scroll_offset += dx * sd->velocity;
-  
+
   size = sd->cont->direction ? sd->cont->h : sd->cont->w;
   pad = sd->cont->direction ? sd->cont->padding.t + sd->cont->padding.b :
-                              sd->cont->padding.l + sd->cont->padding.r;
+    sd->cont->padding.l + sd->cont->padding.r;
   max_scroll = size - sd->length - pad;
 
   if (sd->cont->scroll_offset < max_scroll)
     sd->cont->scroll_offset = max_scroll;
-  
+
   else if (sd->cont->scroll_offset > 0)
     sd->cont->scroll_offset = 0;
 
-  _engage_layout(sd->cont);
+  _engage_layout (sd->cont);
   return 1;
 }
 
 int
-plugin_init(Container_Layout_Plugin *p)
+plugin_init (Container_Layout_Plugin * p)
 {
   p->layout = _engage_layout;
   p->scroll_start = _engage_scroll_start;
@@ -340,4 +353,3 @@
 
   return 1;
 }
-




-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE. 
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to