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
This commit is contained in:
Ali Alzyod 2020-08-05 13:33:03 +09:00 committed by WooHyun Jung
parent ed18471ba9
commit f126c7f06c
3 changed files with 43 additions and 6 deletions

View File

@ -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))
if (!sd->color_is_set)
{
efl_text_color_set(sd->text_obj, r, g, b, a);
// 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)
{

View File

@ -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; }

View File

@ -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);
}