summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJinYong Park <j4939.park@samsung.com>2017-08-10 15:48:36 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-11-21 14:01:48 +0900
commit0cd862ef88ceee71b79a4f52faff527e02789720 (patch)
treee3e03125cbb725cefa946d0f115a22b2f395f2c4
parentcdda66fb56530520b4008ff0b15953ff297820f6 (diff)
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
-rw-r--r--data/elementary/themes/edc/elm/popup.edc42
-rw-r--r--src/bin/elementary/test_popup.c41
-rw-r--r--src/lib/elementary/efl_ui_popup.c48
-rw-r--r--src/lib/elementary/efl_ui_popup.eo38
-rw-r--r--src/lib/elementary/efl_ui_popup_private.h1
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";
536group { "elm/popup/base/event_bg"; 536group { "elm/popup/base/event_bg";
537 parts { 537 parts {
538 rect { "base"; 538 rect { "base";
539 repeat;
540 desc { "default"; 539 desc { "default";
541 color: 0 255 0 128; 540 color: 0 0 0 64;
542 } 541 }
542 desc { "show_image";
543 inherit: "default";
544 hid;
545 }
546 }
547 swallow { "elm.swallow.image";
548 desc { "default";
549 rel.to: "base";
550 hid;
551 }
552 desc { "show_image";
553 inherit: "default";
554 vis;
555 }
556 }
557 rect { "block";
558 desc { "default";
559 rel.to: "base";
560 color: 0 0 0 0;
561 }
562 }
563 }
564
565 programs {
566 program {
567 signal: "elm,state,image,visible"; source: "elm";
568 action: STATE_SET "show_image" 0.0;
569 target: "base";
570 target: "elm.swallow.image";
571 }
572 program {
573 signal: "elm,state,image,hidden"; source: "elm";
574 action: STATE_SET "default" 0.0;
575 target: "base";
576 target: "elm.swallow.image";
577 }
578 program {
579 signal: "mouse,clicked,1"; source: "block";
580 action: SIGNAL_EMIT "elm,action,clicked" "elm";
543 } 581 }
544 } 582 }
545} 583}
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,
939 evas_object_show(win); 939 evas_object_show(win);
940} 940}
941 941
942static void
943_bg_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
944 void *event_info EINA_UNUSED)
945{
946 printf("Popup's background is clicked.\n");
947}
948
949static void
950_image_change_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
951 void *event_info EINA_UNUSED)
952{
953 static int k = 0;
954
955 if (k == 0)
956 {
957 char buf[PATH_MAX];
958 snprintf(buf, sizeof(buf), "%s/images/logo.png", elm_app_data_dir_get());
959 efl_ui_popup_bg_set(data, buf, NULL);
960 efl_ui_popup_bg_repeat_events_set(data, EINA_TRUE);
961 }
962 else
963 {
964 efl_ui_popup_bg_set(data, NULL, NULL);
965 efl_ui_popup_bg_repeat_events_set(data, EINA_FALSE);
966 }
967 k = !k;
968}
969
942void 970void
943test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 971test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
944{ 972{
945 Evas_Object *win; 973 Evas_Object *win, *btn;
946 974
947 win = elm_win_util_standard_add("Efl UI Popup", "Efl UI Popup"); 975 win = elm_win_util_standard_add("Efl UI Popup", "Efl UI Popup");
948 elm_win_autodel_set(win, EINA_TRUE); 976 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
950 evas_object_resize(win, 320, 320); 978 evas_object_resize(win, 320, 320);
951 evas_object_show(win); 979 evas_object_show(win);
952 980
981 btn = elm_button_add(win);
982 elm_object_text_set(btn, "bg repeat events test");
983 evas_object_move(btn, 0, 0);
984 evas_object_resize(btn, 150, 150);
985 evas_object_show(btn);
986
953 Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_CLASS, win); 987 Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_CLASS, win);
954 988
989 evas_object_smart_callback_add(efl_ui_popup, "bg,clicked", _bg_clicked, NULL);
990
955 evas_object_move(efl_ui_popup, 80, 80); 991 evas_object_move(efl_ui_popup, 80, 80);
956 evas_object_resize(efl_ui_popup, 160, 160); 992 evas_object_resize(efl_ui_popup, 160, 160);
957 evas_object_show(efl_ui_popup); 993 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
960 evas_object_geometry_get(efl_ui_popup, &x, &y, &w, &h); 996 evas_object_geometry_get(efl_ui_popup, &x, &y, &w, &h);
961 printf("efl_ui_popup: %d %d %d %d\n", x, y, w, h); 997 printf("efl_ui_popup: %d %d %d %d\n", x, y, w, h);
962 998
963 Evas_Object *btn = elm_button_add(efl_ui_popup); 999 btn = elm_button_add(efl_ui_popup);
964 elm_object_text_set(btn, "Efl.Ui.Popup content"); 1000 elm_object_text_set(btn, "Efl.Ui.Popup content");
1001 evas_object_smart_callback_add(btn, "clicked", _image_change_btn_cb, efl_ui_popup);
965 evas_object_show(btn); 1002 evas_object_show(btn);
966 1003
967 efl_content_set(efl_ui_popup, btn); 1004 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 @@
13#define MY_CLASS_NAME "Efl.Ui.Popup" 13#define MY_CLASS_NAME "Efl.Ui.Popup"
14#define MY_CLASS_NAME_LEGACY "elm_popup" 14#define MY_CLASS_NAME_LEGACY "elm_popup"
15 15
16static void
17_bg_clicked_cb(void *data,
18 Evas_Object *o EINA_UNUSED,
19 const char *emission EINA_UNUSED,
20 const char *source EINA_UNUSED)
21{
22 Evas_Object *obj = data;
23 efl_event_callback_legacy_call(obj, EFL_UI_POPUP_EVENT_BG_CLICKED, NULL);
24}
25
16EOLIAN static void 26EOLIAN static void
17_efl_ui_popup_efl_gfx_position_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, Eina_Position2D pos) 27_efl_ui_popup_efl_gfx_position_set(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED, Eina_Position2D pos)
18{ 28{
@@ -94,6 +104,8 @@ _efl_ui_popup_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Data *pd)
94 elm_widget_theme_object_set(obj, pd->event_bg, "popup", "base", "event_bg"); 104 elm_widget_theme_object_set(obj, pd->event_bg, "popup", "base", "event_bg");
95 evas_object_smart_member_add(pd->event_bg, obj); 105 evas_object_smart_member_add(pd->event_bg, obj);
96 evas_object_stack_below(pd->event_bg, wd->resize_obj); 106 evas_object_stack_below(pd->event_bg, wd->resize_obj);
107
108 edje_object_signal_callback_add(pd->event_bg, "elm,action,clicked", "*", _bg_clicked_cb, obj);
97} 109}
98 110
99EOLIAN static void 111EOLIAN static void
@@ -119,6 +131,42 @@ _efl_ui_popup_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Popup_Data *pd EINA_UNUSED)
119} 131}
120 132
121EOLIAN static void 133EOLIAN static void
134_efl_ui_popup_bg_set(Eo *obj, Efl_Ui_Popup_Data *pd, const char* file, const char* group)
135{
136 Evas_Object *prev_obj = edje_object_part_swallow_get(pd->event_bg, "elm.swallow.image");
137 if (prev_obj)
138 {
139 edje_object_part_unswallow(pd->event_bg, prev_obj);
140 evas_object_del(prev_obj);
141 }
142
143 Evas_Object *image = elm_image_add(obj);
144 Eina_Bool ret = elm_image_file_set(image, file, group);
145 if (!ret)
146 {
147 edje_object_signal_emit(pd->event_bg, "elm,state,image,hidden", "elm");
148 evas_object_del(image);
149 return;
150 }
151 edje_object_part_swallow(pd->event_bg, "elm.swallow.image", image);
152 edje_object_signal_emit(pd->event_bg, "elm,state,image,visible", "elm");
153}
154
155EOLIAN static void
156_efl_ui_popup_bg_repeat_events_set(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Data *pd, Eina_Bool repeat)
157{
158 pd->bg_repeat_events = repeat;
159
160 evas_object_repeat_events_set(pd->event_bg, repeat);
161}
162
163EOLIAN static Eina_Bool
164_efl_ui_popup_bg_repeat_events_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Data *pd)
165{
166 return pd->bg_repeat_events;
167}
168
169EOLIAN static void
122_efl_ui_popup_class_constructor(Efl_Class *klass) 170_efl_ui_popup_class_constructor(Efl_Class *klass)
123{ 171{
124 evas_smart_legacy_type_register(MY_CLASS_NAME, klass); 172 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)
3 legacy_prefix: elm_popup; 3 legacy_prefix: elm_popup;
4 methods { 4 methods {
5 @property parent_window @protected { 5 @property parent_window @protected {
6 get { 6 get {
7 [[Get the parent window of Popup.]] 7 [[Get the parent window of Popup.]]
8 } 8 }
9 values { 9 values {
10 window: Efl.Canvas.Object; 10 window: Efl.Canvas.Object;
11 } 11 }
12 } 12 }
13 bg_set {
14 params {
15 @in file: string; [[The image file path.]]
16 @in group: string; [[The image key in $file (if its an Eet one), or
17 $null, otherwise.]]
18 }
19 }
20 @property bg_repeat_events {
21 set {
22 [[Sets whether events should be passed to by a click outside.
23
24 Note: The default value is $false.
25 ]]
26 }
27 get {
28 [[Returns value indicating whether bg repeat events is enabled or not.]]
29 }
30 values {
31 repeat: bool; [[If $true, events are passed to lower objects.]]
32 }
33 }
13 } 34 }
14 implements { 35 implements {
15 class.constructor; 36 class.constructor;
@@ -18,4 +39,7 @@ class Efl.Ui.Popup(Efl.Ui.Layout)
18 Efl.Container.content { get; set; } 39 Efl.Container.content { get; set; }
19 Efl.Container.content_unset; 40 Efl.Container.content_unset;
20 } 41 }
42 events {
43 bg,clicked; [[This is called whenever the user click background of popup.]]
44 }
21} 45}
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
6{ 6{
7 Evas_Object *win_parent; 7 Evas_Object *win_parent;
8 Evas_Object *event_bg; 8 Evas_Object *event_bg;
9 Eina_Bool bg_repeat_events : 1;
9}; 10};
10 11
11#endif 12#endif