summaryrefslogtreecommitdiff
path: root/src/lib/elementary/efl_ui_text.c
diff options
context:
space:
mode:
authorDaniel Hirt <hirt.danny@gmail.com>2018-11-12 15:09:56 +0200
committerDaniel Hirt <hirt.danny@gmail.com>2018-11-26 13:17:07 +0200
commit3e5616b3467d2cc2e5b52d2bb234f28c7d72e9bc (patch)
tree327f54a73bc3f794307285814b736d6495c4da5e /src/lib/elementary/efl_ui_text.c
parentacee09f5851903a7e16e1507766718ea22a266c8 (diff)
Ui text scroller: add usage of a guide
Diffstat (limited to '')
-rw-r--r--src/lib/elementary/efl_ui_text.c54
1 files changed, 39 insertions, 15 deletions
diff --git a/src/lib/elementary/efl_ui_text.c b/src/lib/elementary/efl_ui_text.c
index 5af9e75213..5d65791a3a 100644
--- a/src/lib/elementary/efl_ui_text.c
+++ b/src/lib/elementary/efl_ui_text.c
@@ -33,6 +33,8 @@ struct _Efl_Ui_Text_Data
33 Evas_Object *mgf_clip; 33 Evas_Object *mgf_clip;
34 Evas_Object *mgf_proxy; 34 Evas_Object *mgf_proxy;
35 Eo *text_obj; 35 Eo *text_obj;
36 Eo *text_guide_obj;
37 Eo *text_table;
36 Eo *pan; 38 Eo *pan;
37 Eo *scroller; 39 Eo *scroller;
38 Eo *manager; 40 Eo *manager;
@@ -831,10 +833,9 @@ _cursor_geometry_recalc(Evas_Object *obj)
831 edje_object_size_min_restricted_calc(sd->cursor, &cw, NULL, cw, 0); 833 edje_object_size_min_restricted_calc(sd->cursor, &cw, NULL, cw, 0);
832 evas_object_geometry_get(sd->entry_edje, &x, &y, &w, &h); 834 evas_object_geometry_get(sd->entry_edje, &x, &y, &w, &h);
833 evas_object_geometry_get( 835 evas_object_geometry_get(
834 edje_object_part_swallow_get(sd->entry_edje, "efl.text"), 836 sd->text_obj,
835 &x2, &y2, &w2, &h2); 837 &x2, &y2, &w2, &h2);
836 cx = cx + x - x2; 838
837 cy = cy + y - y2;
838 efl_ui_scrollable_scroll(sd->scroller, EINA_RECT(cx, cy, cw, ch), EINA_FALSE); 839 efl_ui_scrollable_scroll(sd->scroller, EINA_RECT(cx, cy, cw, ch), EINA_FALSE);
839 840
840} 841}
@@ -946,7 +947,7 @@ _efl_ui_text_efl_ui_focus_object_on_focus_update(Eo *obj, Efl_Ui_Text_Data *sd)
946 } 947 }
947 else 948 else
948 { 949 {
949 Eo *sw = edje_object_part_swallow_get(sd->entry_edje, "efl.text"); 950 Eo *sw = sd->text_obj;
950 951
951 _edje_signal_emit(sd, "efl,action,unfocus", "efl"); 952 _edje_signal_emit(sd, "efl,action,unfocus", "efl");
952 if (sd->scroll) 953 if (sd->scroll)
@@ -1970,6 +1971,20 @@ _cb_deleted(void *data EINA_UNUSED, const Efl_Event *ev)
1970 1971
1971} 1972}
1972 1973
1974static void
1975_update_guide_text(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd)
1976{
1977 const char *txt;
1978 Eina_Bool show_guide;
1979
1980 txt = efl_text_get(sd->text_obj);
1981
1982 show_guide = (!txt || (txt[0] == '\0'));
1983
1984 efl_gfx_entity_visible_set(sd->text_guide_obj, show_guide);
1985
1986}
1987
1973EOLIAN static Eo * 1988EOLIAN static Eo *
1974_efl_ui_text_efl_object_constructor(Eo *obj, Efl_Ui_Text_Data *sd) 1989_efl_ui_text_efl_object_constructor(Eo *obj, Efl_Ui_Text_Data *sd)
1975{ 1990{
@@ -1985,6 +2000,8 @@ _efl_ui_text_efl_object_constructor(Eo *obj, Efl_Ui_Text_Data *sd)
1985 2000
1986 text_obj = efl_add(EFL_UI_INTERNAL_TEXT_INTERACTIVE_CLASS, obj); 2001 text_obj = efl_add(EFL_UI_INTERNAL_TEXT_INTERACTIVE_CLASS, obj);
1987 sd->text_obj = text_obj; 2002 sd->text_obj = text_obj;
2003 sd->text_guide_obj = efl_add(EFL_CANVAS_TEXT_CLASS, obj);
2004 sd->text_table = efl_add(EFL_UI_TABLE_CLASS, obj);
1988 efl_composite_attach(obj, text_obj); 2005 efl_composite_attach(obj, text_obj);
1989 2006
1990 sd->entry_edje = wd->resize_obj; 2007 sd->entry_edje = wd->resize_obj;
@@ -2032,9 +2049,17 @@ _efl_ui_text_efl_object_finalize(Eo *obj,
2032 efl_text_normal_color_set(sd->text_obj, 255, 255, 255, 255); 2049 efl_text_normal_color_set(sd->text_obj, 255, 255, 255, 255);
2033 sd->single_line = !efl_text_multiline_get(sd->text_obj); 2050 sd->single_line = !efl_text_multiline_get(sd->text_obj);
2034 2051
2035 sd->item_fallback_factory = efl_add(EFL_UI_TEXT_FACTORY_FALLBACK_CLASS, obj); 2052 efl_text_set(sd->text_obj, "");
2053 efl_pack_table(sd->text_table, sd->text_obj, 0, 0, 1, 1);
2054 efl_pack_table(sd->text_table, sd->text_guide_obj, 0, 0, 1, 1);
2055
2056 //edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_obj);
2057 //edje_object_part_swallow(sd->entry_edje, "efl.text_guide", sd->text_guide_obj);
2058 edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_table);
2059
2060 _update_guide_text(obj, sd);
2036 2061
2037 edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_obj); 2062 sd->item_fallback_factory = efl_add(EFL_UI_TEXT_FACTORY_FALLBACK_CLASS, obj);
2038 2063
2039 evas_object_size_hint_weight_set 2064 evas_object_size_hint_weight_set
2040 (sd->entry_edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); 2065 (sd->entry_edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -2441,14 +2466,12 @@ _efl_ui_text_scrollable_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Eina_Bool
2441 2466
2442 if (scroll) 2467 if (scroll)
2443 { 2468 {
2444 efl_ref(sd->text_obj);
2445 sd->scroller = efl_add(EFL_UI_INTERNAL_TEXT_SCROLLER_CLASS, obj);
2446 efl_ui_scrollbar_bar_mode_set(sd->scroller, EFL_UI_SCROLLBAR_MODE_AUTO, EFL_UI_SCROLLBAR_MODE_AUTO);
2447 efl_content_set(sd->scroller, sd->text_obj);
2448
2449 edje_object_part_swallow(sd->entry_edje, "efl.text", NULL); 2469 edje_object_part_swallow(sd->entry_edje, "efl.text", NULL);
2470 sd->scroller = efl_add(EFL_UI_INTERNAL_TEXT_SCROLLER_CLASS, obj,
2471 efl_ui_internal_text_scroller_initialize(efl_added,
2472 sd->text_obj, sd->text_table));
2473 efl_ui_scrollbar_bar_mode_set(sd->scroller, EFL_UI_SCROLLBAR_MODE_AUTO, EFL_UI_SCROLLBAR_MODE_AUTO);
2450 edje_object_part_swallow(sd->entry_edje, "efl.text", sd->scroller); 2474 edje_object_part_swallow(sd->entry_edje, "efl.text", sd->scroller);
2451 efl_ui_internal_text_scroller_text_object_set(sd->scroller, sd->text_obj);
2452 evas_object_clip_set(sd->cursor, 2475 evas_object_clip_set(sd->cursor,
2453 efl_ui_internal_text_scroller_viewport_clip_get(sd->scroller)); 2476 efl_ui_internal_text_scroller_viewport_clip_get(sd->scroller));
2454 efl_event_callback_add(sd->scroller, EFL_GFX_ENTITY_EVENT_RESIZE, 2477 efl_event_callback_add(sd->scroller, EFL_GFX_ENTITY_EVENT_RESIZE,
@@ -2457,8 +2480,7 @@ _efl_ui_text_scrollable_set(Eo *obj EINA_UNUSED, Efl_Ui_Text_Data *sd, Eina_Bool
2457 else 2480 else
2458 { 2481 {
2459 efl_content_set(sd->scroller, NULL); 2482 efl_content_set(sd->scroller, NULL);
2460 edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_obj); 2483 edje_object_part_swallow(sd->entry_edje, "efl.text", sd->text_table);
2461 efl_unref(sd->text_obj);
2462 efl_del(sd->scroller); 2484 efl_del(sd->scroller);
2463 sd->scroller = NULL; 2485 sd->scroller = NULL;
2464 } 2486 }
@@ -3258,7 +3280,7 @@ _decoration_create(Eo *obj, Efl_Ui_Text_Data *sd,
3258 evas_object_smart_member_add(ret, sd->entry_edje); 3280 evas_object_smart_member_add(ret, sd->entry_edje);
3259 if (above) 3281 if (above)
3260 { 3282 {
3261 evas_object_stack_above(ret, sd->text_obj); 3283 evas_object_stack_above(ret, sd->text_table);
3262 } 3284 }
3263 else 3285 else
3264 { 3286 {
@@ -3758,6 +3780,7 @@ _efl_ui_text_changed_cb(void *data, const Efl_Event *event EINA_UNUSED)
3758 EFL_UI_TEXT_DATA_GET(data, sd); 3780 EFL_UI_TEXT_DATA_GET(data, sd);
3759 sd->text_changed = EINA_TRUE; 3781 sd->text_changed = EINA_TRUE;
3760 sd->cursor_update = EINA_TRUE; 3782 sd->cursor_update = EINA_TRUE;
3783 _update_guide_text(data, sd);
3761 elm_layout_sizing_eval(data); 3784 elm_layout_sizing_eval(data);
3762 _decoration_defer(data); 3785 _decoration_defer(data);
3763} 3786}
@@ -3770,6 +3793,7 @@ _efl_ui_text_changed_user_cb(void *data, const Efl_Event *event)
3770 if (efl_invalidated_get(event->object)) return; 3793 if (efl_invalidated_get(event->object)) return;
3771 EFL_UI_TEXT_DATA_GET(obj, sd); 3794 EFL_UI_TEXT_DATA_GET(obj, sd);
3772 sd->text_changed = EINA_TRUE; 3795 sd->text_changed = EINA_TRUE;
3796 _update_guide_text(data, sd);
3773 elm_layout_sizing_eval(obj); 3797 elm_layout_sizing_eval(obj);
3774 _decoration_defer_all(obj); 3798 _decoration_defer_all(obj);
3775} 3799}