From 603d8abf2cb1aac5b1b561f164abb284e9738081 Mon Sep 17 00:00:00 2001 From: ChunEon Park Date: Tue, 21 Feb 2012 12:36:54 +0000 Subject: [PATCH] elementary/focus - reviewed done! SVN revision: 68218 --- src/lib/Elementary.h.in | 2 +- src/lib/elm_config.h | 14 ++++++++------ src/lib/elm_deprecated.h | 15 +++++++++++++++ src/lib/elm_engine.h | 5 ++--- src/lib/elm_focus.h | 33 ++++++++++++++++++--------------- src/lib/elm_main.c | 17 +++++++---------- src/lib/elm_widget.c | 45 ++++++++++++++++++++++++--------------------- 7 files changed, 75 insertions(+), 56 deletions(-) diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index a51fa66..6ac1bec 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -198,7 +198,7 @@ EAPI extern Elm_Version *elm_version; #include //Done #include //Done. There are many TODOs in flip.c #include //Done + XXX in header. There are many TODOs in flipselector.c -#include +#include //Done + XXX in header #include //Done + XXX in header #include //Done + XXX in header #include diff --git a/src/lib/elm_config.h b/src/lib/elm_config.h index 1ac38ec..e3204ca 100644 --- a/src/lib/elm_config.h +++ b/src/lib/elm_config.h @@ -44,16 +44,18 @@ EAPI void elm_config_reload(void); * Flush all config settings then apply those settings to all applications * using elementary on the current display. * Following functions will update the config settings - * @li elm_scale_set() - * @li elm_finger_size_set() - * @li elm_profile_set() - * @li elm_font_overlay_set() * @li elm_cache_flush_interval_set() * @li elm_cache_flush_enabled_set() - * @li elm_font_cache_set() - * @li elm_image_cache_set() * @li elm_edje_file_cache_set() * @li elm_edje_collection_cache_set() + * @li elm_finger_size_set() + * @li elm_focus_highlight_enabled_set() + * @li elm_focus_highlight_animate_set() + * @li elm_font_overlay_set() + * @li elm_font_cache_set() + * @li elm_image_cache_set() + * @li elm_profile_set() + * @li elm_scale_set() * @li elm_scroll_bounce_enabled_set() * @li elm_scroll_bounce_friction_set() * @li elm_scroll_page_scroll_friction_set() diff --git a/src/lib/elm_deprecated.h b/src/lib/elm_deprecated.h index ef6ab77..84d19b5 100644 --- a/src/lib/elm_deprecated.h +++ b/src/lib/elm_deprecated.h @@ -1729,6 +1729,21 @@ EINA_DEPRECATED EAPI void elm_object_focus(Evas_Object *obj); EINA_DEPRECATED EAPI void elm_object_unfocus(Evas_Object *obj); /** + * Give focus to near object in one direction. + * + * Give focus to near object in direction of one object. + * If none focusable object in given direction, the focus will not change. + * + * @param obj The reference object + * @param x Horizontal component of direction to focus + * @param y Vertical component of direction to focus + * + * @deprecated Support it later. + * @ingroup Focus + */ +EINA_DEPRECATED EAPI void elm_object_focus_direction_go(Evas_Object *obj, int x, int y); + +/** * @brief Set the frame label * * @param obj The frame object diff --git a/src/lib/elm_engine.h b/src/lib/elm_engine.h index 49cb05d..89ce74f 100644 --- a/src/lib/elm_engine.h +++ b/src/lib/elm_engine.h @@ -43,9 +43,8 @@ EAPI const char *elm_engine_get(void); * * @param engine The rendering engine's name * - * This sets global rendering engine that is applied to all Elementary - * applications. Note that it will take effect only to Elementary windows - * created after this is called. + * Note that it will take effect only to Elementary windows created after + * this is called. * * @see elm_win_add() */ diff --git a/src/lib/elm_focus.h b/src/lib/elm_focus.h index 1ae4fe2..6dfb45c 100644 --- a/src/lib/elm_focus.h +++ b/src/lib/elm_focus.h @@ -36,6 +36,8 @@ * Get the enable status of the focus highlight * * This gets whether the highlight on focused objects is enabled or not + * + * @see elm_focus_highlight_enabled_set() * @ingroup Focus */ EAPI Eina_Bool elm_focus_highlight_enabled_get(void); @@ -46,6 +48,12 @@ EAPI Eina_Bool elm_focus_highlight_enabled_get(void); * @param enable Enable highlight if EINA_TRUE, disable otherwise * * Set whether to show or not the highlight on focused objects + * + * Note that it will take effect only to Elementary windows created after + * this is called. + * + * @see elm_win_add() + * * @ingroup Focus */ EAPI void elm_focus_highlight_enabled_set(Eina_Bool enable); @@ -70,6 +78,11 @@ EAPI Eina_Bool elm_focus_highlight_animate_get(void); * Set whether the focus highlight, if enabled, will animate its switch from * one object to the next * + * Note that it will take effect only to Elementary windows created after + * this is called. + * + * @see elm_win_add() + * * @ingroup Focus */ EAPI void elm_focus_highlight_animate_set(Eina_Bool animate); @@ -107,7 +120,7 @@ EAPI Eina_Bool elm_object_focus_get(const Evas_Object *obj); EAPI void elm_object_focus_set(Evas_Object *obj, Eina_Bool focus); /** - * Set the ability for an Element object to be focused + * Set the ability for an Elmentary object to be focused * * @param obj The Elementary object to operate on * @param enable @c EINA_TRUE if the object can be focused, @c @@ -216,23 +229,10 @@ EAPI void elm_object_focus_custom_chain_prepend(Evas_Object *obj * * @ingroup Focus */ +//XXX: How about elm_object_focus_move()? focus_next() ? EAPI void elm_object_focus_cycle(Evas_Object *obj, Elm_Focus_Direction dir); /** - * Give focus to near object in one direction. - * - * Give focus to near object in direction of one object. - * If none focusable object in given direction, the focus will not change. - * - * @param obj The reference object - * @param x Horizontal component of direction to focus - * @param y Vertical component of direction to focus - * - * @ingroup Focus - */ -EAPI void elm_object_focus_direction_go(Evas_Object *obj, int x, int y); - -/** * Make the elementary object and its children to be unfocusable * (or focusable). * @@ -251,7 +251,9 @@ EAPI void elm_object_focus_direction_go(Evas_Object *obj, int x, * @see elm_object_tree_unfocusable_get() * * @ingroup Focus + * */ + //XXX: How about elm_object_tree_focus_allow_set()? EAPI void elm_object_tree_unfocusable_set(Evas_Object *obj, Eina_Bool tree_unfocusable); /** @@ -265,4 +267,5 @@ EAPI void elm_object_tree_unfocusable_set(Evas_Object *obj, Eina * * @ingroup Focus */ +//XXX: How about elm_object_tree_focus_allow_get()? EAPI Eina_Bool elm_object_tree_unfocusable_get(const Evas_Object *obj); diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c index 53f7a9b..9a56c31 100644 --- a/src/lib/elm_main.c +++ b/src/lib/elm_main.c @@ -1429,16 +1429,13 @@ elm_object_focus_set(Evas_Object *obj, Eina_Bool focus) { EINA_SAFETY_ON_NULL_RETURN(obj); + + if (focus == elm_widget_focus_get(obj)) return; + if (focus) - { - if (elm_widget_focus_get(obj)) return; - elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT); - } + elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT); else - { - if (!elm_widget_can_focus_get(obj)) return; - elm_widget_focused_object_clear(obj); - } + elm_widget_focused_object_clear(obj); } EAPI void @@ -1461,6 +1458,8 @@ elm_object_focus_allow_set(Evas_Object *obj, { EINA_SAFETY_ON_NULL_RETURN(obj); elm_widget_can_focus_set(obj, enable); +/*FIXME: According to the elm_object_focus_allow_get(), child_can_focus field +of the parent should be updated. Otherwise, the checking of it's child focus allow states should not be in elm_object_focus_allow_get() */ } EAPI Eina_Bool @@ -1498,7 +1497,6 @@ elm_object_focus_custom_chain_append(Evas_Object *obj, Evas_Object *relative_child) { EINA_SAFETY_ON_NULL_RETURN(obj); - EINA_SAFETY_ON_NULL_RETURN(child); elm_widget_focus_custom_chain_append(obj, child, relative_child); } @@ -1508,7 +1506,6 @@ elm_object_focus_custom_chain_prepend(Evas_Object *obj, Evas_Object *relative_child) { EINA_SAFETY_ON_NULL_RETURN(obj); - EINA_SAFETY_ON_NULL_RETURN(child); elm_widget_focus_custom_chain_prepend(obj, child, relative_child); } diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c index 64f12b0..bf4f75e 100644 --- a/src/lib/elm_widget.c +++ b/src/lib/elm_widget.c @@ -1148,7 +1148,11 @@ elm_widget_can_focus_set(Evas_Object *obj, Eina_Bool can_focus) { API_ENTRY return; - sd->can_focus = can_focus; + + can_focus = !!can_focus; + + if (sd->can_focus == can_focus) return; + if (can_focus) { evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN, @@ -1207,8 +1211,9 @@ elm_widget_tree_unfocusable_set(Evas_Object *obj, { API_ENTRY return; + tree_unfocusable = !!tree_unfocusable; if (sd->tree_unfocusable == tree_unfocusable) return; - sd->tree_unfocusable = !!tree_unfocusable; + sd->tree_unfocusable = tree_unfocusable; elm_widget_focus_tree_unfocusable_handle(obj); } @@ -1499,7 +1504,7 @@ EAPI const Eina_List * elm_widget_focus_custom_chain_get(const Evas_Object *obj) { API_ENTRY return NULL; - return (const Eina_List *)sd->focus_chain; + return (const Eina_List *) sd->focus_chain; } /** @@ -1547,20 +1552,16 @@ elm_widget_focus_custom_chain_append(Evas_Object *obj, { API_ENTRY return; EINA_SAFETY_ON_NULL_RETURN(child); - if (!sd->focus_next_func) - return; + if (!sd->focus_next_func) return; evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL, _elm_object_focus_chain_del_cb, sd); if (!relative_child) - { - sd->focus_chain = eina_list_append(sd->focus_chain, child); - return; - } - - sd->focus_chain = eina_list_append_relative(sd->focus_chain, child, relative_child); - return; + sd->focus_chain = eina_list_append(sd->focus_chain, child); + else + sd->focus_chain = eina_list_append_relative(sd->focus_chain, + child, relative_child); } /** @@ -1585,20 +1586,17 @@ elm_widget_focus_custom_chain_prepend(Evas_Object *obj, { API_ENTRY return; EINA_SAFETY_ON_NULL_RETURN(child); - if (!sd->focus_next_func) - return; + + if (!sd->focus_next_func) return; evas_object_event_callback_del_full(child, EVAS_CALLBACK_DEL, _elm_object_focus_chain_del_cb, sd); if (!relative_child) - { - sd->focus_chain = eina_list_prepend(sd->focus_chain, child); - return; - } - - sd->focus_chain = eina_list_prepend_relative(sd->focus_chain, child, relative_child); - return; + sd->focus_chain = eina_list_prepend(sd->focus_chain, child); + else + sd->focus_chain = eina_list_prepend_relative(sd->focus_chain, + child, relative_child); } /** @@ -1641,6 +1639,9 @@ elm_widget_focus_cycle(Evas_Object *obj, * * @ingroup Widget */ +//XXX: If x, y indicates the elements of the directional vector, +//It would be better if these values are the normalized value(float x, float y) +//or degree. EAPI void elm_widget_focus_direction_go(Evas_Object *obj __UNUSED__, int x __UNUSED__, @@ -2764,6 +2765,8 @@ elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj) { API_ENTRY return; + //FIXME: Need to check whether the object is unfocusable or not. + if (!elm_widget_parent_get(obj)) elm_widget_focused_object_clear(obj); else -- 2.7.4