summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Alzyod <ali198724@gmail.com>2020-01-02 08:19:24 +0000
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-01-02 12:41:13 +0100
commit3cc8ea77fa5ca6e5c5819ff7c6caecf819d4bc3e (patch)
treec6977c2108a4e66b439f4d84572bc1aa5259c865
parent20b7c515d12ae25b98851cedfd5dc415e0f1dccb (diff)
efl_ui_text: scroller mode clean up
simplify code, and reduce calls: It is only required to set scroll mode in two cases: - When creating scroller - When changing multiline property Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D10981
-rw-r--r--src/lib/elementary/efl_ui_internal_text_scroller.c7
-rw-r--r--src/lib/elementary/efl_ui_textbox.c47
-rw-r--r--src/lib/elementary/efl_ui_textbox.eo1
3 files changed, 32 insertions, 23 deletions
diff --git a/src/lib/elementary/efl_ui_internal_text_scroller.c b/src/lib/elementary/efl_ui_internal_text_scroller.c
index 3387759e38..7f10c2989a 100644
--- a/src/lib/elementary/efl_ui_internal_text_scroller.c
+++ b/src/lib/elementary/efl_ui_internal_text_scroller.c
@@ -63,7 +63,6 @@ _efl_ui_internal_text_scroller_efl_object_constructor(Eo *obj,
63 Efl_Ui_Internal_Text_Scroller_Data *sd EINA_UNUSED) 63 Efl_Ui_Internal_Text_Scroller_Data *sd EINA_UNUSED)
64{ 64{
65 obj = efl_constructor(efl_super(obj, MY_CLASS)); 65 obj = efl_constructor(efl_super(obj, MY_CLASS));
66 //EFL_UI_SCROLLER_DATA_GET_OR_RETURN(obj, psd, NULL);
67 efl_ui_scrollbar_bar_mode_set(obj, 66 efl_ui_scrollbar_bar_mode_set(obj,
68 EFL_UI_SCROLLBAR_MODE_OFF, EFL_UI_SCROLLBAR_MODE_OFF); 67 EFL_UI_SCROLLBAR_MODE_OFF, EFL_UI_SCROLLBAR_MODE_OFF);
69 68
@@ -138,7 +137,6 @@ _efl_ui_internal_text_scroller_efl_object_finalize(Eo *obj,
138 efl_ui_scrollbar_bar_mode_set(obj, 137 efl_ui_scrollbar_bar_mode_set(obj,
139 EFL_UI_SCROLLBAR_MODE_OFF, EFL_UI_SCROLLBAR_MODE_OFF); 138 EFL_UI_SCROLLBAR_MODE_OFF, EFL_UI_SCROLLBAR_MODE_OFF);
140 efl_content_set(obj, sd->text_table); 139 efl_content_set(obj, sd->text_table);
141
142 return obj; 140 return obj;
143} 141}
144 142
@@ -170,16 +168,15 @@ _efl_ui_internal_text_scroller_scroller_mode_set(Eo *obj,
170 Efl_Ui_Internal_Text_Scroller_Data *sd, 168 Efl_Ui_Internal_Text_Scroller_Data *sd,
171 Efl_Ui_Text_Scroller_Mode mode) 169 Efl_Ui_Text_Scroller_Mode mode)
172{ 170{
173 EFL_UI_SCROLLER_DATA_GET_OR_RETURN(obj, psd);
174 sd->mode = mode; 171 sd->mode = mode;
175 if (mode == EFL_UI_TEXT_SCROLLER_MODE_MULTILINE) 172 if (mode == EFL_UI_TEXT_SCROLLER_MODE_MULTILINE)
176 { 173 {
177 efl_ui_scrollbar_bar_mode_set(psd->smanager, 174 efl_ui_scrollbar_bar_mode_set(obj,
178 EFL_UI_SCROLLBAR_MODE_AUTO, EFL_UI_SCROLLBAR_MODE_AUTO); 175 EFL_UI_SCROLLBAR_MODE_AUTO, EFL_UI_SCROLLBAR_MODE_AUTO);
179 } 176 }
180 else // default (single-line) 177 else // default (single-line)
181 { 178 {
182 efl_ui_scrollbar_bar_mode_set(psd->smanager, 179 efl_ui_scrollbar_bar_mode_set(obj,
183 EFL_UI_SCROLLBAR_MODE_OFF, EFL_UI_SCROLLBAR_MODE_OFF); 180 EFL_UI_SCROLLBAR_MODE_OFF, EFL_UI_SCROLLBAR_MODE_OFF);
184 } 181 }
185} 182}
diff --git a/src/lib/elementary/efl_ui_textbox.c b/src/lib/elementary/efl_ui_textbox.c
index da63751e53..c3bbf688b7 100644
--- a/src/lib/elementary/efl_ui_textbox.c
+++ b/src/lib/elementary/efl_ui_textbox.c
@@ -816,24 +816,10 @@ _efl_ui_textbox_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Textbox_Data *s
816 816
817 if (sd->scroll) 817 if (sd->scroll)
818 { 818 {
819 if (!efl_text_multiline_get(obj))
820 {
821 efl_ui_internal_text_scroller_mode_set(sd->scroller,
822 EFL_UI_TEXT_SCROLLER_MODE_SINGLELINE);
823 }
824 else
825 {
826 efl_ui_internal_text_scroller_mode_set(sd->scroller,
827 EFL_UI_TEXT_SCROLLER_MODE_MULTILINE);
828
829 }
830
831 efl_canvas_group_calculate(sd->scroller); 819 efl_canvas_group_calculate(sd->scroller);
832 min = efl_gfx_hint_size_min_get(sd->scroller); 820 min = efl_gfx_hint_size_min_get(sd->scroller);
833 if (!efl_text_multiline_get(obj)) 821 if (!efl_text_multiline_get(obj))
834 { 822 {
835 efl_ui_internal_text_scroller_mode_set(sd->scroller,
836 EFL_UI_TEXT_SCROLLER_MODE_SINGLELINE);
837 edje_object_size_min_calc(wd->resize_obj, &edmin.w, &edmin.h); 823 edje_object_size_min_calc(wd->resize_obj, &edmin.w, &edmin.h);
838 min.w = edmin.w; 824 min.w = edmin.w;
839 min.h = edmin.h; 825 min.h = edmin.h;
@@ -2138,6 +2124,26 @@ _efl_ui_textbox_efl_object_destructor(Eo *obj, Efl_Ui_Textbox_Data *sd)
2138} 2124}
2139 2125
2140EOLIAN static void 2126EOLIAN static void
2127_efl_ui_textbox_efl_text_format_multiline_set(Eo *obj, Efl_Ui_Textbox_Data *sd, Eina_Bool enabled)
2128{
2129 enabled = !!enabled;
2130 if (efl_text_multiline_get(obj) == enabled) return;
2131 efl_text_multiline_set(sd->text_obj, enabled);
2132
2133 if (sd->scroller)
2134 {
2135 if (enabled)
2136 {
2137 efl_ui_internal_text_scroller_mode_set(sd->scroller, EFL_UI_TEXT_SCROLLER_MODE_MULTILINE);
2138 }
2139 else
2140 {
2141 efl_ui_internal_text_scroller_mode_set(sd->scroller, EFL_UI_TEXT_SCROLLER_MODE_SINGLELINE);
2142 }
2143 }
2144}
2145
2146EOLIAN static void
2141_efl_ui_textbox_efl_text_format_password_set(Eo *obj, Efl_Ui_Textbox_Data *sd, Eina_Bool password) 2147_efl_ui_textbox_efl_text_format_password_set(Eo *obj, Efl_Ui_Textbox_Data *sd, Eina_Bool password)
2142{ 2148{
2143 password = !!password; 2149 password = !!password;
@@ -2429,7 +2435,7 @@ _efl_ui_textbox_cnp_mode_get(const Eo *obj EINA_UNUSED, Efl_Ui_Textbox_Data *sd)
2429} 2435}
2430 2436
2431EOLIAN static void 2437EOLIAN static void
2432_efl_ui_textbox_scrollable_set(Eo *obj EINA_UNUSED, Efl_Ui_Textbox_Data *sd, Eina_Bool scroll) 2438_efl_ui_textbox_scrollable_set(Eo *obj, Efl_Ui_Textbox_Data *sd, Eina_Bool scroll)
2433{ 2439{
2434 if (sd->scroll == scroll) return; 2440 if (sd->scroll == scroll) return;
2435 sd->scroll = scroll; 2441 sd->scroll = scroll;
@@ -2440,7 +2446,12 @@ _efl_ui_textbox_scrollable_set(Eo *obj EINA_UNUSED, Efl_Ui_Textbox_Data *sd, Ein
2440 sd->scroller = efl_add(EFL_UI_INTERNAL_TEXT_SCROLLER_CLASS, obj, 2446 sd->scroller = efl_add(EFL_UI_INTERNAL_TEXT_SCROLLER_CLASS, obj,
2441 efl_ui_internal_text_scroller_initialize(efl_added, 2447 efl_ui_internal_text_scroller_initialize(efl_added,
2442 sd->text_obj, sd->text_table)); 2448 sd->text_obj, sd->text_table));
2443 efl_ui_scrollbar_bar_mode_set(sd->scroller, EFL_UI_SCROLLBAR_MODE_AUTO, EFL_UI_SCROLLBAR_MODE_AUTO); 2449
2450 if (efl_text_multiline_get(obj))
2451 efl_ui_internal_text_scroller_mode_set(sd->scroller, EFL_UI_TEXT_SCROLLER_MODE_MULTILINE);
2452 else
2453 efl_ui_internal_text_scroller_mode_set(sd->scroller, EFL_UI_TEXT_SCROLLER_MODE_SINGLELINE);
2454
2444 efl_content_set(efl_part(sd->entry_edje, "efl.text"), sd->scroller); 2455 efl_content_set(efl_part(sd->entry_edje, "efl.text"), sd->scroller);
2445 efl_canvas_object_clipper_set(sd->cursor, 2456 efl_canvas_object_clipper_set(sd->cursor,
2446 efl_ui_internal_text_scroller_viewport_clip_get(sd->scroller)); 2457 efl_ui_internal_text_scroller_viewport_clip_get(sd->scroller));
@@ -3711,11 +3722,11 @@ _part_is_efl_ui_text_part(const Eo *obj EINA_UNUSED, const char *part)
3711//FIXME 3722//FIXME
3712//ELM_PART_OVERRIDE_PARTIAL(efl_ui_text, EFL_UI_TEXTBOX, Efl_Ui_Textbox_Data, _part_is_efl_ui_text_part) 3723//ELM_PART_OVERRIDE_PARTIAL(efl_ui_text, EFL_UI_TEXTBOX, Efl_Ui_Textbox_Data, _part_is_efl_ui_text_part)
3713EOLIAN static Efl_Object * 3724EOLIAN static Efl_Object *
3714_efl_ui_textbox_efl_part_part_get(const Eo *obj, Efl_Ui_Textbox_Data *priv EINA_UNUSED, const char *part) 3725_efl_ui_textbox_efl_part_part_get(const Eo *obj, Efl_Ui_Textbox_Data *priv EINA_UNUSED, const char *part)
3715{ 3726{
3716 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL); 3727 EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
3717 if (_part_is_efl_ui_text_part(obj, part)) return ELM_PART_IMPLEMENT(EFL_UI_TEXT_PART_CLASS, obj, part); 3728 if (_part_is_efl_ui_text_part(obj, part)) return ELM_PART_IMPLEMENT(EFL_UI_TEXT_PART_CLASS, obj, part);
3718 return efl_part_get(efl_super(obj, EFL_UI_TEXTBOX_CLASS), part); 3729 return efl_part_get(efl_super(obj, EFL_UI_TEXTBOX_CLASS), part);
3719} 3730}
3720 3731
3721//FIXME 3732//FIXME
diff --git a/src/lib/elementary/efl_ui_textbox.eo b/src/lib/elementary/efl_ui_textbox.eo
index 9104d436b2..b723c59e44 100644
--- a/src/lib/elementary/efl_ui_textbox.eo
+++ b/src/lib/elementary/efl_ui_textbox.eo
@@ -103,6 +103,7 @@ class @beta Efl.Ui.Textbox extends Efl.Ui.Layout_Base implements Efl.Input.Click
103 Efl.Ui.Widget.interest_region { get; } 103 Efl.Ui.Widget.interest_region { get; }
104 Efl.Ui.Widget.disabled {set;} 104 Efl.Ui.Widget.disabled {set;}
105 Efl.Text_Format.password {set;} 105 Efl.Text_Format.password {set;}
106 Efl.Text_Format.multiline {set;}
106 //Efl.Ui.Widget.widget_sub_object_del; 107 //Efl.Ui.Widget.widget_sub_object_del;
107 //Elm.Interface_Scrollable.policy { set; } 108 //Elm.Interface_Scrollable.policy { set; }
108 //Elm.Interface_Scrollable.bounce_allow { set; } 109 //Elm.Interface_Scrollable.bounce_allow { set; }