Enlightenment CVS committal

Author  : raster
Project : e17
Module  : libs/edje

Dir     : e17/libs/edje/src/lib


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


Log Message:


tilman's edje font metrics patch

===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_data.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -3 -r1.34 -r1.35
--- edje_data.c 9 Oct 2006 06:01:13 -0000       1.34
+++ edje_data.c 30 Mar 2007 23:39:41 -0000      1.35
@@ -345,6 +345,7 @@
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, 
"mouse_events", mouse_events, EET_T_CHAR);
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, 
"repeat_events", repeat_events, EET_T_CHAR);
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "clip_to_id", 
clip_to_id, EET_T_INT);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, 
"use_alternate_font_metrics", use_alternate_font_metrics, EET_T_UCHAR);
    EET_DATA_DESCRIPTOR_ADD_SUB(_edje_edd_edje_part, Edje_Part, "default_desc", 
default_desc, _edje_edd_edje_part_description);
    EET_DATA_DESCRIPTOR_ADD_LIST(_edje_edd_edje_part, Edje_Part, "other_desc", 
other_desc, _edje_edd_edje_part_description);
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "dragable.x", 
dragable.x, EET_T_CHAR);
===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_private.h,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -3 -r1.117 -r1.118
--- edje_private.h      6 Mar 2007 12:03:34 -0000       1.117
+++ edje_private.h      30 Mar 2007 23:39:41 -0000      1.118
@@ -401,6 +401,7 @@
    unsigned char          mouse_events; /* it will affect/respond to mouse 
events */
    unsigned char          repeat_events; /* it will repeat events to objects 
below */
    int                    clip_to_id; /* the part id to clip this one to */   
+   unsigned char  use_alternate_font_metrics;
    Edje_Part_Description *default_desc; /* the part descriptor for default */
    Evas_List             *other_desc; /* other possible descriptors */
    struct {
===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_text.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -3 -r1.57 -r1.58
--- edje_text.c 30 Sep 2006 10:18:31 -0000      1.57
+++ edje_text.c 30 Mar 2007 23:39:41 -0000      1.58
@@ -10,6 +10,31 @@
 #endif
 #include <assert.h>
 
+/* returns with and height for this part.
+ *
+ * depending on the value of the use_alternate_font_metrics flag, it will
+ * either use evas_object_geometry_get() or the _advance_get() functions.
+ *
+ * The latter is useful if you want to make sure that width and height
+ * are the same value for the same number of characters in the text.
+ * This usually only makes sense for monospaced fonts.
+ *
+ * In future changes to this file, you probably should use this wrapper
+ * function everywhere instead of calling evas_object_geometry_get()
+ * directly.
+ */
+static inline void
+part_get_geometry(Edje_Real_Part *rp, Evas_Coord *w, Evas_Coord *h)
+{
+   if (!rp->part->use_alternate_font_metrics)
+     evas_object_geometry_get(rp->object, NULL, NULL, w, h);
+   else
+     {
+       if (w) *w = evas_object_text_horiz_advance_get(rp->object);
+       if (h) *h = evas_object_text_vert_advance_get(rp->object);
+     }
+}
+
 void
 _edje_text_init(void)
 {
@@ -140,7 +165,7 @@
    evas_object_text_font_set(ep->object, font, size);
    evas_object_text_text_set(ep->object, text);
 
-   evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
+   part_get_geometry(ep, &tw, &th);
 
    p = ((sw - tw) * params->text.elipsis);
 
@@ -237,7 +262,7 @@
        _edje_text_fit_set(buf, text, c1, c2);
 
        evas_object_text_text_set(ep->object, buf);
-       evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
+       part_get_geometry(ep, &tw, &th);
      }
 
    *free_text = 1;
@@ -352,7 +377,7 @@
 
        evas_object_text_font_set(ep->object, font, size);
        evas_object_text_text_set(ep->object, text);
-       evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
+       part_get_geometry(ep, &tw, &th);
        if (tw > sw)
          {
             int psize;
@@ -367,7 +392,7 @@
                  else evas_object_text_font_source_set(ep->object, NULL);
                  
                  evas_object_text_font_set(ep->object, font, size);
-                 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
+                 part_get_geometry(ep, &tw, &th);
                  if ((size > 0) && (tw == 0)) break;
               }
          }
@@ -385,7 +410,7 @@
                  else evas_object_text_font_source_set(ep->object, NULL);
                  
                  evas_object_text_font_set(ep->object, font, size);
-                 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
+                 part_get_geometry(ep, &tw, &th);
                  if ((size > 0) && (tw == 0)) break;
               }
          }
@@ -403,7 +428,7 @@
        
        evas_object_text_font_set(ep->object, font, size);
        evas_object_text_text_set(ep->object, text);
-       evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
+       part_get_geometry(ep, &tw, &th);
 
        /* only grow the font size if we didn't already reach the max size
         * for the x axis
@@ -422,7 +447,7 @@
                  else evas_object_text_font_source_set(ep->object, NULL);
                  
                  evas_object_text_font_set(ep->object, font, size);
-                 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
+                 part_get_geometry(ep, &tw, &th);
                  if ((size > 0) && (th == 0)) break;
               }
             size -= dif;
@@ -441,7 +466,7 @@
                  else evas_object_text_font_source_set(ep->object, NULL);
                  
                  evas_object_text_font_set(ep->object, font, size);
-                 evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
+                 part_get_geometry(ep, &tw, &th);
                  if ((size > 0) && (th == 0)) break;
               }
          }
@@ -473,7 +498,7 @@
    
    evas_object_text_font_set(ep->object, font, size);
    evas_object_text_text_set(ep->object, text);
-   evas_object_geometry_get(ep->object, NULL, NULL, &tw, &th);
+   part_get_geometry(ep, &tw, &th);
    ep->offset.x = ((sw - tw) * params->text.align.x);
    ep->offset.y = ((sh - th) * params->text.align.y);
    



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to