zmike pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=151862f50cac4ee42ec5a96ad98d3fe2d1a0fdff
commit 151862f50cac4ee42ec5a96ad98d3fe2d1a0fdff Author: Marcel Hollerbach <[email protected]> Date: Mon Mar 23 12:12:12 2020 -0400 efl_ui_widget: fix disabled set behaviour Summary: this fixes disabled set behaviour. This ensures that when setting disabled twice, that unsetting it once does not break the overall state. This never appeared in any real life example, because elm_object_disabled_set is already checking for equalness. However, this is not wanted here, because the simple setter can also be used to sync the state with the parent, which appears to be helpfull. Depends on D11550 Reviewers: zmike Reviewed By: zmike Subscribers: zmike, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D11551 --- src/lib/elementary/efl_ui_widget.c | 20 +++++++++++-------- src/tests/elementary/efl_ui_test_widget.c | 33 +++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/src/lib/elementary/efl_ui_widget.c b/src/lib/elementary/efl_ui_widget.c index 929e53a2e4..f5063a3575 100644 --- a/src/lib/elementary/efl_ui_widget.c +++ b/src/lib/elementary/efl_ui_widget.c @@ -2111,7 +2111,9 @@ EOLIAN static void _efl_ui_widget_disabled_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd, Eina_Bool disabled) { Efl_Ui_Widget *subs; - int distance, parent_counter = (pd->parent_obj ? _disabled_counter_get(pd->parent_obj) : 0); + int old_state, distance, parent_counter = (pd->parent_obj ? _disabled_counter_get(pd->parent_obj) : 0); + + old_state = pd->disabled; if (disabled) pd->disabled ++; @@ -2125,15 +2127,17 @@ _efl_ui_widget_disabled_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd, Eina distance = MAX(MIN(disabled, 1), 0); pd->disabled = parent_counter + distance; } - for (unsigned int i = 0; i < eina_array_count(pd->children); ++i) + if (old_state != pd->disabled) { - subs = eina_array_data_get(pd->children, i); - if (efl_isa(subs, EFL_UI_WIDGET_CLASS)) - efl_ui_widget_disabled_set(subs, efl_ui_widget_disabled_get(obj)); + for (unsigned int i = 0; i < eina_array_count(pd->children); ++i) + { + subs = eina_array_data_get(pd->children, i); + if (efl_isa(subs, EFL_UI_WIDGET_CLASS)) + efl_ui_widget_disabled_set(subs, efl_ui_widget_disabled_get(obj)); + } + if (efl_finalized_get(obj)) + _elm_widget_full_eval_children(obj, pd); } - - if (efl_finalized_get(obj)) - _elm_widget_full_eval_children(obj, pd); } EOLIAN static Eina_Bool diff --git a/src/tests/elementary/efl_ui_test_widget.c b/src/tests/elementary/efl_ui_test_widget.c index 7b260dd40c..cbef4fa385 100644 --- a/src/tests/elementary/efl_ui_test_widget.c +++ b/src/tests/elementary/efl_ui_test_widget.c @@ -364,6 +364,38 @@ EFL_START_TEST(efl_ui_test_widget_tree_unfocusable) } EFL_END_TEST +#define CHECK_DISABLED_STATE(x) \ + ck_assert_int_eq(efl_ui_widget_disabled_get(s.box), x); \ + ck_assert_int_eq(efl_ui_widget_disabled_get(s.win), x); \ + ck_assert_int_eq(efl_ui_widget_disabled_get(s.ic), x); \ + ck_assert_int_eq(efl_ui_widget_disabled_get(s.btn1), x); \ + ck_assert_int_eq(efl_ui_widget_disabled_get(s.btn2), x) + + +EFL_START_TEST(efl_ui_test_widget_disabled_repeat_call) +{ + State s; + + _small_ui(&s); + CHECK_DISABLED_STATE(0); + + efl_ui_widget_disabled_set(s.win, EINA_TRUE); + CHECK_DISABLED_STATE(1); + + efl_ui_widget_disabled_set(s.win, EINA_FALSE); + CHECK_DISABLED_STATE(0); + + efl_ui_widget_disabled_set(s.win, EINA_TRUE); + CHECK_DISABLED_STATE(1); + + efl_ui_widget_disabled_set(s.win, EINA_TRUE); + CHECK_DISABLED_STATE(1); + + efl_ui_widget_disabled_set(s.win, EINA_FALSE); + CHECK_DISABLED_STATE(0); +} +EFL_END_TEST + void efl_ui_test_widget(TCase *tc) { tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown); @@ -379,4 +411,5 @@ void efl_ui_test_widget(TCase *tc) tcase_add_test(tc, efl_ui_test_widget_disabled_behaviour); tcase_add_test(tc, efl_ui_test_widget_win_provider_find); tcase_add_test(tc, efl_ui_test_widget_tree_unfocusable); + tcase_add_test(tc, efl_ui_test_widget_disabled_repeat_call); } --
