From c31fc46a46162839eed9d613916b0a559100ea58 Mon Sep 17 00:00:00 2001 From: tasn Date: Sun, 8 May 2011 11:20:13 +0000 Subject: [PATCH] Evas textblock: Move ellipsis handling to a different function. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@59272 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/canvas/evas_object_textblock.c | 140 +++++++++++++++++---------------- 1 file changed, 74 insertions(+), 66 deletions(-) diff --git a/src/lib/canvas/evas_object_textblock.c b/src/lib/canvas/evas_object_textblock.c index 01871e3..2950c34 100644 --- a/src/lib/canvas/evas_object_textblock.c +++ b/src/lib/canvas/evas_object_textblock.c @@ -3214,6 +3214,79 @@ _layout_ellipsis_item_new(Ctxt *c, const Evas_Object_Textblock_Item *cur_it) return ellip_ti; } +/** + * @internel + * Handle ellipsis + */ +static inline void +_layout_handle_ellipsis(Ctxt *c, Evas_Object_Textblock_Item *it, Eina_List *i) +{ + Evas_Object_Textblock_Text_Item *ellip_ti, *last_ti; + Evas_Object_Textblock_Item *last_it; + Evas_Coord save_cx; + int wrap; + ellip_ti = _layout_ellipsis_item_new(c, it); + last_it = it; + last_ti = _ITEM_TEXT(it); + + save_cx = c->x; + c->w -= ellip_ti->parent.w; + do + { + wrap = _layout_text_cutoff_get(c, last_it->format, + last_ti); + if ((wrap > 0) && !IS_AT_END(last_ti, (size_t) wrap)) + { + _layout_item_text_split_strip_white(c, last_ti, i, wrap); + } + else if (wrap == 0) + { + if (!c->ln->items) + break; + /* We haven't added it yet at this point */ + if (_ITEM(last_ti) != it) + { + last_it = + _ITEM(EINA_INLIST_GET(last_it)->prev); + c->ln->items = _ITEM(eina_inlist_remove( + EINA_INLIST_GET(c->ln->items), + EINA_INLIST_GET(_ITEM(last_ti)))); + } + else + { + last_it = + _ITEM(EINA_INLIST_GET(c->ln->items)->last); + } + last_ti = _ITEM_TEXT(last_it); + if (last_it) + { + c->x -= last_it->adv; + } + } + } + while (last_it && (wrap == 0)); + c->x = save_cx; + c->w += ellip_ti->parent.w; + /* If we should add this item, do it */ + if (last_it == it) + { + c->ln->items = (Evas_Object_Textblock_Item *) + eina_inlist_append(EINA_INLIST_GET(c->ln->items), + EINA_INLIST_GET(it)); + if (it->type == EVAS_TEXTBLOCK_ITEM_FORMAT) + { + Evas_Object_Textblock_Format_Item *fi; + fi = _ITEM_FORMAT(it); + fi->y = c->y; + } + } + c->ln->items = (Evas_Object_Textblock_Item *) + eina_inlist_append(EINA_INLIST_GET(c->ln->items), + EINA_INLIST_GET(_ITEM(ellip_ti))); + c->ln->ellip_ti = ellip_ti; + _layout_line_finalize(c, ellip_ti->parent.format); +} + /* 0 means go ahead, 1 means break without an error, 2 means * break with an error, should probably clean this a bit (enum/macro) * FIXME ^ */ @@ -3310,72 +3383,7 @@ _layout_visualize_par(Ctxt *c) (2 * it->h + c->y > c->h - c->o->style_pad.t - c->o->style_pad.b)) { - Evas_Object_Textblock_Text_Item *ellip_ti, *last_ti; - Evas_Object_Textblock_Item *last_it; - Evas_Coord save_cx; - int wrap; - ellip_ti = _layout_ellipsis_item_new(c, it); - last_it = it; - last_ti = _ITEM_TEXT(it); - - save_cx = c->x; - c->w -= ellip_ti->parent.w; - do - { - wrap = _layout_text_cutoff_get(c, last_it->format, - last_ti); - if ((wrap > 0) && !IS_AT_END(last_ti, (size_t) wrap)) - { - _layout_item_text_split_strip_white(c, last_ti, i, - wrap); - } - else if (wrap == 0) - { - if (!c->ln->items) - break; - /* We haven't added it yet at this point */ - if (_ITEM(last_ti) != it) - { - last_it = - _ITEM(EINA_INLIST_GET(last_it)->prev); - c->ln->items = _ITEM(eina_inlist_remove( - EINA_INLIST_GET(c->ln->items), - EINA_INLIST_GET(_ITEM(last_ti)))); - } - else - { - last_it = - _ITEM(EINA_INLIST_GET(c->ln->items)->last); - } - last_ti = _ITEM_TEXT(last_it); - if (last_it) - { - c->x -= last_it->adv; - } - } - } - while (last_it && (wrap == 0)); - c->x = save_cx; - c->w += ellip_ti->parent.w; - /* If we should add this item, do it */ - if (last_it == it) - { - c->ln->items = (Evas_Object_Textblock_Item *) - eina_inlist_append(EINA_INLIST_GET(c->ln->items), - EINA_INLIST_GET(it)); - if (it->type == EVAS_TEXTBLOCK_ITEM_FORMAT) - { - Evas_Object_Textblock_Format_Item *fi; - fi = _ITEM_FORMAT(it); - fi->y = c->y; - } - } - c->ln->items = (Evas_Object_Textblock_Item *) - eina_inlist_append(EINA_INLIST_GET(c->ln->items), - EINA_INLIST_GET(_ITEM(ellip_ti))); - c->ln->ellip_ti = ellip_ti; - _layout_line_finalize(c, ellip_ti->parent.format); - + _layout_handle_ellipsis(c, it, i); ret = 1; goto end; } -- 2.7.4