summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaehyun Cho <jae_hyun.cho@samsung.com>2017-10-30 20:03:01 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-11-21 14:01:48 +0900
commit35486bd3d934acbe76e8250bca71fee24f2453db (patch)
tree31871e5011110d7347331f4bf6d624d93fd6fc2b /src
parentf279491ca0fa65445f1c262a898db8ba647c075f (diff)
test_ui_popup: Move code for Efl.Ui.Popup classes from test_popup
Code refactoring to replace legacy APIs and move test code for Efl.Ui.Popup and its sub classes from test_popup to test_ui_popup.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile_Elementary.am1
-rw-r--r--src/bin/elementary/Makefile.am1
-rw-r--r--src/bin/elementary/test.c20
-rw-r--r--src/bin/elementary/test_popup.c585
-rw-r--r--src/bin/elementary/test_ui_popup.c529
5 files changed, 541 insertions, 595 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 370bb55bf2..39b04c0cc8 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -926,6 +926,7 @@ bin/elementary/test_transit_bezier.c \
926bin/elementary/test_ui_box.c \ 926bin/elementary/test_ui_box.c \
927bin/elementary/test_ui_clock.c \ 927bin/elementary/test_ui_clock.c \
928bin/elementary/test_ui_grid.c \ 928bin/elementary/test_ui_grid.c \
929bin/elementary/test_ui_popup.c \
929bin/elementary/test_ui_textpath.c \ 930bin/elementary/test_ui_textpath.c \
930bin/elementary/test_video.c \ 931bin/elementary/test_video.c \
931bin/elementary/test_weather.c \ 932bin/elementary/test_weather.c \
diff --git a/src/bin/elementary/Makefile.am b/src/bin/elementary/Makefile.am
index df71027a38..559018aba2 100644
--- a/src/bin/elementary/Makefile.am
+++ b/src/bin/elementary/Makefile.am
@@ -138,6 +138,7 @@ test_tooltip.c \
138test_transit.c \ 138test_transit.c \
139test_transit_bezier.c \ 139test_transit_bezier.c \
140test_ui_clock.c \ 140test_ui_clock.c \
141test_ui_popup.c \
141test_video.c \ 142test_video.c \
142test_weather.c \ 143test_weather.c \
143test_web.c \ 144test_web.c \
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index f7dc6fa46d..2c9786cea8 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -274,11 +274,11 @@ void test_naviframe_complex(void *data, Evas_Object *obj, void *event_info);
274void test_datetime(void *data, Evas_Object *obj, void *event_info); 274void test_datetime(void *data, Evas_Object *obj, void *event_info);
275void test_ui_clock(void *data, Evas_Object *obj, void *event_info); 275void test_ui_clock(void *data, Evas_Object *obj, void *event_info);
276void test_popup(void *data, Evas_Object *obj, void *event_info); 276void test_popup(void *data, Evas_Object *obj, void *event_info);
277void test_efl_ui_popup(void *data, Evas_Object *obj, void *event_info); 277void test_ui_popup(void *data, Evas_Object *obj, void *event_info);
278void test_efl_ui_popup_alert(void *data, Evas_Object *obj, void *event_info); 278void test_ui_popup_alert(void *data, Evas_Object *obj, void *event_info);
279void test_efl_ui_popup_alert_scroll(void *data, Evas_Object *obj, void *event_info); 279void test_ui_popup_alert_scroll(void *data, Evas_Object *obj, void *event_info);
280void test_efl_ui_popup_alert_text(void *data, Evas_Object *obj, void *event_info); 280void test_ui_popup_alert_text(void *data, Evas_Object *obj, void *event_info);
281void test_efl_ui_popup_anchor(void *data, Evas_Object *obj, void *event_info); 281void test_ui_popup_anchor(void *data, Evas_Object *obj, void *event_info);
282void test_dayselector(void *data, Evas_Object *obj, void *event_info); 282void test_dayselector(void *data, Evas_Object *obj, void *event_info);
283void test_image(void *data, Evas_Object *obj, void *event_info); 283void test_image(void *data, Evas_Object *obj, void *event_info);
284void test_image_scale_type(void *data, Evas_Object *obj, void *event_info); 284void test_image_scale_type(void *data, Evas_Object *obj, void *event_info);
@@ -1011,11 +1011,11 @@ add_tests:
1011 ADD_TEST(NULL, "Popups", "Tooltip 3", test_tooltip3); 1011 ADD_TEST(NULL, "Popups", "Tooltip 3", test_tooltip3);
1012 ADD_TEST(NULL, "Popups", "Tooltip 4", test_tooltip4); 1012 ADD_TEST(NULL, "Popups", "Tooltip 4", test_tooltip4);
1013 ADD_TEST(NULL, "Popups", "Popup", test_popup); 1013 ADD_TEST(NULL, "Popups", "Popup", test_popup);
1014 ADD_TEST(NULL, "Popups", "Efl UI Popup", test_efl_ui_popup); 1014 ADD_TEST(NULL, "Popups", "UI.Popup", test_ui_popup);
1015 ADD_TEST(NULL, "Popups", "Efl UI Popup Alert", test_efl_ui_popup_alert); 1015 ADD_TEST(NULL, "Popups", "UI.Popup.Alert", test_ui_popup_alert);
1016 ADD_TEST(NULL, "Popups", "Efl UI Popup Alert Scroll", test_efl_ui_popup_alert_scroll); 1016 ADD_TEST(NULL, "Popups", "UI.Popup.Alert.Scroll", test_ui_popup_alert_scroll);
1017 ADD_TEST(NULL, "Popups", "Efl UI Popup Alert Text", test_efl_ui_popup_alert_text); 1017 ADD_TEST(NULL, "Popups", "UI.Popup.Alert.Text", test_ui_popup_alert_text);
1018 ADD_TEST(NULL, "Popups", "Efl UI Popup Anchor", test_efl_ui_popup_anchor); 1018 ADD_TEST(NULL, "Popups", "UI.Popup.Anchor", test_ui_popup_anchor);
1019 1019
1020 //------------------------------// 1020 //------------------------------//
1021 ADD_TEST(NULL, "Times & Dates", "Calendar", test_calendar); 1021 ADD_TEST(NULL, "Times & Dates", "Calendar", test_calendar);
diff --git a/src/bin/elementary/test_popup.c b/src/bin/elementary/test_popup.c
index 3a16718571..da9bbca934 100644
--- a/src/bin/elementary/test_popup.c
+++ b/src/bin/elementary/test_popup.c
@@ -2,7 +2,6 @@
2# include "elementary_config.h" 2# include "elementary_config.h"
3#endif 3#endif
4 4
5#define EFL_UI_POPUP_ANCHOR_BETA
6#include <Elementary.h> 5#include <Elementary.h>
7 6
8#define POPUP_POINT_MAX 8 7#define POPUP_POINT_MAX 8
@@ -940,587 +939,3 @@ test_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
940 evas_object_resize(win, 480, 400); 939 evas_object_resize(win, 480, 400);
941 evas_object_show(win); 940 evas_object_show(win);
942} 941}
943
944typedef struct
945{
946 Evas_Object *win;
947 Evas_Object *panel_win;
948 Evas_Object *efl_ui_popup;
949 Evas_Object *button;
950} efl_ui_popup_data;
951
952static void
953_bg_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
954 void *event_info EINA_UNUSED)
955{
956 printf("Popup's background is clicked.\n");
957}
958
959static void
960_timeout_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
961{
962 efl_ui_popup_data *p_data = data;
963 p_data->efl_ui_popup = NULL;
964 printf("Popup times out and it is deleted.\n");
965}
966
967static void
968_delete_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
969 void *event_info EINA_UNUSED)
970{
971 efl_ui_popup_data *p_data = data;
972 if (p_data->efl_ui_popup)
973 {
974 evas_object_del(p_data->efl_ui_popup);
975 p_data->efl_ui_popup = NULL;
976 return;
977 }
978 printf("Efl.Ui.Popup is not exist.\n");
979}
980
981static Evas_Object*
982_create_popup(efl_ui_popup_data *p_data)
983{
984 if (!p_data->win) return NULL;
985 if (p_data->efl_ui_popup)
986 {
987 printf("Efl.Ui.Popup is already created.\n");
988 evas_object_show(p_data->efl_ui_popup);
989 return p_data->efl_ui_popup;
990 }
991
992 Evas_Object *efl_ui_popup = efl_add(EFL_UI_POPUP_CLASS, p_data->win);
993
994 evas_object_smart_callback_add(efl_ui_popup, "bg,clicked", _bg_clicked, NULL);
995 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_EVENT_TIMEOUT, _timeout_cb, p_data);
996 evas_object_resize(efl_ui_popup, 160, 160);
997 evas_object_show(efl_ui_popup);
998
999 Evas_Object *btn = elm_button_add(efl_ui_popup);
1000 elm_object_text_set(btn, "Efl.Ui.Popup");
1001 evas_object_show(btn);
1002
1003 efl_content_set(efl_ui_popup, btn);
1004
1005 return efl_ui_popup;
1006}
1007
1008static void
1009_create_cb(void *data, Evas_Object *obj EINA_UNUSED,
1010 void *event_info EINA_UNUSED)
1011{
1012 efl_ui_popup_data *p_data = data;
1013 p_data->efl_ui_popup = _create_popup(p_data);
1014}
1015
1016static void
1017_bg_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1018 void *event_info EINA_UNUSED)
1019{
1020 static int k = 0;
1021 efl_ui_popup_data *p_data = data;
1022 if (!p_data->efl_ui_popup) return;
1023 if (k == 0)
1024 {
1025 char buf[PATH_MAX];
1026 snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", elm_app_data_dir_get());
1027 efl_ui_popup_bg_set(p_data->efl_ui_popup, buf, NULL);
1028 elm_object_text_set(obj, "Bg UnSet");
1029 }
1030 else
1031 {
1032 efl_ui_popup_bg_set(p_data->efl_ui_popup, NULL, NULL);
1033 elm_object_text_set(obj, "Bg Set");
1034 }
1035 k = !k;
1036}
1037
1038static void
1039_repeat_event_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1040 void *event_info EINA_UNUSED)
1041{
1042 efl_ui_popup_data *p_data = data;
1043 if (!p_data->efl_ui_popup) return;
1044 if (!efl_ui_popup_bg_repeat_events_get(p_data->efl_ui_popup))
1045 {
1046 efl_ui_popup_bg_repeat_events_set(p_data->efl_ui_popup, EINA_TRUE);
1047 elm_object_text_set(obj, "Repeat Event UnSet");
1048 }
1049 else
1050 {
1051 efl_ui_popup_bg_repeat_events_set(p_data->efl_ui_popup, EINA_FALSE);
1052 elm_object_text_set(obj, "Repeat Event Set");
1053 }
1054}
1055
1056static void
1057_repeat_test_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1058 void *event_info EINA_UNUSED)
1059{
1060 printf("Repeat Test Button is Clicked.\n");
1061}
1062
1063static void
1064_dummy_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1065 void *event_info EINA_UNUSED)
1066{
1067 efl_ui_popup_data *p_data = data;
1068 if (!p_data->efl_ui_popup) return;
1069 if (!evas_object_visible_get(p_data->button))
1070 {
1071 evas_object_show(p_data->button);
1072 elm_object_text_set(obj, "Hide Dummy Button");
1073 }
1074 else
1075 {
1076 evas_object_hide(p_data->button);
1077 elm_object_text_set(obj, "Show Dummy Button");
1078 }
1079}
1080
1081static void
1082_center_align_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1083 void *event_info EINA_UNUSED)
1084{
1085 efl_ui_popup_data *p_data = data;
1086 if (!p_data->efl_ui_popup) return;
1087 efl_ui_popup_align_set(p_data->efl_ui_popup, EFL_UI_POPUP_ALIGN_CENTER);
1088}
1089
1090static void
1091_left_align_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1092 void *event_info EINA_UNUSED)
1093{
1094 efl_ui_popup_data *p_data = data;
1095 if (!p_data->efl_ui_popup) return;
1096 efl_ui_popup_align_set(p_data->efl_ui_popup, EFL_UI_POPUP_ALIGN_LEFT);
1097}
1098
1099static void
1100_right_align_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1101 void *event_info EINA_UNUSED)
1102{
1103 efl_ui_popup_data *p_data = data;
1104 if (!p_data->efl_ui_popup) return;
1105 efl_ui_popup_align_set(p_data->efl_ui_popup, EFL_UI_POPUP_ALIGN_RIGHT);
1106}
1107
1108static void
1109_top_align_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1110 void *event_info EINA_UNUSED)
1111{
1112 efl_ui_popup_data *p_data = data;
1113 if (!p_data->efl_ui_popup) return;
1114 efl_ui_popup_align_set(p_data->efl_ui_popup, EFL_UI_POPUP_ALIGN_TOP);
1115}
1116
1117static void
1118_bottom_align_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1119 void *event_info EINA_UNUSED)
1120{
1121 efl_ui_popup_data *p_data = data;
1122 if (!p_data->efl_ui_popup) return;
1123 efl_ui_popup_align_set(p_data->efl_ui_popup, EFL_UI_POPUP_ALIGN_BOTTOM);
1124}
1125
1126static void
1127_position_set_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1128 void *event_info EINA_UNUSED)
1129{
1130 efl_ui_popup_data *p_data = data;
1131 if (!p_data->efl_ui_popup) return;
1132 evas_object_move(p_data->efl_ui_popup, 0, 0);
1133}
1134
1135static void
1136_timeout_set_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1137 void *event_info EINA_UNUSED)
1138{
1139 efl_ui_popup_data *p_data = data;
1140 if (!p_data->efl_ui_popup) return;
1141 efl_ui_popup_timeout_set(p_data->efl_ui_popup, 3);
1142 printf("timemout is set to 3 seconds\n");
1143}
1144
1145static void
1146_win_del(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1147{
1148 efl_ui_popup_data *p_data = data;
1149 evas_object_del(p_data->panel_win);
1150 free(p_data);
1151 printf("window is deleted\n");
1152}
1153
1154static void
1155_panel_win_del(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1156{
1157 efl_ui_popup_data *p_data = data;
1158 evas_object_del(p_data->win);
1159 free(p_data);
1160 printf("window is deleted\n");
1161}
1162
1163void
1164test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1165{
1166 efl_ui_popup_data *p_data = (efl_ui_popup_data*)calloc(1, sizeof(efl_ui_popup_data));
1167
1168 Evas_Object *win, *panel_win;
1169
1170 win = elm_win_util_standard_add("Efl UI Popup", "Efl UI Popup");
1171 elm_win_autodel_set(win, EINA_TRUE);
1172 evas_object_smart_callback_add(win, "delete,request", _win_del, p_data);
1173
1174 evas_object_resize(win, 500, 500);
1175 evas_object_show(win);
1176
1177 panel_win = elm_win_util_standard_add("Efl UI Popup Panel", "Efl UI Popup Panel");
1178 elm_win_autodel_set(panel_win, EINA_TRUE);
1179 evas_object_smart_callback_add(panel_win, "delete,request", _panel_win_del, p_data);
1180
1181 evas_object_resize(panel_win, 300, 500);
1182 evas_object_show(panel_win);
1183
1184 Evas_Object *repeat_test_btn;
1185 repeat_test_btn = elm_button_add(win);
1186 evas_object_move(repeat_test_btn, 0, 0);
1187 evas_object_resize(repeat_test_btn, 100, 100);
1188 elm_object_text_set(repeat_test_btn, "Repeat Event Test");
1189 evas_object_smart_callback_add(repeat_test_btn, "clicked", _repeat_test_cb, NULL);
1190 evas_object_hide(repeat_test_btn);
1191
1192 p_data->win = win;
1193 p_data->panel_win = panel_win;
1194 p_data->button = repeat_test_btn;
1195 p_data->efl_ui_popup = _create_popup(p_data);
1196
1197 Evas_Object *create_btn;
1198 create_btn = elm_button_add(panel_win);
1199 elm_object_text_set(create_btn, "Create Popup");
1200 evas_object_move(create_btn, 0, 0);
1201 evas_object_resize(create_btn, 150, 50);
1202 evas_object_show(create_btn);
1203 evas_object_smart_callback_add(create_btn, "clicked", _create_cb, p_data);
1204
1205 Evas_Object *delete_btn;
1206 delete_btn = elm_button_add(panel_win);
1207 elm_object_text_set(delete_btn, "Delete Popup");
1208 evas_object_move(delete_btn, 150, 0);
1209 evas_object_resize(delete_btn, 150, 50);
1210 evas_object_show(delete_btn);
1211 evas_object_smart_callback_add(delete_btn, "clicked", _delete_cb, p_data);
1212
1213 Evas_Object *repeat_event_btn;
1214 repeat_event_btn = elm_button_add(panel_win);
1215 elm_object_text_set(repeat_event_btn, "Repeat Event Set");
1216 evas_object_move(repeat_event_btn, 0, 50);
1217 evas_object_resize(repeat_event_btn, 150, 50);
1218 evas_object_show(repeat_event_btn);
1219 evas_object_smart_callback_add(repeat_event_btn, "clicked", _repeat_event_cb, p_data);
1220
1221 Evas_Object *dummy_btn;
1222 dummy_btn = elm_button_add(panel_win);
1223 elm_object_text_set(dummy_btn, "Show Dummy Button");
1224 evas_object_move(dummy_btn, 150, 50);
1225 evas_object_resize(dummy_btn, 150, 50);
1226 evas_object_show(dummy_btn);
1227 evas_object_smart_callback_add(dummy_btn, "clicked", _dummy_cb, p_data);
1228
1229 Evas_Object *bg_btn;
1230 bg_btn = elm_button_add(panel_win);
1231 evas_object_move(bg_btn, 0, 100);
1232 evas_object_resize(bg_btn, 150, 50);
1233 elm_object_text_set(bg_btn, "Bg Set");
1234 evas_object_show(bg_btn);
1235 evas_object_smart_callback_add(bg_btn, "clicked", _bg_cb, p_data);
1236
1237 Evas_Object *timeout_btn;
1238 timeout_btn = elm_button_add(panel_win);
1239 elm_object_text_set(timeout_btn, "Timeout Set");
1240 evas_object_move(timeout_btn, 150, 100);
1241 evas_object_resize(timeout_btn, 150, 50);
1242 evas_object_show(timeout_btn);
1243 evas_object_smart_callback_add(timeout_btn, "clicked", _timeout_set_cb, p_data);
1244
1245 Evas_Object *center_btn;
1246 center_btn = elm_button_add(panel_win);
1247 elm_object_text_set(center_btn, "Center Align");
1248 evas_object_move(center_btn, 0, 150);
1249 evas_object_resize(center_btn, 150, 50);
1250 evas_object_show(center_btn);
1251 evas_object_smart_callback_add(center_btn, "clicked", _center_align_cb, p_data);
1252
1253 Evas_Object *top_btn;
1254 top_btn = elm_button_add(panel_win);
1255 elm_object_text_set(top_btn, "Top Align");
1256 evas_object_move(top_btn, 150, 150);
1257 evas_object_resize(top_btn, 150, 50);
1258 evas_object_show(top_btn);
1259 evas_object_smart_callback_add(top_btn, "clicked", _top_align_cb, p_data);
1260
1261 Evas_Object *left_btn;
1262 left_btn = elm_button_add(panel_win);
1263 elm_object_text_set(left_btn, "Left Align");
1264 evas_object_move(left_btn, 0, 200);
1265 evas_object_resize(left_btn, 150, 50);
1266 evas_object_show(left_btn);
1267 evas_object_smart_callback_add(left_btn, "clicked", _left_align_cb, p_data);
1268
1269 Evas_Object *right_btn;
1270 right_btn = elm_button_add(panel_win);
1271 elm_object_text_set(right_btn, "Right Align");
1272 evas_object_move(right_btn, 150, 200);
1273 evas_object_resize(right_btn, 150, 50);
1274 evas_object_show(right_btn);
1275 evas_object_smart_callback_add(right_btn, "clicked", _right_align_cb, p_data);
1276
1277 Evas_Object *bottom_btn;
1278 bottom_btn = elm_button_add(panel_win);
1279 elm_object_text_set(bottom_btn, "Bottom Align");
1280 evas_object_move(bottom_btn, 0, 250);
1281 evas_object_resize(bottom_btn, 150, 50);
1282 evas_object_show(bottom_btn);
1283 evas_object_smart_callback_add(bottom_btn, "clicked", _bottom_align_cb, p_data);
1284
1285 Evas_Object *position_btn;
1286 position_btn = elm_button_add(panel_win);
1287 elm_object_text_set(position_btn, "Position Set (x:0, y:0)");
1288 evas_object_move(position_btn, 150, 250);
1289 evas_object_resize(position_btn, 150, 50);
1290 evas_object_show(position_btn);
1291 evas_object_smart_callback_add(position_btn, "clicked", _position_set_cb, p_data);
1292}
1293
1294static void
1295efl_ui_popup_alert_clicked_cb(void *data EINA_UNUSED, const Efl_Event *ev)
1296{
1297 Efl_Ui_Popup_Alert_Clicked_Event *event = ev->info;
1298
1299 if (event->button_type == EFL_UI_POPUP_ALERT_BUTTON_POSITIVE)
1300 printf("Positive Button is clicked\n");
1301 else if(event->button_type == EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE)
1302 printf("Negative Button is clicked\n");
1303 else if(event->button_type == EFL_UI_POPUP_ALERT_BUTTON_USER)
1304 printf("User Button is clicked\n");
1305}
1306
1307void
1308test_efl_ui_popup_alert(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1309{
1310 Evas_Object *win;
1311 char buf[PATH_MAX];
1312
1313 win = elm_win_util_standard_add("Efl UI Popup Alert", "Efl UI Popup Alert");
1314 elm_win_autodel_set(win, EINA_TRUE);
1315
1316 evas_object_resize(win, 320, 320);
1317 evas_object_show(win);
1318
1319 Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_ALERT_CLASS, win);
1320
1321 efl_text_set(efl_part(efl_ui_popup, "title"), "title");
1322
1323 evas_object_resize(efl_ui_popup, 160, 160);
1324 evas_object_show(efl_ui_popup);
1325
1326 Evas_Object *layout = elm_layout_add(efl_ui_popup);
1327 snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
1328 elm_layout_file_set(layout, buf, "efl_ui_popup_scroll_content");
1329 evas_object_show(layout);
1330
1331 efl_content_set(efl_ui_popup, layout);
1332 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_POSITIVE, "Yes");
1333 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE, "No");
1334 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_USER, "Cancel");
1335
1336 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_ALERT_EVENT_CLICKED, efl_ui_popup_alert_clicked_cb, NULL);
1337}
1338
1339void
1340test_efl_ui_popup_alert_scroll(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1341{
1342 Evas_Object *win;
1343 char buf[PATH_MAX];
1344
1345 win = elm_win_util_standard_add("Efl UI Popup Alert Scroll", "Efl UI Popup Alert Scroll");
1346 elm_win_autodel_set(win, EINA_TRUE);
1347
1348 evas_object_resize(win, 320, 320);
1349 evas_object_show(win);
1350
1351 Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_ALERT_SCROLL_CLASS, win);
1352
1353 efl_text_set(efl_part(efl_ui_popup, "title"), "title");
1354
1355 evas_object_resize(efl_ui_popup, 160, 160);
1356 evas_object_show(efl_ui_popup);
1357
1358 Evas_Object *layout = elm_layout_add(efl_ui_popup);
1359 snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
1360 elm_layout_file_set(layout, buf, "efl_ui_popup_scroll_content");
1361 evas_object_show(layout);
1362
1363 efl_content_set(efl_ui_popup, layout);
1364
1365 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_POSITIVE, "Yes");
1366 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE, "No");
1367 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_USER, "Cancel");
1368
1369 efl_ui_popup_alert_scroll_expandable_set(efl_ui_popup, EINA_TRUE, EINA_TRUE);
1370 efl_gfx_size_hint_max_set(efl_ui_popup, EINA_SIZE2D(300, 180));
1371
1372 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_ALERT_EVENT_CLICKED, efl_ui_popup_alert_clicked_cb, NULL);
1373}
1374
1375void
1376test_efl_ui_popup_alert_text(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1377{
1378 Evas_Object *win;
1379
1380 win = elm_win_util_standard_add("Efl UI Popup Alert Text", "Efl UI Popup Alert Text");
1381 elm_win_autodel_set(win, EINA_TRUE);
1382
1383 evas_object_resize(win, 320, 320);
1384 evas_object_show(win);
1385
1386 Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_ALERT_TEXT_CLASS, win);
1387
1388 efl_text_set(efl_part(efl_ui_popup, "title"), "title");
1389
1390 evas_object_resize(efl_ui_popup, 160, 160);
1391 evas_object_show(efl_ui_popup);
1392
1393 efl_text_set(efl_ui_popup,
1394 "This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup"
1395 "This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup"
1396 "This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup");
1397
1398 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_POSITIVE, "Yes");
1399 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE, "No");
1400 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_USER, "Cancel");
1401
1402 efl_ui_popup_alert_text_expandable_set(efl_ui_popup, EINA_TRUE);
1403 efl_gfx_size_hint_max_set(efl_ui_popup, EINA_SIZE2D(100, 180));
1404
1405 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_ALERT_EVENT_CLICKED, efl_ui_popup_alert_clicked_cb, NULL);
1406}
1407
1408static void
1409_anchor_set_cb(void *data, Evas_Object *obj EINA_UNUSED,
1410 void *event_info EINA_UNUSED)
1411{
1412 efl_ui_popup_anchor_set(data, obj);
1413}
1414
1415static void
1416_anchor_unset_cb(void *data, Evas_Object *obj EINA_UNUSED,
1417 void *event_info EINA_UNUSED)
1418{
1419 efl_ui_popup_anchor_set(data, NULL);
1420}
1421
1422void
1423test_efl_ui_popup_anchor(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1424{
1425 efl_ui_popup_data *p_data = (efl_ui_popup_data*)calloc(1, sizeof(efl_ui_popup_data));
1426
1427 Evas_Object *win, *layout, *tbl, *btn;
1428 char buf[PATH_MAX];
1429
1430 win = elm_win_util_standard_add("Efl UI Popup Anchor", "Efl UI Popup Anchor");
1431 elm_win_autodel_set(win, EINA_TRUE);
1432 evas_object_smart_callback_add(win, "delete,request", _win_del, p_data);
1433
1434 evas_object_resize(win, 500, 500);
1435 evas_object_show(win);
1436
1437 layout = elm_layout_add(win);
1438 snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
1439 elm_layout_file_set(layout, buf, "efl_ui_popup_anchor_layout");
1440 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1441 elm_win_resize_object_add(win, layout);
1442 evas_object_show(layout);
1443
1444 Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_ANCHOR_CLASS, win);
1445
1446 efl_ui_popup_bg_repeat_events_set(efl_ui_popup, EINA_TRUE);
1447
1448 //Default align priority order is top, left, right, bottom, center.
1449 efl_ui_popup_anchor_align_priority_set(efl_ui_popup, EFL_UI_POPUP_ALIGN_TOP,
1450 EFL_UI_POPUP_ALIGN_BOTTOM,
1451 EFL_UI_POPUP_ALIGN_LEFT,
1452 EFL_UI_POPUP_ALIGN_RIGHT,
1453 EFL_UI_POPUP_ALIGN_CENTER);
1454
1455 evas_object_move(efl_ui_popup, 80, 80);
1456 evas_object_resize(efl_ui_popup, 160, 120);
1457 evas_object_show(efl_ui_popup);
1458
1459 p_data->win = win;
1460 p_data->efl_ui_popup = efl_ui_popup;
1461
1462 for (int i = 0; i < 6; i++)
1463 {
1464 btn = elm_button_add(win);
1465 elm_object_text_set(btn, "anchor");
1466 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1467 evas_object_smart_callback_add(btn, "clicked", _anchor_set_cb, efl_ui_popup);
1468
1469 snprintf(buf, sizeof(buf), "anchor%d", i+1);
1470 elm_object_part_content_set(layout, buf, btn);
1471 }
1472
1473 btn = elm_button_add(win);
1474 elm_object_text_set(btn, "anchor none");
1475 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1476 evas_object_smart_callback_add(btn, "clicked", _anchor_unset_cb, efl_ui_popup);
1477 elm_object_part_content_set(layout, "anchor_none", btn);
1478
1479 tbl = elm_table_add(efl_ui_popup);
1480 evas_object_size_hint_weight_set(tbl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1481 evas_object_size_hint_align_set(tbl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1482
1483 btn = elm_button_add(efl_ui_popup);
1484 elm_object_text_set(btn, "Center Align");
1485 evas_object_size_hint_min_set(btn, 70, 35);
1486 evas_object_smart_callback_add(btn, "clicked", _center_align_cb, p_data);
1487 elm_table_pack(tbl, btn, 0, 0, 1, 1);
1488 evas_object_show(btn);
1489
1490 btn = elm_button_add(efl_ui_popup);
1491 elm_object_text_set(btn, "Left Align");
1492 evas_object_size_hint_min_set(btn, 70, 35);
1493 evas_object_smart_callback_add(btn, "clicked", _left_align_cb, p_data);
1494 elm_table_pack(tbl, btn, 1, 0, 1, 1);
1495 evas_object_show(btn);
1496
1497 btn = elm_button_add(efl_ui_popup);
1498 elm_object_text_set(btn, "Right Align");
1499 evas_object_size_hint_min_set(btn, 70, 35);
1500 evas_object_smart_callback_add(btn, "clicked", _right_align_cb, p_data);
1501 elm_table_pack(tbl, btn, 2, 0, 1, 1);
1502 evas_object_show(btn);
1503
1504 btn = elm_button_add(efl_ui_popup);
1505 elm_object_text_set(btn, "Top Align");
1506 evas_object_size_hint_min_set(btn, 70, 35);
1507 evas_object_smart_callback_add(btn, "clicked", _top_align_cb, p_data);
1508 elm_table_pack(tbl, btn, 0, 1, 1, 1);
1509 evas_object_show(btn);
1510
1511 btn = elm_button_add(efl_ui_popup);
1512 elm_object_text_set(btn, "Bottom Align");
1513 evas_object_size_hint_min_set(btn, 70, 35);
1514 evas_object_smart_callback_add(btn, "clicked", _bottom_align_cb, p_data);
1515 elm_table_pack(tbl, btn, 1, 1, 1, 1);
1516 evas_object_show(btn);
1517
1518 btn = elm_button_add(efl_ui_popup);
1519 elm_object_text_set(btn, "Position Set");
1520 evas_object_size_hint_min_set(btn, 70, 35);
1521 evas_object_smart_callback_add(btn, "clicked", _position_set_cb, p_data);
1522 elm_table_pack(tbl, btn, 2, 1, 1, 1);
1523 evas_object_show(btn);
1524
1525 efl_content_set(efl_ui_popup, tbl);
1526}
diff --git a/src/bin/elementary/test_ui_popup.c b/src/bin/elementary/test_ui_popup.c
new file mode 100644
index 0000000000..2c7075de32
--- /dev/null
+++ b/src/bin/elementary/test_ui_popup.c
@@ -0,0 +1,529 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#define EFL_UI_POPUP_ANCHOR_BETA
6#include <Elementary.h>
7
8#define POPUP_POINT_MAX 8
9
10typedef struct
11{
12 Eo *win;
13 Eo *panel_win;
14 Eo *efl_ui_popup;
15 Eo *button;
16} efl_ui_popup_data;
17
18static void
19_bg_clicked(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
20{
21 printf("Popup's background is clicked.\n");
22}
23
24static void
25_timeout_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
26{
27 efl_ui_popup_data *p_data = data;
28 p_data->efl_ui_popup = NULL;
29 printf("Popup times out and it is deleted.\n");
30}
31
32static void
33_delete_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
34{
35 efl_ui_popup_data *p_data = data;
36 if (p_data->efl_ui_popup)
37 {
38 efl_del(p_data->efl_ui_popup);
39 p_data->efl_ui_popup = NULL;
40 return;
41 }
42 printf("Efl.Ui.Popup does not exist.\n");
43}
44
45static Eo*
46_create_popup(efl_ui_popup_data *p_data)
47{
48 if (!p_data->win) return NULL;
49 if (p_data->efl_ui_popup)
50 {
51 printf("Efl.Ui.Popup is already created.\n");
52 efl_gfx_visible_set(p_data->efl_ui_popup, EINA_TRUE);
53 return p_data->efl_ui_popup;
54 }
55
56 Eo *efl_ui_popup = efl_add(EFL_UI_POPUP_CLASS, p_data->win);
57
58 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_EVENT_BG_CLICKED, _bg_clicked, NULL);
59 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_EVENT_TIMEOUT, _timeout_cb, p_data);
60 efl_gfx_size_set(efl_ui_popup, EINA_SIZE2D(160, 160));
61
62 Eo *btn = efl_add(EFL_UI_BUTTON_CLASS, efl_ui_popup);
63 efl_text_set(btn, "Efl.Ui.Popup");
64
65 efl_content_set(efl_ui_popup, btn);
66
67 return efl_ui_popup;
68}
69
70static void
71_create_cb(void *data, const Efl_Event *ev EINA_UNUSED)
72{
73 efl_ui_popup_data *p_data = data;
74 p_data->efl_ui_popup = _create_popup(p_data);
75}
76
77static void
78_bg_cb(void *data EINA_UNUSED, const Efl_Event *ev)
79{
80 static int k = 0;
81 efl_ui_popup_data *p_data = data;
82 if (!p_data->efl_ui_popup) return;
83 if (k == 0)
84 {
85 char buf[PATH_MAX];
86 snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", elm_app_data_dir_get());
87 efl_ui_popup_bg_set(p_data->efl_ui_popup, buf, NULL);
88 efl_text_set(ev->object, "Bg UnSet");
89 }
90 else
91 {
92 efl_ui_popup_bg_set(p_data->efl_ui_popup, NULL, NULL);
93 efl_text_set(ev->object, "Bg Set");
94 }
95 k = !k;
96}
97
98static void
99_repeat_event_cb(void *data EINA_UNUSED, const Efl_Event *ev)
100{
101 efl_ui_popup_data *p_data = data;
102 if (!p_data->efl_ui_popup) return;
103 if (!efl_ui_popup_bg_repeat_events_get(p_data->efl_ui_popup))
104 {
105 efl_ui_popup_bg_repeat_events_set(p_data->efl_ui_popup, EINA_TRUE);
106 efl_text_set(ev->object, "Repeat Event UnSet");
107 }
108 else
109 {
110 efl_ui_popup_bg_repeat_events_set(p_data->efl_ui_popup, EINA_FALSE);
111 efl_text_set(ev->object, "Repeat Event Set");
112 }
113}
114
115static void
116_repeat_test_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
117{
118 printf("Repeat Test Button is Clicked.\n");
119}
120
121static void
122_dummy_cb(void *data EINA_UNUSED, const Efl_Event *ev)
123{
124 efl_ui_popup_data *p_data = data;
125 if (!p_data->efl_ui_popup) return;
126 if (!efl_gfx_visible_get(p_data->button))
127 {
128 efl_gfx_visible_set(p_data->button, EINA_TRUE);
129 efl_text_set(ev->object, "Hide Dummy Button");
130 }
131 else
132 {
133 efl_gfx_visible_set(p_data->button, EINA_FALSE);
134 efl_text_set(ev->object, "Show Dummy Button");
135 }
136}
137
138static void
139_center_align_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
140{
141 efl_ui_popup_data *p_data = data;
142 if (!p_data->efl_ui_popup) return;
143 efl_ui_popup_align_set(p_data->efl_ui_popup, EFL_UI_POPUP_ALIGN_CENTER);
144}
145
146static void
147_left_align_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
148{
149 efl_ui_popup_data *p_data = data;
150 if (!p_data->efl_ui_popup) return;
151 efl_ui_popup_align_set(p_data->efl_ui_popup, EFL_UI_POPUP_ALIGN_LEFT);
152}
153
154static void
155_right_align_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
156{
157 efl_ui_popup_data *p_data = data;
158 if (!p_data->efl_ui_popup) return;
159 efl_ui_popup_align_set(p_data->efl_ui_popup, EFL_UI_POPUP_ALIGN_RIGHT);
160}
161
162static void
163_top_align_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
164{
165 efl_ui_popup_data *p_data = data;
166 if (!p_data->efl_ui_popup) return;
167 efl_ui_popup_align_set(p_data->efl_ui_popup, EFL_UI_POPUP_ALIGN_TOP);
168}
169
170static void
171_bottom_align_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
172{
173 efl_ui_popup_data *p_data = data;
174 if (!p_data->efl_ui_popup) return;
175 efl_ui_popup_align_set(p_data->efl_ui_popup, EFL_UI_POPUP_ALIGN_BOTTOM);
176}
177
178static void
179_position_set_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
180{
181 efl_ui_popup_data *p_data = data;
182 if (!p_data->efl_ui_popup) return;
183 efl_gfx_position_set(p_data->efl_ui_popup, EINA_POSITION2D(0, 0));
184}
185
186static void
187_timeout_set_cb(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
188{
189 efl_ui_popup_data *p_data = data;
190 if (!p_data->efl_ui_popup) return;
191 efl_ui_popup_timeout_set(p_data->efl_ui_popup, 3);
192 printf("timemout is set to 3 seconds\n");
193}
194
195static void
196_win_del(void *data, const Efl_Event *ev EINA_UNUSED)
197{
198 efl_ui_popup_data *p_data = data;
199 efl_del(p_data->panel_win);
200 free(p_data);
201 printf("window is deleted\n");
202}
203
204static void
205_panel_win_del(void *data, const Efl_Event *ev EINA_UNUSED)
206{
207 efl_ui_popup_data *p_data = data;
208 efl_del(p_data->win);
209 free(p_data);
210 printf("window is deleted\n");
211}
212
213void
214test_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
215{
216 efl_ui_popup_data *p_data = (efl_ui_popup_data*)calloc(1, sizeof(efl_ui_popup_data));
217
218 Eo *win = efl_add(EFL_UI_WIN_CLASS, NULL,
219 efl_text_set(efl_added, "Efl.Ui.Popup"),
220 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
221 efl_event_callback_add(win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _win_del, p_data);
222
223 efl_gfx_size_set(win, EINA_SIZE2D(500, 500));
224
225 Eo *panel_win = efl_add(EFL_UI_WIN_CLASS, NULL,
226 efl_text_set(efl_added, "Efl.Ui.Popup Panel"),
227 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
228 efl_event_callback_add(panel_win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _panel_win_del, p_data);
229
230 efl_gfx_size_set(panel_win, EINA_SIZE2D(300, 500));
231
232 Eo *repeat_test_btn = efl_add(EFL_UI_BUTTON_CLASS, win);
233 efl_gfx_position_set(repeat_test_btn, EINA_POSITION2D(0, 0));
234 efl_gfx_size_set(repeat_test_btn, EINA_SIZE2D(100, 100));
235 efl_text_set(repeat_test_btn, "Repeat Event Test");
236 efl_event_callback_add(repeat_test_btn, EFL_UI_EVENT_CLICKED, _repeat_test_cb, NULL);
237 efl_gfx_visible_set(repeat_test_btn, EINA_FALSE);
238
239 p_data->win = win;
240 p_data->panel_win = panel_win;
241 p_data->button = repeat_test_btn;
242 p_data->efl_ui_popup = _create_popup(p_data);
243
244 Eo *create_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
245 efl_text_set(create_btn, "Create Popup");
246 efl_gfx_position_set(create_btn, EINA_POSITION2D(0, 0));
247 efl_gfx_size_set(create_btn, EINA_SIZE2D(150, 50));
248 efl_event_callback_add(create_btn, EFL_UI_EVENT_CLICKED, _create_cb, p_data);
249
250 Eo *delete_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
251 efl_text_set(delete_btn, "Delete Popup");
252 efl_gfx_position_set(delete_btn, EINA_POSITION2D(150, 0));
253 efl_gfx_size_set(delete_btn, EINA_SIZE2D(150, 50));
254 efl_event_callback_add(delete_btn, EFL_UI_EVENT_CLICKED, _delete_cb, p_data);
255
256 Eo *repeat_event_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
257 efl_text_set(repeat_event_btn, "Repeat Event Set");
258 efl_gfx_position_set(repeat_event_btn, EINA_POSITION2D(0, 50));
259 efl_gfx_size_set(repeat_event_btn, EINA_SIZE2D(150, 50));
260 efl_event_callback_add(repeat_event_btn, EFL_UI_EVENT_CLICKED, _repeat_event_cb, p_data);
261
262 Eo *dummy_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
263 efl_text_set(dummy_btn, "Show Dummy Button");
264 efl_gfx_position_set(dummy_btn, EINA_POSITION2D(150, 50));
265 efl_gfx_size_set(dummy_btn, EINA_SIZE2D(150, 50));
266 efl_event_callback_add(dummy_btn, EFL_UI_EVENT_CLICKED, _dummy_cb, p_data);
267
268 Eo *bg_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
269 efl_gfx_position_set(bg_btn, EINA_POSITION2D(0, 100));
270 efl_gfx_size_set(bg_btn, EINA_SIZE2D(150, 50));
271 efl_text_set(bg_btn, "Bg Set");
272 efl_event_callback_add(bg_btn, EFL_UI_EVENT_CLICKED, _bg_cb, p_data);
273
274 Eo *timeout_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
275 efl_text_set(timeout_btn, "Timeout Set");
276 efl_gfx_position_set(timeout_btn, EINA_POSITION2D(150, 100));
277 efl_gfx_size_set(timeout_btn, EINA_SIZE2D(150, 50));
278 efl_event_callback_add(timeout_btn, EFL_UI_EVENT_CLICKED, _timeout_set_cb, p_data);
279
280 Eo *center_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
281 efl_text_set(center_btn, "Center Align");
282 efl_gfx_position_set(center_btn, EINA_POSITION2D(0, 150));
283 efl_gfx_size_set(center_btn, EINA_SIZE2D(150, 50));
284 efl_event_callback_add(center_btn, EFL_UI_EVENT_CLICKED, _center_align_cb, p_data);
285
286 Eo *top_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
287 efl_text_set(top_btn, "Top Align");
288 efl_gfx_position_set(top_btn, EINA_POSITION2D(150, 150));
289 efl_gfx_size_set(top_btn, EINA_SIZE2D(150, 50));
290 efl_event_callback_add(top_btn, EFL_UI_EVENT_CLICKED, _top_align_cb, p_data);
291
292 Eo *left_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
293 efl_text_set(left_btn, "Left Align");
294 efl_gfx_position_set(left_btn, EINA_POSITION2D(0, 200));
295 efl_gfx_size_set(left_btn, EINA_SIZE2D(150, 50));
296 efl_event_callback_add(left_btn, EFL_UI_EVENT_CLICKED, _left_align_cb, p_data);
297
298 Eo *right_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
299 efl_text_set(right_btn, "Right Align");
300 efl_gfx_position_set(right_btn, EINA_POSITION2D(150, 200));
301 efl_gfx_size_set(right_btn, EINA_SIZE2D(150, 50));
302 efl_event_callback_add(right_btn, EFL_UI_EVENT_CLICKED, _right_align_cb, p_data);
303
304 Eo *bottom_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
305 efl_text_set(bottom_btn, "Bottom Align");
306 efl_gfx_position_set(bottom_btn, EINA_POSITION2D(0, 250));
307 efl_gfx_size_set(bottom_btn, EINA_SIZE2D(150, 50));
308 efl_event_callback_add(bottom_btn, EFL_UI_EVENT_CLICKED, _bottom_align_cb, p_data);
309
310 Eo *position_btn = efl_add(EFL_UI_BUTTON_CLASS, panel_win);
311 efl_text_set(position_btn, "Position Set (x:0, y:0)");
312 efl_gfx_position_set(position_btn, EINA_POSITION2D(150, 250));
313 efl_gfx_size_set(position_btn, EINA_SIZE2D(150, 50));
314 efl_event_callback_add(position_btn, EFL_UI_EVENT_CLICKED, _position_set_cb, p_data);
315}
316
317static void
318efl_ui_popup_alert_clicked_cb(void *data EINA_UNUSED, const Efl_Event *ev)
319{
320 Efl_Ui_Popup_Alert_Clicked_Event *event = ev->info;
321
322 if (event->button_type == EFL_UI_POPUP_ALERT_BUTTON_POSITIVE)
323 printf("Positive Button is clicked\n");
324 else if(event->button_type == EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE)
325 printf("Negative Button is clicked\n");
326 else if(event->button_type == EFL_UI_POPUP_ALERT_BUTTON_USER)
327 printf("User Button is clicked\n");
328}
329
330void
331test_ui_popup_alert(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
332{
333 char buf[PATH_MAX];
334
335 Eo *win = efl_add(EFL_UI_WIN_CLASS, NULL,
336 efl_text_set(efl_added, "Efl.Ui.Popup.Alert"),
337 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
338
339 efl_gfx_size_set(win, EINA_SIZE2D(320, 320));
340
341 Eo *efl_ui_popup = efl_add(EFL_UI_POPUP_ALERT_CLASS, win);
342
343 efl_text_set(efl_part(efl_ui_popup, "title"), "title");
344
345 efl_gfx_size_set(efl_ui_popup, EINA_SIZE2D(160, 160));
346
347 Eo *layout = efl_add(EFL_UI_LAYOUT_CLASS, efl_ui_popup);
348 snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
349 efl_file_set(layout, buf, "efl_ui_popup_scroll_content");
350
351 efl_content_set(efl_ui_popup, layout);
352 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_POSITIVE, "Yes");
353 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE, "No");
354 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_USER, "Cancel");
355
356 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_ALERT_EVENT_CLICKED, efl_ui_popup_alert_clicked_cb, NULL);
357}
358
359void
360test_ui_popup_alert_scroll(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
361{
362 char buf[PATH_MAX];
363
364 Eo *win = efl_add(EFL_UI_WIN_CLASS, NULL,
365 efl_text_set(efl_added, "Efl.Ui.Popup.Alert.Scroll"),
366 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
367
368 efl_gfx_size_set(win, EINA_SIZE2D(320, 320));
369
370 Eo *efl_ui_popup= efl_add(EFL_UI_POPUP_ALERT_SCROLL_CLASS, win);
371
372 efl_text_set(efl_part(efl_ui_popup, "title"), "title");
373
374 efl_gfx_size_set(efl_ui_popup, EINA_SIZE2D(160, 160));
375
376 Eo *layout = efl_add(EFL_UI_LAYOUT_CLASS, efl_ui_popup);
377 snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
378 efl_file_set(layout, buf, "efl_ui_popup_scroll_content");
379
380 efl_content_set(efl_ui_popup, layout);
381
382 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_POSITIVE, "Yes");
383 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE, "No");
384 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_USER, "Cancel");
385
386 efl_ui_popup_alert_scroll_expandable_set(efl_ui_popup, EINA_TRUE, EINA_TRUE);
387 efl_gfx_size_hint_max_set(efl_ui_popup, EINA_SIZE2D(300, 180));
388
389 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_ALERT_EVENT_CLICKED, efl_ui_popup_alert_clicked_cb, NULL);
390}
391
392void
393test_ui_popup_alert_text(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
394{
395 Eo *win = efl_add(EFL_UI_WIN_CLASS, NULL,
396 efl_text_set(efl_added, "Efl.Ui.Popup.Alert.Text"),
397 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
398
399 efl_gfx_size_set(win, EINA_SIZE2D(320, 320));
400
401 Eo *efl_ui_popup= efl_add(EFL_UI_POPUP_ALERT_TEXT_CLASS, win);
402
403 efl_text_set(efl_part(efl_ui_popup, "title"), "title");
404
405 efl_gfx_size_set(efl_ui_popup, EINA_SIZE2D(160, 160));
406
407 efl_text_set(efl_ui_popup,
408 "This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup"
409 "This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup"
410 "This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup This is Text Popup");
411
412 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_POSITIVE, "Yes");
413 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE, "No");
414 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_USER, "Cancel");
415
416 efl_ui_popup_alert_text_expandable_set(efl_ui_popup, EINA_TRUE);
417 efl_gfx_size_hint_max_set(efl_ui_popup, EINA_SIZE2D(100, 180));
418
419 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_ALERT_EVENT_CLICKED, efl_ui_popup_alert_clicked_cb, NULL);
420}
421
422static void
423_anchor_set_cb(void *data, const Efl_Event *ev)
424{
425 efl_ui_popup_anchor_set(data, ev->object);
426}
427
428static void
429_anchor_unset_cb(void *data, const Efl_Event *ev EINA_UNUSED)
430{
431 efl_ui_popup_anchor_set(data, NULL);
432}
433
434void
435test_ui_popup_anchor(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
436{
437 efl_ui_popup_data *p_data = (efl_ui_popup_data*)calloc(1, sizeof(efl_ui_popup_data));
438
439 char buf[PATH_MAX];
440
441 Eo *win = efl_add(EFL_UI_WIN_CLASS, NULL,
442 efl_text_set(efl_added, "Efl.Ui.Popup.Anchor"),
443 efl_ui_win_autodel_set(efl_added, EINA_TRUE));
444 efl_event_callback_add(win, EFL_UI_WIN_EVENT_DELETE_REQUEST, _win_del, p_data);
445
446 efl_gfx_size_set(win, EINA_SIZE2D(500, 500));
447
448 Eo *layout = efl_add(EFL_UI_LAYOUT_CLASS, win);
449 snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
450 efl_file_set(layout, buf, "efl_ui_popup_anchor_layout");
451 efl_gfx_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
452 efl_content_set(win, layout);
453
454 Eo *efl_ui_popup = efl_add(EFL_UI_POPUP_ANCHOR_CLASS, win);
455
456 efl_ui_popup_bg_repeat_events_set(efl_ui_popup, EINA_TRUE);
457
458 //Default align priority order is top, left, right, bottom, center.
459 efl_ui_popup_anchor_align_priority_set(efl_ui_popup, EFL_UI_POPUP_ALIGN_TOP,
460 EFL_UI_POPUP_ALIGN_BOTTOM,
461 EFL_UI_POPUP_ALIGN_LEFT,
462 EFL_UI_POPUP_ALIGN_RIGHT,
463 EFL_UI_POPUP_ALIGN_CENTER);
464
465 efl_gfx_position_set(efl_ui_popup, EINA_POSITION2D(80, 80));
466 efl_gfx_size_set(efl_ui_popup, EINA_SIZE2D(160, 120));
467
468 p_data->win = win;
469 p_data->efl_ui_popup = efl_ui_popup;
470
471 Eo *btn = NULL;
472 for (int i = 0; i < 6; i++)
473 {
474 btn = efl_add(EFL_UI_BUTTON_CLASS, win);
475 efl_text_set(btn, "anchor");
476 efl_gfx_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
477 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _anchor_set_cb, efl_ui_popup);
478
479 snprintf(buf, sizeof(buf), "anchor%d", i+1);
480 efl_content_set(efl_part(layout, buf), btn);
481 }
482
483 btn = efl_add(EFL_UI_BUTTON_CLASS, win);
484 efl_text_set(btn, "anchor none");
485 efl_gfx_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
486 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _anchor_unset_cb, efl_ui_popup);
487 efl_content_set(efl_part(layout, "anchor_none"), btn);
488
489 Eo *grid = efl_add(EFL_UI_GRID_CLASS, efl_ui_popup);
490 efl_gfx_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
491
492 btn = efl_add(EFL_UI_BUTTON_CLASS, efl_ui_popup);
493 efl_text_set(btn, "Center Align");
494 efl_gfx_size_hint_min_set(btn, EINA_SIZE2D(70, 35));
495 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _center_align_cb, p_data);
496 efl_pack_grid(grid, btn, 0, 0, 1, 1);
497
498 btn = efl_add(EFL_UI_BUTTON_CLASS, efl_ui_popup);
499 efl_text_set(btn, "Left Align");
500 efl_gfx_size_hint_min_set(btn, EINA_SIZE2D(70, 35));
501 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _left_align_cb, p_data);
502 efl_pack_grid(grid, btn, 1, 0, 1, 1);
503
504 btn = efl_add(EFL_UI_BUTTON_CLASS, efl_ui_popup);
505 efl_text_set(btn, "Right Align");
506 efl_gfx_size_hint_min_set(btn, EINA_SIZE2D(70, 35));
507 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _right_align_cb, p_data);
508 efl_pack_grid(grid, btn, 2, 0, 1, 1);
509
510 btn = efl_add(EFL_UI_BUTTON_CLASS, efl_ui_popup);
511 efl_text_set(btn, "Top Align");
512 efl_gfx_size_hint_min_set(btn, EINA_SIZE2D(70, 35));
513 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _top_align_cb, p_data);
514 efl_pack_grid(grid, btn, 0, 1, 1, 1);
515
516 btn = efl_add(EFL_UI_BUTTON_CLASS, efl_ui_popup);
517 efl_text_set(btn, "Bottom Align");
518 efl_gfx_size_hint_min_set(btn, EINA_SIZE2D(70, 35));
519 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _bottom_align_cb, p_data);
520 efl_pack_grid(grid, btn, 1, 1, 1, 1);
521
522 btn = efl_add(EFL_UI_BUTTON_CLASS, efl_ui_popup);
523 efl_text_set(btn, "Position Set");
524 efl_gfx_size_hint_min_set(btn, EINA_SIZE2D(70, 35));
525 efl_event_callback_add(btn, EFL_UI_EVENT_CLICKED, _position_set_cb, p_data);
526 efl_pack_grid(grid, btn, 2, 1, 1, 1);
527
528 efl_content_set(efl_ui_popup, grid);
529}