summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaehyub Kim <taehyub.kim@samsung.com>2017-08-23 15:50:18 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-11-28 17:15:42 +0900
commitd3a14d08b09a2200b9a85c7ad4d93914a14f6de2 (patch)
tree4c6930d77f269495fb1104188c38239a577fe555
parentb38ad0971cb3bf8d84fcfcce51fdc1cca73c460f (diff)
efl_ui_popup_alert: add Efl.Ui.Popup.Alert class
Summary: Add initial code for Efl.Ui.Popup.Alert class. It supports setting title and buttons. Test Plan: 1. run elementary_test -to efluipopupalert Reviewers: Jaehyun_Cho, jpeg, cedric, thiepha, Blackmole, woohyun Differential Revision: https://phab.enlightenment.org/D5108
-rw-r--r--data/elementary/objects/test.edc32
-rw-r--r--data/elementary/themes/edc/elm/popup.edc163
-rw-r--r--src/Makefile_Elementary.am3
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_popup.c44
-rw-r--r--src/lib/elementary/Elementary.h1
-rw-r--r--src/lib/elementary/efl_ui_popup_alert.c218
-rw-r--r--src/lib/elementary/efl_ui_popup_alert.eo40
-rw-r--r--src/lib/elementary/efl_ui_popup_alert_private.h22
9 files changed, 525 insertions, 0 deletions
diff --git a/data/elementary/objects/test.edc b/data/elementary/objects/test.edc
index 9e95ffd..834bea4 100644
--- a/data/elementary/objects/test.edc
+++ b/data/elementary/objects/test.edc
@@ -901,4 +901,36 @@ collections {
901 901
902 } 902 }
903 } 903 }
904 group { "efl_ui_popup_scroll_content";
905 parts {
906 rect { "base";
907 desc { "default";
908 min: 200 200;
909 color: 255 0 0 255;
910 }
911 }
912 rect { "top";
913 desc { "default";
914 fixed: 0 1;
915 min: 100 20;
916 color: 255 255 0 255;
917 rel1.to: "base";
918 rel2.to: "base";
919 rel2.relative: 1.0 0.0;
920 align: 0.5 0;
921 }
922 }
923 rect { "bottom";
924 desc { "default";
925 fixed: 0 1;
926 min: 100 20;
927 color: 255 255 0 255;
928 rel1.to: "base";
929 rel2.to: "base";
930 rel1.relative: 0.0 1.0;
931 align: 0.5 1.0;
932 }
933 }
934 }
935 }
904} 936}
diff --git a/data/elementary/themes/edc/elm/popup.edc b/data/elementary/themes/edc/elm/popup.edc
index 7fb127b..cb534a8 100644
--- a/data/elementary/themes/edc/elm/popup.edc
+++ b/data/elementary/themes/edc/elm/popup.edc
@@ -141,6 +141,14 @@ group { name: "elm/label/base/popup/default";
141 tag: "whitecolor" "+ color=#fff"; 141 tag: "whitecolor" "+ color=#fff";
142 tag: "tab" "\t"; 142 tag: "tab" "\t";
143 } 143 }
144 style { name: "popup_title_style_ellipsis";
145 base: "font="FNBD" font_size=10 text_class=label align=center color=#fff color_class=popup_title_text style=shadow,bottom shadow_color=#00000080 ellipsis=1.0 wrap=mixed";
146 tag: "br" "\n";
147 tag: "hilight" "+ font="FNBD" text_class=label_light";
148 tag: "b" "+ font="FNBD" text_class=label_light";
149 tag: "whitecolor" "+ color=#fff";
150 tag: "tab" "\t";
151 }
144 } 152 }
145 parts { 153 parts {
146 part { name: "elm.text"; type: TEXTBLOCK; mouse_events: 0; 154 part { name: "elm.text"; type: TEXTBLOCK; mouse_events: 0;
@@ -533,6 +541,91 @@ group { "elm/popup/base/view";
533 } 541 }
534} 542}
535 543
544group { "elm/popup/base/alert";
545 images.image: "rounded_square.png" COMP;
546 parts {
547 image { "bg";
548 desc { "default";
549 min: 100 100;
550 image.border: 15 15 15 15;
551 image.normal: "rounded_square.png";
552 }
553 }
554 spacer { "base";
555 desc { "default";
556 rel.to: "bg";
557 rel1.offset: 10 10;
558 rel2.offset: -11 -11;
559 }
560 }
561 rect { "title_bg";
562 desc { "default";
563 fixed: 0 1;
564 min: 0 0;
565 rel.to: "base";
566 rel2.relative: 1.0 0.0;
567 align: 0.5 0.0;
568 color: 0 0 0 0;
569 }
570 desc { "title_visible";
571 inherit: "default";
572 min: 0 20;
573 }
574 }
575 textblock { "elm.text.title";
576 scale;
577 desc { "default";
578 fixed: 1 1;
579 text {
580 style: "popup_title_style_ellipsis";
581 }
582 rel.to: "title_bg";
583 hid;
584 }
585 desc { "title_visible";
586 inherit: "default";
587 vis;
588 }
589 }
590 swallow { "buttons";
591 desc { "default";
592 fixed: 0 1;
593 rel.to: "base";
594 rel1.relative: 0.0 1.0;
595 align: 0.5 1.0;
596 min: 0 0;
597 }
598 desc { "button_visible";
599 inherit: "default";
600 min: 0 30;
601 }
602 }
603 swallow { "elm.swallow.content";
604 desc { "default";
605 rel1.to_x: "base";
606 rel1.to_y: "title_bg";
607 rel2.to_x: "base";
608 rel2.to_y: "buttons";
609 rel1.relative: 0.0 1.0;
610 rel2.relative: 1.0 0.0;
611 }
612 }
613 }
614 programs {
615 program {
616 signal: "elm,title,show"; source: "elm";
617 action: STATE_SET "title_visible" 0.0;
618 target: "title_bg";
619 target: "elm.text.title";
620 }
621 program {
622 signal: "elm,buttons,show"; source: "elm";
623 action: STATE_SET "button_visible" 0.0;
624 target: "buttons";
625 }
626 }
627}
628
536group { "elm/popup/base/event_bg"; 629group { "elm/popup/base/event_bg";
537 parts { 630 parts {
538 rect { "base"; 631 rect { "base";
@@ -581,3 +674,73 @@ group { "elm/popup/base/event_bg";
581 } 674 }
582 } 675 }
583} 676}
677
678group { "elm/popup/base/button1";
679 parts {
680 swallow { "elm.swallow.button1";
681 }
682 }
683}
684
685group { "elm/popup/base/button2";
686 parts {
687 spacer { "div1";
688 desc { "default";
689 rel1.relative: 0.5 0.5;
690 rel2.relative: 0.5 0.5;
691 min: 5 5;
692 }
693 }
694 swallow { "elm.swallow.button1";
695 desc { "default";
696 rel2.to_x: "div1";
697 rel2.relative: 0.0 1.0;
698 }
699 }
700 swallow { "elm.swallow.button2";
701 desc { "default";
702 rel1.to_x: "div1";
703 rel1.relative: 1.0 0.0;
704 }
705 }
706 }
707}
708
709group { "elm/popup/base/button3";
710 parts {
711 spacer { "div1";
712 desc { "default";
713 rel1.relative: 0.333 0.5;
714 rel2.relative: 0.333 0.5;
715 min: 5 5;
716 }
717 }
718 spacer { "div2";
719 desc { "default";
720 rel1.relative: 0.666 0.5;
721 rel2.relative: 0.666 0.5;
722 min: 5 5;
723 }
724 }
725 swallow { "elm.swallow.button1";
726 desc { "default";
727 rel2.to_x: "div1";
728 rel2.relative: 0.0 1.0;
729 }
730 }
731 swallow { "elm.swallow.button2";
732 desc { "default";
733 rel1.to_x: "div1";
734 rel2.to_x: "div2";
735 rel1.relative: 1.0 0.0;
736 rel2.relative: 0.0 1.0;
737 }
738 }
739 swallow { "elm.swallow.button3";
740 desc { "default";
741 rel1.to_x: "div2";
742 rel1.relative: 1.0 0.0;
743 }
744 }
745 }
746}
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index d825df3..40c1611 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -34,6 +34,7 @@ elm_public_eolian_files = \
34 lib/elementary/efl_ui_text_interactive.eo \ 34 lib/elementary/efl_ui_text_interactive.eo \
35 lib/elementary/efl_ui_text.eo \ 35 lib/elementary/efl_ui_text.eo \
36 lib/elementary/efl_ui_popup.eo \ 36 lib/elementary/efl_ui_popup.eo \
37 lib/elementary/efl_ui_popup_alert.eo \
37 lib/elementary/efl_ui_text_editable.eo \ 38 lib/elementary/efl_ui_text_editable.eo \
38 lib/elementary/efl_ui_text_async.eo \ 39 lib/elementary/efl_ui_text_async.eo \
39 lib/elementary/efl_ui_textpath.eo \ 40 lib/elementary/efl_ui_textpath.eo \
@@ -287,6 +288,7 @@ includesunstable_HEADERS = \
287 lib/elementary/elm_widget_icon.h \ 288 lib/elementary/elm_widget_icon.h \
288 lib/elementary/efl_ui_widget_image.h \ 289 lib/elementary/efl_ui_widget_image.h \
289 lib/elementary/efl_ui_popup_private.h \ 290 lib/elementary/efl_ui_popup_private.h \
291 lib/elementary/efl_ui_popup_alert_private.h \
290 lib/elementary/elm_widget_index.h \ 292 lib/elementary/elm_widget_index.h \
291 lib/elementary/elm_widget_inwin.h \ 293 lib/elementary/elm_widget_inwin.h \
292 lib/elementary/elm_widget_label.h \ 294 lib/elementary/elm_widget_label.h \
@@ -697,6 +699,7 @@ lib_elementary_libelementary_la_SOURCES = \
697 lib/elementary/efl_ui_box_layout.c \ 699 lib/elementary/efl_ui_box_layout.c \
698 lib/elementary/efl_ui_box_private.h \ 700 lib/elementary/efl_ui_box_private.h \
699 lib/elementary/efl_ui_popup.c \ 701 lib/elementary/efl_ui_popup.c \
702 lib/elementary/efl_ui_popup_alert.c \
700 lib/elementary/efl_ui_grid.c \ 703 lib/elementary/efl_ui_grid.c \
701 lib/elementary/efl_ui_grid_static.c \ 704 lib/elementary/efl_ui_grid_static.c \
702 lib/elementary/efl_ui_grid_private.h \ 705 lib/elementary/efl_ui_grid_private.h \
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 63e902e..aebb39a 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -275,6 +275,7 @@ void 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_efl_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_dayselector(void *data, Evas_Object *obj, void *event_info); 279void test_dayselector(void *data, Evas_Object *obj, void *event_info);
279void test_image(void *data, Evas_Object *obj, void *event_info); 280void test_image(void *data, Evas_Object *obj, void *event_info);
280void test_image_scale_type(void *data, Evas_Object *obj, void *event_info); 281void test_image_scale_type(void *data, Evas_Object *obj, void *event_info);
@@ -1044,6 +1045,7 @@ add_tests:
1044 ADD_TEST(NULL, "Popups", "Tooltip 4", test_tooltip4); 1045 ADD_TEST(NULL, "Popups", "Tooltip 4", test_tooltip4);
1045 ADD_TEST(NULL, "Popups", "Popup", test_popup); 1046 ADD_TEST(NULL, "Popups", "Popup", test_popup);
1046 ADD_TEST(NULL, "Popups", "Efl UI Popup", test_efl_ui_popup); 1047 ADD_TEST(NULL, "Popups", "Efl UI Popup", test_efl_ui_popup);
1048 ADD_TEST(NULL, "Popups", "Efl UI Popup Alert", test_efl_ui_popup_alert);
1047 1049
1048 //------------------------------// 1050 //------------------------------//
1049 ADD_TEST(NULL, "Times & Dates", "Calendar", test_calendar); 1051 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 e42b7dc..4074862 100644
--- a/src/bin/elementary/test_popup.c
+++ b/src/bin/elementary/test_popup.c
@@ -1092,3 +1092,47 @@ test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
1092 1092
1093 efl_content_set(efl_ui_popup, btn); 1093 efl_content_set(efl_ui_popup, btn);
1094} 1094}
1095
1096static void
1097efl_ui_popup_alert_clicked_cb(void *data EINA_UNUSED, const Efl_Event *ev)
1098{
1099 Efl_Ui_Popup_Alert_Button type = (Efl_Ui_Popup_Alert_Button)ev->info;
1100 if (type == EFL_UI_POPUP_ALERT_BUTTON_POSITIVE)
1101 printf("Positive Button is clicked\n");
1102 else if(type == EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE)
1103 printf("Negative Button is clicked\n");
1104 else if(type == EFL_UI_POPUP_ALERT_BUTTON_USER)
1105 printf("User Button is clicked\n");
1106}
1107
1108void
1109test_efl_ui_popup_alert(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1110{
1111 Evas_Object *win;
1112 char buf[PATH_MAX];
1113
1114 win = elm_win_util_standard_add("Efl UI Popup Alert", "Efl UI Popup Alert");
1115 elm_win_autodel_set(win, EINA_TRUE);
1116
1117 evas_object_resize(win, 320, 320);
1118 evas_object_show(win);
1119
1120 Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_ALERT_CLASS, win);
1121
1122 efl_ui_popup_alert_title_set(efl_ui_popup, "title");
1123
1124 evas_object_resize(efl_ui_popup, 160, 160);
1125 evas_object_show(efl_ui_popup);
1126
1127 Evas_Object *layout = elm_layout_add(efl_ui_popup);
1128 snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
1129 elm_layout_file_set(layout, buf, "efl_ui_popup_scroll_content");
1130 evas_object_show(layout);
1131
1132 efl_content_set(efl_ui_popup, layout);
1133 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_POSITIVE, "Yes");
1134 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE, "No");
1135 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_USER, "Cancel");
1136
1137 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_ALERT_EVENT_CLICKED, efl_ui_popup_alert_clicked_cb, NULL);
1138}
diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h
index e2e221c..9512118 100644
--- a/src/lib/elementary/Elementary.h
+++ b/src/lib/elementary/Elementary.h
@@ -302,6 +302,7 @@ EAPI extern Elm_Version *elm_version;
302# include <efl_ui_text_interactive.eo.h> 302# include <efl_ui_text_interactive.eo.h>
303# include <efl_ui_text.eo.h> 303# include <efl_ui_text.eo.h>
304# include <efl_ui_popup.eo.h> 304# include <efl_ui_popup.eo.h>
305# include <efl_ui_popup_alert.eo.h>
305# include <efl_ui_text_editable.eo.h> 306# include <efl_ui_text_editable.eo.h>
306# include <efl_ui_text_async.eo.h> 307# include <efl_ui_text_async.eo.h>
307# include <efl_ui_clock.eo.h> 308# include <efl_ui_clock.eo.h>
diff --git a/src/lib/elementary/efl_ui_popup_alert.c b/src/lib/elementary/efl_ui_popup_alert.c
new file mode 100644
index 0000000..6c7a9a5
--- /dev/null
+++ b/src/lib/elementary/efl_ui_popup_alert.c
@@ -0,0 +1,218 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4
5#include <Elementary.h>
6
7#include "elm_priv.h"
8#include "efl_ui_popup_alert_private.h"
9
10#define MY_CLASS EFL_UI_POPUP_ALERT_CLASS
11#define MY_CLASS_NAME "Efl.Ui.Popup.Alert"
12
13EOLIAN static void
14_efl_ui_popup_alert_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Popup_Alert_Data *pd EINA_UNUSED)
15{
16 elm_layout_sizing_eval(efl_super(obj, MY_CLASS));
17
18 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
19 Evas_Coord minw = -1, minh = -1;
20
21 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
22 edje_object_size_min_restricted_calc
23 (wd->resize_obj, &minw, &minh, minw, minh);
24 evas_object_size_hint_min_set(obj, minw, minh);
25
26 Evas_Coord w, h;
27 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
28}
29
30EOLIAN static void
31_efl_ui_popup_alert_title_set(Eo *obj, Efl_Ui_Popup_Alert_Data *pd, const char *text)
32{
33 if (pd->title_text)
34 {
35 eina_stringshare_del(pd->title_text);
36 pd->title_text = NULL;
37 }
38
39 pd->title_text = eina_stringshare_add(text);
40 elm_object_part_text_set(obj, "elm.text.title", text);
41 elm_layout_signal_emit(obj, "elm,title,show", "elm");
42
43 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
44 edje_object_message_signal_process(wd->resize_obj);
45 elm_layout_sizing_eval(obj);
46}
47
48EOLIAN static const char *
49_efl_ui_popup_alert_title_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Alert_Data *pd)
50{
51 if (pd->title_text)
52 return pd->title_text;
53 return NULL;
54}
55
56static void
57_positive_button_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
58 void *event_info EINA_UNUSED)
59{
60 Eo *popup_obj = data;
61 efl_event_callback_call(popup_obj, EFL_UI_POPUP_ALERT_EVENT_CLICKED, (void *)(uintptr_t)EFL_UI_POPUP_ALERT_BUTTON_POSITIVE);
62}
63
64static void
65_negative_button_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
66 void *event_info EINA_UNUSED)
67{
68 Eo *popup_obj = data;
69 efl_event_callback_call(popup_obj, EFL_UI_POPUP_ALERT_EVENT_CLICKED, (void *)(uintptr_t)EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE);
70}
71
72static void
73_user_button_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
74 void *event_info EINA_UNUSED)
75{
76 Eo *popup_obj = data;
77 efl_event_callback_call(popup_obj, EFL_UI_POPUP_ALERT_EVENT_CLICKED, (void *)(uintptr_t)EFL_UI_POPUP_ALERT_BUTTON_USER);
78}
79
80EOLIAN static void
81_efl_ui_popup_alert_button_set(Eo *obj, Efl_Ui_Popup_Alert_Data *pd, Efl_Ui_Popup_Alert_Button type, const char *text)
82{
83 if (pd->button[type])
84 {
85 evas_object_del(pd->button[type]);
86 pd->button[type] = NULL;
87 }
88 pd->button[type] = elm_button_add(obj);
89 elm_object_text_set(pd->button[type], text);
90
91 switch (type)
92 {
93 case EFL_UI_POPUP_ALERT_BUTTON_POSITIVE:
94 evas_object_smart_callback_add(pd->button[type], "clicked",
95 _positive_button_clicked_cb,
96 obj);
97 break;
98 case EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE:
99 evas_object_smart_callback_add(pd->button[type], "clicked",
100 _negative_button_clicked_cb,
101 obj);
102 break;
103 case EFL_UI_POPUP_ALERT_BUTTON_USER:
104 evas_object_smart_callback_add(pd->button[type], "clicked",
105 _user_button_clicked_cb,
106 obj);
107 break;
108 default:
109 break;
110 }
111
112 Evas_Object * cur_content = efl_content_unset(efl_part(obj, "buttons"));
113 if (cur_content)
114 {
115 efl_content_unset(efl_part(cur_content, "elm.swallow.button1"));
116 efl_content_unset(efl_part(cur_content, "elm.swallow.button2"));
117 efl_content_unset(efl_part(cur_content, "elm.swallow.button3"));
118 evas_object_del(cur_content);
119 }
120
121 if (pd->button[EFL_UI_POPUP_ALERT_BUTTON_POSITIVE]
122 && pd->button[EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE]
123 && pd->button[EFL_UI_POPUP_ALERT_BUTTON_USER])
124 {
125 pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_3] = elm_layout_add(obj);
126 elm_layout_theme_set(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_3], "popup", "base", "button3");
127 efl_content_set(efl_part(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_3], "elm.swallow.button1"), pd->button[EFL_UI_POPUP_ALERT_BUTTON_USER]);
128 efl_content_set(efl_part(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_3], "elm.swallow.button2"), pd->button[EFL_UI_POPUP_ALERT_BUTTON_POSITIVE]);
129 efl_content_set(efl_part(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_3], "elm.swallow.button3"), pd->button[EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE]);
130 efl_content_set(efl_part(obj, "buttons"), pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_3]);
131 }
132 else if (pd->button[EFL_UI_POPUP_ALERT_BUTTON_POSITIVE]
133 && pd->button[EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE])
134 {
135 pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2] = elm_layout_add(obj);
136 elm_layout_theme_set(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2], "popup", "base", "button2");
137 efl_content_set(efl_part(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2], "elm.swallow.button1"), pd->button[EFL_UI_POPUP_ALERT_BUTTON_POSITIVE]);
138 efl_content_set(efl_part(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2], "elm.swallow.button2"), pd->button[EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE]);
139 efl_content_set(efl_part(obj, "buttons"), pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2]);
140 }
141 else if (pd->button[EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE]
142 && pd->button[EFL_UI_POPUP_ALERT_BUTTON_USER])
143 {
144 pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2] = elm_layout_add(obj);
145 elm_layout_theme_set(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2], "popup", "base", "button2");
146 efl_content_set(efl_part(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2], "elm.swallow.button1"), pd->button[EFL_UI_POPUP_ALERT_BUTTON_USER]);
147 efl_content_set(efl_part(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2], "elm.swallow.button2"), pd->button[EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE]);
148 efl_content_set(efl_part(obj, "buttons"), pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2]);
149 }
150 else if (pd->button[EFL_UI_POPUP_ALERT_BUTTON_POSITIVE]
151 && pd->button[EFL_UI_POPUP_ALERT_BUTTON_USER])
152 {
153 pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2] = elm_layout_add(obj);
154 elm_layout_theme_set(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2], "popup", "base", "button2");
155 efl_content_set(efl_part(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2], "elm.swallow.button1"), pd->button[EFL_UI_POPUP_ALERT_BUTTON_USER]);
156 efl_content_set(efl_part(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2], "elm.swallow.button2"), pd->button[EFL_UI_POPUP_ALERT_BUTTON_POSITIVE]);
157 efl_content_set(efl_part(obj, "buttons"), pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2]);
158 }
159 else if (pd->button[EFL_UI_POPUP_ALERT_BUTTON_POSITIVE])
160 {
161 pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1] = elm_layout_add(obj);
162 elm_layout_theme_set(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1], "popup", "base", "button1");
163 efl_content_set(efl_part(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1], "elm.swallow.button1"), pd->button[EFL_UI_POPUP_ALERT_BUTTON_POSITIVE]);
164 efl_content_set(efl_part(obj, "buttons"), pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1]);
165 }
166 else if (pd->button[EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE])
167 {
168 pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1] = elm_layout_add(obj);
169 elm_layout_theme_set(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1], "popup", "base", "button1");
170 efl_content_set(efl_part(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1], "elm.swallow.button1"), pd->button[EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE]);
171 efl_content_set(efl_part(obj, "buttons"), pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1]);
172 }
173 else if (pd->button[EFL_UI_POPUP_ALERT_BUTTON_USER])
174 {
175 pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1] = elm_layout_add(obj);
176 elm_layout_theme_set(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1], "popup", "base", "button1");
177 efl_content_set(efl_part(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1], "elm.swallow.button1"), pd->button[EFL_UI_POPUP_ALERT_BUTTON_USER]);
178 efl_content_set(efl_part(obj, "buttons"), pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1]);
179 }
180
181 elm_layout_signal_emit(obj, "elm,buttons,show", "elm");
182 elm_layout_sizing_eval(obj);
183}
184
185EOLIAN static void
186_efl_ui_popup_alert_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Alert_Data *pd EINA_UNUSED)
187{
188 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
189
190 efl_canvas_group_add(efl_super(obj, MY_CLASS));
191 elm_widget_sub_object_parent_add(obj);
192
193 elm_layout_theme_set(efl_super(obj, MY_CLASS), "popup", "base", "alert");
194}
195
196EOLIAN static void
197_efl_ui_popup_alert_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Popup_Alert_Data *pd)
198{
199 if (pd->title_text)
200 {
201 eina_stringshare_del(pd->title_text);
202 pd->title_text = NULL;
203 }
204
205 efl_canvas_group_del(efl_super(obj, MY_CLASS));
206}
207
208EOLIAN static void
209_efl_ui_popup_alert_class_constructor(Efl_Class *klass)
210{
211 evas_smart_legacy_type_register(MY_CLASS_NAME, klass);
212}
213
214#define EFL_UI_POPUP_ALERT_EXTRA_OPS \
215 EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_popup_alert), \
216 ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_popup_alert)
217
218#include "efl_ui_popup_alert.eo.c"
diff --git a/src/lib/elementary/efl_ui_popup_alert.eo b/src/lib/elementary/efl_ui_popup_alert.eo
new file mode 100644
index 0000000..8ac3799
--- /dev/null
+++ b/src/lib/elementary/efl_ui_popup_alert.eo
@@ -0,0 +1,40 @@
1enum Efl.Ui.Popup.Alert.Button {
2 [[Defines the type of the alert button.]]
3 positive = 0, [[Button having positive meaning. e.g. "Yes"]]
4 negative, [[Button having negative meaning. e.g. "No"]]
5 user [[Button having user-defined meaning. e.g. "Cancel"]]
6}
7
8class Efl.Ui.Popup.Alert(Efl.Ui.Popup)
9{
10 methods {
11 @property title {
12 set {
13 [[Set the title of popup.]]
14 }
15 get {
16 [[Get the title of popup.]]
17 }
18 values {
19 text: string;
20 }
21 }
22 @property button {
23 set {
24 [[Set popup buttons.]]
25 }
26 keys {
27 type: Efl.Ui.Popup.Alert.Button;
28 }
29 values {
30 text: string;
31 }
32 }
33 }
34 implements {
35 class.constructor;
36 }
37 events {
38 clicked;
39 }
40}
diff --git a/src/lib/elementary/efl_ui_popup_alert_private.h b/src/lib/elementary/efl_ui_popup_alert_private.h
new file mode 100644
index 0000000..15e7691
--- /dev/null
+++ b/src/lib/elementary/efl_ui_popup_alert_private.h
@@ -0,0 +1,22 @@
1#ifndef EFL_UI_POPUP_ALERT_H
2#define EFL_UI_POPUP_ALERT_H
3
4#include "Elementary.h"
5
6typedef enum
7{
8 EFL_UI_POPUP_ALERT_BUTTON_1 = 0,
9 EFL_UI_POPUP_ALERT_BUTTON_2,
10 EFL_UI_POPUP_ALERT_BUTTON_3,
11 EFL_UI_POPUP_ALERT_BUTTON_COUNT
12} Efl_Ui_Popup_Alert_Button_Type;
13
14typedef struct _Efl_Ui_Popup_Alert_Data Efl_Ui_Popup_Alert_Data;
15struct _Efl_Ui_Popup_Alert_Data
16{
17 const char *title_text;
18 Evas_Object *button[EFL_UI_POPUP_ALERT_BUTTON_COUNT];
19 Evas_Object *button_layout[EFL_UI_POPUP_ALERT_BUTTON_COUNT];
20};
21
22#endif