summaryrefslogtreecommitdiff
path: root/src/lib/evas
diff options
context:
space:
mode:
authorYoungbok Shin <youngb.shin@samsung.com>2017-11-06 11:29:43 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-11-06 11:29:43 +0900
commita386597ad92a1022ba41f94afdb28bdf9136d551 (patch)
treeccc6a2f33b40c5de147eb811565f9cd03c639bba /src/lib/evas
parentbb4d158ca38edaf73fd490e30814c5a085649f34 (diff)
evas textblock: handle ellipsis when text's height exceed its area by "br"
Summary: Textblock's ellipsis feature only worked when text's width exceeds its area. So, it didn't work when text's height exceeds its area by "br" tags. This patch will do ellipsis when only ellipsis=1.0 is set. @fix Test Plan: make check Reviewers: herdsman, raster, cedric, jpeg, sohyun Reviewed By: raster Subscribers: woohyun Differential Revision: https://phab.enlightenment.org/D5412
Diffstat (limited to 'src/lib/evas')
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c104
1 files changed, 103 insertions, 1 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index ea0a4ffb69..c311b58909 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -2904,6 +2904,7 @@ struct _Ctxt
2904 Evas_Textblock_Align_Auto align_auto : 2; 2904 Evas_Textblock_Align_Auto align_auto : 2;
2905 Eina_Bool width_changed : 1; 2905 Eina_Bool width_changed : 1;
2906 Eina_Bool handle_obstacles : 1; 2906 Eina_Bool handle_obstacles : 1;
2907 Eina_Bool vertical_ellipsis : 1; /**<EINA_TRUE if needs vertical ellipsis, else EINA_FALSE. */
2907}; 2908};
2908 2909
2909static void _layout_text_add_logical_item(Ctxt *c, Evas_Object_Textblock_Text_Item *ti, Eina_List *rel); 2910static void _layout_text_add_logical_item(Ctxt *c, Evas_Object_Textblock_Text_Item *ti, Eina_List *rel);
@@ -3922,6 +3923,35 @@ loop_advance:
3922 } 3923 }
3923 } 3924 }
3924 3925
3926 /* Check current line's height is acceptable or not */
3927 if ((fmt->ellipsis == 1.0) &&
3928 (c->h > 0) && (c->y + c->ln->h > c->h))
3929 {
3930 /* No text is shown when the object height is smaller than actual font size's height.
3931 * Vertical ellipsis is not handled if the object has only one line. */
3932 if ((EINA_INLIST_GET(c->paragraphs) != EINA_INLIST_GET(c->par)) ||
3933 EINA_INLIST_GET(c->par->lines) != EINA_INLIST_GET(c->ln))
3934 {
3935 if (((c->position == TEXTBLOCK_POSITION_START) ||
3936 (c->position == TEXTBLOCK_POSITION_SINGLE))
3937 && (c->maxascent > c->ascent))
3938 c->y -= c->o->style_pad.t;
3939
3940 /* Remove current line */
3941 c->par->lines = (Evas_Object_Textblock_Line *)eina_inlist_remove(
3942 EINA_INLIST_GET(c->par->lines), EINA_INLIST_GET(c->ln));
3943
3944 if (c->o->ellip_ti && (_ITEM(c->o->ellip_ti)->ln == c->ln))
3945 _ITEM(c->o->ellip_ti)->ln = NULL;
3946
3947 _line_free(c->ln);
3948 c->ln = NULL;
3949 c->vertical_ellipsis = EINA_TRUE;
3950
3951 return;
3952 }
3953 }
3954
3925 c->ln->baseline = c->ascent; 3955 c->ln->baseline = c->ascent;
3926 /* FIXME: Actually needs to be adjusted using the actual font value. 3956 /* FIXME: Actually needs to be adjusted using the actual font value.
3927 * Also, underline_extend is actually not being used. */ 3957 * Also, underline_extend is actually not being used. */
@@ -3997,7 +4027,9 @@ _layout_line_advance(Ctxt *c, Evas_Object_Textblock_Format *fmt)
3997 last_fmt = _ITEM(EINA_INLIST_GET(c->ln->items)->last)->format; 4027 last_fmt = _ITEM(EINA_INLIST_GET(c->ln->items)->last)->format;
3998 } 4028 }
3999 _layout_line_finalize(c, last_fmt); 4029 _layout_line_finalize(c, last_fmt);
4000 _layout_line_new(c, fmt); 4030
4031 if (!c->vertical_ellipsis)
4032 _layout_line_new(c, fmt);
4001} 4033}
4002 4034
4003/** 4035/**
@@ -5903,6 +5935,13 @@ _layout_par(Ctxt *c)
5903 else 5935 else
5904 { 5936 {
5905 _layout_line_advance(c, it->format); 5937 _layout_line_advance(c, it->format);
5938
5939 if (c->vertical_ellipsis)
5940 {
5941 ret = 1;
5942 goto end;
5943 }
5944
5906 item_preadv = EINA_FALSE; 5945 item_preadv = EINA_FALSE;
5907 } 5946 }
5908 } 5947 }
@@ -5954,6 +5993,12 @@ _layout_par(Ctxt *c)
5954 it = _ITEM(eina_list_data_get(i)); 5993 it = _ITEM(eina_list_data_get(i));
5955 } 5994 }
5956 _layout_line_advance(c, it->format); 5995 _layout_line_advance(c, it->format);
5996
5997 if (c->vertical_ellipsis)
5998 {
5999 ret = 1;
6000 goto end;
6001 }
5957 } 6002 }
5958 } 6003 }
5959 6004
@@ -5967,6 +6012,9 @@ _layout_par(Ctxt *c)
5967 6012
5968 /* Here 'it' is the last format used */ 6013 /* Here 'it' is the last format used */
5969 _layout_line_finalize(c, it->format); 6014 _layout_line_finalize(c, it->format);
6015
6016 if (c->vertical_ellipsis)
6017 ret = 1;
5970 } 6018 }
5971 6019
5972end: 6020end:
@@ -6401,6 +6449,59 @@ _layout_visual(Ctxt *c)
6401 /* Clear the rest of the paragraphs and mark as invisible */ 6449 /* Clear the rest of the paragraphs and mark as invisible */
6402 if (c->par) 6450 if (c->par)
6403 { 6451 {
6452 if (c->vertical_ellipsis)
6453 {
6454 c->vertical_ellipsis = EINA_FALSE;
6455
6456 /* If there is no lines, go to the previous paragraph */
6457 if (!c->par->lines)
6458 c->par = (Evas_Object_Textblock_Paragraph *)EINA_INLIST_GET(c->par)->prev;
6459
6460 if (c->par)
6461 {
6462 if (c->par->lines)
6463 c->ln = (Evas_Object_Textblock_Line *)EINA_INLIST_GET(c->par->lines)->last;
6464
6465 if (c->ln && c->ln->items)
6466 {
6467 /* Ellipsize previous line */
6468 Evas_Object_Textblock_Item *last_it, *it;
6469 Eina_List *i;
6470
6471 last_it = _ITEM(EINA_INLIST_GET(c->ln->items)->last);
6472 c->ln->items = (Evas_Object_Textblock_Item *)eina_inlist_remove(
6473 EINA_INLIST_GET(c->ln->items), EINA_INLIST_GET(last_it));
6474 EINA_LIST_FOREACH(c->par->logical_items, i, it)
6475 {
6476 if (last_it == it)
6477 break;
6478 }
6479
6480 /* Reset previous data before ellipsis */
6481 c->y -= c->ln->h;
6482 c->ln->x = c->ln->y = c->ln->w = c->ln->h = 0;
6483 c->ascent = c->descent = 0;
6484 c->maxascent = c->maxdescent = 0;
6485 c->x = last_it->x;
6486#ifdef BIDI_SUPPORT
6487 if (c->par->is_bidi)
6488 _layout_update_bidi_props(c->o, c->par);
6489#endif
6490
6491 _layout_handle_ellipsis(c, last_it, i);
6492
6493#ifdef BIDI_SUPPORT
6494 if (c->par->bidi_props)
6495 {
6496 evas_bidi_paragraph_props_unref(c->par->bidi_props);
6497 c->par->bidi_props = NULL;
6498 }
6499#endif
6500 }
6501 last_vis_par = c->par;
6502 }
6503 }
6504
6404 c->par = (Evas_Object_Textblock_Paragraph *) 6505 c->par = (Evas_Object_Textblock_Paragraph *)
6405 EINA_INLIST_GET(c->par)->next; 6506 EINA_INLIST_GET(c->par)->next;
6406 while (c->par) 6507 while (c->par)
@@ -6502,6 +6603,7 @@ _layout_setup(Ctxt *c, const Eo *eo_obj, Evas_Coord w, Evas_Coord h)
6502 c->w = w; 6603 c->w = w;
6503 c->h = h; 6604 c->h = h;
6504 c->style_pad.r = c->style_pad.l = c->style_pad.t = c->style_pad.b = 0; 6605 c->style_pad.r = c->style_pad.l = c->style_pad.t = c->style_pad.b = 0;
6606 c->vertical_ellipsis = EINA_FALSE;
6505 6607
6506 /* Update all obstacles */ 6608 /* Update all obstacles */
6507 if (c->o->obstacle_changed || c->width_changed) 6609 if (c->o->obstacle_changed || c->width_changed)