From 31a38db7b7f040388b196e941236323a6d77d126 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 27 Feb 2019 14:00:14 -0500 Subject: [PATCH] efl_ui_widget: redo disable handling before the disable property was a bit weird. Setting something to disabled=true will disable all children of the widget that is changed. However, only the update function of the children will get the false flag, not the flag itself. Which means, to query the real disabled state, we need to walk up the parent relations. With this patch, every change to disabled will go through the disabled property, which mean, a implementor can just overwrite the disabled property, and adjust its internal state there. Just be carefull, a set to disabled=true still might result in disabled=false. This makes the function on_disable_update unneccesary. Which also cleans up the Efl.Ui.Widget class. ref T7553 Depends on D8016 Reviewed-by: Mike Blumenkrantz Differential Revision: https://phab.enlightenment.org/D8017 --- src/lib/elementary/efl_ui_layout.c | 56 +++++++++------------ src/lib/elementary/efl_ui_layout_base.eo | 2 +- src/lib/elementary/efl_ui_panel.c | 9 ++-- src/lib/elementary/efl_ui_panel.eo | 2 +- src/lib/elementary/efl_ui_text.c | 22 ++++---- src/lib/elementary/efl_ui_text.eo | 2 +- src/lib/elementary/efl_ui_widget.c | 84 ++++++++++--------------------- src/lib/elementary/efl_ui_widget.eo | 13 +---- src/lib/elementary/efl_ui_win.c | 5 +- src/lib/elementary/elm_entry.c | 36 +++++++------ src/lib/elementary/elm_entry.eo | 2 +- src/lib/elementary/elm_gesture_layer.c | 10 ++-- src/lib/elementary/elm_gesture_layer.eo | 2 +- src/lib/elementary/elm_list.c | 11 ++-- src/lib/elementary/elm_list.eo | 2 +- src/lib/elementary/elm_main.c | 14 ++++++ src/lib/elementary/elm_panel.c | 13 ++--- src/lib/elementary/elm_panel.eo | 2 +- src/lib/elementary/elm_segment_control.c | 11 ++-- src/lib/elementary/elm_segment_control.eo | 2 +- src/lib/elementary/elm_slider.c | 9 ++-- src/lib/elementary/elm_slider.eo | 2 +- src/lib/elementary/elm_widget.h | 2 +- src/lib/elementary_tizen/elc_ctxpopup.c | 15 ------ src/tests/elementary/elm_test_box.c | 38 ++++++++++++++ 25 files changed, 173 insertions(+), 193 deletions(-) diff --git a/src/lib/elementary/efl_ui_layout.c b/src/lib/elementary/efl_ui_layout.c index cd984b0..0dbd36c 100644 --- a/src/lib/elementary/efl_ui_layout.c +++ b/src/lib/elementary/efl_ui_layout.c @@ -471,12 +471,29 @@ _efl_ui_layout_highlight_in_theme(Evas_Object *obj) elm_widget_access_highlight_in_theme_set(obj, EINA_FALSE); } +static void +_flush_mirrored_state(Eo *obj) +{ + char prefix[4], state[10], signal[100]; + + if (efl_ui_widget_disabled_get(obj)) + snprintf(state, sizeof(state), "disabled"); + else + snprintf(state, sizeof(state), "enabled"); + + if (!elm_widget_is_legacy(obj)) + snprintf(prefix, sizeof(prefix), "efl"); + else + snprintf(prefix, sizeof(prefix), "elm"); + + snprintf(signal, sizeof(signal), "%s,state,%s", prefix, state); + efl_layout_signal_emit(obj, signal, prefix); +} + static Eina_Bool _visuals_refresh(Evas_Object *obj, Efl_Ui_Layout_Data *sd) { - Eina_Bool ret = EINA_FALSE; - ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); /* TIZEN_ONLY(20180420): Do text/content set when new theme is applied */ @@ -494,41 +511,18 @@ _visuals_refresh(Evas_Object *obj, efl_gfx_entity_scale_get(obj) * elm_config_scale_get()); _efl_ui_layout_highlight_in_theme(obj); - - ret = efl_ui_widget_on_disabled_update(obj, elm_widget_disabled_get(obj)); + _flush_mirrored_state(obj); elm_layout_sizing_eval(obj); - return ret; + return EINA_TRUE; } -EOLIAN static Eina_Bool -_efl_ui_layout_base_efl_ui_widget_on_disabled_update(Eo *obj, Efl_Ui_Layout_Data *_pd EINA_UNUSED, Eina_Bool disabled) +EOLIAN static void +_efl_ui_layout_base_efl_ui_widget_disabled_set(Eo *obj, Efl_Ui_Layout_Data *_pd EINA_UNUSED, Eina_Bool disabled) { - ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE); - - // Not calling efl_super here: Elm.Widget simply returns false. - - if (elm_widget_is_legacy(obj)) - { - if (disabled) - edje_object_signal_emit - (wd->resize_obj, "elm,state,disabled", "elm"); - else - edje_object_signal_emit - (wd->resize_obj, "elm,state,enabled", "elm"); - } - else - { - if (disabled) - edje_object_signal_emit - (wd->resize_obj, "efl,state,disabled", "efl"); - else - edje_object_signal_emit - (wd->resize_obj, "efl,state,enabled", "efl"); - } - - return EINA_TRUE; + efl_ui_widget_disabled_set(efl_super(obj, MY_CLASS), disabled); + _flush_mirrored_state(obj); } static Efl_Ui_Theme_Apply_Result diff --git a/src/lib/elementary/efl_ui_layout_base.eo b/src/lib/elementary/efl_ui_layout_base.eo index c0ef29c..85a5103 100644 --- a/src/lib/elementary/efl_ui_layout_base.eo +++ b/src/lib/elementary/efl_ui_layout_base.eo @@ -68,7 +68,7 @@ abstract @beta Efl.Ui.Layout_Base extends Efl.Ui.Widget implements Efl.Container Efl.Layout.Group.part_exist { get; } Efl.Ui.Widget.widget_sub_object_add; Efl.Ui.Widget.theme_apply; - Efl.Ui.Widget.on_disabled_update; + Efl.Ui.Widget.disabled {set;} Efl.Ui.Widget.widget_sub_object_del; Efl.Ui.Focus.Object.on_focus_update; Efl.Container.content_count; diff --git a/src/lib/elementary/efl_ui_panel.c b/src/lib/elementary/efl_ui_panel.c index 77c8ae1..285cebf 100644 --- a/src/lib/elementary/efl_ui_panel.c +++ b/src/lib/elementary/efl_ui_panel.c @@ -1156,11 +1156,10 @@ _scroll_cb(Evas_Object *obj, void *data EINA_UNUSED) (obj, EFL_UI_EVENT_SCROLL, (void *) &event); } -EOLIAN static Eina_Bool -_efl_ui_panel_efl_ui_widget_on_disabled_update(Eo *obj, Efl_Ui_Panel_Data *sd, Eina_Bool disabled) +EOLIAN static void +_efl_ui_panel_efl_ui_widget_disabled_set(Eo *obj, Efl_Ui_Panel_Data *sd, Eina_Bool disabled) { - if (!efl_ui_widget_on_disabled_update(efl_super(obj, MY_CLASS), disabled)) - return EINA_FALSE; + efl_ui_widget_disabled_set(efl_super(obj, MY_CLASS), disabled); if (sd->scrollable) { @@ -1191,8 +1190,6 @@ _efl_ui_panel_efl_ui_widget_on_disabled_update(Eo *obj, Efl_Ui_Panel_Data *sd, E sd->callback_added = EINA_TRUE; } } - - return EINA_TRUE; } EOLIAN static double diff --git a/src/lib/elementary/efl_ui_panel.eo b/src/lib/elementary/efl_ui_panel.eo index 8aa1189..f1dadaa 100644 --- a/src/lib/elementary/efl_ui_panel.eo +++ b/src/lib/elementary/efl_ui_panel.eo @@ -80,7 +80,7 @@ class @beta Efl.Ui.Panel extends Efl.Ui.Layout implements Efl.Ui.Focus.Layer, El Efl.Gfx.Entity.size { set; } Efl.Canvas.Group.group_member_add; Efl.Ui.Widget.theme_apply; - Efl.Ui.Widget.on_disabled_update; + Efl.Ui.Widget.disabled {set;} Efl.Ui.Widget.on_access_update; Efl.Ui.Widget.widget_event; Efl.Ui.Widget.interest_region { get; } diff --git a/src/lib/elementary/efl_ui_text.c b/src/lib/elementary/efl_ui_text.c index c6655ac..b079bf2 100644 --- a/src/lib/elementary/efl_ui_text.c +++ b/src/lib/elementary/efl_ui_text.c @@ -698,10 +698,12 @@ _get_drop_format(Evas_Object *obj) } /* we can't reuse layout's here, because it's on entry_edje only */ -EOLIAN static Eina_Bool -_efl_ui_text_efl_ui_widget_on_disabled_update(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Bool disabled) +EOLIAN static void +_efl_ui_text_efl_ui_widget_disabled_set(Eo *obj, Efl_Ui_Text_Data *sd, Eina_Bool disabled) { - const char *emission ; + const char *emission; + + efl_ui_widget_disabled_set(efl_super(obj, MY_CLASS), disabled); elm_drop_target_del(obj, sd->drop_format, _dnd_enter_cb, NULL, @@ -709,16 +711,16 @@ _efl_ui_text_efl_ui_widget_on_disabled_update(Eo *obj, Efl_Ui_Text_Data *sd, Ein _dnd_pos_cb, NULL, _dnd_drop_cb, NULL); - emission = disabled ? "efl,state,disabled" : "efl,state,enabled"; + emission = efl_ui_widget_disabled_get(obj) ? "efl,state,disabled" : "efl,state,enabled"; edje_object_signal_emit(sd->entry_edje, emission, "efl"); if (sd->scroll) { edje_object_signal_emit(sd->scr_edje, emission, "efl"); - //elm_interface_scrollable_freeze_set(obj, disabled); + elm_interface_scrollable_freeze_set(obj, efl_ui_widget_disabled_get(obj)); } - sd->disabled = disabled; + sd->disabled = efl_ui_widget_disabled_get(obj); - if (!disabled) + if (!efl_ui_widget_disabled_get(obj)) { sd->drop_format = _get_drop_format(obj); elm_drop_target_add(obj, sd->drop_format, @@ -727,8 +729,6 @@ _efl_ui_text_efl_ui_widget_on_disabled_update(Eo *obj, Efl_Ui_Text_Data *sd, Ein _dnd_pos_cb, NULL, _dnd_drop_cb, NULL); } - - return EINA_TRUE; } /* we can't issue the layout's theming code here, cause it assumes an @@ -2071,7 +2071,7 @@ _format_color_parse(const char *str, int slen, /** * @internal * Updates the text properties of the object from the theme. - * + * * This update functions skips any property that was already set, * to allow users to override the theme during the construction of the widget. */ @@ -3642,7 +3642,7 @@ _anchor_format_parse(const char *item) static Anchor * _anchor_get(Eo *obj, Efl_Ui_Text_Data *sd, Efl_Text_Annotate_Annotation *an) { - Anchor *anc; + Anchor *anc; Eina_List *i; const char *str; diff --git a/src/lib/elementary/efl_ui_text.eo b/src/lib/elementary/efl_ui_text.eo index c4f4bf9..79727f7 100644 --- a/src/lib/elementary/efl_ui_text.eo +++ b/src/lib/elementary/efl_ui_text.eo @@ -334,7 +334,7 @@ class @beta Efl.Ui.Text extends Efl.Ui.Layout_Base implements Efl.Ui.Clickable, Efl.Ui.Widget.theme_apply; Efl.Ui.Focus.Object.on_focus_update; Efl.Ui.Widget.interest_region { get; } - Efl.Ui.Widget.on_disabled_update; + Efl.Ui.Widget.disabled {set;} //Efl.Ui.Widget.widget_sub_object_del; //Elm.Interface_Scrollable.policy { set; } //Elm.Interface_Scrollable.bounce_allow { set; } diff --git a/src/lib/elementary/efl_ui_widget.c b/src/lib/elementary/efl_ui_widget.c index e895678..db3d5cb 100644 --- a/src/lib/elementary/efl_ui_widget.c +++ b/src/lib/elementary/efl_ui_widget.c @@ -92,7 +92,6 @@ struct _Elm_Translate_String_Data static void _efl_ui_widget_efl_canvas_object_paragraph_direction_set_internal(Eo *obj EINA_UNUSED, Efl_Ui_Widget_Data *sd, Evas_BiDi_Direction dir); // TIZEN_ONLY(20180117): Override Paragraph Direction APIs static void _if_focused_revert(Evas_Object *obj, Eina_Bool can_focus_only); //TIZEN_ONLY(20180607): Restore legacy focus -static void elm_widget_disabled_internal(Eo *obj, Eina_Bool disabled); static void _on_sub_obj_hide(void *data, const Efl_Event *event); static inline Eina_Bool _elm_widget_focus_chain_manager_is(const Evas_Object *obj); @@ -257,7 +256,8 @@ _elm_scrollable_is(const Evas_Object *obj) efl_isa(obj, EFL_UI_SCROLLABLE_INTERACTIVE_INTERFACE); } -static void _on_sub_obj_del(void *data, const Efl_Event *event); +static void +_on_sub_obj_del(void *data, const Efl_Event *event); static void _propagate_event(void *data, const Efl_Event *eo_event); static void _elm_widget_focus_tree_unfocusable_handle(Eo *obj); static void _elm_widget_shadow_update(Efl_Ui_Widget *obj); @@ -1461,8 +1461,6 @@ EOLIAN static Efl_Ui_Theme_Apply_Result _efl_ui_widget_theme_apply(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED) { _elm_widget_mirrored_reload(obj); - if (elm_widget_disabled_get(obj)) - elm_widget_disabled_internal(obj, elm_widget_disabled_get(obj)); return EFL_UI_THEME_APPLY_RESULT_SUCCESS; } @@ -1634,9 +1632,9 @@ _efl_ui_widget_widget_sub_object_add(Eo *obj, Elm_Widget_Smart_Data *sd, Evas_Ob if (elm_widget_is_legacy(sobj)) efl_ui_widget_focus_disabled_handle(sobj); // - efl_ui_widget_on_disabled_update(sobj, EINA_TRUE); } } + efl_ui_widget_disabled_set(sobj, efl_ui_widget_disabled_get(obj)); _elm_widget_top_win_focused_set(sobj, sd->top_win_focused); @@ -2704,26 +2702,37 @@ _elm_widget_top_win_focused_get(const Evas_Object *obj) } EOLIAN static void -_efl_ui_widget_disabled_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool disabled) +_efl_ui_widget_disabled_set(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd, Eina_Bool disabled) { - if (sd->disabled == disabled) return; - sd->disabled = !!disabled; + Efl_Ui_Widget *subs; + Eina_List *n; + + if (disabled) + pd->disabled ++; + else + pd->disabled = MAX(pd->disabled - 1 ,0); - elm_widget_disabled_internal(obj, disabled); + EINA_LIST_FOREACH(pd->subobjs, n, subs) + { + //TIZEN_ONLY(20180607): Restore legacy focus + if (elm_widget_is(subs)) + { + if (elm_widget_is_legacy(subs)) + efl_ui_widget_focus_disabled_handle((Evas_Object *)subs); + } + // + 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, sd); + _elm_widget_full_eval_children(obj, pd); } EOLIAN static Eina_Bool -_efl_ui_widget_disabled_get(const Eo *obj, Elm_Widget_Smart_Data *sd) +_efl_ui_widget_disabled_get(const Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *pd) { - Eo *parent; - - if (sd->disabled) return EINA_TRUE; - if ((parent = elm_widget_parent_get(obj)) != NULL) - return elm_widget_disabled_get(parent); - return EINA_FALSE; + return pd->disabled > 0; } /** @@ -5764,12 +5773,6 @@ _efl_ui_widget_efl_ui_focus_object_on_focus_update(Eo *obj, Elm_Widget_Smart_Dat } EOLIAN static Eina_Bool -_efl_ui_widget_on_disabled_update(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, Eina_Bool disabled EINA_UNUSED) -{ - return EINA_FALSE; -} - -EOLIAN static Eina_Bool _efl_ui_widget_widget_event(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *_pd EINA_UNUSED, const Efl_Event *eo_event EINA_UNUSED, Evas_Object *source EINA_UNUSED) { return EINA_FALSE; @@ -9765,41 +9768,6 @@ _efl_ui_widget_focus_restore(Eo *obj, Elm_Widget_Smart_Data *_pd EINA_UNUSED) //END -static void -_elm_widget_disabled_eval(const Evas_Object *obj, Eina_Bool disabled) -{ - const Eina_List *l; - Evas_Object *child; - ELM_WIDGET_DATA_GET(obj, sd); - - EINA_LIST_FOREACH(sd->subobjs, l, child) - { - if (elm_widget_is(child)) - { - //TIZEN_ONLY(20180607): Restore legacy focus - if (elm_widget_is_legacy(obj)) - efl_ui_widget_focus_disabled_handle((Evas_Object *)obj); - // - efl_ui_widget_on_disabled_update(child, disabled); - _elm_widget_disabled_eval(child, disabled); - } - } -} - -static void -elm_widget_disabled_internal(Eo *obj, Eina_Bool disabled) -{ - if (!disabled && elm_widget_disabled_get(elm_widget_parent_get(obj))) - return; - //TIZEN_ONLY(20180607): Restore legacy focus - if (elm_widget_is_legacy(obj)) - efl_ui_widget_focus_disabled_handle(obj); - // - efl_ui_widget_on_disabled_update(obj, disabled); - _elm_widget_disabled_eval(obj, disabled); -} - - EOLIAN static void _efl_ui_widget_show_region_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Rect sr, Eina_Bool forceshow) { diff --git a/src/lib/elementary/efl_ui_widget.eo b/src/lib/elementary/efl_ui_widget.eo index 89233b5..8a3d7b5 100644 --- a/src/lib/elementary/efl_ui_widget.eo +++ b/src/lib/elementary/efl_ui_widget.eo @@ -115,6 +115,8 @@ abstract @beta Efl.Ui.Widget extends Efl.Canvas.Group implements Efl.Access.Obje @property disabled { [[Whether the widget is enabled (accepts and reacts to user inputs). + The property works counted, this means, whenever n-caller set the value to $true, n-caller have to set it to $false in order to get it out of the disabled state again. + Each widget may handle the disabled state differently, but overall disabled widgets shall not respond to any input events. This is $false by default, meaning the widget is enabled. @@ -383,17 +385,6 @@ abstract @beta Efl.Ui.Widget extends Efl.Canvas.Group implements Efl.Access.Obje @.orientation_mode is $disabled.]] } } - on_disabled_update @protected { - [[Virtual function called when the widget becomes disabled. - - This may be triggered even if this widget is not disabled, as the - parent widget could be disabled and propagate its state. - ]] - params { - disabled: bool; [[The new value of @.disabled.]] - } - return: bool; [[Indicates if the operation succeeded.]] - } theme_apply @protected { [[Virtual function called when the widget needs to re-apply its theme. diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c index f4e9bbb..58c2b35 100644 --- a/src/lib/elementary/efl_ui_win.c +++ b/src/lib/elementary/efl_ui_win.c @@ -8030,7 +8030,7 @@ static Efl_Ui_Theme_Apply_Result _elm_win_theme_internal(Eo *obj, Efl_Ui_Win_Data *sd) { Efl_Ui_Theme_Apply_Result int_ret = EFL_UI_THEME_APPLY_RESULT_FAIL; - Eina_Bool ret = EINA_FALSE, prev_alpha; + Eina_Bool prev_alpha; const char *s; int_ret = elm_widget_theme_object_set(obj, sd->legacy.edje, "win", "base", @@ -8042,9 +8042,6 @@ _elm_win_theme_internal(Eo *obj, Efl_Ui_Win_Data *sd) efl_gfx_entity_scale_get(obj) * elm_config_scale_get()); efl_event_callback_legacy_call(obj, EFL_UI_WIN_EVENT_THEME_CHANGED, NULL); - ret = efl_ui_widget_on_disabled_update(obj, elm_widget_disabled_get(obj)); - - if (!ret) int_ret = EFL_UI_THEME_APPLY_RESULT_FAIL; prev_alpha = sd->theme_alpha; s = edje_object_data_get(sd->legacy.edje, "alpha"); diff --git a/src/lib/elementary/elm_entry.c b/src/lib/elementary/elm_entry.c index 200cb69..9fa1e6d 100644 --- a/src/lib/elementary/elm_entry.c +++ b/src/lib/elementary/elm_entry.c @@ -1155,11 +1155,25 @@ _get_drop_format(Evas_Object *obj) return ELM_SEL_FORMAT_MARKUP; } -/* we can't reuse layout's here, because it's on entry_edje only */ -EOLIAN static Eina_Bool -_elm_entry_efl_ui_widget_on_disabled_update(Eo *obj, Elm_Entry_Data *sd, Eina_Bool disabled) +static void +_flush_disabled_state(Eo *obj, Elm_Entry_Data *sd) { const char *emission; + emission = efl_ui_widget_disabled_get(obj) ? "elm,state,disabled" : "elm,state,enabled"; + edje_object_signal_emit(sd->entry_edje, emission, "elm"); + if (sd->scroll) + { + edje_object_signal_emit(sd->scr_edje, emission, "elm"); + elm_interface_scrollable_freeze_set(obj, efl_ui_widget_disabled_get(obj)); + } +} + +/* we can't reuse layout's here, because it's on entry_edje only */ +EOLIAN static void +_elm_entry_efl_ui_widget_disabled_set(Eo *obj, Elm_Entry_Data *sd, Eina_Bool disabled) +{ + + efl_ui_widget_disabled_set(efl_super(obj, MY_CLASS), disabled); elm_drop_target_del(obj, sd->drop_format, _dnd_enter_cb, NULL, @@ -1167,16 +1181,10 @@ _elm_entry_efl_ui_widget_on_disabled_update(Eo *obj, Elm_Entry_Data *sd, Eina_Bo _dnd_pos_cb, NULL, _dnd_drop_cb, NULL); - emission = disabled ? "elm,state,disabled" : "elm,state,enabled"; - edje_object_signal_emit(sd->entry_edje, emission, "elm"); - if (sd->scroll) - { - edje_object_signal_emit(sd->scr_edje, emission, "elm"); - elm_interface_scrollable_freeze_set(obj, disabled); - } - sd->disabled = disabled; + _flush_disabled_state(obj, sd); + sd->disabled = efl_ui_widget_disabled_get(obj); - if (!disabled) + if (!efl_ui_widget_disabled_get(obj)) { sd->drop_format = _get_drop_format(obj); elm_drop_target_add(obj, sd->drop_format, @@ -1185,8 +1193,6 @@ _elm_entry_efl_ui_widget_on_disabled_update(Eo *obj, Elm_Entry_Data *sd, Eina_Bo _dnd_pos_cb, NULL, _dnd_drop_cb, NULL); } - - return EINA_TRUE; } /* It gets the background object from from_edje object and @@ -1425,6 +1431,8 @@ _elm_entry_efl_ui_widget_theme_apply(Eo *obj, Elm_Entry_Data *sd) evas_object_unref(obj); + _flush_disabled_state(obj, sd); + return theme_apply; } diff --git a/src/lib/elementary/elm_entry.eo b/src/lib/elementary/elm_entry.eo index d143bb2..4eb6154 100644 --- a/src/lib/elementary/elm_entry.eo +++ b/src/lib/elementary/elm_entry.eo @@ -887,7 +887,7 @@ class Elm.Entry extends Efl.Ui.Layout_Base implements Elm.Interface_Scrollable, Efl.Ui.Widget_Focus_Manager.focus_manager_create; Efl.Ui.Focus.Object.on_focus_update; Efl.Ui.Widget.interest_region { get; } - Efl.Ui.Widget.on_disabled_update; + Efl.Ui.Widget.disabled {set;} Efl.Ui.Widget.widget_sub_object_del; Elm.Interface_Scrollable.policy { set; } Elm.Interface_Scrollable.bounce_allow { set; } diff --git a/src/lib/elementary/elm_gesture_layer.c b/src/lib/elementary/elm_gesture_layer.c index c711e2a..b1c3212 100644 --- a/src/lib/elementary/elm_gesture_layer.c +++ b/src/lib/elementary/elm_gesture_layer.c @@ -3733,15 +3733,15 @@ _rotate_test(Evas_Object *obj, } } -EOLIAN static Eina_Bool -_elm_gesture_layer_efl_ui_widget_on_disabled_update(Eo *obj, Elm_Gesture_Layer_Data *_pd EINA_UNUSED, Eina_Bool disabled) +EOLIAN static void +_elm_gesture_layer_efl_ui_widget_disabled_set(Eo *obj, Elm_Gesture_Layer_Data *_pd EINA_UNUSED, Eina_Bool disabled) { - if (disabled) + efl_ui_widget_disabled_set(efl_super(obj, MY_CLASS), disabled); + + if (efl_ui_widget_disabled_get(obj)) _callbacks_unregister(obj); else _callbacks_register(obj); - - return EINA_TRUE; } EOLIAN static void diff --git a/src/lib/elementary/elm_gesture_layer.eo b/src/lib/elementary/elm_gesture_layer.eo index a639dfd..ab77f84 100644 --- a/src/lib/elementary/elm_gesture_layer.eo +++ b/src/lib/elementary/elm_gesture_layer.eo @@ -162,6 +162,6 @@ class Elm.Gesture_Layer extends Efl.Ui.Widget implements Efl.Ui.Legacy implements { class.constructor; Efl.Object.constructor; - Efl.Ui.Widget.on_disabled_update; + Efl.Ui.Widget.disabled {set;} } } diff --git a/src/lib/elementary/elm_list.c b/src/lib/elementary/elm_list.c index a77dcb0..1bbae20 100644 --- a/src/lib/elementary/elm_list.c +++ b/src/lib/elementary/elm_list.c @@ -1090,13 +1090,12 @@ _show_region_hook(void *data EINA_UNUSED, Evas_Object *obj, Eina_Rect r) elm_interface_scrollable_content_region_set(obj, r.x, r.y, r.w, r.h); } -EOLIAN static Eina_Bool -_elm_list_efl_ui_widget_on_disabled_update(Eo *obj, Elm_List_Data *sd, Eina_Bool disabled) +EOLIAN static void +_elm_list_efl_ui_widget_disabled_set(Eo *obj, Elm_List_Data *sd, Eina_Bool disabled) { - if (!efl_ui_widget_on_disabled_update(efl_super(obj, MY_CLASS), disabled)) - return EINA_FALSE; + efl_ui_widget_disabled_set(efl_super(obj, MY_CLASS), disabled); - if (disabled) + if (efl_ui_widget_disabled_get(obj)) { elm_widget_scroll_freeze_push(obj); elm_widget_scroll_hold_push(obj); @@ -1109,8 +1108,6 @@ _elm_list_efl_ui_widget_on_disabled_update(Eo *obj, Elm_List_Data *sd, Eina_Bool elm_widget_scroll_freeze_pop(obj); elm_widget_scroll_hold_pop(obj); } - - return EINA_TRUE; } static void diff --git a/src/lib/elementary/elm_list.eo b/src/lib/elementary/elm_list.eo index f20e3ef..18a7bc1 100644 --- a/src/lib/elementary/elm_list.eo +++ b/src/lib/elementary/elm_list.eo @@ -400,7 +400,7 @@ class Elm.List extends Efl.Ui.Layout implements Elm.Interface_Scrollable, Efl.Ui.Widget.theme_apply; Efl.Ui.Widget.on_access_update; Efl.Ui.Widget.focus_highlight_geometry { get; } - Efl.Ui.Widget.on_disabled_update; + Efl.Ui.Widget.disabled {set;} Efl.Ui.Focus.Object.on_focus_update; Efl.Ui.L10n.translation_update; Efl.Ui.Widget.widget_sub_object_del; diff --git a/src/lib/elementary/elm_main.c b/src/lib/elementary/elm_main.c index 45f9849..0961f90 100644 --- a/src/lib/elementary/elm_main.c +++ b/src/lib/elementary/elm_main.c @@ -1629,6 +1629,20 @@ elm_object_disabled_set(Evas_Object *obj, Eina_Bool disabled) { EINA_SAFETY_ON_NULL_RETURN(obj); + ELM_WIDGET_DATA_GET_OR_RETURN(obj, pd); + ELM_WIDGET_DATA_GET_OR_RETURN(efl_ui_widget_parent_get(obj), ppd); + if (disabled) + { + //we aim here for the disabled count of parent + 1 + if (pd->disabled == ppd->disabled + 1) return; + pd->disabled = ppd->disabled; + } + else + { + //we aim for the same disabled count as the parent here + if (pd->disabled == ppd->disabled) return; + pd->disabled = ppd->disabled + 1; + } elm_widget_disabled_set(obj, disabled); } diff --git a/src/lib/elementary/elm_panel.c b/src/lib/elementary/elm_panel.c index 44fea69..23d7371 100644 --- a/src/lib/elementary/elm_panel.c +++ b/src/lib/elementary/elm_panel.c @@ -1335,15 +1335,14 @@ _scroll_cb(Evas_Object *obj, void *data EINA_UNUSED) (obj, EFL_UI_EVENT_SCROLL, (void *) &event); } -EOLIAN static Eina_Bool -_elm_panel_efl_ui_widget_on_disabled_update(Eo *obj, Elm_Panel_Data *sd, Eina_Bool disabled) +EOLIAN static void +_elm_panel_efl_ui_widget_disabled_set(Eo *obj, Elm_Panel_Data *sd, Eina_Bool disabled) { - if (!efl_ui_widget_on_disabled_update(efl_super(obj, MY_CLASS), disabled)) - return EINA_FALSE; + efl_ui_widget_disabled_set(efl_super(obj, MY_CLASS), disabled); if (sd->scrollable) { - if (disabled && sd->callback_added) + if (efl_ui_widget_disabled_get(obj) && sd->callback_added) { evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down); @@ -1356,7 +1355,7 @@ _elm_panel_efl_ui_widget_on_disabled_update(Eo *obj, Elm_Panel_Data *sd, Eina_Bo sd->callback_added = EINA_FALSE; } - else if (!disabled && !sd->callback_added) + else if (!efl_ui_widget_disabled_get(obj) && !sd->callback_added) { evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down, sd); @@ -1370,8 +1369,6 @@ _elm_panel_efl_ui_widget_on_disabled_update(Eo *obj, Elm_Panel_Data *sd, Eina_Bo sd->callback_added = EINA_TRUE; } } - - return EINA_TRUE; } EOLIAN static double diff --git a/src/lib/elementary/elm_panel.eo b/src/lib/elementary/elm_panel.eo index 0dd5e63..eb53bf8 100644 --- a/src/lib/elementary/elm_panel.eo +++ b/src/lib/elementary/elm_panel.eo @@ -83,7 +83,7 @@ class Elm.Panel extends Efl.Ui.Layout implements Efl.Ui.Focus.Layer, Elm.Interfa Efl.Gfx.Entity.size { set; } Efl.Canvas.Group.group_member_add; Efl.Ui.Widget.theme_apply; - Efl.Ui.Widget.on_disabled_update; + Efl.Ui.Widget.disabled {set;} Efl.Ui.Widget.on_access_update; Efl.Ui.Widget.widget_event; Efl.Ui.Widget.interest_region { get; } diff --git a/src/lib/elementary/elm_segment_control.c b/src/lib/elementary/elm_segment_control.c index 3bcc720..5a51829 100644 --- a/src/lib/elementary/elm_segment_control.c +++ b/src/lib/elementary/elm_segment_control.c @@ -244,15 +244,12 @@ _elm_segment_control_efl_ui_widget_theme_apply(Eo *obj, Elm_Segment_Control_Data return int_ret; } -EOLIAN static Eina_Bool -_elm_segment_control_efl_ui_widget_on_disabled_update(Eo *obj, Elm_Segment_Control_Data *sd, Eina_Bool disabled) -{ - if (!efl_ui_widget_on_disabled_update(efl_super(obj, MY_CLASS), disabled)) - return EINA_FALSE; +EOLIAN static void +_elm_segment_control_efl_ui_widget_disabled_set(Eo *obj, Elm_Segment_Control_Data *sd, Eina_Bool disabled) +{ + efl_ui_widget_disabled_set(efl_super(obj, MY_CLASS), disabled); _update_list(sd); - - return EINA_TRUE; } // TODO: elm_widget_focus_list_next_get supports only Elm_widget list, diff --git a/src/lib/elementary/elm_segment_control.eo b/src/lib/elementary/elm_segment_control.eo index 5bbce6f..50f6a1e 100644 --- a/src/lib/elementary/elm_segment_control.eo +++ b/src/lib/elementary/elm_segment_control.eo @@ -138,7 +138,7 @@ class Elm.Segment_Control extends Efl.Ui.Layout implements Efl.Ui.Focus.Composit Efl.Object.constructor; Efl.Ui.Widget.theme_apply; Efl.Ui.Widget.on_access_update; - Efl.Ui.Widget.on_disabled_update; + Efl.Ui.Widget.disabled {set;} Efl.Ui.L10n.translation_update; } events { diff --git a/src/lib/elementary/elm_slider.c b/src/lib/elementary/elm_slider.c index e903c36..066f200 100644 --- a/src/lib/elementary/elm_slider.c +++ b/src/lib/elementary/elm_slider.c @@ -1592,11 +1592,10 @@ _elm_slider_efl_ui_i18n_mirrored_set(Eo *obj EINA_UNUSED, Elm_Slider_Data *_pd E // //TIZEN_ONLY(20170419): fix slider indicator behavior -EOLIAN static Eina_Bool -_elm_slider_efl_ui_widget_on_disabled_update(Eo *obj, Elm_Slider_Data *sd, Eina_Bool disabled) +EOLIAN static void +_elm_slider_efl_ui_widget_disabled_set(Eo *obj, Elm_Slider_Data *sd, Eina_Bool disabled) { - if (!efl_ui_widget_on_disabled_update(efl_super(obj, MY_CLASS), disabled)) - return EINA_FALSE; + efl_ui_widget_disabled_set(efl_super(obj, MY_CLASS), disabled); if (sd->popup) { @@ -1613,8 +1612,6 @@ _elm_slider_efl_ui_widget_on_disabled_update(Eo *obj, Elm_Slider_Data *sd, Eina_ else edje_object_signal_emit(sd->popup2, "elm,state,enabled", "elm"); } - - return EINA_TRUE; } // diff --git a/src/lib/elementary/elm_slider.eo b/src/lib/elementary/elm_slider.eo index 676430f..bb5ef57 100644 --- a/src/lib/elementary/elm_slider.eo +++ b/src/lib/elementary/elm_slider.eo @@ -23,7 +23,7 @@ class Elm.Slider extends Efl.Ui.Slider_Interval implements Efl.Ui.Legacy, Efl.Part.part_get; //TIZEN_ONLY(20170419): fix slider indicator behavior - Efl.Ui.Widget.on_disabled_update; + Efl.Ui.Widget.disabled {set;} // //TIZEN_ONLY(20161115): apply UI Mirroring for Tizen 3.0 UX diff --git a/src/lib/elementary/elm_widget.h b/src/lib/elementary/elm_widget.h index 05f5317..aa024b1 100644 --- a/src/lib/elementary/elm_widget.h +++ b/src/lib/elementary/elm_widget.h @@ -371,6 +371,7 @@ typedef struct _Elm_Widget_Smart_Data int child_drag_x_locked; int child_drag_y_locked; + int disabled; Eina_Inlist *translate_strings; Eina_List *focus_chain; @@ -421,7 +422,6 @@ typedef struct _Elm_Widget_Smart_Data Eina_Bool highlight_ignore : 1; Eina_Bool highlight_in_theme : 1; Eina_Bool access_highlight_in_theme : 1; - Eina_Bool disabled : 1; Eina_Bool is_mirrored : 1; Eina_Bool mirrored_auto_mode : 1; /* This is TRUE by default */ Eina_Bool still_in : 1; diff --git a/src/lib/elementary_tizen/elc_ctxpopup.c b/src/lib/elementary_tizen/elc_ctxpopup.c index 0100e78..b3073ff 100644 --- a/src/lib/elementary_tizen/elc_ctxpopup.c +++ b/src/lib/elementary_tizen/elc_ctxpopup.c @@ -2033,21 +2033,6 @@ _list_new(Evas_Object *obj) elm_ctxpopup_horizontal_set(obj, sd->horizontal); } -EOLIAN static Eina_Bool -_elm_ctxpopup_efl_ui_widget_on_disabled_update(Eo *obj, Elm_Ctxpopup_Data *sd, Eina_Bool disabled) -{ - Eina_List *l; - Elm_Ctxpopup_Item_Data *it; - - if (!efl_ui_widget_on_disabled_update(efl_super(obj, MY_CLASS), disabled)) - return EINA_FALSE; - - EINA_LIST_FOREACH(sd->items, l, it) - elm_object_disabled_set(EO_OBJ(it), disabled); - - return EINA_TRUE; -} - EOLIAN static void _elm_ctxpopup_efl_canvas_group_group_add(Eo *obj, Elm_Ctxpopup_Data *priv) { diff --git a/src/tests/elementary/elm_test_box.c b/src/tests/elementary/elm_test_box.c index e5a8683..e8c126f 100644 --- a/src/tests/elementary/elm_test_box.c +++ b/src/tests/elementary/elm_test_box.c @@ -41,8 +41,46 @@ EFL_START_TEST(elm_atspi_role_get) } EFL_END_TEST +EFL_START_TEST(elm_box_disabled_test) +{ + Evas_Object *win, *box, *o; + Efl_Access_Role role; + + win = win_add(NULL, "box", ELM_WIN_BASIC); + + box = elm_box_add(win); + elm_win_resize_object_add(box, win); + role = efl_access_object_role_get(box); + + for (int i = 0; i < 3; ++i) + { + o = elm_button_add(box); + elm_box_pack_end(box, o); + } + + elm_object_disabled_set(box, EINA_TRUE); + elm_object_disabled_set(box, EINA_TRUE); + ck_assert_int_eq(elm_object_disabled_get(box), EINA_TRUE); + ck_assert_int_eq(elm_object_disabled_get(o), EINA_TRUE); + elm_object_disabled_set(box, EINA_FALSE); + ck_assert_int_eq(elm_object_disabled_get(box), EINA_FALSE); + ck_assert_int_eq(elm_object_disabled_get(o), EINA_FALSE); + elm_object_disabled_set(box, EINA_TRUE); + elm_object_disabled_set(o, EINA_TRUE); + ck_assert_int_eq(elm_object_disabled_get(box), EINA_TRUE); + ck_assert_int_eq(elm_object_disabled_get(o), EINA_TRUE); + elm_object_disabled_set(box, EINA_FALSE); + ck_assert_int_eq(elm_object_disabled_get(box), EINA_FALSE); + ck_assert_int_eq(elm_object_disabled_get(o), EINA_TRUE); + + ck_assert(role == EFL_ACCESS_ROLE_FILLER); + +} +EFL_END_TEST + void elm_test_box(TCase *tc) { tcase_add_test(tc, elm_box_legacy_type_check); tcase_add_test(tc, elm_atspi_role_get); + tcase_add_test(tc, elm_box_disabled_test); } -- 2.7.4