Evas textblock: Fixed native size calculation - margins were not used.
authortasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 31 Jan 2012 11:32:48 +0000 (11:32 +0000)
committertasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 31 Jan 2012 11:32:48 +0000 (11:32 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@67631 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/canvas/evas_object_textblock.c
src/tests/evas_test_textblock.c

index 19ea238..53f9a77 100644 (file)
@@ -9062,12 +9062,22 @@ _size_native_calc_line_finalize(const Evas_Object *obj, Eina_List *items,
    Eina_List *i;
 
    it = eina_list_data_get(items);
-   /* If there are no text items yet, calc ascent/descent
-    * according to the current format. */
-   if (it && (*ascent + *descent == 0))
-      _layout_format_ascent_descent_adjust(obj, ascent, descent, it->format);
-
    *w = 0;
+
+   if (it)
+     {
+        /* If there are no text items yet, calc ascent/descent
+         * according to the current format. */
+        if (*ascent + *descent == 0)
+           _layout_format_ascent_descent_adjust(obj, ascent, descent,
+                 it->format);
+
+        /* Add margins. */
+        if (it->format)
+           *w = it->format->margin.l + it->format->margin.r;
+      }
+
+
    /* Adjust all the item sizes according to the final line size,
     * and update the x positions of all the items of the line. */
    EINA_LIST_FOREACH(items, i, it)
index cf6a78b..7413f70 100644 (file)
@@ -2090,6 +2090,29 @@ START_TEST(evas_textblock_size)
    fail_if((w != nw) || (h != nh));
    fail_if(w <= 0);
 
+   /* This time with margins. */
+     {
+        Evas_Textblock_Style *newst;
+        Evas_Coord oldw, oldh, oldnw, oldnh;
+
+        evas_object_textblock_text_markup_set(tb, buf);
+        evas_object_textblock_size_formatted_get(tb, &oldw, &oldh);
+        evas_object_textblock_size_native_get(tb, &oldnw, &oldnh);
+
+
+        newst = evas_textblock_style_new();
+        fail_if(!newst);
+        evas_textblock_style_set(newst,
+              "DEFAULT='left_margin=4 right_margin=4'");
+        evas_object_textblock_style_user_set(tb, newst);
+
+        evas_object_textblock_size_formatted_get(tb, &w, &h);
+        evas_object_textblock_size_native_get(tb, &nw, &nh);
+
+        fail_if((w != oldw + 8) || (h != oldh) ||
+              (nw != oldnw + 8) || (nh != oldnh));
+     }
+
    /* FIXME: There is a lot more to be done. */
    END_TB_TEST();
 }