summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-21 19:44:48 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-21 19:48:46 +0100
commitf5ac9a3e6ca230ea913eda0e315a553a41bb7f6e (patch)
tree43169e0823b4e1b14dd762c0144f4bd5b3029725
parent2677b9d4808b4f99da1b15d12d3bba04b6908aa2 (diff)
efl_ui_widget: fix disabled set behaviourdevs/bu5hm4n/work_widget
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.
-rw-r--r--src/lib/elementary/efl_ui_widget.c20
-rw-r--r--src/tests/elementary/efl_ui_test_widget.c39
2 files changed, 51 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
2111_efl_ui_widget_disabled_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd, Eina_Bool disabled) 2111_efl_ui_widget_disabled_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd, Eina_Bool disabled)
2112{ 2112{
2113 Efl_Ui_Widget *subs; 2113 Efl_Ui_Widget *subs;
2114 int distance, parent_counter = (pd->parent_obj ? _disabled_counter_get(pd->parent_obj) : 0); 2114 int old_state, distance, parent_counter = (pd->parent_obj ? _disabled_counter_get(pd->parent_obj) : 0);
2115
2116 old_state = pd->disabled;
2115 2117
2116 if (disabled) 2118 if (disabled)
2117 pd->disabled ++; 2119 pd->disabled ++;
@@ -2125,15 +2127,17 @@ _efl_ui_widget_disabled_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd, Eina
2125 distance = MAX(MIN(disabled, 1), 0); 2127 distance = MAX(MIN(disabled, 1), 0);
2126 pd->disabled = parent_counter + distance; 2128 pd->disabled = parent_counter + distance;
2127 } 2129 }
2128 for (unsigned int i = 0; i < eina_array_count(pd->children); ++i) 2130 if (old_state != pd->disabled)
2129 { 2131 {
2130 subs = eina_array_data_get(pd->children, i); 2132 for (unsigned int i = 0; i < eina_array_count(pd->children); ++i)
2131 if (efl_isa(subs, EFL_UI_WIDGET_CLASS)) 2133 {
2132 efl_ui_widget_disabled_set(subs, efl_ui_widget_disabled_get(obj)); 2134 subs = eina_array_data_get(pd->children, i);
2135 if (efl_isa(subs, EFL_UI_WIDGET_CLASS))
2136 efl_ui_widget_disabled_set(subs, efl_ui_widget_disabled_get(obj));
2137 }
2138 if (efl_finalized_get(obj))
2139 _elm_widget_full_eval_children(obj, pd);
2133 } 2140 }
2134
2135 if (efl_finalized_get(obj))
2136 _elm_widget_full_eval_children(obj, pd);
2137} 2141}
2138 2142
2139EOLIAN static Eina_Bool 2143EOLIAN 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..c369ad4565 100644
--- a/src/tests/elementary/efl_ui_test_widget.c
+++ b/src/tests/elementary/efl_ui_test_widget.c
@@ -364,6 +364,44 @@ EFL_START_TEST(efl_ui_test_widget_tree_unfocusable)
364} 364}
365EFL_END_TEST 365EFL_END_TEST
366 366
367#define CHECK_DISABLED_STATE(x) \
368 ck_assert_int_eq(efl_ui_widget_disabled_get(s.box), x); \
369 ck_assert_int_eq(efl_ui_widget_disabled_get(s.win), x); \
370 ck_assert_int_eq(efl_ui_widget_disabled_get(s.ic), x); \
371 ck_assert_int_eq(efl_ui_widget_disabled_get(s.btn1), x); \
372 ck_assert_int_eq(efl_ui_widget_disabled_get(s.btn2), x)
373
374
375EFL_START_TEST(efl_ui_test_widget_disabled_repeat_call)
376{
377 State s;
378
379 _small_ui(&s);
380 printf("ASD\n");
381 CHECK_DISABLED_STATE(0);
382
383 printf("ASD\n");
384 efl_ui_widget_disabled_set(s.win, EINA_TRUE);
385 CHECK_DISABLED_STATE(1);
386
387 printf("ASD\n");
388 efl_ui_widget_disabled_set(s.win, EINA_FALSE);
389 CHECK_DISABLED_STATE(0);
390
391 printf("ASD\n");
392 efl_ui_widget_disabled_set(s.win, EINA_TRUE);
393 CHECK_DISABLED_STATE(1);
394
395 printf("ASD\n");
396 efl_ui_widget_disabled_set(s.win, EINA_TRUE);
397 CHECK_DISABLED_STATE(1);
398
399 printf("ASD\n");
400 efl_ui_widget_disabled_set(s.win, EINA_FALSE);
401 CHECK_DISABLED_STATE(0);
402}
403EFL_END_TEST
404
367void efl_ui_test_widget(TCase *tc) 405void efl_ui_test_widget(TCase *tc)
368{ 406{
369 tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown); 407 tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown);
@@ -379,4 +417,5 @@ void efl_ui_test_widget(TCase *tc)
379 tcase_add_test(tc, efl_ui_test_widget_disabled_behaviour); 417 tcase_add_test(tc, efl_ui_test_widget_disabled_behaviour);
380 tcase_add_test(tc, efl_ui_test_widget_win_provider_find); 418 tcase_add_test(tc, efl_ui_test_widget_win_provider_find);
381 tcase_add_test(tc, efl_ui_test_widget_tree_unfocusable); 419 tcase_add_test(tc, efl_ui_test_widget_tree_unfocusable);
420 tcase_add_test(tc, efl_ui_test_widget_disabled_repeat_call);
382} 421}