summaryrefslogtreecommitdiff
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
parente7618b7169b691cb21a1de40e906ffead307aa4a (diff)
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)
1377EOLIAN static void 1377EOLIAN static void
1378_efl_ui_widget_widget_parent_set(Eo *obj, Elm_Widget_Smart_Data *pd, Efl_Ui_Widget *parent) 1378_efl_ui_widget_widget_parent_set(Eo *obj, Elm_Widget_Smart_Data *pd, Efl_Ui_Widget *parent)
1379{ 1379{
1380 Eina_Bool mirrored, pmirrored = efl_ui_mirrored_get(obj);
1381 Efl_Ui_Widget *old_parent; 1380 Efl_Ui_Widget *old_parent;
1382 //check if we are in the subobject list of parents 1381 //check if we are in the subobject list of parents
1383 if (parent) 1382 if (parent)
@@ -1386,32 +1385,33 @@ _efl_ui_widget_widget_parent_set(Eo *obj, Elm_Widget_Smart_Data *pd, Efl_Ui_Widg
1386 EINA_SAFETY_ON_FALSE_RETURN(eina_list_data_find(ppd->subobjs, obj)); 1385 EINA_SAFETY_ON_FALSE_RETURN(eina_list_data_find(ppd->subobjs, obj));
1387 } 1386 }
1388 1387
1388 /* NOTE: In the following two lines, 'obj' is correct. Do not change it.
1389 * Due to elementary's scale policy, scale and prev_scale can be different in
1390 * some cases. This happens when obj's previous parent and new parent have
1391 * different scale value.
1392 * For example, if obj's previous parent's scale is 5 and new parent's scale
1393 * is 2 while obj's scale is 0. Then 'prev_pscale' is 5 and 'scale' is 2. So
1394 * we need to reset obj's scale to 5.
1395 * Note that each widget's scale is 1.0 by default.
1396 */
1397 double scale, prev_scale = efl_gfx_entity_scale_get(obj);
1398 Elm_Theme *th, *prev_th = elm_widget_theme_get(obj);
1399 Eina_Bool mirrored, pmirrored = efl_ui_mirrored_get(parent);
1400
1389 old_parent = pd->parent_obj; 1401 old_parent = pd->parent_obj;
1390 pd->parent_obj = parent; 1402 pd->parent_obj = parent;
1391 1403
1392 // now lets sync up all states 1404 // now lets sync up all states
1393
1394 if (pd->parent_obj) 1405 if (pd->parent_obj)
1395 { 1406 {
1396 /* NOTE: In the following two lines, 'sobj' is correct. Do not change it.
1397 * Due to elementary's scale policy, scale and pscale can be different in
1398 * some cases. This happens when sobj's previous parent and new parent have
1399 * different scale value.
1400 * For example, if sobj's previous parent's scale is 5 and new parent's scale
1401 * is 2 while sobj's scale is 0. Then 'pscale' is 5 and 'scale' is 2. So we
1402 * need to reset sobj's scale to 5.
1403 * Note that each widget's scale is 0 by default.
1404 */
1405 double scale, pscale = efl_gfx_entity_scale_get(obj);
1406 Elm_Theme *th, *pth = elm_widget_theme_get(obj);
1407
1408 scale = efl_gfx_entity_scale_get(obj); 1407 scale = efl_gfx_entity_scale_get(obj);
1409 th = elm_widget_theme_get(obj); 1408 th = elm_widget_theme_get(obj);
1410 mirrored = efl_ui_mirrored_get(obj); 1409 mirrored = efl_ui_mirrored_get(obj);
1411 1410
1412 if (!pd->on_create) 1411 if (!pd->on_create)
1413 { 1412 {
1414 if ((scale != pscale) || (th != pth) || (pmirrored != mirrored)) 1413 if ((scale != prev_scale) || (th != prev_th) ||
1414 (pmirrored != mirrored))
1415 elm_widget_theme(obj); 1415 elm_widget_theme(obj);
1416 } 1416 }
1417 if (_is_focused(obj)) _parents_focus(parent); 1417 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)
188} 188}
189EFL_END_TEST 189EFL_END_TEST
190 190
191EFL_START_TEST(efl_ui_test_widget_sub_object_theme_sync)
192{
193 State s;
194 Efl_Canvas_Layout *edje;
195
196 _small_ui(&s);
197 edje = elm_widget_resize_object_get(s.btn1);
198
199 ck_assert_double_eq(efl_gfx_entity_scale_get(s.btn1), 1.0);
200 ck_assert_double_eq(efl_gfx_entity_scale_get(edje), 1.0);
201 ck_assert_double_eq(efl_gfx_entity_scale_get(s.btn2), 1.0);
202
203 efl_gfx_entity_scale_set(s.win, 0.123);
204 ck_assert_double_eq(efl_gfx_entity_scale_get(s.btn1), 0.123);
205 ck_assert_double_eq(efl_gfx_entity_scale_get(edje), 0.123);
206 ck_assert_double_eq(efl_gfx_entity_scale_get(s.btn2), 0.123);
207
208 efl_ui_widget_sub_object_del(s.box, s.btn1);
209 efl_gfx_entity_scale_set(s.win, 0.456);
210 ck_assert_double_eq(efl_gfx_entity_scale_get(s.btn1), 1.0);
211 ck_assert_double_eq(efl_gfx_entity_scale_get(edje), 0.123);
212 ck_assert_double_eq(efl_gfx_entity_scale_get(s.btn2), 0.456);
213
214 efl_gfx_entity_scale_set(s.win, 0.789);
215 efl_ui_widget_sub_object_add(s.box, s.btn1);
216 ck_assert_double_eq(efl_gfx_entity_scale_get(s.btn1), 0.789);
217 ck_assert_double_eq(efl_gfx_entity_scale_get(edje), 0.789);
218 ck_assert_double_eq(efl_gfx_entity_scale_get(s.btn2), 0.789);
219}
220EFL_END_TEST
221
191void efl_ui_test_widget(TCase *tc) 222void efl_ui_test_widget(TCase *tc)
192{ 223{
193 tcase_add_test(tc, efl_ui_test_widget_parent_iterator); 224 tcase_add_test(tc, efl_ui_test_widget_parent_iterator);
@@ -196,4 +227,5 @@ void efl_ui_test_widget(TCase *tc)
196 tcase_add_test(tc, efl_ui_test_widget_iterator); 227 tcase_add_test(tc, efl_ui_test_widget_iterator);
197 tcase_add_test(tc, efl_ui_test_widget_sub_iterator); 228 tcase_add_test(tc, efl_ui_test_widget_sub_iterator);
198 tcase_add_test(tc, efl_ui_test_widget_sub_object_add_del); 229 tcase_add_test(tc, efl_ui_test_widget_sub_object_add_del);
230 tcase_add_test(tc, efl_ui_test_widget_sub_object_theme_sync);
199} 231}