summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2013-09-30 16:15:16 +0100
committerTom Hacohen <tom@stosb.com>2013-09-30 16:15:16 +0100
commitbb84a01f7ce9d04b8d9ea9e14f8480f44b8449e1 (patch)
tree1d7511f2a1c51a8369e0d1e052051f7bff683dd6
parentad89985d41af1a53d8c8b129544ba808df50b5d7 (diff)
Evas textblock: Moved relayout checks to a function.
This cleans up the code a bit and makes it a bit simpler.
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c152
1 files changed, 40 insertions, 112 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index e0aff4d4ef..ce34a1cdfe 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -5309,6 +5309,23 @@ _relayout(const Evas_Object *eo_obj)
5309 o->redraw = 1; 5309 o->redraw = 1;
5310} 5310}
5311 5311
5312/*
5313 * @internal
5314 * Check if the object needs a relayout, and if so, execute it.
5315 */
5316static inline void
5317_relayout_if_needed(Evas_Object *eo_obj, const Evas_Object_Textblock *o)
5318{
5319 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS);
5320
5321 evas_object_textblock_coords_recalc(eo_obj, obj, obj->private_data);
5322 if (!o->formatted.valid)
5323 {
5324 LYDBG("ZZ: relayout\n");
5325 _relayout(eo_obj);
5326 }
5327}
5328
5312/** 5329/**
5313 * @internal 5330 * @internal
5314 * Find the layout item and line that match the text node and position passed. 5331 * Find the layout item and line that match the text node and position passed.
@@ -5326,14 +5343,8 @@ _find_layout_item_line_match(Evas_Object *eo_obj, Evas_Object_Textblock_Node_Tex
5326 Evas_Object_Textblock_Paragraph *found_par; 5343 Evas_Object_Textblock_Paragraph *found_par;
5327 Evas_Object_Textblock_Line *ln; 5344 Evas_Object_Textblock_Line *ln;
5328 Evas_Object_Textblock *o = eo_data_scope_get(eo_obj, MY_CLASS); 5345 Evas_Object_Textblock *o = eo_data_scope_get(eo_obj, MY_CLASS);
5329 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS);
5330 5346
5331 evas_object_textblock_coords_recalc(eo_obj, obj, obj->private_data); 5347 _relayout_if_needed(eo_obj, o);
5332 if (!o->formatted.valid)
5333 {
5334 LYDBG("ZZ: relayout 1\n");
5335 _relayout(eo_obj);
5336 }
5337 5348
5338 found_par = n->par; 5349 found_par = n->par;
5339 if (found_par) 5350 if (found_par)
@@ -7443,14 +7454,8 @@ evas_textblock_cursor_line_char_first(Evas_Textblock_Cursor *cur)
7443 if (!cur) return; 7454 if (!cur) return;
7444 TB_NULL_CHECK(cur->node); 7455 TB_NULL_CHECK(cur->node);
7445 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS); 7456 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS);
7446 Evas_Object_Protected_Data *obj = eo_data_scope_get(cur->obj, EVAS_OBJ_CLASS);
7447 7457
7448 evas_object_textblock_coords_recalc(cur->obj, obj, obj->private_data); 7458 _relayout_if_needed(cur->obj, o);
7449 if (!o->formatted.valid)
7450 {
7451 LYDBG("ZZ: relayout 2\n");
7452 _relayout(cur->obj);
7453 }
7454 7459
7455 _find_layout_item_match(cur, &ln, &it); 7460 _find_layout_item_match(cur, &ln, &it);
7456 7461
@@ -7483,14 +7488,8 @@ evas_textblock_cursor_line_char_last(Evas_Textblock_Cursor *cur)
7483 if (!cur) return; 7488 if (!cur) return;
7484 TB_NULL_CHECK(cur->node); 7489 TB_NULL_CHECK(cur->node);
7485 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS); 7490 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS);
7486 Evas_Object_Protected_Data *obj = eo_data_scope_get(cur->obj, EVAS_OBJ_CLASS);
7487 7491
7488 evas_object_textblock_coords_recalc(cur->obj, obj, obj->private_data); 7492 _relayout_if_needed(cur->obj, o);
7489 if (!o->formatted.valid)
7490 {
7491 LYDBG("ZZ: relayout 3\n");
7492 _relayout(cur->obj);
7493 }
7494 7493
7495 _find_layout_item_match(cur, &ln, &it); 7494 _find_layout_item_match(cur, &ln, &it);
7496 7495
@@ -8028,14 +8027,8 @@ evas_textblock_cursor_line_set(Evas_Textblock_Cursor *cur, int line)
8028 if (!cur) return EINA_FALSE; 8027 if (!cur) return EINA_FALSE;
8029 8028
8030 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS); 8029 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS);
8031 Evas_Object_Protected_Data *obj = eo_data_scope_get(cur->obj, EVAS_OBJ_CLASS);
8032 8030
8033 evas_object_textblock_coords_recalc(cur->obj, obj, obj->private_data); 8031 _relayout_if_needed(cur->obj, o);
8034 if (!o->formatted.valid)
8035 {
8036 LYDBG("ZZ: relayout 4\n");
8037 _relayout(cur->obj);
8038 }
8039 8032
8040 ln = _find_layout_line_num(cur->obj, line); 8033 ln = _find_layout_line_num(cur->obj, line);
8041 if (!ln) return EINA_FALSE; 8034 if (!ln) return EINA_FALSE;
@@ -9287,14 +9280,8 @@ evas_textblock_cursor_geometry_bidi_get(const Evas_Textblock_Cursor *cur, Evas_C
9287{ 9280{
9288 if (!cur) return EINA_FALSE; 9281 if (!cur) return EINA_FALSE;
9289 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS); 9282 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS);
9290 Evas_Object_Protected_Data *obj = eo_data_scope_get(cur->obj, EVAS_OBJ_CLASS);
9291 9283
9292 evas_object_textblock_coords_recalc(cur->obj, obj, obj->private_data); 9284 _relayout_if_needed(cur->obj, o);
9293 if (!o->formatted.valid)
9294 {
9295 LYDBG("ZZ: relayout 5\n");
9296 _relayout(cur->obj);
9297 }
9298 9285
9299 if (ctype == EVAS_TEXTBLOCK_CURSOR_UNDER) 9286 if (ctype == EVAS_TEXTBLOCK_CURSOR_UNDER)
9300 { 9287 {
@@ -9475,14 +9462,8 @@ evas_textblock_cursor_geometry_get(const Evas_Textblock_Cursor *cur, Evas_Coord
9475 int ret = -1; 9462 int ret = -1;
9476 if (!cur) return -1; 9463 if (!cur) return -1;
9477 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS); 9464 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS);
9478 Evas_Object_Protected_Data *obj = eo_data_scope_get(cur->obj, EVAS_OBJ_CLASS);
9479 9465
9480 evas_object_textblock_coords_recalc(cur->obj, obj, obj->private_data); 9466 _relayout_if_needed(cur->obj, o);
9481 if (!o->formatted.valid)
9482 {
9483 LYDBG("ZZ: relayout 6\n");
9484 _relayout(cur->obj);
9485 }
9486 9467
9487 if (ctype == EVAS_TEXTBLOCK_CURSOR_UNDER) 9468 if (ctype == EVAS_TEXTBLOCK_CURSOR_UNDER)
9488 { 9469 {
@@ -9549,14 +9530,8 @@ _evas_textblock_cursor_char_pen_geometry_common_get(int (*query_func) (void *dat
9549 9530
9550 if (!cur) return -1; 9531 if (!cur) return -1;
9551 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS); 9532 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS);
9552 Evas_Object_Protected_Data *obj = eo_data_scope_get(cur->obj, EVAS_OBJ_CLASS);
9553 9533
9554 evas_object_textblock_coords_recalc(cur->obj, obj, obj->private_data); 9534 _relayout_if_needed(cur->obj, o);
9555 if (!o->formatted.valid)
9556 {
9557 LYDBG("ZZ: relayout 7\n");
9558 _relayout(cur->obj);
9559 }
9560 9535
9561 if (!cur->node) 9536 if (!cur->node)
9562 { 9537 {
@@ -9685,14 +9660,9 @@ evas_textblock_cursor_line_geometry_get(const Evas_Textblock_Cursor *cur, Evas_C
9685 9660
9686 if (!cur) return -1; 9661 if (!cur) return -1;
9687 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS); 9662 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS);
9688 Evas_Object_Protected_Data *obj = eo_data_scope_get(cur->obj, EVAS_OBJ_CLASS);
9689 9663
9690 evas_object_textblock_coords_recalc(cur->obj, obj, obj->private_data); 9664 _relayout_if_needed(cur->obj, o);
9691 if (!o->formatted.valid) 9665
9692 {
9693 LYDBG("ZZ: relayout 8\n");
9694 _relayout(cur->obj);
9695 }
9696 if (!cur->node) 9666 if (!cur->node)
9697 { 9667 {
9698 ln = o->paragraphs->lines; 9668 ln = o->paragraphs->lines;
@@ -9741,14 +9711,9 @@ evas_textblock_cursor_char_coord_set(Evas_Textblock_Cursor *cur, Evas_Coord x, E
9741 9711
9742 if (!cur) return EINA_FALSE; 9712 if (!cur) return EINA_FALSE;
9743 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS); 9713 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS);
9744 Evas_Object_Protected_Data *obj = eo_data_scope_get(cur->obj, EVAS_OBJ_CLASS);
9745 9714
9746 evas_object_textblock_coords_recalc(cur->obj, obj, obj->private_data); 9715 _relayout_if_needed(cur->obj, o);
9747 if (!o->formatted.valid) 9716
9748 {
9749 LYDBG("ZZ: relayout 9\n");
9750 _relayout(cur->obj);
9751 }
9752 x += o->style_pad.l; 9717 x += o->style_pad.l;
9753 y += o->style_pad.t; 9718 y += o->style_pad.t;
9754 9719
@@ -9855,14 +9820,9 @@ evas_textblock_cursor_line_coord_set(Evas_Textblock_Cursor *cur, Evas_Coord y)
9855 9820
9856 if (!cur) return -1; 9821 if (!cur) return -1;
9857 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS); 9822 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS);
9858 Evas_Object_Protected_Data *obj = eo_data_scope_get(cur->obj, EVAS_OBJ_CLASS);
9859 9823
9860 evas_object_textblock_coords_recalc(cur->obj, obj, obj->private_data); 9824 _relayout_if_needed(cur->obj, o);
9861 if (!o->formatted.valid) 9825
9862 {
9863 LYDBG("ZZ: relayout 10\n");
9864 _relayout(cur->obj);
9865 }
9866 y += o->style_pad.t; 9826 y += o->style_pad.t;
9867 9827
9868 found_par = _layout_find_paragraph_by_y(o, y); 9828 found_par = _layout_find_paragraph_by_y(o, y);
@@ -10250,14 +10210,9 @@ evas_textblock_cursor_range_geometry_get(const Evas_Textblock_Cursor *cur1, cons
10250 if (!cur2 || !cur2->node) return NULL; 10210 if (!cur2 || !cur2->node) return NULL;
10251 if (cur1->obj != cur2->obj) return NULL; 10211 if (cur1->obj != cur2->obj) return NULL;
10252 Evas_Object_Textblock *o = eo_data_scope_get(cur1->obj, MY_CLASS); 10212 Evas_Object_Textblock *o = eo_data_scope_get(cur1->obj, MY_CLASS);
10253 Evas_Object_Protected_Data *obj = eo_data_scope_get(cur1->obj, EVAS_OBJ_CLASS);
10254 10213
10255 evas_object_textblock_coords_recalc(cur1->obj, obj, obj->private_data); 10214 _relayout_if_needed(cur1->obj, o);
10256 if (!o->formatted.valid) 10215
10257 {
10258 LYDBG("ZZ: relayout 11\n");
10259 _relayout(cur1->obj);
10260 }
10261 if (evas_textblock_cursor_compare(cur1, cur2) > 0) 10216 if (evas_textblock_cursor_compare(cur1, cur2) > 0)
10262 { 10217 {
10263 const Evas_Textblock_Cursor *tc; 10218 const Evas_Textblock_Cursor *tc;
@@ -10327,14 +10282,9 @@ evas_textblock_cursor_format_item_geometry_get(const Evas_Textblock_Cursor *cur,
10327 10282
10328 if (!cur || !evas_textblock_cursor_format_is_visible_get(cur)) return EINA_FALSE; 10283 if (!cur || !evas_textblock_cursor_format_is_visible_get(cur)) return EINA_FALSE;
10329 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS); 10284 Evas_Object_Textblock *o = eo_data_scope_get(cur->obj, MY_CLASS);
10330 Evas_Object_Protected_Data *obj = eo_data_scope_get(cur->obj, EVAS_OBJ_CLASS);
10331 10285
10332 evas_object_textblock_coords_recalc(cur->obj, obj, obj->private_data); 10286 _relayout_if_needed(cur->obj, o);
10333 if (!o->formatted.valid) 10287
10334 {
10335 LYDBG("ZZ: relayout 12\n");
10336 _relayout(cur->obj);
10337 }
10338 if (!evas_textblock_cursor_format_is_visible_get(cur)) return EINA_FALSE; 10288 if (!evas_textblock_cursor_format_is_visible_get(cur)) return EINA_FALSE;
10339 _find_layout_item_line_match(cur->obj, cur->node, cur->pos, &ln, &it); 10289 _find_layout_item_line_match(cur->obj, cur->node, cur->pos, &ln, &it);
10340 fi = _ITEM_FORMAT(it); 10290 fi = _ITEM_FORMAT(it);
@@ -10457,14 +10407,9 @@ _textblock_size_formatted_get(Eo *eo_obj, void *_pd, va_list *list)
10457 const Evas_Object_Textblock *o = _pd; 10407 const Evas_Object_Textblock *o = _pd;
10458 Evas_Coord *w = va_arg(*list, Evas_Coord *); 10408 Evas_Coord *w = va_arg(*list, Evas_Coord *);
10459 Evas_Coord *h = va_arg(*list, Evas_Coord *); 10409 Evas_Coord *h = va_arg(*list, Evas_Coord *);
10460 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS);
10461 10410
10462 evas_object_textblock_coords_recalc(eo_obj, obj, obj->private_data); 10411 _relayout_if_needed(eo_obj, o);
10463 if (!o->formatted.valid) 10412
10464 {
10465 LYDBG("ZZ: relayout 13\n");
10466 _relayout(eo_obj);
10467 }
10468 if (w) *w = o->formatted.w; 10413 if (w) *w = o->formatted.w;
10469 if (h) *h = o->formatted.h; 10414 if (h) *h = o->formatted.h;
10470} 10415}
@@ -10628,14 +10573,8 @@ _textblock_size_native_get(Eo *eo_obj, void *_pd, va_list *list)
10628 Textblock_Position position = TEXTBLOCK_POSITION_START; 10573 Textblock_Position position = TEXTBLOCK_POSITION_START;
10629 /* We just want the layout objects to update, should probably 10574 /* We just want the layout objects to update, should probably
10630 * split that. */ 10575 * split that. */
10631 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS); 10576 _relayout_if_needed(eo_obj, o);
10632 10577
10633 evas_object_textblock_coords_recalc(eo_obj, obj, obj->private_data);
10634 if (!o->formatted.valid)
10635 {
10636 LYDBG("ZZ: relayout 14\n");
10637 _relayout(eo_obj);
10638 }
10639 EINA_INLIST_FOREACH(o->paragraphs, par) 10578 EINA_INLIST_FOREACH(o->paragraphs, par)
10640 { 10579 {
10641 Evas_Coord tw, th; 10580 Evas_Coord tw, th;
@@ -10670,14 +10609,9 @@ _textblock_style_insets_get(Eo *eo_obj, void *_pd, va_list *list)
10670 Evas_Coord *r = va_arg(*list, Evas_Coord *); 10609 Evas_Coord *r = va_arg(*list, Evas_Coord *);
10671 Evas_Coord *t = va_arg(*list, Evas_Coord *); 10610 Evas_Coord *t = va_arg(*list, Evas_Coord *);
10672 Evas_Coord *b = va_arg(*list, Evas_Coord *); 10611 Evas_Coord *b = va_arg(*list, Evas_Coord *);
10673 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS);
10674 10612
10675 evas_object_textblock_coords_recalc(eo_obj, obj, obj->private_data); 10613 _relayout_if_needed(eo_obj, o);
10676 if (!o->formatted.valid) 10614
10677 {
10678 LYDBG("ZZ: relayout 15\n");
10679 _relayout(eo_obj);
10680 }
10681 if (l) *l = o->style_pad.l; 10615 if (l) *l = o->style_pad.l;
10682 if (r) *r = o->style_pad.r; 10616 if (r) *r = o->style_pad.r;
10683 if (t) *t = o->style_pad.t; 10617 if (t) *t = o->style_pad.t;
@@ -11436,14 +11370,8 @@ _evas_textblock_check_item_node_link(Evas_Object *eo_obj)
11436 Evas_Object_Textblock_Item *it; 11370 Evas_Object_Textblock_Item *it;
11437 11371
11438 if (!o) return EINA_FALSE; 11372 if (!o) return EINA_FALSE;
11439 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJ_CLASS);
11440 11373
11441 evas_object_textblock_coords_recalc(eo_obj, obj, obj->private_data); 11374 _relayout_if_needed(eo_obj, o);
11442 if (!o->formatted.valid)
11443 {
11444 LYDBG("ZZ: relayout 17\n");
11445 _relayout(eo_obj);
11446 }
11447 11375
11448 EINA_INLIST_FOREACH(o->paragraphs, par) 11376 EINA_INLIST_FOREACH(o->paragraphs, par)
11449 { 11377 {