summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Alzyod <ali198724@gmail.com>2019-12-13 15:10:32 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2019-12-13 15:10:32 +0900
commit3372a701d301fef9b1d033b97df0f38de130456f (patch)
tree58322c401cfac1fba5dc837f095e9911fbea4c0b
parent181ec112f6cc577c4efc7f7a5550a186bf97c9d3 (diff)
efl_canvas_text: event emitting
Summary: 1- Emitting changed event when adding text using cursors. 2- remove attribute,changed event since it is not used now 3- Emitting layout,finished event when finish layouting Reviewers: woohyun, cedric, bu5hm4n Reviewed By: cedric Subscribers: bu5hm4n, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10834
-rw-r--r--src/lib/evas/canvas/efl_canvas_textblock.eo1
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c37
-rw-r--r--src/tests/evas/evas_test_textblock.c15
3 files changed, 46 insertions, 7 deletions
diff --git a/src/lib/evas/canvas/efl_canvas_textblock.eo b/src/lib/evas/canvas/efl_canvas_textblock.eo
index 5d38ecfe6c..2c00967374 100644
--- a/src/lib/evas/canvas/efl_canvas_textblock.eo
+++ b/src/lib/evas/canvas/efl_canvas_textblock.eo
@@ -558,7 +558,6 @@ class @beta Efl.Canvas.Textblock extends Efl.Canvas.Object implements Efl.Text,
558 } 558 }
559 events { 559 events {
560 changed: void; [[Called when canvas text changed ]] 560 changed: void; [[Called when canvas text changed ]]
561 attributes,changed: void; [[Called when attributes change]]
562 layout,finished: void; [[Called when the object has been layed out]] 561 layout,finished: void; [[Called when the object has been layed out]]
563 style_insets,changed: void; [[Called when the property @.style_insets changed.]] 562 style_insets,changed: void; [[Called when the property @.style_insets changed.]]
564 } 563 }
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index 019af5382d..33458fea98 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -7330,6 +7330,10 @@ _layout_done(Ctxt *c, Evas_Coord *w_ret, Evas_Coord *h_ret)
7330 7330
7331 c->o->obstacle_changed = EINA_FALSE; 7331 c->o->obstacle_changed = EINA_FALSE;
7332 } 7332 }
7333 else
7334 {
7335 efl_event_callback_call(c->obj, EFL_CANVAS_TEXTBLOCK_EVENT_LAYOUT_FINISHED, NULL);
7336 }
7333} 7337}
7334 7338
7335static Eina_Bool 7339static Eina_Bool
@@ -8510,7 +8514,6 @@ _efl_canvas_textblock_efl_text_markup_markup_set(Eo *eo_obj, Efl_Canvas_Textbloc
8510{ 8514{
8511 ASYNC_BLOCK; 8515 ASYNC_BLOCK;
8512 _evas_object_textblock_text_markup_set(eo_obj, o, text); 8516 _evas_object_textblock_text_markup_set(eo_obj, o, text);
8513 efl_event_callback_call(eo_obj, EFL_CANVAS_TEXTBLOCK_EVENT_CHANGED, NULL);
8514} 8517}
8515 8518
8516static void 8519static void
@@ -8525,6 +8528,7 @@ _evas_object_textblock_text_markup_prepend(Eo *eo_obj,
8525 /* Stop calls for _evas_textblock_changed for each cursor_text_append or cursor_format_append 8528 /* Stop calls for _evas_textblock_changed for each cursor_text_append or cursor_format_append
8526 * this should be done once, when markup_prepend finished */ 8529 * this should be done once, when markup_prepend finished */
8527 o->pause_change = EINA_TRUE; 8530 o->pause_change = EINA_TRUE;
8531
8528 if (text) 8532 if (text)
8529 { 8533 {
8530 char *s, *p; 8534 char *s, *p;
@@ -8657,6 +8661,7 @@ _evas_object_textblock_text_markup_prepend(Eo *eo_obj,
8657 p++; 8661 p++;
8658 } 8662 }
8659 } 8663 }
8664
8660 o->pause_change = EINA_FALSE; 8665 o->pause_change = EINA_FALSE;
8661 _evas_textblock_changed(o, eo_obj); 8666 _evas_textblock_changed(o, eo_obj);
8662} 8667}
@@ -11377,7 +11382,7 @@ _evas_textblock_changed(Efl_Canvas_Textblock_Data *o, Evas_Object *eo_obj)
11377 If format changed we need to refit content again. 11382 If format changed we need to refit content again.
11378 If content already fitting then ignore fitting (fitting cause fall to this callback) 11383 If content already fitting then ignore fitting (fitting cause fall to this callback)
11379 */ 11384 */
11380 if (!fit_is_fitting(eo_obj)) 11385 if (!fit_is_fitting(eo_obj) && o->fit_content_config.options != TEXTBLOCK_FIT_MODE_NONE)
11381 { 11386 {
11382 fit_cache_clear(&o->fit_content_config, FIT_CACHE_ALL); 11387 fit_cache_clear(&o->fit_content_config, FIT_CACHE_ALL);
11383 fit_text_block(eo_obj); 11388 fit_text_block(eo_obj);
@@ -11406,6 +11411,7 @@ _evas_textblock_cursor_text_append(Efl_Text_Cursor_Handle *cur, const char *_tex
11406 int len = 0; 11411 int len = 0;
11407 11412
11408 if (!cur) return 0; 11413 if (!cur) return 0;
11414 if (!_text || !(*_text)) return 0;
11409 Evas_Object_Protected_Data *obj = efl_data_scope_get(cur->obj, EFL_CANVAS_OBJECT_CLASS); 11415 Evas_Object_Protected_Data *obj = efl_data_scope_get(cur->obj, EFL_CANVAS_OBJECT_CLASS);
11410 evas_object_async_block(obj); 11416 evas_object_async_block(obj);
11411 text = eina_unicode_utf8_to_unicode(_text, &len); 11417 text = eina_unicode_utf8_to_unicode(_text, &len);
@@ -11465,7 +11471,10 @@ _evas_textblock_cursor_text_append(Efl_Text_Cursor_Handle *cur, const char *_tex
11465 _evas_textblock_cursors_update_offset(cur, cur->node, cur->pos, len); 11471 _evas_textblock_cursors_update_offset(cur, cur->node, cur->pos, len);
11466 11472
11467 if (!o->pause_change) 11473 if (!o->pause_change)
11468 _evas_textblock_changed(o, cur->obj); 11474 {
11475 _evas_textblock_changed(o, cur->obj);
11476 efl_event_callback_call(cur->obj, EFL_CANVAS_TEXTBLOCK_EVENT_CHANGED, NULL);
11477 }
11469 n->dirty = EINA_TRUE; 11478 n->dirty = EINA_TRUE;
11470 free(text); 11479 free(text);
11471 11480
@@ -15654,7 +15663,7 @@ void fit_style_update(Evas_Object *object, int i_font_size, Eina_Bool disable_el
15654 } 15663 }
15655 } 15664 }
15656 15665
15657 _canvas_text_format_changed(object,o); 15666 _canvas_text_format_changed(object,o);
15658} 15667}
15659 15668
15660static void 15669static void
@@ -15806,12 +15815,28 @@ _efl_canvas_textblock_efl_text_text_set(Eo *eo_obj, Efl_Canvas_Textblock_Data *o
15806 const char *text) 15815 const char *text)
15807{ 15816{
15808 ASYNC_BLOCK; 15817 ASYNC_BLOCK;
15818 const char *old_txt = efl_text_get(eo_obj);
15819 Eina_Bool was_empty = (!old_txt || !(*old_txt));
15820
15821 // Nothing to do
15822 if (was_empty && (!text || !(*text)))
15823 return;
15824
15825 /*
15826 * Reduce changed events to one time emit only, in the appending phase
15827 */
15828 efl_event_freeze(eo_obj);
15809 evas_object_textblock_text_markup_set(eo_obj, ""); 15829 evas_object_textblock_text_markup_set(eo_obj, "");
15810 _cursor_text_append(o->cursor, text); 15830 efl_event_thaw(eo_obj);
15831
15832 if (text && *text)
15833 _cursor_text_append(o->cursor, text);
15834 else if(!was_empty)
15835 efl_event_callback_call(eo_obj, EFL_CANVAS_TEXTBLOCK_EVENT_CHANGED, NULL);
15836
15811 if (eo_obj) 15837 if (eo_obj)
15812 { 15838 {
15813 _evas_textblock_changed(o, eo_obj); 15839 _evas_textblock_changed(o, eo_obj);
15814 efl_event_callback_call(eo_obj, EFL_CANVAS_TEXTBLOCK_EVENT_CHANGED, NULL);
15815 } 15840 }
15816} 15841}
15817 15842
diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c
index 1a75153dd9..16fd38f437 100644
--- a/src/tests/evas/evas_test_textblock.c
+++ b/src/tests/evas/evas_test_textblock.c
@@ -4472,11 +4472,20 @@ EFL_START_TEST(efl_text)
4472} 4472}
4473EFL_END_TEST 4473EFL_END_TEST
4474 4474
4475static void
4476_increment_int_changed(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
4477{
4478 int *value = data;
4479 (*value)++;
4480}
4481
4475EFL_START_TEST(efl_canvas_textblock_cursor) 4482EFL_START_TEST(efl_canvas_textblock_cursor)
4476{ 4483{
4477 START_EFL_CANVAS_TEXTBLOCK_TEST(); 4484 START_EFL_CANVAS_TEXTBLOCK_TEST();
4478 int pos; 4485 int pos;
4479 4486
4487 int changed_emit = 0;
4488 efl_event_callback_add(txt, EFL_CANVAS_TEXTBLOCK_EVENT_CHANGED, _increment_int_changed, &changed_emit);
4480 const char *buf = "abcdefghij"; 4489 const char *buf = "abcdefghij";
4481 efl_text_set(txt, buf); 4490 efl_text_set(txt, buf);
4482 fail_if(strcmp(efl_text_get(txt), buf)); 4491 fail_if(strcmp(efl_text_get(txt), buf));
@@ -4501,6 +4510,12 @@ EFL_START_TEST(efl_canvas_textblock_cursor)
4501 pos = efl_text_cursor_position_get(cursor1); 4510 pos = efl_text_cursor_position_get(cursor1);
4502 ck_assert_int_eq(pos, 1); 4511 ck_assert_int_eq(pos, 1);
4503 4512
4513 efl_text_set(txt, "");
4514 efl_text_set(txt, "");
4515 efl_text_cursor_text_insert(cursor1, "aa");
4516
4517 ck_assert_int_eq(changed_emit, 3);
4518
4504 END_EFL_CANVAS_TEXTBLOCK_TEST(); 4519 END_EFL_CANVAS_TEXTBLOCK_TEST();
4505} 4520}
4506EFL_END_TEST 4521EFL_END_TEST