Evas textblock: Fixed relative items size calculation.
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 21 Jul 2011 12:53:39 +0000 (12:53 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 21 Jul 2011 12:53:39 +0000 (12:53 +0000)
Now they are calculated according to real line height, and not just line
height before this point. Furthermore, this also fixes some issues with
wrapping not being correct.

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@61557 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/canvas/evas_object_textblock.c

index 0951fe5..254be3b 100644 (file)
@@ -2381,38 +2381,16 @@ _layout_calculate_format_item_size(const Evas_Object *obj,
  * @param add_line true if we should create a line, false otherwise.
  */
 static void
-_layout_line_finalize(Ctxt *c, Evas_Object_Textblock_Format *fmt)
+_layout_line_finalize(Ctxt *c, Evas_Object_Textblock_Format *fmt __UNUSED__)
 {
    Evas_Object_Textblock_Item *it;
-   Eina_Bool no_text = EINA_TRUE;
    Evas_Coord x = 0;
 
-   c->maxascent = c->maxdescent = 0;
+   /* Adjust all the item sizes according to the final line size,
+    * and update the x positions of all the items of the line. */
    EINA_INLIST_FOREACH(c->ln->items, it)
      {
-        if (it->type == EVAS_TEXTBLOCK_ITEM_TEXT)
-          {
-             Evas_Object_Textblock_Text_Item *ti = _ITEM_TEXT(it);
-             _layout_format_ascent_descent_adjust(c->obj, &c->maxascent,
-                   &c->maxdescent, ti->parent.format);
-             no_text = EINA_FALSE;
-             break;
-          }
-     }
-
-   if (no_text)
-      _layout_format_ascent_descent_adjust(c->obj, &c->maxascent,
-            &c->maxdescent, fmt);
-
-   EINA_INLIST_FOREACH(c->ln->items, it)
-     {
-        if (it->type == EVAS_TEXTBLOCK_ITEM_TEXT)
-          {
-             Evas_Object_Textblock_Text_Item *ti = _ITEM_TEXT(it);
-             _layout_format_ascent_descent_adjust(c->obj, &c->maxascent,
-                   &c->maxdescent, ti->parent.format);
-          }
-        else
+        if (it->type == EVAS_TEXTBLOCK_ITEM_FORMAT)
           {
              Evas_Object_Textblock_Format_Item *fi = _ITEM_FORMAT(it);
              if (!fi->formatme) goto loop_advance;
@@ -3556,6 +3534,23 @@ _layout_par(Ctxt *c)
              continue;
           }
 
+        if (it->type == EVAS_TEXTBLOCK_ITEM_TEXT)
+          {
+             Evas_Object_Textblock_Text_Item *ti = _ITEM_TEXT(it);
+             _layout_format_ascent_descent_adjust(c->obj, &c->maxascent,
+                   &c->maxdescent, ti->parent.format);
+          }
+        else
+          {
+             Evas_Object_Textblock_Format_Item *fi = _ITEM_FORMAT(it);
+             if (fi->formatme)
+               {
+                  _layout_calculate_format_item_size(c->obj, fi, &c->maxascent,
+                        &c->maxdescent, &fi->y, &fi->parent.w, &fi->parent.h);
+                  fi->parent.adv = fi->parent.w;
+               }
+          }
+
 
         /* Check if we need to wrap, i.e the text is bigger than the width,
            or we already found a wrap point. */