tasn pushed a commit to branch master.

commit 4bcf4991ebf11b3035a89cc53ead459e15966243
Author: Tom Hacohen <[email protected]>
Date:   Mon Aug 19 16:43:31 2013 +0100

    Evas textblock: Fixed calculation of maxdescent.
    
    Thanks to YoungBok Shin for reporting.
---
 src/lib/evas/canvas/evas_object_textblock.c | 33 ++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/src/lib/evas/canvas/evas_object_textblock.c 
b/src/lib/evas/canvas/evas_object_textblock.c
index 6a0f3bc..c9a5b82 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -2460,7 +2460,8 @@ typedef enum
 {
    TEXTBLOCK_POSITION_START,
    TEXTBLOCK_POSITION_END,
-   TEXTBLOCK_POSITION_ELSE
+   TEXTBLOCK_POSITION_ELSE,
+   TEXTBLOCK_POSITION_SINGLE
 } Textblock_Position;
 
 /**
@@ -2581,7 +2582,8 @@ _layout_item_ascent_descent_adjust(const Evas_Object 
*eo_obj,
      {
         void *fi = _ITEM_TEXT(it)->text_props.font_instance;
 
-        if (position == TEXTBLOCK_POSITION_START)
+        if ((position == TEXTBLOCK_POSITION_START) ||
+              (position == TEXTBLOCK_POSITION_SINGLE))
           {
              int asc = 0;
 
@@ -2599,7 +2601,9 @@ _layout_item_ascent_descent_adjust(const Evas_Object 
*eo_obj,
              if (maxascent && (asc > *maxascent))
                 *maxascent = asc;
           }
-        else if (position == TEXTBLOCK_POSITION_END)
+
+        if ((position == TEXTBLOCK_POSITION_END) ||
+              (position == TEXTBLOCK_POSITION_SINGLE))
           {
              int desc = 0;
 
@@ -2615,7 +2619,7 @@ _layout_item_ascent_descent_adjust(const Evas_Object 
*eo_obj,
                      ENFN->font_max_descent_get(ENDT, it->format->font.font);
                }
 
-             if (maxdescent && (desc < *maxdescent))
+             if (maxdescent && (desc > *maxdescent))
                 *maxdescent = desc;
           }
      }
@@ -3259,7 +3263,9 @@ _layout_line_finalize(Ctxt *c, 
Evas_Object_Textblock_Format *fmt)
    Evas_Object_Textblock_Item *it;
    Evas_Coord x = 0;
 
-   c->position = TEXTBLOCK_POSITION_ELSE;
+   if (c->position == TEXTBLOCK_POSITION_START)
+      c->position = TEXTBLOCK_POSITION_ELSE;
+
    /* If there are no text items yet, calc ascent/descent
     * according to the current format. */
    if (c->maxascent + c->maxdescent == 0)
@@ -4298,6 +4304,9 @@ _layout_handle_ellipsis(Ctxt *c, 
Evas_Object_Textblock_Item *it, Eina_List *i)
    c->ln->items = (Evas_Object_Textblock_Item *)
       eina_inlist_append(EINA_INLIST_GET(c->ln->items),
             EINA_INLIST_GET(_ITEM(ellip_ti)));
+
+   c->position = (c->position == TEXTBLOCK_POSITION_START) ?
+      TEXTBLOCK_POSITION_SINGLE : TEXTBLOCK_POSITION_END;
    _layout_line_finalize(c, ellip_ti->parent.format);
 }
 
@@ -4638,8 +4647,15 @@ _layout_par(Ctxt *c)
              _layout_line_advance(c, it->format);
           }
      }
+
    if (c->ln->items)
      {
+        if (c->par && !EINA_INLIST_GET(c->par)->next)
+          {
+             c->position = (c->position == TEXTBLOCK_POSITION_START) ?
+                TEXTBLOCK_POSITION_SINGLE : TEXTBLOCK_POSITION_END;
+          }
+
         /* Here 'it' is the last format used */
         _layout_line_finalize(c, it->format);
      }
@@ -10222,6 +10238,11 @@ _size_native_calc_line_finalize(const Evas_Object 
*eo_obj, Eina_List *items,
              _layout_calculate_format_item_size(eo_obj, fi, ascent,
                    descent, &fy, &fw, &fh);
           }
+        else
+          {
+             _layout_item_ascent_descent_adjust(eo_obj, ascent, descent,
+                   it, position);
+          }
 
 loop_advance:
         *w += it->adv;
@@ -10284,6 +10305,8 @@ _size_native_calc_paragraph_size(const Evas_Object 
*eo_obj,
           }
      }
 
+   *position = (*position == TEXTBLOCK_POSITION_START) ?
+      TEXTBLOCK_POSITION_SINGLE : TEXTBLOCK_POSITION_END;
    _size_native_calc_line_finalize(eo_obj, line_items, &ascent, &descent, &w, 
*position);
 
    line_items = eina_list_free(line_items);

-- 

------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk

Reply via email to