Enlightenment CVS committal

Author  : rephorm
Project : e17
Module  : libs/edje

Dir     : e17/libs/edje/src/lib


Modified Files:
        edje_calc.c edje_data.c edje_private.h 


Log Message:

add linear gradient specific fill options
used (inside a part description) as follows:

Horizontal from left to right filling entire part:

  gradient {
    spectrum: "black_to_white";
    rel1 {
      relative: 0 0.5;
      offset: 0 0;
    }
    rel2 {
      relative: 1 0.5;
      offset: -1 0;
    }
  }

Diagonal from top left to bottom right:


  gradient {
    spectrum: "black_to_white";
    rel1 {
      relative: 0 0;
      offset: 0 0;
    }
    rel2 {
      relative: 1 1;
      offset: -1 -1;
    }
  }

If either rel1 or rel2 is present in the gradient block of a linear gradient, 
these will override any angle/origin/size specified in the fill block ('spread' 
is still honored).



===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_calc.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -3 -r1.87 -r1.88
--- edje_calc.c 8 Aug 2006 20:25:24 -0000       1.87
+++ edje_calc.c 21 Aug 2006 03:00:01 -0000      1.88
@@ -906,19 +906,69 @@
          }
      }
    /* fill */
-   params->smooth = desc->fill.smooth;
-   if (flags & FLAG_X)
+
+   if (ep->part->type == EDJE_PART_TYPE_GRADIENT && desc->gradient.use_rel && 
(!desc->gradient.type || !strcmp(desc->gradient.type, "linear")))
      {
-       params->fill.x = desc->fill.pos_abs_x + (params->w * 
desc->fill.pos_rel_x);
-       params->fill.w = desc->fill.abs_x + (params->w * desc->fill.rel_x);
+       int x2, y2;
+       int dx, dy;
+       double m;
+       int angle;
+
+       params->fill.x = desc->gradient.rel1.offset_x + (params->w * 
desc->gradient.rel1.relative_x);
+       params->fill.y = desc->gradient.rel1.offset_y + (params->h * 
desc->gradient.rel1.relative_y);
+
+       x2 = desc->gradient.rel2.offset_x + (params->w * 
desc->gradient.rel2.relative_x);
+       y2 = desc->gradient.rel2.offset_y + (params->h * 
desc->gradient.rel2.relative_y);
+
+       params->fill.w = 1; /* doesn't matter for linear grads */
+
+       dy = y2 - params->fill.y;
+       dx = x2 - params->fill.x;
+       params->fill.h = sqrt(dx * dx + dy * dy);
+
+       params->fill.spread = desc->fill.spread;
+
+       if (dx == 0 && dy == 0)
+         {
+            angle = 0;
+         }
+       else if (dx == 0)
+         {
+            if (dy > 0) angle = 0;
+            else angle = 180;
+         }
+       else if (dy == 0)
+         {
+            if (dx > 0) angle = 270;
+            else angle = 90;
+         }
+       else
+         {
+            m = (double)dx / (double)dy;
+            angle = atan(m) * 180 / M_PI;
+            if (dy < 0) 
+              angle = 180 - angle;
+            else
+              angle = 360 - angle;
+         }
+       params->fill.angle = angle;
      }
-   if (flags & FLAG_Y)
+   else
      {
-       params->fill.y = desc->fill.pos_abs_y + (params->h * 
desc->fill.pos_rel_y);
-       params->fill.h = desc->fill.abs_y + (params->h * desc->fill.rel_y);
+       params->smooth = desc->fill.smooth;
+       if (flags & FLAG_X)
+         {
+            params->fill.x = desc->fill.pos_abs_x + (params->w * 
desc->fill.pos_rel_x);
+            params->fill.w = desc->fill.abs_x + (params->w * desc->fill.rel_x);
+         }
+       if (flags & FLAG_Y)
+         {
+            params->fill.y = desc->fill.pos_abs_y + (params->h * 
desc->fill.pos_rel_y);
+            params->fill.h = desc->fill.abs_y + (params->h * desc->fill.rel_y);
+         }
+       params->fill.angle = desc->fill.angle;
+       params->fill.spread = desc->fill.spread;
      }
-   params->fill.angle = desc->fill.angle;
-   params->fill.spread = desc->fill.spread;
    /* colors */
 
    params->color.r = desc->color.r;
===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_data.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -3 -r1.32 -r1.33
--- edje_data.c 2 Aug 2006 10:52:44 -0000       1.32
+++ edje_data.c 21 Aug 2006 03:00:01 -0000      1.33
@@ -322,6 +322,15 @@
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, 
Edje_Part_Description, "text.elipsis", text.elipsis, EET_T_DOUBLE);
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, 
Edje_Part_Description, "gradient.id", gradient.id, EET_T_INT);
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, 
Edje_Part_Description, "gradient.type", gradient.type, EET_T_STRING);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, 
Edje_Part_Description, "gradient.use_rel", gradient.use_rel, EET_T_INT);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, 
Edje_Part_Description, "gradient.rel1.relative_x", gradient.rel1.relative_x, 
EET_T_DOUBLE);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, 
Edje_Part_Description, "gradient.rel1.relative_y", gradient.rel1.relative_y, 
EET_T_DOUBLE);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, 
Edje_Part_Description, "gradient.rel1.offset_x", gradient.rel1.offset_x, 
EET_T_INT);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, 
Edje_Part_Description, "gradient.rel1.offset_y", gradient.rel1.offset_y, 
EET_T_INT);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, 
Edje_Part_Description, "gradient.rel2.relative_x", gradient.rel2.relative_x, 
EET_T_DOUBLE);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, 
Edje_Part_Description, "gradient.rel2.relative_y", gradient.rel2.relative_y, 
EET_T_DOUBLE);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, 
Edje_Part_Description, "gradient.rel2.offset_x", gradient.rel2.offset_x, 
EET_T_INT);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description, 
Edje_Part_Description, "gradient.rel2.offset_y", gradient.rel2.offset_y, 
EET_T_INT);
    
    NEWD("Edje_Part",
        Edje_Part);
===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_private.h,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -3 -r1.113 -r1.114
--- edje_private.h      2 Aug 2006 10:52:44 -0000       1.113
+++ edje_private.h      21 Aug 2006 03:00:01 -0000      1.114
@@ -468,9 +468,16 @@
    } image;
 
    struct {
-     int            id; /* the spectrum id to use */
-     char          *type; /* type of spectrum - 'linear', 'radial', etc */
-     char          *params; /* params for spectrum type */
+      int            id; /* the spectrum id to use */
+      char          *type; /* type of spectrum - 'linear', 'radial', etc */
+      char          *params; /* params for spectrum type */
+      int            use_rel; /* 1 - use rel1,rel2; 0 - use fill */
+      struct {
+         double      relative_x;
+         double      relative_y;
+         int         offset_x;
+         int         offset_y;
+      } rel1, rel2; /* linear gradient fill options */
    } gradient;
    
    struct {



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to