summaryrefslogtreecommitdiff
path: root/src/lib/elementary
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
parentacee09f5851903a7e16e1507766718ea22a266c8 (diff)
Ui text scroller: add usage of a guide
Diffstat (limited to 'src/lib/elementary')
-rw-r--r--src/lib/elementary/efl_ui_internal_text_scroller.c43
-rw-r--r--src/lib/elementary/efl_ui_internal_text_scroller.eo27
-rw-r--r--src/lib/elementary/efl_ui_text.c54
3 files changed, 84 insertions, 40 deletions
diff --git a/src/lib/elementary/efl_ui_internal_text_scroller.c b/src/lib/elementary/efl_ui_internal_text_scroller.c
index bda295a2ec..fa63a9d6ba 100644
--- a/src/lib/elementary/efl_ui_internal_text_scroller.c
+++ b/src/lib/elementary/efl_ui_internal_text_scroller.c
@@ -29,7 +29,8 @@
29 29
30typedef struct _Efl_Ui_Internal_Text_Scroller_Data 30typedef struct _Efl_Ui_Internal_Text_Scroller_Data
31{ 31{
32 Efl_Canvas_Text *content; 32 Efl_Canvas_Text *text_obj;
33 Efl_Ui_Table *text_table;
33 Eo *smanager; 34 Eo *smanager;
34 35
35 Efl_Ui_Text_Scroller_Mode mode; 36 Efl_Ui_Text_Scroller_Mode mode;
@@ -75,9 +76,9 @@ _efl_ui_internal_text_scroller_elm_layout_sizing_eval(Eo *obj,
75 76
76 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 77 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
77 78
78 if (sd->content) 79 if (sd->text_obj)
79 { 80 {
80 efl_gfx_size_hint_weight_get(sd->content, &xw, &yw); 81 efl_gfx_size_hint_weight_get(sd->text_table, &xw, &yw);
81 } 82 }
82 83
83 if (psd->smanager) 84 if (psd->smanager)
@@ -87,17 +88,21 @@ _efl_ui_internal_text_scroller_elm_layout_sizing_eval(Eo *obj,
87 88
88 edje_object_size_min_calc(wd->resize_obj, &vmw, &vmh); 89 edje_object_size_min_calc(wd->resize_obj, &vmw, &vmh);
89 90
90 if (sd->content) 91 if (sd->text_obj)
91 { 92 {
92 Eina_Size2D fsz = EINA_SIZE2D(0, 0); 93 Eina_Size2D fsz = EINA_SIZE2D(0, 0);
93 Eina_Size2D sz = EINA_SIZE2D(0, 0); 94 Eina_Size2D sz = EINA_SIZE2D(0, 0);
94 95
95 sz = efl_gfx_entity_size_get(sd->content); 96 sz = efl_gfx_entity_size_get(sd->text_table);
96 efl_event_freeze(sd->content); 97 efl_event_freeze(sd->text_table);
97 efl_gfx_entity_size_set(sd->content, view.size); 98 efl_event_freeze(sd->text_obj);
98 efl_canvas_text_size_formatted_get(sd->content, &fsz.w, &fsz.h); 99 efl_gfx_entity_size_set(sd->text_table, view.size);
99 efl_gfx_entity_size_set(sd->content, sz); 100 efl_gfx_entity_size_set(sd->text_obj, view.size);
100 efl_event_thaw(sd->content); 101 efl_canvas_text_size_formatted_get(sd->text_obj, &fsz.w, &fsz.h);
102 efl_gfx_entity_size_set(sd->text_table, sz);
103 efl_gfx_entity_size_set(sd->text_obj, sz);
104 efl_event_thaw(sd->text_obj);
105 efl_event_thaw(sd->text_table);
101 106
102 107
103 if (sd->mode == EFL_UI_TEXT_SCROLLER_MODE_SINGLELINE) 108 if (sd->mode == EFL_UI_TEXT_SCROLLER_MODE_SINGLELINE)
@@ -118,7 +123,7 @@ _efl_ui_internal_text_scroller_elm_layout_sizing_eval(Eo *obj,
118 } 123 }
119 124
120 // FIXME: should be restricted_min? 125 // FIXME: should be restricted_min?
121 efl_gfx_entity_size_set(sd->content, fsz); 126 efl_gfx_entity_size_set(sd->text_table, fsz);
122 efl_gfx_size_hint_min_set(obj, size); 127 efl_gfx_size_hint_min_set(obj, size);
123 efl_gfx_size_hint_max_set(obj, EINA_SIZE2D(-1, size.h)); 128 efl_gfx_size_hint_max_set(obj, EINA_SIZE2D(-1, size.h));
124 } 129 }
@@ -131,6 +136,7 @@ _efl_ui_internal_text_scroller_efl_object_finalize(Eo *obj,
131 obj = efl_finalize(efl_super(obj, MY_CLASS)); 136 obj = efl_finalize(efl_super(obj, MY_CLASS));
132 efl_ui_scrollbar_bar_mode_set(obj, 137 efl_ui_scrollbar_bar_mode_set(obj,
133 EFL_UI_SCROLLBAR_MODE_OFF, EFL_UI_SCROLLBAR_MODE_OFF); 138 EFL_UI_SCROLLBAR_MODE_OFF, EFL_UI_SCROLLBAR_MODE_OFF);
139 efl_content_set(obj, sd->text_table);
134 140
135 return obj; 141 return obj;
136} 142}
@@ -143,12 +149,19 @@ _efl_ui_internal_text_scroller_efl_object_destructor(Eo *obj,
143} 149}
144 150
145EOLIAN static void 151EOLIAN static void
146_efl_ui_internal_text_scroller_text_object_set(Eo *obj, 152_efl_ui_internal_text_scroller_initialize(Eo *obj,
147 Efl_Ui_Internal_Text_Scroller_Data *sd, 153 Efl_Ui_Internal_Text_Scroller_Data *sd,
148 Efl_Canvas_Text *text_obj) 154 Efl_Canvas_Text *text_obj,
155 Efl_Ui_Table *text_table)
149{ 156{
150 sd->content = text_obj; 157 if (efl_finalized_get(obj))
151 efl_content_set(obj, text_obj); 158 {
159 ERR("Can only be called on construction");
160 return;
161 }
162
163 sd->text_obj = text_obj;
164 sd->text_table = text_table;
152} 165}
153 166
154EOLIAN static void 167EOLIAN static void
diff --git a/src/lib/elementary/efl_ui_internal_text_scroller.eo b/src/lib/elementary/efl_ui_internal_text_scroller.eo
index 70586260fa..47624e44b3 100644
--- a/src/lib/elementary/efl_ui_internal_text_scroller.eo
+++ b/src/lib/elementary/efl_ui_internal_text_scroller.eo
@@ -7,17 +7,14 @@ enum Efl.Ui.Text_Scroller_Mode
7 7
8class Efl.Ui.Internal_Text_Scroller (Efl.Ui.Scroller) 8class Efl.Ui.Internal_Text_Scroller (Efl.Ui.Scroller)
9{ 9{
10 [[Efl ui text scroller class]] 10 [[Internal-usage text scroller class.
11
12 This class is a special scroller that evaluates its size based on the
13 $Efl.Canvas.Text object it holds. On initialization the object is meant
14 to be passed along a container (so that other objects such as
15 a "guide hint" text object are store in such container.
16 ]]
11 methods { 17 methods {
12 @property text_object {
13 [[The Efl.Canvas.Text content of this scroller]]
14 set {
15 [[Sets the given text object as the content of this scroller]]
16 }
17 values {
18 text_obj: Efl.Canvas.Text @nullable;
19 }
20 }
21 @property scroller_mode { 18 @property scroller_mode {
22 [[Mode of operation for the scroller]] 19 [[Mode of operation for the scroller]]
23 set { 20 set {
@@ -36,6 +33,16 @@ class Efl.Ui.Internal_Text_Scroller (Efl.Ui.Scroller)
36 clip: Efl.Object; 33 clip: Efl.Object;
37 } 34 }
38 } 35 }
36 initialize {
37 [[The Efl.Canvas.Text content of this scroller.
38 This should be called upon constructing the object.
39 ]]
40 params {
41 text_obj: Efl.Canvas.Text @nullable; [[The text object to query]]
42 text_table: Efl.Ui.Table @nullable; [[The table container of
43 the $text_obj]]
44 }
45 }
39 } 46 }
40 implements { 47 implements {
41 Efl.Object.constructor; 48 Efl.Object.constructor;
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}