summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Alzyod <ali198724@gmail.com>2020-08-05 13:33:03 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2020-08-05 13:33:03 +0900
commitf126c7f06c63405424fb71c0cb37bd503427a9ba (patch)
tree30400b360f5a760d0057299729d0445f134f8268
parented18471ba955be316abb2117ebdde3f3df418751 (diff)
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
-rw-r--r--src/lib/elementary/efl_ui_textbox.c26
-rw-r--r--src/lib/elementary/efl_ui_textbox.eo1
-rw-r--r--src/tests/elementary/efl_ui_test_text.c24
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
99 Eina_Bool text_changed : 1; 99 Eina_Bool text_changed : 1;
100 Eina_Bool calc_force : 1; 100 Eina_Bool calc_force : 1;
101 Eina_Bool cursor_update : 1; 101 Eina_Bool cursor_update : 1;
102 Eina_Bool color_is_set : 1;
102}; 103};
103 104
104struct _Anchor 105struct _Anchor
@@ -1607,13 +1608,18 @@ _update_text_theme(Eo *obj, Efl_Ui_Textbox_Data *sd)
1607 } 1608 }
1608 1609
1609 // color 1610 // color
1610 if (disabled) 1611 if (!sd->color_is_set)
1611 colorcode = efl_layout_group_data_get(wd->resize_obj, "style.color_disabled"); 1612 {
1612 if (!colorcode) 1613 // If user set color by him self, we will not change it back even if
1613 colorcode = efl_layout_group_data_get(wd->resize_obj, "style.color"); 1614 // control become disabled.
1614 if (colorcode && _format_color_parse(colorcode, strlen(colorcode), &r, &g, &b, &a)) 1615 if (disabled)
1615 { 1616 colorcode = efl_layout_group_data_get(wd->resize_obj, "style.color_disabled");
1616 efl_text_color_set(sd->text_obj, r, g, b, a); 1617 if (!colorcode)
1618 colorcode = efl_layout_group_data_get(wd->resize_obj, "style.color");
1619 if (colorcode && _format_color_parse(colorcode, strlen(colorcode), &r, &g, &b, &a))
1620 {
1621 efl_text_color_set(sd->text_obj, r, g, b, a);
1622 }
1617 } 1623 }
1618 1624
1619 // Guide Text 1625 // Guide Text
@@ -1811,6 +1817,12 @@ _efl_ui_textbox_efl_text_format_password_set(Eo *obj, Efl_Ui_Textbox_Data *sd, E
1811 } 1817 }
1812} 1818}
1813 1819
1820EOLIAN static void
1821_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)
1822{
1823 pd->color_is_set = EINA_TRUE;
1824 efl_text_color_set(pd->text_obj, r, g, b, a);
1825}
1814static void 1826static void
1815_efl_ui_textbox_calc_force(Eo *obj, Efl_Ui_Textbox_Data *sd) 1827_efl_ui_textbox_calc_force(Eo *obj, Efl_Ui_Textbox_Data *sd)
1816{ 1828{
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,
112 Efl.Ui.Widget.disabled {set;} 112 Efl.Ui.Widget.disabled {set;}
113 Efl.Text_Format.password {set;} 113 Efl.Text_Format.password {set;}
114 Efl.Text_Format.multiline {set;} 114 Efl.Text_Format.multiline {set;}
115 Efl.Text_Style.text_color { set; }
115 Efl.Access.Object.state_set { get; } 116 Efl.Access.Object.state_set { get; }
116 Efl.Access.Object.i18n_name { get; } 117 Efl.Access.Object.i18n_name { get; }
117 Efl.Access.Text.access_text { get; } 118 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)
300} 300}
301EFL_END_TEST 301EFL_END_TEST
302 302
303EFL_START_TEST(text_on_startup)
304{
305 Eo *txt, *win;
306 win = win_add();
307 unsigned char r,g,b,a;
308 txt = efl_add(EFL_UI_TEXTBOX_CLASS, win,
309 efl_text_color_set(efl_added, 0, 255, 0, 255),
310 efl_text_font_size_set(efl_added, 50),
311 efl_text_font_family_set(efl_added, "Arial"));
312
313 ck_assert_int_eq(efl_text_font_size_get(txt), 50);
314 ck_assert_str_eq(efl_text_font_family_get(txt), "Arial");
315 efl_text_color_get(txt, &r, &g, &b, &a);
316 ck_assert_int_eq(r, 0);
317 ck_assert_int_eq(g, 255);
318 ck_assert_int_eq(b, 0);
319 ck_assert_int_eq(a, 255);
320
321 efl_del(txt);
322 efl_del(win);
323}
324EFL_END_TEST
325
303EFL_START_TEST(text_multiline_selection) 326EFL_START_TEST(text_multiline_selection)
304{ 327{
305 Eo *txt, *win; 328 Eo *txt, *win;
@@ -473,4 +496,5 @@ void efl_ui_test_text(TCase *tc)
473 tcase_add_test(tc, text_multiline_selection); 496 tcase_add_test(tc, text_multiline_selection);
474 tcase_add_test(tc, text_singleline_cursor_movement); 497 tcase_add_test(tc, text_singleline_cursor_movement);
475 tcase_add_test(tc, text_multiline_singleline_cursor_pos); 498 tcase_add_test(tc, text_multiline_singleline_cursor_pos);
499 tcase_add_test(tc, text_on_startup);
476} 500}