woohyun pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=f126c7f06c63405424fb71c0cb37bd503427a9ba

commit f126c7f06c63405424fb71c0cb37bd503427a9ba
Author: Ali Alzyod <ali198...@gmail.com>
Date:   Wed Aug 5 13:33:03 2020 +0900

    efl_ui_textbox: preserve changing user color set
    
    Summary:
    setting color inside the constructor call will be override in theme apply 
because it happen later.
    txt = efl_add(EFL_UI_TEXTBOX_CLASS, win,
                   efl_text_color_set(efl_added, 0, 255, 0, 255));
    
    Now we will preserve user choice, to not change it during theme apply.
    
    Test Plan: ninja test
    
    Reviewers: woohyun, bu5hm4n, zmike, segfaultxavi
    
    Subscribers: cedric, #reviewers, #committers
    
    Tags: #efl
    
    Differential Revision: https://phab.enlightenment.org/D11942
---
 src/lib/elementary/efl_ui_textbox.c     | 26 +++++++++++++++++++-------
 src/lib/elementary/efl_ui_textbox.eo    |  1 +
 src/tests/elementary/efl_ui_test_text.c | 24 ++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/src/lib/elementary/efl_ui_textbox.c 
b/src/lib/elementary/efl_ui_textbox.c
index bd97b47db7..22c731f94b 100644
--- a/src/lib/elementary/efl_ui_textbox.c
+++ b/src/lib/elementary/efl_ui_textbox.c
@@ -99,6 +99,7 @@ struct _Efl_Ui_Textbox_Data
    Eina_Bool                             text_changed : 1;
    Eina_Bool                             calc_force : 1;
    Eina_Bool                             cursor_update : 1;
+   Eina_Bool                             color_is_set : 1;
 };
 
 struct _Anchor
@@ -1607,13 +1608,18 @@ _update_text_theme(Eo *obj, Efl_Ui_Textbox_Data *sd)
      }
 
    // color
-   if (disabled)
-     colorcode = efl_layout_group_data_get(wd->resize_obj, 
"style.color_disabled");
-   if (!colorcode)
-     colorcode = efl_layout_group_data_get(wd->resize_obj, "style.color");
-   if (colorcode && _format_color_parse(colorcode, strlen(colorcode), &r, &g, 
&b, &a))
-     {
-        efl_text_color_set(sd->text_obj, r, g, b, a);
+   if (!sd->color_is_set)
+     {
+        // If user set color by him self, we will not change it back even if
+        // control become disabled.
+        if (disabled)
+          colorcode = efl_layout_group_data_get(wd->resize_obj, 
"style.color_disabled");
+        if (!colorcode)
+          colorcode = efl_layout_group_data_get(wd->resize_obj, "style.color");
+        if (colorcode && _format_color_parse(colorcode, strlen(colorcode), &r, 
&g, &b, &a))
+          {
+             efl_text_color_set(sd->text_obj, r, g, b, a);
+          }
      }
 
    // Guide Text
@@ -1811,6 +1817,12 @@ _efl_ui_textbox_efl_text_format_password_set(Eo *obj, 
Efl_Ui_Textbox_Data *sd, E
      }
 }
 
+EOLIAN static void
+_efl_ui_textbox_efl_text_style_text_color_set(Eo *obj EINA_UNUSED, 
Efl_Ui_Textbox_Data *pd, unsigned char r, unsigned char g, unsigned char b, 
unsigned char a)
+{
+   pd->color_is_set = EINA_TRUE;
+   efl_text_color_set(pd->text_obj, r, g, b, a);
+}
 static void
 _efl_ui_textbox_calc_force(Eo *obj, Efl_Ui_Textbox_Data *sd)
 {
diff --git a/src/lib/elementary/efl_ui_textbox.eo 
b/src/lib/elementary/efl_ui_textbox.eo
index 9cd5c520b5..1c63b602a1 100644
--- a/src/lib/elementary/efl_ui_textbox.eo
+++ b/src/lib/elementary/efl_ui_textbox.eo
@@ -112,6 +112,7 @@ class Efl.Ui.Textbox extends Efl.Ui.Layout_Base implements 
Efl.Input.Clickable,
       Efl.Ui.Widget.disabled {set;}
       Efl.Text_Format.password {set;}
       Efl.Text_Format.multiline {set;}
+      Efl.Text_Style.text_color { set; }
       Efl.Access.Object.state_set { get; }
       Efl.Access.Object.i18n_name { get; }
       Efl.Access.Text.access_text { get; }
diff --git a/src/tests/elementary/efl_ui_test_text.c 
b/src/tests/elementary/efl_ui_test_text.c
index 3eb9909d53..ad876c6bcd 100644
--- a/src/tests/elementary/efl_ui_test_text.c
+++ b/src/tests/elementary/efl_ui_test_text.c
@@ -300,6 +300,29 @@ EFL_START_TEST(text_editable)
 }
 EFL_END_TEST
 
+EFL_START_TEST(text_on_startup)
+{
+   Eo *txt, *win;
+   win = win_add();
+   unsigned char r,g,b,a;
+   txt = efl_add(EFL_UI_TEXTBOX_CLASS, win,
+               efl_text_color_set(efl_added, 0, 255, 0, 255),
+               efl_text_font_size_set(efl_added, 50),
+               efl_text_font_family_set(efl_added, "Arial"));
+
+   ck_assert_int_eq(efl_text_font_size_get(txt), 50);
+   ck_assert_str_eq(efl_text_font_family_get(txt), "Arial");
+   efl_text_color_get(txt, &r, &g, &b, &a);
+   ck_assert_int_eq(r, 0);
+   ck_assert_int_eq(g, 255);
+   ck_assert_int_eq(b, 0);
+   ck_assert_int_eq(a, 255);
+
+   efl_del(txt);
+   efl_del(win);
+}
+EFL_END_TEST
+
 EFL_START_TEST(text_multiline_selection)
 {
    Eo *txt, *win;
@@ -473,4 +496,5 @@ void efl_ui_test_text(TCase *tc)
    tcase_add_test(tc, text_multiline_selection);
    tcase_add_test(tc, text_singleline_cursor_movement);
    tcase_add_test(tc, text_multiline_singleline_cursor_pos);
+   tcase_add_test(tc, text_on_startup);
 }

-- 


Reply via email to