elm_object_tree_unfocusble_set/get added : merge with 61838
authorWooHyun Jung <wh0705.jung@samsung.com>
Thu, 28 Jul 2011 07:31:51 +0000 (16:31 +0900)
committerWooHyun Jung <wh0705.jung@samsung.com>
Thu, 28 Jul 2011 07:50:22 +0000 (16:50 +0900)
Change-Id: I56026006db5bd7989dc554dc7841d2f4c477653e

src/lib/Elementary.h.in
src/lib/elm_main.c
src/lib/elm_widget.c
src/lib/elm_widget.h

index 060ed15..93965ec 100644 (file)
@@ -1087,6 +1087,40 @@ extern "C" {
    EAPI void             elm_object_focus_cycle(Evas_Object *obj, Elm_Focus_Direction dir) EINA_ARG_NONNULL(1);
    EAPI void             elm_object_focus_direction_go(Evas_Object *obj, int x, int y) EINA_ARG_NONNULL(1);
 
+   /**
+    * Make the elementary object and its children to be unfocusable (or focusable).
+    *
+    * @param obj The Elementary object to operate on
+    * @param tree_unfocusable @c EINA_TRUE for unfocusable,
+    *        @c EINA_FALSE for focusable.
+    *
+    * This sets whether the object @p obj and its children objects
+    * able to take focus or not. If the tree is unfocusable,
+    * newest focused object which is not in this tree will get focus.
+    * This API can be helpful for an object to be deleted.
+    * When an object will be deleted soon, it and its children may not
+    * want to get focus (by focus reverting or by other focus controls).
+    * Then, just use this API before deleting.
+    *
+    * @see elm_object_tree_unfocusable_get()
+    *
+    * @ingroup Focus
+    */
+   EAPI void             elm_object_tree_unfocusable_set(Evas_Object *obj, Eina_Bool tree_unfocusable); EINA_ARG_NONNULL(1);
+
+   /**
+    * Get whether an Elementary object and its children are unfocusable or not.
+    *
+    * @param obj The Elementary object to get the information from
+    * @return @c EINA_TRUE, if the tree is unfocussable,
+    *         @c EINA_FALSE if not (and on errors).
+    *
+    * @see elm_object_tree_unfocusable_set()
+    *
+    * @ingroup Focus
+    */
+   EAPI Eina_Bool        elm_object_tree_unfocusable_get(const Evas_Object *obj); EINA_ARG_NONNULL(1);
+
    EAPI Eina_Bool        elm_scroll_bounce_enabled_get(void);
    EAPI void             elm_scroll_bounce_enabled_set(Eina_Bool enabled);
    EAPI void             elm_scroll_bounce_enabled_all_set(Eina_Bool enabled);
index 522f263..4bd783b 100644 (file)
@@ -2449,6 +2449,21 @@ elm_object_focus_direction_go(Evas_Object *obj,
    elm_widget_focus_direction_go(obj, x, y);
 }
 
+EAPI void
+elm_object_tree_unfocusable_set(Evas_Object *obj,
+                                Eina_Bool    tree_unfocusable)
+{
+   EINA_SAFETY_ON_NULL_RETURN(obj);
+   elm_widget_tree_unfocusable_set(obj, tree_unfocusable);
+}
+
+EAPI Eina_Bool
+elm_object_tree_unfocusable_get(const Evas_Object *obj)
+{
+   EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
+   return elm_widget_tree_unfocusable_get(obj);
+}
+
 /**
  * Get the enable status of the focus highlight
  *
index 9a65f01..14ae3fb 100644 (file)
@@ -96,6 +96,7 @@ struct _Smart_Data
    Eina_Bool    can_focus : 1;
    Eina_Bool    child_can_focus : 1;
    Eina_Bool    focused : 1;
+   Eina_Bool    tree_unfocusable : 1;
    Eina_Bool    highlight_ignore : 1;
    Eina_Bool    highlight_in_theme : 1;
    Eina_Bool    disabled : 1;
@@ -1055,6 +1056,49 @@ elm_widget_child_can_focus_get(const Evas_Object *obj)
    return sd->child_can_focus;
 }
 
+/**
+ * @internal
+ *
+ * This API makes the widget object and its children to be unfocusable.
+ *
+ * This API can be helpful for an object to be deleted.
+ * When an object will be deleted soon, it and its children may not
+ * want to get focus (by focus reverting or by other focus controls).
+ * Then, just use this API before deleting.
+ *
+ * @param obj The widget root of sub-tree
+ * @param tree_unfocusable If true, set the object sub-tree as unfocusable
+ *
+ * @ingroup Widget
+ */
+EAPI void
+elm_widget_tree_unfocusable_set(Evas_Object *obj,
+                                Eina_Bool    tree_unfocusable)
+{
+   API_ENTRY return;
+
+   if (sd->tree_unfocusable == tree_unfocusable) return;
+   sd->tree_unfocusable = !!tree_unfocusable;
+   elm_widget_focus_tree_unfocusable_handle(obj);
+}
+
+/**
+ * @internal
+ *
+ * This returns true, if the object sub-tree is unfocusable.
+ *
+ * @param obj The widget root of sub-tree
+ * @return EINA_TRUE if the object sub-tree is unfocusable
+ *
+ * @ingroup Widget
+ */
+EAPI Eina_Bool
+elm_widget_tree_unfocusable_get(const Evas_Object *obj)
+{
+   API_ENTRY return EINA_FALSE;
+   return sd->tree_unfocusable;
+}
+
 EAPI void
 elm_widget_highlight_ignore_set(Evas_Object *obj,
                                 Eina_Bool    ignore)
@@ -1445,7 +1489,9 @@ elm_widget_focus_next_get(const Evas_Object  *obj,
    API_ENTRY return EINA_FALSE;
 
    /* Ignore if disabled */
-   if ((!evas_object_visible_get(obj)) || (elm_widget_disabled_get(obj)))
+   if ((!evas_object_visible_get(obj))
+       || (elm_widget_disabled_get(obj))
+       || (elm_widget_tree_unfocusable_get(obj)))
      return EINA_FALSE;
 
    /* Try use hook */
@@ -1746,13 +1792,14 @@ elm_widget_focus_steal(Evas_Object *obj)
    if (sd->focused) return;
    if (sd->disabled) return;
    if (!sd->can_focus) return;
+   if (sd->tree_unfocusable) return;
    parent = obj;
    for (;;)
      {
         o = elm_widget_parent_get(parent);
         if (!o) break;
         sd = evas_object_smart_data_get(o);
-        if (sd->disabled) return;
+        if (sd->disabled || sd->tree_unfocusable) return;
         if (sd->focused) break;
         parent = o;
      }
@@ -1806,25 +1853,7 @@ elm_widget_disabled_set(Evas_Object *obj,
 
    if (sd->disabled == disabled) return;
    sd->disabled = !!disabled;
-   if (sd->focused)
-     {
-        Evas_Object *o, *parent;
-        parent = obj;
-        o = elm_widget_parent_get(parent);
-        if (!o)
-          elm_widget_focused_object_clear(parent);
-        else
-          {
-             parent = o;
-             for (;;)
-               {
-                  o = elm_widget_parent_get(parent);
-                  if (!o) break;
-                  parent = o;
-               }
-             elm_widget_focus_cycle(parent, ELM_FOCUS_NEXT);
-          }
-     }
+   elm_widget_focus_disabled_handle(obj);
    if (sd->disable_func) sd->disable_func(obj);
 }
 
@@ -2290,6 +2319,25 @@ elm_widget_focus_mouse_down_handle(Evas_Object *obj)
    elm_widget_focus_steal(o);
 }
 
+EAPI void
+elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj)
+{
+   API_ENTRY return;
+
+   if (!elm_widget_parent_get(obj))
+     elm_widget_focused_object_clear(obj);
+   else
+     _if_focused_revert(obj, EINA_TRUE);
+}
+
+EAPI void
+elm_widget_focus_disabled_handle(Evas_Object *obj)
+{
+   API_ENTRY return;
+
+   elm_widget_focus_tree_unfocusable_handle(obj);
+}
+
 /**
  * @internal
  *
@@ -2794,7 +2842,9 @@ _newest_focus_order_get(Evas_Object  *obj,
 
    API_ENTRY return NULL;
 
-   if ((!evas_object_visible_get(obj)) || (elm_widget_disabled_get(obj)))
+   if (!evas_object_visible_get(obj)
+       || (elm_widget_disabled_get(obj))
+       || (elm_widget_tree_unfocusable_get(obj)))
      return NULL;
 
    best = NULL;
index 5f938a5..a909b5b 100644 (file)
@@ -243,6 +243,8 @@ EAPI void            *elm_widget_signal_callback_del(Evas_Object *obj, const cha
 EAPI void             elm_widget_can_focus_set(Evas_Object *obj, Eina_Bool can_focus);
 EAPI Eina_Bool        elm_widget_can_focus_get(const Evas_Object *obj);
 EAPI Eina_Bool        elm_widget_child_can_focus_get(const Evas_Object *obj);
+EAPI void             elm_widget_tree_unfocusable_set(Evas_Object *obj, Eina_Bool tree_unfocusable);
+EAPI Eina_Bool        elm_widget_tree_unfocusable_get(const Evas_Object *obj);
 EAPI void             elm_widget_highlight_ignore_set(Evas_Object *obj, Eina_Bool ignore);
 EAPI Eina_Bool        elm_widget_highlight_ignore_get(const Evas_Object *obj);
 EAPI void             elm_widget_highlight_in_theme_set(Evas_Object *obj, Eina_Bool highlight);
@@ -310,6 +312,8 @@ EAPI Eina_List       *elm_widget_stringlist_get(const char *str);
 EAPI void             elm_widget_stringlist_free(Eina_List *list);
 EAPI void             elm_widget_focus_hide_handle(Evas_Object *obj);
 EAPI void             elm_widget_focus_mouse_down_handle(Evas_Object *obj);
+EAPI void             elm_widget_focus_tree_unfocusable_handle(Evas_Object *obj);
+EAPI void             elm_widget_focus_disabled_handle(Evas_Object *obj);
 EAPI void             elm_widget_text_part_set(Evas_Object *obj, const char *item, const char *label);
 EAPI const char      *elm_widget_text_part_get(const Evas_Object *obj, const char *item);