forked from enlightenment/efl
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:
parent
ed18471ba9
commit
f126c7f06c
|
@ -99,6 +99,7 @@ struct _Efl_Ui_Textbox_Data
|
||||||
Eina_Bool text_changed : 1;
|
Eina_Bool text_changed : 1;
|
||||||
Eina_Bool calc_force : 1;
|
Eina_Bool calc_force : 1;
|
||||||
Eina_Bool cursor_update : 1;
|
Eina_Bool cursor_update : 1;
|
||||||
|
Eina_Bool color_is_set : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Anchor
|
struct _Anchor
|
||||||
|
@ -1607,13 +1608,18 @@ _update_text_theme(Eo *obj, Efl_Ui_Textbox_Data *sd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// color
|
// color
|
||||||
if (disabled)
|
if (!sd->color_is_set)
|
||||||
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 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
|
// 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
|
static void
|
||||||
_efl_ui_textbox_calc_force(Eo *obj, Efl_Ui_Textbox_Data *sd)
|
_efl_ui_textbox_calc_force(Eo *obj, Efl_Ui_Textbox_Data *sd)
|
||||||
{
|
{
|
||||||
|
|
|
@ -112,6 +112,7 @@ class Efl.Ui.Textbox extends Efl.Ui.Layout_Base implements Efl.Input.Clickable,
|
||||||
Efl.Ui.Widget.disabled {set;}
|
Efl.Ui.Widget.disabled {set;}
|
||||||
Efl.Text_Format.password {set;}
|
Efl.Text_Format.password {set;}
|
||||||
Efl.Text_Format.multiline {set;}
|
Efl.Text_Format.multiline {set;}
|
||||||
|
Efl.Text_Style.text_color { set; }
|
||||||
Efl.Access.Object.state_set { get; }
|
Efl.Access.Object.state_set { get; }
|
||||||
Efl.Access.Object.i18n_name { get; }
|
Efl.Access.Object.i18n_name { get; }
|
||||||
Efl.Access.Text.access_text { get; }
|
Efl.Access.Text.access_text { get; }
|
||||||
|
|
|
@ -300,6 +300,29 @@ EFL_START_TEST(text_editable)
|
||||||
}
|
}
|
||||||
EFL_END_TEST
|
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)
|
EFL_START_TEST(text_multiline_selection)
|
||||||
{
|
{
|
||||||
Eo *txt, *win;
|
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_multiline_selection);
|
||||||
tcase_add_test(tc, text_singleline_cursor_movement);
|
tcase_add_test(tc, text_singleline_cursor_movement);
|
||||||
tcase_add_test(tc, text_multiline_singleline_cursor_pos);
|
tcase_add_test(tc, text_multiline_singleline_cursor_pos);
|
||||||
|
tcase_add_test(tc, text_on_startup);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue