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)
downloadefl-3cc8ea77fa5ca6e5c5819ff7c6caecf819d4bc3e.tar.gz
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,
Efl_Ui_Internal_Text_Scroller_Data *sd EINA_UNUSED)
{
obj = efl_constructor(efl_super(obj, MY_CLASS));
- //EFL_UI_SCROLLER_DATA_GET_OR_RETURN(obj, psd, NULL);
efl_ui_scrollbar_bar_mode_set(obj,
EFL_UI_SCROLLBAR_MODE_OFF, EFL_UI_SCROLLBAR_MODE_OFF);
@@ -138,7 +137,6 @@ _efl_ui_internal_text_scroller_efl_object_finalize(Eo *obj,
efl_ui_scrollbar_bar_mode_set(obj,
EFL_UI_SCROLLBAR_MODE_OFF, EFL_UI_SCROLLBAR_MODE_OFF);
efl_content_set(obj, sd->text_table);
-
return obj;
}
@@ -170,16 +168,15 @@ _efl_ui_internal_text_scroller_scroller_mode_set(Eo *obj,
Efl_Ui_Internal_Text_Scroller_Data *sd,
Efl_Ui_Text_Scroller_Mode mode)
{
- EFL_UI_SCROLLER_DATA_GET_OR_RETURN(obj, psd);
sd->mode = mode;
if (mode == EFL_UI_TEXT_SCROLLER_MODE_MULTILINE)
{
- efl_ui_scrollbar_bar_mode_set(psd->smanager,
+ efl_ui_scrollbar_bar_mode_set(obj,
EFL_UI_SCROLLBAR_MODE_AUTO, EFL_UI_SCROLLBAR_MODE_AUTO);
}
else // default (single-line)
{
- efl_ui_scrollbar_bar_mode_set(psd->smanager,
+ efl_ui_scrollbar_bar_mode_set(obj,
EFL_UI_SCROLLBAR_MODE_OFF, EFL_UI_SCROLLBAR_MODE_OFF);
}
}
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
if (sd->scroll)
{
- if (!efl_text_multiline_get(obj))
- {
- efl_ui_internal_text_scroller_mode_set(sd->scroller,
- EFL_UI_TEXT_SCROLLER_MODE_SINGLELINE);
- }
- else
- {
- efl_ui_internal_text_scroller_mode_set(sd->scroller,
- EFL_UI_TEXT_SCROLLER_MODE_MULTILINE);
-
- }
-
efl_canvas_group_calculate(sd->scroller);
min = efl_gfx_hint_size_min_get(sd->scroller);
if (!efl_text_multiline_get(obj))
{
- efl_ui_internal_text_scroller_mode_set(sd->scroller,
- EFL_UI_TEXT_SCROLLER_MODE_SINGLELINE);
edje_object_size_min_calc(wd->resize_obj, &edmin.w, &edmin.h);
min.w = edmin.w;
min.h = edmin.h;
@@ -2138,6 +2124,26 @@ _efl_ui_textbox_efl_object_destructor(Eo *obj, Efl_Ui_Textbox_Data *sd)
}
EOLIAN static void
+_efl_ui_textbox_efl_text_format_multiline_set(Eo *obj, Efl_Ui_Textbox_Data *sd, Eina_Bool enabled)
+{
+ enabled = !!enabled;
+ if (efl_text_multiline_get(obj) == enabled) return;
+ efl_text_multiline_set(sd->text_obj, enabled);
+
+ if (sd->scroller)
+ {
+ if (enabled)
+ {
+ efl_ui_internal_text_scroller_mode_set(sd->scroller, EFL_UI_TEXT_SCROLLER_MODE_MULTILINE);
+ }
+ else
+ {
+ efl_ui_internal_text_scroller_mode_set(sd->scroller, EFL_UI_TEXT_SCROLLER_MODE_SINGLELINE);
+ }
+ }
+}
+
+EOLIAN static void
_efl_ui_textbox_efl_text_format_password_set(Eo *obj, Efl_Ui_Textbox_Data *sd, Eina_Bool password)
{
password = !!password;
@@ -2429,7 +2435,7 @@ _efl_ui_textbox_cnp_mode_get(const Eo *obj EINA_UNUSED, Efl_Ui_Textbox_Data *sd)
}
EOLIAN static void
-_efl_ui_textbox_scrollable_set(Eo *obj EINA_UNUSED, Efl_Ui_Textbox_Data *sd, Eina_Bool scroll)
+_efl_ui_textbox_scrollable_set(Eo *obj, Efl_Ui_Textbox_Data *sd, Eina_Bool scroll)
{
if (sd->scroll == scroll) return;
sd->scroll = scroll;
@@ -2440,7 +2446,12 @@ _efl_ui_textbox_scrollable_set(Eo *obj EINA_UNUSED, Efl_Ui_Textbox_Data *sd, Ein
sd->scroller = efl_add(EFL_UI_INTERNAL_TEXT_SCROLLER_CLASS, obj,
efl_ui_internal_text_scroller_initialize(efl_added,
sd->text_obj, sd->text_table));
- efl_ui_scrollbar_bar_mode_set(sd->scroller, EFL_UI_SCROLLBAR_MODE_AUTO, EFL_UI_SCROLLBAR_MODE_AUTO);
+
+ if (efl_text_multiline_get(obj))
+ efl_ui_internal_text_scroller_mode_set(sd->scroller, EFL_UI_TEXT_SCROLLER_MODE_MULTILINE);
+ else
+ efl_ui_internal_text_scroller_mode_set(sd->scroller, EFL_UI_TEXT_SCROLLER_MODE_SINGLELINE);
+
efl_content_set(efl_part(sd->entry_edje, "efl.text"), sd->scroller);
efl_canvas_object_clipper_set(sd->cursor,
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)
//FIXME
//ELM_PART_OVERRIDE_PARTIAL(efl_ui_text, EFL_UI_TEXTBOX, Efl_Ui_Textbox_Data, _part_is_efl_ui_text_part)
EOLIAN static Efl_Object *
-_efl_ui_textbox_efl_part_part_get(const Eo *obj, Efl_Ui_Textbox_Data *priv EINA_UNUSED, const char *part)
+_efl_ui_textbox_efl_part_part_get(const Eo *obj, Efl_Ui_Textbox_Data *priv EINA_UNUSED, const char *part)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
if (_part_is_efl_ui_text_part(obj, part)) return ELM_PART_IMPLEMENT(EFL_UI_TEXT_PART_CLASS, obj, part);
- return efl_part_get(efl_super(obj, EFL_UI_TEXTBOX_CLASS), part);
+ return efl_part_get(efl_super(obj, EFL_UI_TEXTBOX_CLASS), part);
}
//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
Efl.Ui.Widget.interest_region { get; }
Efl.Ui.Widget.disabled {set;}
Efl.Text_Format.password {set;}
+ Efl.Text_Format.multiline {set;}
//Efl.Ui.Widget.widget_sub_object_del;
//Elm.Interface_Scrollable.policy { set; }
//Elm.Interface_Scrollable.bounce_allow { set; }