Enlightenment CVS committal

Author  : tsauerbeck
Project : e17
Module  : libs/edje

Dir     : e17/libs/edje/src/lib


Modified Files:
        edje_calc.c 


Log Message:
reduced code duplication
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/edje/src/lib/edje_calc.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -3 -r1.44 -r1.45
--- edje_calc.c 27 Oct 2004 06:07:50 -0000      1.44
+++ edje_calc.c 29 Oct 2004 14:56:27 -0000      1.45
@@ -1,3 +1,7 @@
+/*
+ * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+ */
+
 #include "Edje.h"
 #include "edje_private.h"
 
@@ -42,53 +46,55 @@
    ed->dirty = 1;
 }
 
-void
-_edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, char  *d1, double v1, char 
*d2, double v2)
+Edje_Part_Description *
+_edje_part_description_find(Edje *ed, Edje_Part *ep, char *name,
+                            double val)
 {
-   if (!d1) d1 = "default";
-   if (!d2) d2 = "default";
+   Edje_Part_Description *ret = NULL;
+   Evas_List *l;
+   double min_dst = 999.0;
 
-   if (!strcmp(d1, "default") && (v1 == 0.0))
-     ep->param1.description = ep->part->default_desc;
-   else
+   if (!strcmp(name, "default") && val == 0.0)
+     return ep->default_desc;
+
+   if (!strcmp(name, "default"))
      {
-       Evas_List *l;
-       double min_dst;
-       Edje_Part_Description *desc_found;
+       ret = ep->default_desc;
+       min_dst = ABS(ep->default_desc->state.value - val);
+     }
 
-       desc_found = NULL;
-       min_dst = 999.0;
-       if (!strcmp("default", d1))
-         {
-            desc_found = ep->part->default_desc;
-            min_dst = ep->part->default_desc->state.value - v1;
-            if (min_dst < 0) min_dst = -min_dst;
-         }
-       for (l = ep->part->other_desc; l; l = l->next)
+   for (l = ep->other_desc; l; l = l->next)
+     {
+       Edje_Part_Description *d = l->data;
+
+       if (!strcmp (d->state.name, name))
          {
-            Edje_Part_Description *desc;
-            
-            desc = l->data;
-            if (!strcmp(desc->state.name, d1))
+            double dst;
+
+            dst = ABS(d->state.value - val);
+            if (dst < min_dst)
               {
-                 double dst;
-                 
-                 dst = desc->state.value - v1;
-                 if (dst == 0.0)
-                   {
-                      desc_found = desc;
-                      break;
-                   }
-                 if (dst < 0.0) dst = -dst;
-                 if (dst < min_dst)
-                   {
-                      desc_found = desc;
-                      min_dst = dst;
-                   }
+                 ret = d;
+                 min_dst = dst;
               }
          }
-       ep->param1.description = desc_found;
      }
+
+   return ret;
+}
+
+void
+_edje_part_description_apply(Edje *ed, Edje_Real_Part *ep, char  *d1, double v1, char 
*d2, double v2)
+{
+   if (!d1) d1 = "default";
+   if (!d2) d2 = "default";
+
+   ep->param1.description = _edje_part_description_find(ed, ep->part, d1, v1);
+   if (!ep->param1.description)
+     ep->param1.description = ep->part->default_desc;
+
+   ep->param2.description = _edje_part_description_find(ed, ep->part, d2, v2);
+
    ep->param1.rel1_to_x = NULL;
    ep->param1.rel1_to_y = NULL;
    ep->param1.rel2_to_x = NULL;
@@ -105,49 +111,6 @@
          ep->param1.rel2_to_y = ed->table_parts[ep->param1.description->rel2.id_y % 
ed->table_parts_size];
      }
    
-   if (!strcmp(d2, "default") && (v2 == 0.0))
-     ep->param2.description = ep->part->default_desc;
-   else
-     {
-       Evas_List *l;
-       double min_dst;
-       Edje_Part_Description *desc_found;
-       
-       desc_found = NULL;
-       min_dst = 999.0;
-       if (!strcmp("default", d2))
-         {
-            desc_found = ep->part->default_desc;
-            min_dst = ep->part->default_desc->state.value - v2;
-            if (min_dst < 0) min_dst = -min_dst;
-         }
-       for (l = ep->part->other_desc; l; l = l->next)
-         {
-            Edje_Part_Description *desc;
-            
-            desc = l->data;
-            if (!strcmp(desc->state.name, d2))
-              {
-                 double dst;
-                 
-                 dst = desc->state.value - v2;
-                 if (dst == 0.0)
-                   {
-                      desc_found = desc;
-                      break;
-                   }
-                 if (dst < 0.0) dst = -dst;
-                 if (dst < min_dst)
-                   {
-                      desc_found = desc;
-                      min_dst = dst;
-                   }
-              }
-         }
-       ep->param2.description = desc_found;
-     }
-   if (!ep->param1.description)
-     ep->param1.description = ep->part->default_desc;
    ep->param1.rel1_to_x = NULL;
    ep->param1.rel1_to_y = NULL;
    ep->param1.rel2_to_x = NULL;




-------------------------------------------------------
This Newsletter Sponsored by: Macrovision 
For reliable Linux application installations, use the industry's leading
setup authoring tool, InstallShield X. Learn more and evaluate 
today. http://clk.atdmt.com/MSI/go/ins0030000001msi/direct/01/
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to