ui.widget: fix theme_apply working in sub_object_add

It seems that theme_apply in sub_object_add haven't worked since commit
f6fa1ef612.

scale, theme property will be set properly when the parent is changed.

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es>
Differential Revision: https://phab.enlightenment.org/D8283
This commit is contained in:
Yeongjong Lee 2019-03-11 21:21:22 +00:00 committed by Marcel Hollerbach
parent 8ef176ca53
commit c3f823418d
2 changed files with 47 additions and 15 deletions

View File

@ -1377,7 +1377,6 @@ elm_widget_sub_object_parent_add(Evas_Object *sobj)
EOLIAN static void
_efl_ui_widget_widget_parent_set(Eo *obj, Elm_Widget_Smart_Data *pd, Efl_Ui_Widget *parent)
{
Eina_Bool mirrored, pmirrored = efl_ui_mirrored_get(obj);
Efl_Ui_Widget *old_parent;
//check if we are in the subobject list of parents
if (parent)
@ -1386,32 +1385,33 @@ _efl_ui_widget_widget_parent_set(Eo *obj, Elm_Widget_Smart_Data *pd, Efl_Ui_Widg
EINA_SAFETY_ON_FALSE_RETURN(eina_list_data_find(ppd->subobjs, obj));
}
/* NOTE: In the following two lines, 'obj' is correct. Do not change it.
* Due to elementary's scale policy, scale and prev_scale can be different in
* some cases. This happens when obj's previous parent and new parent have
* different scale value.
* For example, if obj's previous parent's scale is 5 and new parent's scale
* is 2 while obj's scale is 0. Then 'prev_pscale' is 5 and 'scale' is 2. So
* we need to reset obj's scale to 5.
* Note that each widget's scale is 1.0 by default.
*/
double scale, prev_scale = efl_gfx_entity_scale_get(obj);
Elm_Theme *th, *prev_th = elm_widget_theme_get(obj);
Eina_Bool mirrored, pmirrored = efl_ui_mirrored_get(parent);
old_parent = pd->parent_obj;
pd->parent_obj = parent;
// now lets sync up all states
if (pd->parent_obj)
{
/* NOTE: In the following two lines, 'sobj' is correct. Do not change it.
* Due to elementary's scale policy, scale and pscale can be different in
* some cases. This happens when sobj's previous parent and new parent have
* different scale value.
* For example, if sobj's previous parent's scale is 5 and new parent's scale
* is 2 while sobj's scale is 0. Then 'pscale' is 5 and 'scale' is 2. So we
* need to reset sobj's scale to 5.
* Note that each widget's scale is 0 by default.
*/
double scale, pscale = efl_gfx_entity_scale_get(obj);
Elm_Theme *th, *pth = elm_widget_theme_get(obj);
scale = efl_gfx_entity_scale_get(obj);
th = elm_widget_theme_get(obj);
mirrored = efl_ui_mirrored_get(obj);
if (!pd->on_create)
{
if ((scale != pscale) || (th != pth) || (pmirrored != mirrored))
if ((scale != prev_scale) || (th != prev_th) ||
(pmirrored != mirrored))
elm_widget_theme(obj);
}
if (_is_focused(obj)) _parents_focus(parent);

View File

@ -188,6 +188,37 @@ EFL_START_TEST(efl_ui_test_widget_sub_object_add_del)
}
EFL_END_TEST
EFL_START_TEST(efl_ui_test_widget_sub_object_theme_sync)
{
State s;
Efl_Canvas_Layout *edje;
_small_ui(&s);
edje = elm_widget_resize_object_get(s.btn1);
ck_assert(EINA_DBL_EQ(efl_gfx_entity_scale_get(s.btn1), 1.0));
ck_assert(EINA_DBL_EQ(efl_gfx_entity_scale_get(edje), 1.0));
ck_assert(EINA_DBL_EQ(efl_gfx_entity_scale_get(s.btn2), 1.0));
efl_gfx_entity_scale_set(s.win, 0.123);
ck_assert(EINA_DBL_EQ(efl_gfx_entity_scale_get(s.btn1), 0.123));
ck_assert(EINA_DBL_EQ(efl_gfx_entity_scale_get(edje), 0.123));
ck_assert(EINA_DBL_EQ(efl_gfx_entity_scale_get(s.btn2), 0.123));
efl_ui_widget_sub_object_del(s.box, s.btn1);
efl_gfx_entity_scale_set(s.win, 0.456);
ck_assert(EINA_DBL_EQ(efl_gfx_entity_scale_get(s.btn1), 1.0));
ck_assert(EINA_DBL_EQ(efl_gfx_entity_scale_get(edje), 0.123));
ck_assert(EINA_DBL_EQ(efl_gfx_entity_scale_get(s.btn2), 0.456));
efl_gfx_entity_scale_set(s.win, 0.789);
efl_ui_widget_sub_object_add(s.box, s.btn1);
ck_assert(EINA_DBL_EQ(efl_gfx_entity_scale_get(s.btn1), 0.789));
ck_assert(EINA_DBL_EQ(efl_gfx_entity_scale_get(edje), 0.789));
ck_assert(EINA_DBL_EQ(efl_gfx_entity_scale_get(s.btn2), 0.789));
}
EFL_END_TEST
void efl_ui_test_widget(TCase *tc)
{
tcase_add_test(tc, efl_ui_test_widget_parent_iterator);
@ -196,4 +227,5 @@ void efl_ui_test_widget(TCase *tc)
tcase_add_test(tc, efl_ui_test_widget_iterator);
tcase_add_test(tc, efl_ui_test_widget_sub_iterator);
tcase_add_test(tc, efl_ui_test_widget_sub_object_add_del);
tcase_add_test(tc, efl_ui_test_widget_sub_object_theme_sync);
}