raster pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=519a501c262c499ce4a662221aa0382e017d6681

commit 519a501c262c499ce4a662221aa0382e017d6681
Author: Amitesh Singh <[email protected]>
Date:   Sat Dec 28 17:33:10 2013 +0900

    [elc_popup] - Added focus support on popup-base's swallow parts.
    
    Summary:
     Currently the focus was only on popup-content and popup-action area.
    New API elm_layout_content_swallow_list_get() which returns the list of
    swallow parts.
    
    Test Plan: elementary_test -to popup. click on "subpopup + X button"
    
    Reviewers: seoz, raster, woohyun
    
    Reviewed By: raster
    
    CC: nirajkr, aryarockstar, kashish
    
    Differential Revision: https://phab.enlightenment.org/D375
---
 data/themes/edc/elm/popup.edc  | 43 ++++++++++++++++++++++++++++++++++++++++++
 src/bin/test_popup.c           | 39 ++++++++++++++++++++++++++++++++++++++
 src/lib/elc_popup.c            | 21 ++++++++++++++++++++-
 src/lib/elm_container.c        |  1 +
 src/lib/elm_layout.c           | 28 +++++++++++++++++++++++++++
 src/lib/elm_layout_legacy.h    | 12 ++++++++++++
 src/lib/elm_widget_container.h | 12 ++++++++++++
 7 files changed, 155 insertions(+), 1 deletion(-)

diff --git a/data/themes/edc/elm/popup.edc b/data/themes/edc/elm/popup.edc
index b568549..2616a28 100644
--- a/data/themes/edc/elm/popup.edc
+++ b/data/themes/edc/elm/popup.edc
@@ -453,3 +453,46 @@ group { name: "elm/popup/item/popup/default";
       }
    }
 }
+
+group { name: "elm/popup/base/subpopup";
+   inherit: "elm/popup/base/default";
+   parts {
+      part { name: "pad.closebtn"; type: SPACER;
+         description { state: "default" 0.0;
+            rel1.to: "base";
+            rel1.relative: 1 0;
+            rel2.to: "base";
+            rel2.relative: 1 0;
+            min: 2 2;
+            max: 2 2;
+            fixed: 1 1;
+            align: 0 1;
+         }
+      }
+      part { name: "elm.swallow.closebtn"; type: SWALLOW;
+         scale: 1;
+         description { state: "default" 0.0;
+            rel1.to: "pad.closebtn";
+            rel1.relative: 1 0;
+            rel2.to: "pad.closebtn";
+            rel2.relative: 1 0;
+            align: 0 1;
+            fixed: 1 1;
+         }
+      }
+   }
+}
+
+group { name: "elm/popup/content/popup/subpopup";
+   inherit: "elm/popup/content/popup/default";
+}
+
+group { name: "elm/popup/buttons1/popup/subpopup";
+   inherit: "elm/popup/buttons1/popup/default";
+}
+group { name: "elm/popup/buttons2/popup/subpopup";
+   inherit: "elm/popup/buttons2/popup/default";
+}
+group { name: "elm/popup/buttons3/popup/subpopup";
+   inherit: "elm/popup/buttons3/popup/default";
+}
diff --git a/src/bin/test_popup.c b/src/bin/test_popup.c
index 3a43a53..b627249 100644
--- a/src/bin/test_popup.c
+++ b/src/bin/test_popup.c
@@ -592,6 +592,40 @@ _popup_center_title_list_content_1button_cb(void *data, 
Evas_Object *obj EINA_UN
    evas_object_show(popup);
 }
 
+static void
+_subpopup_cb(void *data, Evas_Object *obj EINA_UNUSED,
+                                            void *event_info EINA_UNUSED)
+{
+   Evas_Object *popup;
+   Evas_Object *btn, *btnclose;
+
+   popup = elm_popup_add(data);
+   elm_object_style_set(popup, "subpopup");
+   elm_object_part_text_set(popup, "title,text", "Title");
+
+   // button as a popup content
+   btn = elm_button_add(popup);
+   elm_object_text_set(btn, "content");
+   elm_object_part_content_set(popup, "elm.swallow.content", btn);
+
+   // popup buttons
+   btn = elm_button_add(popup);
+   elm_object_text_set(btn, "OK");
+   elm_object_part_content_set(popup, "button1", btn);
+   evas_object_smart_callback_add(btn, "clicked", _popup_close_cb, popup);
+
+   //popup-base close button
+   btnclose = elm_button_add(popup);
+   //TODO: write a X style button theme
+   elm_object_text_set(btnclose, "x");
+   elm_object_part_content_set(popup, "elm.swallow.closebtn", btnclose);
+   evas_object_smart_callback_add(btnclose, "clicked", _popup_close_cb, popup);
+
+   // popup show should be called after adding all the contents and the buttons
+   // of popup to set the focus into popup's contents correctly.
+   evas_object_show(popup);
+}
+
 void
 test_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
            void *event_info EINA_UNUSED)
@@ -599,6 +633,8 @@ test_popup(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED,
    Evas_Object *win, *list;
 
    win = elm_win_util_standard_add("popup", "Popup");
+   elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
+   elm_win_focus_highlight_animate_set(win, EINA_TRUE);
    elm_win_autodel_set(win, EINA_TRUE);
 
    list = elm_list_add(win);
@@ -641,6 +677,9 @@ test_popup(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED,
    elm_list_item_append(list, "popup-center-title + list content + 1 button",
                         NULL, NULL, 
_popup_center_title_list_content_1button_cb,
                         win);
+   elm_list_item_append(list, "subpopup + X button",
+                        NULL, NULL, _subpopup_cb,
+                        win);
    elm_list_go(list);
    evas_object_show(list);
 
diff --git a/src/lib/elc_popup.c b/src/lib/elc_popup.c
index ef32208..70cf8bd 100644
--- a/src/lib/elc_popup.c
+++ b/src/lib/elc_popup.c
@@ -1262,6 +1262,12 @@ _elm_popup_smart_content_get(Eo *obj, void *_pd 
EINA_UNUSED, va_list *list)
         content = _action_button_get(obj, i);
      }
    else
+     {
+        eo_do_super(obj, MY_CLASS,
+                    elm_obj_container_content_get(part, &content));
+     }
+
+   if (!content)
      goto err;
 
    *ret = content;
@@ -1355,6 +1361,7 @@ _elm_popup_smart_focus_next(Eo *obj EINA_UNUSED, void 
*_pd, va_list *list)
 {
    Evas_Object *ao;
    Eina_List *items = NULL;
+   Eina_List *base_items = NULL;
 
    Elm_Popup_Smart_Data *sd = _pd;
 
@@ -1382,8 +1389,14 @@ _elm_popup_smart_focus_next(Eo *obj EINA_UNUSED, void 
*_pd, va_list *list)
    /* action area */
    if (sd->action_area) items = eina_list_append(items, sd->action_area);
 
+   /* base */
+   eo_do_super(obj, MY_CLASS, 
elm_obj_container_content_swallow_list_get(&base_items));
+
+   items = eina_list_merge(items, base_items);
+
    if (!elm_widget_focus_list_next_get(obj, items, eina_list_data_get, dir, 
next))
      *next = obj;
+   eina_list_free(items);
 
    return;
 }
@@ -1400,7 +1413,7 @@ _elm_popup_smart_focus_direction(Eo *obj EINA_UNUSED, 
void *_pd, va_list *list)
 {
    Evas_Object *ao;
    Eina_List *items = NULL;
-
+   Eina_List *base_items = NULL;
    Elm_Popup_Smart_Data *sd = _pd;
 
    Evas_Object *base = va_arg(*list, Evas_Object *);
@@ -1429,8 +1442,14 @@ _elm_popup_smart_focus_direction(Eo *obj EINA_UNUSED, 
void *_pd, va_list *list)
    /* action area */
    if (sd->action_area) items = eina_list_append(items, sd->action_area);
 
+   /* base*/
+   eo_do_super(obj, MY_CLASS, 
elm_obj_container_content_swallow_list_get(&base_items));
+
+   items = eina_list_merge(items, base_items);
+
    elm_widget_focus_list_direction_get
      (obj, base, items, eina_list_data_get, degree, direction, weight);
+   eina_list_free(items);
 
    return;
 }
diff --git a/src/lib/elm_container.c b/src/lib/elm_container.c
index c70ec68..1d4d67b 100644
--- a/src/lib/elm_container.c
+++ b/src/lib/elm_container.c
@@ -16,6 +16,7 @@ static const Eo_Op_Description op_desc[] = {
      EO_OP_DESCRIPTION(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_SET, "Set the content 
on part of a given container widget."),
      EO_OP_DESCRIPTION(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_GET, "Get the content 
on a part of a given container widget"),
      EO_OP_DESCRIPTION(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_UNSET, "Unset the 
content on a part of a given container widget"),
+     EO_OP_DESCRIPTION(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_SWALLOW_LIST_GET, "Get 
the list of swallow parts of a given container widget"),
      EO_OP_DESCRIPTION_SENTINEL
 };
 
diff --git a/src/lib/elm_layout.c b/src/lib/elm_layout.c
index 8b79570..9a83f50 100644
--- a/src/lib/elm_layout.c
+++ b/src/lib/elm_layout.c
@@ -1170,6 +1170,33 @@ _elm_layout_smart_content_unset(Eo *obj, void *_pd, 
va_list *list)
      }
 }
 
+EAPI Eina_List *
+elm_layout_content_swallow_list_get(const Evas_Object *obj)
+{
+   ELM_LAYOUT_CHECK(obj) NULL;
+   Eina_List *ret = NULL;
+   eo_do(obj, elm_obj_container_content_swallow_list_get(&ret));
+   return ret;
+}
+
+static void
+_elm_layout_smart_content_swallow_list_get(Eo *obj EINA_UNUSED, void *_pd, 
va_list *list)
+{
+   Elm_Layout_Smart_Data *sd = _pd;
+
+   Eina_List **ret = va_arg(*list, Eina_List **);
+   if (ret) *ret = NULL;
+
+   Elm_Layout_Sub_Object_Data *sub_d = NULL;
+   Eina_List *l = NULL;
+
+   EINA_LIST_FOREACH(sd->subs, l, sub_d)
+     {
+        if (sub_d->type == SWALLOW)
+          *ret = eina_list_append(*ret, sub_d->obj);
+     }
+}
+
 EAPI Eina_Bool
 elm_layout_text_set(Evas_Object *obj,
                     const char *part,
@@ -2243,6 +2270,7 @@ _class_constructor(Eo_Class *klass)
         EO_OP_FUNC(ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_SET), 
_elm_layout_smart_content_set),
         EO_OP_FUNC(ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_GET), 
_elm_layout_smart_content_get),
         
EO_OP_FUNC(ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_UNSET), 
_elm_layout_smart_content_unset),
+        
EO_OP_FUNC(ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_SWALLOW_LIST_GET),
 _elm_layout_smart_content_swallow_list_get),
 
         EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_FILE_SET), 
_elm_layout_smart_file_set),
         EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_THEME_SET), 
_elm_layout_smart_theme_set),
diff --git a/src/lib/elm_layout_legacy.h b/src/lib/elm_layout_legacy.h
index c4b25b3..3fb37f4 100644
--- a/src/lib/elm_layout_legacy.h
+++ b/src/lib/elm_layout_legacy.h
@@ -638,3 +638,15 @@ EAPI Eina_Bool                    
elm_layout_text_set(Evas_Object *obj, const ch
  */
 EAPI const char                  *elm_layout_text_get(const Evas_Object *obj, 
const char *part);
 
+/**
+ * Get the list of swallow parts of a given container widget
+ *
+ * @param obj The layout object
+ *
+ * @return list of swallow parts which should be freed by the user program 
with elm_list_free()
+ *
+ * @since 1.9
+ *
+ * @ingroup Layout
+ */
+EAPI Eina_List                   *elm_layout_content_swallow_list_get(const 
Evas_Object *obj);
diff --git a/src/lib/elm_widget_container.h b/src/lib/elm_widget_container.h
index 4427fdd..a081ae5 100644
--- a/src/lib/elm_widget_container.h
+++ b/src/lib/elm_widget_container.h
@@ -41,6 +41,7 @@ enum
    ELM_OBJ_CONTAINER_SUB_ID_CONTENT_SET,
    ELM_OBJ_CONTAINER_SUB_ID_CONTENT_GET,
    ELM_OBJ_CONTAINER_SUB_ID_CONTENT_UNSET,
+   ELM_OBJ_CONTAINER_SUB_ID_CONTENT_SWALLOW_LIST_GET,
    ELM_OBJ_CONTAINER_SUB_ID_LAST
 };
 /**
@@ -87,4 +88,15 @@ enum
  */
 #define elm_obj_container_content_unset(name, ret) 
ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_UNSET), 
EO_TYPECHECK(const char*, name), EO_TYPECHECK(Evas_Object **,ret)
 
+/**
+ * @def elm_obj_container_content_list_get
+ * @since 1.9
+ *
+ * No description supplied by the EAPI.
+ *
+ * @param[out] ret Eina_List **
+ *
+ */
+#define elm_obj_container_content_swallow_list_get(ret) 
ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_SWALLOW_LIST_GET), 
EO_TYPECHECK(Eina_List **,ret)
+
 #endif

-- 


Reply via email to