jaehyun pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=bccd97bd62a0a2a9d95ba7d87949d92302ef50d2

commit bccd97bd62a0a2a9d95ba7d87949d92302ef50d2
Author: JinYong Park <j4939.p...@samsung.com>
Date:   Thu Aug 10 15:48:36 2017 +0900

    efl_ui_popup: add bg_set and bg_repeat_events_set/get API
    
    Summary:
    add bg_set and bg_repeat_events_set/get API
    bg_set enables user change popup's outside bg
    bg_repeat_events_set enables popup's outside bg repeat events
    
    Test Plan:
     1. run elementary_test -to efluipopup
     2. click outside area of popup
     3. click button in popup
    
    Reviewers: Jaehyun_Cho, herb, thiepha, woohyun, cedric, jpeg, singh.amitesh
    
    Reviewed By: Jaehyun_Cho
    
    Subscribers: jpeg
    
    Tags: #efl
    
    Differential Revision: https://phab.enlightenment.org/D5054
---
 data/elementary/themes/edc/elm/popup.edc  | 42 +++++++++++++++++++++++++--
 src/bin/elementary/test_popup.c           | 41 ++++++++++++++++++++++++--
 src/lib/elementary/efl_ui_popup.c         | 48 +++++++++++++++++++++++++++++++
 src/lib/elementary/efl_ui_popup.eo        | 38 +++++++++++++++++++-----
 src/lib/elementary/efl_ui_popup_private.h |  1 +
 5 files changed, 159 insertions(+), 11 deletions(-)

diff --git a/data/elementary/themes/edc/elm/popup.edc 
b/data/elementary/themes/edc/elm/popup.edc
index ec79630716..7fb127b812 100644
--- a/data/elementary/themes/edc/elm/popup.edc
+++ b/data/elementary/themes/edc/elm/popup.edc
@@ -536,10 +536,48 @@ group { "elm/popup/base/view";
 group { "elm/popup/base/event_bg";
    parts {
       rect { "base";
-         repeat;
          desc { "default";
-            color: 0 255 0 128;
+            color: 0 0 0 64;
          }
+         desc { "show_image";
+            inherit: "default";
+            hid;
+         }
+      }
+      swallow { "elm.swallow.image";
+         desc { "default";
+            rel.to: "base";
+            hid;
+         }
+         desc { "show_image";
+            inherit: "default";
+            vis;
+         }
+      }
+      rect { "block";
+         desc { "default";
+            rel.to: "base";
+            color: 0 0 0 0;
+         }
+      }
+   }
+
+   programs {
+      program {
+         signal: "elm,state,image,visible"; source: "elm";
+         action: STATE_SET "show_image" 0.0;
+         target: "base";
+         target: "elm.swallow.image";
+      }
+      program {
+         signal: "elm,state,image,hidden"; source: "elm";
+         action: STATE_SET "default" 0.0;
+         target: "base";
+         target: "elm.swallow.image";
+      }
+      program {
+         signal: "mouse,clicked,1"; source: "block";
+         action: SIGNAL_EMIT "elm,action,clicked" "elm";
       }
    }
 }
diff --git a/src/bin/elementary/test_popup.c b/src/bin/elementary/test_popup.c
index dbbb1a8891..cc9de42f82 100644
--- a/src/bin/elementary/test_popup.c
+++ b/src/bin/elementary/test_popup.c
@@ -939,10 +939,38 @@ test_popup(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED,
    evas_object_show(win);
 }
 
+static void
+_bg_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
+                      void *event_info EINA_UNUSED)
+{
+   printf("Popup's background is clicked.\n");
+}
+
+static void
+_image_change_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
+                      void *event_info EINA_UNUSED)
+{
+   static int k = 0;
+
+   if (k == 0)
+     {
+        char buf[PATH_MAX];
+        snprintf(buf, sizeof(buf), "%s/images/logo.png", 
elm_app_data_dir_get());
+        efl_ui_popup_bg_set(data, buf, NULL);
+        efl_ui_popup_bg_repeat_events_set(data, EINA_TRUE);
+     }
+   else
+     {
+        efl_ui_popup_bg_set(data, NULL, NULL);
+        efl_ui_popup_bg_repeat_events_set(data, EINA_FALSE);
+     }
+   k = !k;
+}
+
 void
 test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void 
*event_info EINA_UNUSED)
 {
-   Evas_Object *win;
+   Evas_Object *win, *btn;
 
    win = elm_win_util_standard_add("Efl UI Popup", "Efl UI Popup");
    elm_win_autodel_set(win, EINA_TRUE);
@@ -950,8 +978,16 @@ test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED, void *ev
    evas_object_resize(win, 320, 320);
    evas_object_show(win);
 
+   btn = elm_button_add(win);
+   elm_object_text_set(btn, "bg repeat events test");
+   evas_object_move(btn, 0, 0);
+   evas_object_resize(btn, 150, 150);
+   evas_object_show(btn);
+
    Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_CLASS, win);
 
+   evas_object_smart_callback_add(efl_ui_popup, "bg,clicked", _bg_clicked, 
NULL);
+
    evas_object_move(efl_ui_popup, 80, 80);
    evas_object_resize(efl_ui_popup, 160, 160);
    evas_object_show(efl_ui_popup);
@@ -960,8 +996,9 @@ test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED, void *ev
    evas_object_geometry_get(efl_ui_popup, &x, &y, &w, &h);
    printf("efl_ui_popup: %d %d %d %d\n", x, y, w, h);
 
-   Evas_Object *btn = elm_button_add(efl_ui_popup);
+   btn = elm_button_add(efl_ui_popup);
    elm_object_text_set(btn, "Efl.Ui.Popup content");
+   evas_object_smart_callback_add(btn, "clicked", _image_change_btn_cb, 
efl_ui_popup);
    evas_object_show(btn);
 
    efl_content_set(efl_ui_popup, btn);
diff --git a/src/lib/elementary/efl_ui_popup.c 
b/src/lib/elementary/efl_ui_popup.c
index 4b938a7016..972342b5ca 100644
--- a/src/lib/elementary/efl_ui_popup.c
+++ b/src/lib/elementary/efl_ui_popup.c
@@ -13,6 +13,16 @@
 #define MY_CLASS_NAME "Efl.Ui.Popup"
 #define MY_CLASS_NAME_LEGACY "elm_popup"
 
+static void
+_bg_clicked_cb(void *data,
+                  Evas_Object *o EINA_UNUSED,
+                  const char *emission EINA_UNUSED,
+                  const char *source EINA_UNUSED)
+{
+   Evas_Object *obj = data;
+   efl_event_callback_legacy_call(obj, EFL_UI_POPUP_EVENT_BG_CLICKED, NULL);
+}
+
 EOLIAN static void
 _efl_ui_popup_efl_gfx_position_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, 
Eina_Position2D pos)
 {
@@ -94,6 +104,8 @@ _efl_ui_popup_efl_canvas_group_group_add(Eo *obj, 
Efl_Ui_Popup_Data *pd)
    elm_widget_theme_object_set(obj, pd->event_bg, "popup", "base", "event_bg");
    evas_object_smart_member_add(pd->event_bg, obj);
    evas_object_stack_below(pd->event_bg, wd->resize_obj);
+
+   edje_object_signal_callback_add(pd->event_bg, "elm,action,clicked", "*", 
_bg_clicked_cb, obj);
 }
 
 EOLIAN static void
@@ -119,6 +131,42 @@ _efl_ui_popup_elm_layout_sizing_eval(Eo *obj, 
Efl_Ui_Popup_Data *pd EINA_UNUSED)
 }
 
 EOLIAN static void
+_efl_ui_popup_bg_set(Eo *obj, Efl_Ui_Popup_Data *pd, const char* file, const 
char* group)
+{
+   Evas_Object *prev_obj = edje_object_part_swallow_get(pd->event_bg, 
"elm.swallow.image");
+   if (prev_obj)
+   {
+     edje_object_part_unswallow(pd->event_bg, prev_obj);
+     evas_object_del(prev_obj);
+   }
+
+   Evas_Object *image = elm_image_add(obj);
+   Eina_Bool ret = elm_image_file_set(image, file, group);
+   if (!ret)
+   {
+      edje_object_signal_emit(pd->event_bg, "elm,state,image,hidden", "elm");
+      evas_object_del(image);
+      return;
+   }
+   edje_object_part_swallow(pd->event_bg, "elm.swallow.image", image);
+   edje_object_signal_emit(pd->event_bg, "elm,state,image,visible", "elm");
+}
+
+EOLIAN static void
+_efl_ui_popup_bg_repeat_events_set(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Data *pd, 
Eina_Bool repeat)
+{
+   pd->bg_repeat_events = repeat;
+
+   evas_object_repeat_events_set(pd->event_bg, repeat);
+}
+
+EOLIAN static Eina_Bool
+_efl_ui_popup_bg_repeat_events_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Data *pd)
+{
+  return pd->bg_repeat_events;
+}
+
+EOLIAN static void
 _efl_ui_popup_class_constructor(Efl_Class *klass)
 {
    evas_smart_legacy_type_register(MY_CLASS_NAME, klass);
diff --git a/src/lib/elementary/efl_ui_popup.eo 
b/src/lib/elementary/efl_ui_popup.eo
index 8383e7c269..07b415955e 100644
--- a/src/lib/elementary/efl_ui_popup.eo
+++ b/src/lib/elementary/efl_ui_popup.eo
@@ -3,13 +3,34 @@ class Efl.Ui.Popup(Efl.Ui.Layout)
    legacy_prefix: elm_popup;
    methods {
        @property parent_window @protected {
-           get {
-              [[Get the parent window of Popup.]]
-           }
-           values {
-               window: Efl.Canvas.Object;
-           }
-       }
+         get {
+            [[Get the parent window of Popup.]]
+         }
+         values {
+            window: Efl.Canvas.Object;
+         }
+      }
+      bg_set {
+         params {
+            @in file: string; [[The image file path.]]
+            @in group: string; [[The image key in $file (if its an Eet one), or
+                                 $null, otherwise.]]
+         }
+      }
+      @property bg_repeat_events {
+         set {
+            [[Sets whether events should be passed to by a click outside.
+
+              Note: The default value is $false.
+            ]]
+         }
+         get {
+            [[Returns value indicating whether bg repeat events is enabled or 
not.]]
+         }
+         values {
+            repeat: bool; [[If $true, events are passed to lower objects.]]
+         }
+      }
    }
    implements {
       class.constructor;
@@ -18,4 +39,7 @@ class Efl.Ui.Popup(Efl.Ui.Layout)
       Efl.Container.content { get; set; }
       Efl.Container.content_unset;
    }
+   events {
+      bg,clicked; [[This is called whenever the user click background of 
popup.]]
+   }
 }
diff --git a/src/lib/elementary/efl_ui_popup_private.h 
b/src/lib/elementary/efl_ui_popup_private.h
index d0b979ba05..191a5544de 100644
--- a/src/lib/elementary/efl_ui_popup_private.h
+++ b/src/lib/elementary/efl_ui_popup_private.h
@@ -6,6 +6,7 @@ struct _Efl_Ui_Popup_Data
 {
    Evas_Object *win_parent;
    Evas_Object *event_bg;
+   Eina_Bool    bg_repeat_events : 1;
 };
 
 #endif

-- 


Reply via email to