popup: add popup dismiss function for hide effect 06/57906/1
authortaehyub <taehyub.kim@samsung.com>
Thu, 31 Dec 2015 04:08:28 +0000 (13:08 +0900)
committertaehyub <taehyub.kim@samsung.com>
Tue, 26 Jan 2016 01:37:50 +0000 (10:37 +0900)
Summary: add popup dismiss function for hide effect

Test Plan:
 1. applied this patch
 2. launch elementary_test
 3. run "popup" -> "popup-center-title + text + 1 button + hide effect"
 4. click the "close" button and check the hide effect

Reviewers: Hermet, woohyun, kimcinoo, raster

Differential Revision: https://phab.enlightenment.org/D3502

@feature

Conflicts:
src/lib/elm_notify.c

Change-Id: Ibabb48c30ad3e78bd7dc1ace5cd7f0bf12c69a2d

src/bin/test_popup.c
src/lib/elc_popup.c
src/lib/elm_notify.c
src/lib/elm_notify.eo
src/lib/elm_popup.eo

index dcfba0eebc942581a4a25a28882c4f36fc5383c2..3ab08e1722a80d0d105cf36bc0cee73ae2ab676b 100644 (file)
@@ -40,6 +40,13 @@ _popup_close_cb(void *data, Evas_Object *obj EINA_UNUSED,
    evas_object_del(data);
 }
 
+static void
+_popup_dismiss_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
+                      void *event_info EINA_UNUSED)
+{
+   elm_popup_dismiss(data);
+}
+
 static void
 _popup_align_cb(void *data, Evas_Object *obj EINA_UNUSED,
                void *event_info EINA_UNUSED)
@@ -795,6 +802,34 @@ _popup_content_only_cb(void *data, Evas_Object *obj EINA_UNUSED,
    elm_object_focus_set(btn, EINA_TRUE);
 }
 
+static void
+_popup_center_title_text_1button_hide_effect_cb(void *data, Evas_Object *obj EINA_UNUSED,
+                                                void *event_info EINA_UNUSED)
+{
+   Evas_Object *popup;
+   Evas_Object *btn;
+
+   popup = elm_popup_add(data);
+   elm_popup_scrollable_set(popup, is_popup_scroll);
+
+   // popup text
+   elm_object_text_set(popup, "This Popup has title area, content area and "
+                       "action area set, action area has one button Close");
+   // popup title
+   elm_object_part_text_set(popup, "title,text", "Title");
+
+   // popup buttons
+   btn = elm_button_add(popup);
+   elm_object_text_set(btn, "Close");
+   elm_object_part_content_set(popup, "button1", btn);
+   evas_object_smart_callback_add(popup, "dismissed", _response_cb, NULL);
+   evas_object_smart_callback_add(btn, "clicked", _popup_dismiss_btn_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);
+}
+
 static void
 _focus_changed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
 {
@@ -873,6 +908,8 @@ test_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
    elm_list_item_append(list, "popup with content only",
                         NULL, NULL, _popup_content_only_cb,
                         win);
+   elm_list_item_append(list, "popup-center-title + text + 1 button + hide effect", NULL,
+                        NULL, _popup_center_title_text_1button_hide_effect_cb, win);
    elm_list_go(list);
    evas_object_show(list);
 
index 9e8d0415fd094ac9ba4240973c2a915790e99839..dba021223f1e642dc11724aab201e9d8c9e54da5 100644 (file)
@@ -51,6 +51,10 @@ static Eina_Bool
 _timeout_cb(void *data, Eo *obj EINA_UNUSED,
             const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED);
 
+static Eina_Bool
+_hide_effect_finished_cb(void *data, Eo *obj EINA_UNUSED,
+            const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED);
+
 static const Elm_Action key_actions[] = {
    {"move", _key_action_move},
    {NULL, NULL}
@@ -58,7 +62,8 @@ static const Elm_Action key_actions[] = {
 
 EO_CALLBACKS_ARRAY_DEFINE(_notify_cb,
    { ELM_NOTIFY_EVENT_BLOCK_CLICKED, _block_clicked_cb },
-   { ELM_NOTIFY_EVENT_TIMEOUT, _timeout_cb }
+   { ELM_NOTIFY_EVENT_TIMEOUT, _timeout_cb },
+   { ELM_NOTIFY_EVENT_DISMISSED, _hide_effect_finished_cb }
 );
 
 static void  _on_content_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
@@ -113,6 +118,16 @@ _timeout_cb(void *data,
    return EINA_TRUE;
 }
 
+static Eina_Bool
+_hide_effect_finished_cb(void *data,
+      Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   eo_do(data, eo_event_callback_call(ELM_POPUP_EVENT_DISMISSED, NULL));
+
+   return EINA_TRUE;
+}
+
+
 static Evas_Object *
 _access_object_get(const Evas_Object *obj, const char* part)
 {
@@ -1817,6 +1832,13 @@ _elm_popup_scrollable_get(Eo *obj EINA_UNUSED, Elm_Popup_Data *pd)
    return pd->scroll;
 }
 
+EOLIAN static void
+_elm_popup_dismiss(Eo *obj EINA_UNUSED, Elm_Popup_Data *pd)
+{
+   elm_layout_signal_emit(pd->main_layout, "elm,state,hide", "elm");
+   elm_notify_dismiss(pd->notify);
+}
+
 static void
 _elm_popup_class_constructor(Eo_Class *klass)
 {
index 82f98d3020fe65f9d5399e45115b6f59007dfe1f..e97fd6d511e837213c837171da89be56468236e8 100644 (file)
@@ -431,6 +431,8 @@ _hide_finished_cb(void *data,
    sd->had_hidden = EINA_TRUE;
    evas_object_hide(sd->notify);
    if (!sd->allow_events) evas_object_hide(sd->block_events);
+   eo_do_super(data, MY_CLASS, evas_obj_smart_hide());
+   eo_do(data, eo_event_callback_call(ELM_NOTIFY_EVENT_DISMISSED, NULL));
 }
 
 EOLIAN static void
@@ -675,6 +677,14 @@ _elm_notify_align_set(Eo *obj, Elm_Notify_Data *sd, double horizontal, double ve
    _calc(obj);
 }
 
+EOLIAN static void
+_elm_notify_dismiss(Eo *obj EINA_UNUSED, Elm_Notify_Data *sd)
+{
+   elm_layout_signal_emit(sd->block_events, "elm,state,hide", "elm");
+   edje_object_signal_emit(sd->notify, "elm,state,hide", "elm");
+}
+
+
 EOLIAN static void
 _elm_notify_align_get(Eo *obj EINA_UNUSED, Elm_Notify_Data *sd, double *horizontal, double *vertical)
 {
index 23b21ec52f7314d58db6104fb69c4b468679971d..581051382303d637366fa3395cd3017b79a4312a 100644 (file)
@@ -68,6 +68,9 @@ class Elm.Notify (Elm.Container)
             timeout: double; [[The timeout in seconds]]
          }
       }
+      dismiss {
+         [[Dismiss a notify object.]]
+      }
    }
    implements {
       class.constructor;
@@ -94,6 +97,7 @@ class Elm.Notify (Elm.Container)
    events {
       block,clicked;
       timeout;
+      dismissed;
    }
 
 }
index b80f8f8ecf3878c66a45dc22cb804e26bca0bd60..95d51d05f8b563c1b9d9253e328b80ddb8357acd 100644 (file)
@@ -156,6 +156,9 @@ class Elm.Popup (Elm.Layout, Elm_Interface_Atspi_Widget_Action)
             @in data: const(void)* @optional; [[Data passed to $func above.]]
          }
       }
+      dismiss {
+         [[Dismiss a Popup object.]]
+      }
    }
    implements {
       class.constructor;
@@ -188,6 +191,7 @@ class Elm.Popup (Elm.Layout, Elm_Interface_Atspi_Widget_Action)
       item,unfocused;
       language,changed;
       access,changed;
+      dismissed;
    }
 
 }