aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYeongjong Lee <yj34.lee@samsung.com>2019-03-11 09:44:16 +0000
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-03-11 21:34:57 +0100
commitda0ff534716774b35a98c359e8c7fd7bdde7a3d2 (patch)
tree9cab1d99dc822903a92123460f351edbc8757036
parentbuild: do not reply on header checking libinotify.h (diff)
downloadefl-da0ff534716774b35a98c359e8c7fd7bdde7a3d2.tar.gz
ui.widget: fix theme_apply working in sub_object_add
It seems that theme_apply in sub_object_add haven't worked since commit f6fa1ef6120fdebcdaf1568674c48b9d17f76f64. scale, theme property will be set properly when the parent is changed. Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D8283
-rw-r--r--src/lib/elementary/efl_ui_widget.c30
-rw-r--r--src/tests/elementary/efl_ui_test_widget.c32
2 files changed, 47 insertions, 15 deletions
diff --git a/src/lib/elementary/efl_ui_widget.c b/src/lib/elementary/efl_ui_widget.c
index acab4f32f5..ca2b975954 100644
--- a/src/lib/elementary/efl_ui_widget.c
+++ b/src/lib/elementary/efl_ui_widget.c
@@ -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);
diff --git a/src/tests/elementary/efl_ui_test_widget.c b/src/tests/elementary/efl_ui_test_widget.c
index d5f9c4d525..221978bade 100644
--- a/src/tests/elementary/efl_ui_test_widget.c
+++ b/src/tests/elementary/efl_ui_test_widget.c
@@ -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_double_eq(efl_gfx_entity_scale_get(s.btn1), 1.0);
+ ck_assert_double_eq(efl_gfx_entity_scale_get(edje), 1.0);
+ ck_assert_double_eq(efl_gfx_entity_scale_get(s.btn2), 1.0);
+
+ efl_gfx_entity_scale_set(s.win, 0.123);
+ ck_assert_double_eq(efl_gfx_entity_scale_get(s.btn1), 0.123);
+ ck_assert_double_eq(efl_gfx_entity_scale_get(edje), 0.123);
+ ck_assert_double_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_double_eq(efl_gfx_entity_scale_get(s.btn1), 1.0);
+ ck_assert_double_eq(efl_gfx_entity_scale_get(edje), 0.123);
+ ck_assert_double_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_double_eq(efl_gfx_entity_scale_get(s.btn1), 0.789);
+ ck_assert_double_eq(efl_gfx_entity_scale_get(edje), 0.789);
+ ck_assert_double_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);
}