Edje calc: Fix Evas Text width calculation with ellipsis 45/83945/3
authorYoungbok Shin <youngb.shin@samsung.com>
Tue, 12 Jul 2016 01:20:03 +0000 (10:20 +0900)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Thu, 18 Aug 2016 13:14:40 +0000 (06:14 -0700)
Summary:
To keep consistency with Evas Textblock part in edje,
text.min has to work logically even if ellipsis is enabled.
If a Text part has minimum width, maximum width and "text.min: 1 X;",
Text part should be expanded until its width reaches to the maximum width.
Then, ellipsis will work. Singleline Textblock is also working like this.
@fix

Reviewers: cedric, herdsman, raster, tasn

Subscribers: Blackmole, z-wony, jpeg

Differential Revision: https://phab.enlightenment.org/D3587

Conflicts:
src/lib/edje/edje_text.c

Change-Id: Id2fac23c01364d78ef8c50b3559e66252b50489c

src/bin/edje/edje_cc_handlers.c
src/lib/edje/edje_calc.c
src/lib/edje/edje_text.c

index ade4c08..d1c1937 100644 (file)
@@ -14103,19 +14103,6 @@ edje_cc_handlers_hierarchy_free(void)
    part_hierarchy = NULL;
 }
 
-static Eina_Bool
-_part_text_ellipsis_check(Edje_Part *ep, Edje_Part_Description_Common *desc)
-{
-   Edje_Part_Description_Text *ed;
-
-   if ((ep->type != EDJE_PART_TYPE_TEXT) && (ep->type != EDJE_PART_TYPE_TEXTBLOCK))
-     return EINA_FALSE;
-
-   ed = (Edje_Part_Description_Text*)desc;
-
-   return ((ed->text.ellipsis != -1) && ed->text.min_x);
-}
-
 static void
 edje_cc_handlers_hierarchy_pop(void)
 {  /* Remove part from hierarchy stack when finished parsing it */
@@ -14133,25 +14120,11 @@ edje_cc_handlers_hierarchy_pop(void)
                         file_in, line - 1, current_de->entry, current_part->name);
                     exit(-1);
                }
-             if (_part_text_ellipsis_check(current_part, current_part->other.desc[i]))
-               {
-                  WRN("Part '%s' in group '%s' contains description '%s:%g' which has text.min: 1 X; but not text.ellipsis: -1;",
-                      current_part->name, current_de->entry,
-                      current_part->other.desc[i]->state.name, current_part->other.desc[i]->state.value);
-                  WRN("This is almost certainly not what you want.");
-               }
           }
 
         /* auto-add default desc if it was omitted */
         if (!current_part->default_desc)
           ob_collections_group_parts_part_description();
-        else if (_part_text_ellipsis_check(current_part, current_part->default_desc))
-          {
-             WRN("Part '%s' in group '%s' contains description '%s:%g' which has text.min: 1 X; but not text.ellipsis: -1;",
-                 current_part->name, current_de->entry,
-                 current_part->default_desc->state.name, current_part->default_desc->state.value);
-             WRN("This is almost certainly not what you want.");
-          }
      }
 
    if (info)
index 3f60e49..393689e 100644 (file)
@@ -1722,20 +1722,26 @@ _edje_part_recalc_single_text(FLOAT_T sc EINA_UNUSED,
 
    if (chosen_desc->text.max_x)
      {
-        if ((*maxw < 0) || (mw < *maxw)) *maxw = mw;
+        if ((*maxw < 0) || (mw > *maxw)) *maxw = mw;
      }
    if (chosen_desc->text.max_y)
      {
-        if ((*maxh < 0) || (mh < *maxh)) *maxh = mh;
+        if ((*maxh < 0) || (mh > *maxh)) *maxh = mh;
      }
    if (chosen_desc->text.min_x)
      {
         if (mw > *minw) *minw = mw;
+        if ((*maxw > -1) && (*minw > *maxw)) *minw = *maxw;
      }
    if (chosen_desc->text.min_y)
      {
         if (mh > *minh) *minh = mh;
+        if ((*maxh > -1) && (*minh > *maxh)) *minh = *maxh;
      }
+   if ((*maxw > -1) && (mw > *maxw)) mw = *maxw;
+   if ((*maxh > -1) && (mh > *maxh)) mh = *maxh;
+
+   evas_object_resize(ep->object, mw, mh);
 }
 
 #else
index 1b5d705..74e9e64 100644 (file)
@@ -132,7 +132,7 @@ _edje_text_fit_x(Edje *ed, Edje_Real_Part *ep,
    if (ep->part->scale) evas_object_scale_set(ep->object, TO_DOUBLE(sc));
 
    eo_do(ep->object,
-         evas_obj_text_ellipsis_set(chosen_desc->text.min_x ? -1 : params->type.text.ellipsis),
+         evas_obj_text_ellipsis_set(params->type.text.ellipsis),
          efl_text_properties_font_set(font, size),
          efl_text_set(text),
          efl_gfx_size_set(sw, sh));
@@ -478,28 +478,11 @@ _edje_text_recalc_apply(Edje *ed, Edje_Real_Part *ep,
                                 text, font, size,
                                 sw, sh, &free_text);
      }
-   /* when evas ellipsis support was added in efl 1.8 and used to replace
-    * previous support, SOMEONE, who I shall call "cedric", borked ellipsis
-    * defaults. as a result, edje_cc continued using 0.0 (left-most) as its default value
-    * for ellipsis while evas used -1.0 (no ellipsizing).
-    * this was moderately okay for a time because nobody was using it or GROUP parts
-    * with text in them very frequently, and so nobody noticed that the mismatch was breaking
-    * sizing in some cases when the edje ellipsis value failed to be applied,
-    * which occurred any time text.min_x was set; in this case, ellipsis would NEVER be
-    * correctly applied, and instead the text object would only ever get the first
-    * ellipsis_set(0), permanently breaking the part.
-    * the only way to fix this while preserving previous behavior was to bump
-    * the edje file minor version and then check it here to ignore "unset" ellipsis
-    * values from old file versions.
-    * the downside is that this will break old files which have text.min_x set to 0...maybe.
-    *
-    * -zmike
-    * 22 April 2014
-    */
-   else if (((ed->file->version >= 3) && (ed->file->minor >= 6)) ||
-            params->type.text.ellipsis)
-     evas_object_text_ellipsis_set(ep->object,
-                                   chosen_desc->text.min_x ? -1 : params->type.text.ellipsis);
+   else if ((ed->file->version >= 3) && (ed->file->minor >= 6))
+     {
+        evas_object_text_ellipsis_set(ep->object,
+                                      params->type.text.ellipsis);
+     }
 
    eina_stringshare_replace(&ep->typedata.text->cache.out_str, text);
    ep->typedata.text->cache.in_w = sw;