forked from enlightenment/efl
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
This commit is contained in:
parent
b38ad0971c
commit
d3a14d08b0
|
@ -901,4 +901,36 @@ collections {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
group { "efl_ui_popup_scroll_content";
|
||||||
|
parts {
|
||||||
|
rect { "base";
|
||||||
|
desc { "default";
|
||||||
|
min: 200 200;
|
||||||
|
color: 255 0 0 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rect { "top";
|
||||||
|
desc { "default";
|
||||||
|
fixed: 0 1;
|
||||||
|
min: 100 20;
|
||||||
|
color: 255 255 0 255;
|
||||||
|
rel1.to: "base";
|
||||||
|
rel2.to: "base";
|
||||||
|
rel2.relative: 1.0 0.0;
|
||||||
|
align: 0.5 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rect { "bottom";
|
||||||
|
desc { "default";
|
||||||
|
fixed: 0 1;
|
||||||
|
min: 100 20;
|
||||||
|
color: 255 255 0 255;
|
||||||
|
rel1.to: "base";
|
||||||
|
rel2.to: "base";
|
||||||
|
rel1.relative: 0.0 1.0;
|
||||||
|
align: 0.5 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,14 @@ group { name: "elm/label/base/popup/default";
|
||||||
tag: "whitecolor" "+ color=#fff";
|
tag: "whitecolor" "+ color=#fff";
|
||||||
tag: "tab" "\t";
|
tag: "tab" "\t";
|
||||||
}
|
}
|
||||||
|
style { name: "popup_title_style_ellipsis";
|
||||||
|
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";
|
||||||
|
tag: "br" "\n";
|
||||||
|
tag: "hilight" "+ font="FNBD" text_class=label_light";
|
||||||
|
tag: "b" "+ font="FNBD" text_class=label_light";
|
||||||
|
tag: "whitecolor" "+ color=#fff";
|
||||||
|
tag: "tab" "\t";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
parts {
|
parts {
|
||||||
part { name: "elm.text"; type: TEXTBLOCK; mouse_events: 0;
|
part { name: "elm.text"; type: TEXTBLOCK; mouse_events: 0;
|
||||||
|
@ -533,6 +541,91 @@ group { "elm/popup/base/view";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
group { "elm/popup/base/alert";
|
||||||
|
images.image: "rounded_square.png" COMP;
|
||||||
|
parts {
|
||||||
|
image { "bg";
|
||||||
|
desc { "default";
|
||||||
|
min: 100 100;
|
||||||
|
image.border: 15 15 15 15;
|
||||||
|
image.normal: "rounded_square.png";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spacer { "base";
|
||||||
|
desc { "default";
|
||||||
|
rel.to: "bg";
|
||||||
|
rel1.offset: 10 10;
|
||||||
|
rel2.offset: -11 -11;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rect { "title_bg";
|
||||||
|
desc { "default";
|
||||||
|
fixed: 0 1;
|
||||||
|
min: 0 0;
|
||||||
|
rel.to: "base";
|
||||||
|
rel2.relative: 1.0 0.0;
|
||||||
|
align: 0.5 0.0;
|
||||||
|
color: 0 0 0 0;
|
||||||
|
}
|
||||||
|
desc { "title_visible";
|
||||||
|
inherit: "default";
|
||||||
|
min: 0 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
textblock { "elm.text.title";
|
||||||
|
scale;
|
||||||
|
desc { "default";
|
||||||
|
fixed: 1 1;
|
||||||
|
text {
|
||||||
|
style: "popup_title_style_ellipsis";
|
||||||
|
}
|
||||||
|
rel.to: "title_bg";
|
||||||
|
hid;
|
||||||
|
}
|
||||||
|
desc { "title_visible";
|
||||||
|
inherit: "default";
|
||||||
|
vis;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
swallow { "buttons";
|
||||||
|
desc { "default";
|
||||||
|
fixed: 0 1;
|
||||||
|
rel.to: "base";
|
||||||
|
rel1.relative: 0.0 1.0;
|
||||||
|
align: 0.5 1.0;
|
||||||
|
min: 0 0;
|
||||||
|
}
|
||||||
|
desc { "button_visible";
|
||||||
|
inherit: "default";
|
||||||
|
min: 0 30;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
swallow { "elm.swallow.content";
|
||||||
|
desc { "default";
|
||||||
|
rel1.to_x: "base";
|
||||||
|
rel1.to_y: "title_bg";
|
||||||
|
rel2.to_x: "base";
|
||||||
|
rel2.to_y: "buttons";
|
||||||
|
rel1.relative: 0.0 1.0;
|
||||||
|
rel2.relative: 1.0 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
programs {
|
||||||
|
program {
|
||||||
|
signal: "elm,title,show"; source: "elm";
|
||||||
|
action: STATE_SET "title_visible" 0.0;
|
||||||
|
target: "title_bg";
|
||||||
|
target: "elm.text.title";
|
||||||
|
}
|
||||||
|
program {
|
||||||
|
signal: "elm,buttons,show"; source: "elm";
|
||||||
|
action: STATE_SET "button_visible" 0.0;
|
||||||
|
target: "buttons";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
group { "elm/popup/base/event_bg";
|
group { "elm/popup/base/event_bg";
|
||||||
parts {
|
parts {
|
||||||
rect { "base";
|
rect { "base";
|
||||||
|
@ -581,3 +674,73 @@ group { "elm/popup/base/event_bg";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
group { "elm/popup/base/button1";
|
||||||
|
parts {
|
||||||
|
swallow { "elm.swallow.button1";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
group { "elm/popup/base/button2";
|
||||||
|
parts {
|
||||||
|
spacer { "div1";
|
||||||
|
desc { "default";
|
||||||
|
rel1.relative: 0.5 0.5;
|
||||||
|
rel2.relative: 0.5 0.5;
|
||||||
|
min: 5 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
swallow { "elm.swallow.button1";
|
||||||
|
desc { "default";
|
||||||
|
rel2.to_x: "div1";
|
||||||
|
rel2.relative: 0.0 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
swallow { "elm.swallow.button2";
|
||||||
|
desc { "default";
|
||||||
|
rel1.to_x: "div1";
|
||||||
|
rel1.relative: 1.0 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
group { "elm/popup/base/button3";
|
||||||
|
parts {
|
||||||
|
spacer { "div1";
|
||||||
|
desc { "default";
|
||||||
|
rel1.relative: 0.333 0.5;
|
||||||
|
rel2.relative: 0.333 0.5;
|
||||||
|
min: 5 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spacer { "div2";
|
||||||
|
desc { "default";
|
||||||
|
rel1.relative: 0.666 0.5;
|
||||||
|
rel2.relative: 0.666 0.5;
|
||||||
|
min: 5 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
swallow { "elm.swallow.button1";
|
||||||
|
desc { "default";
|
||||||
|
rel2.to_x: "div1";
|
||||||
|
rel2.relative: 0.0 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
swallow { "elm.swallow.button2";
|
||||||
|
desc { "default";
|
||||||
|
rel1.to_x: "div1";
|
||||||
|
rel2.to_x: "div2";
|
||||||
|
rel1.relative: 1.0 0.0;
|
||||||
|
rel2.relative: 0.0 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
swallow { "elm.swallow.button3";
|
||||||
|
desc { "default";
|
||||||
|
rel1.to_x: "div2";
|
||||||
|
rel1.relative: 1.0 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ elm_public_eolian_files = \
|
||||||
lib/elementary/efl_ui_text_interactive.eo \
|
lib/elementary/efl_ui_text_interactive.eo \
|
||||||
lib/elementary/efl_ui_text.eo \
|
lib/elementary/efl_ui_text.eo \
|
||||||
lib/elementary/efl_ui_popup.eo \
|
lib/elementary/efl_ui_popup.eo \
|
||||||
|
lib/elementary/efl_ui_popup_alert.eo \
|
||||||
lib/elementary/efl_ui_text_editable.eo \
|
lib/elementary/efl_ui_text_editable.eo \
|
||||||
lib/elementary/efl_ui_text_async.eo \
|
lib/elementary/efl_ui_text_async.eo \
|
||||||
lib/elementary/efl_ui_textpath.eo \
|
lib/elementary/efl_ui_textpath.eo \
|
||||||
|
@ -287,6 +288,7 @@ includesunstable_HEADERS = \
|
||||||
lib/elementary/elm_widget_icon.h \
|
lib/elementary/elm_widget_icon.h \
|
||||||
lib/elementary/efl_ui_widget_image.h \
|
lib/elementary/efl_ui_widget_image.h \
|
||||||
lib/elementary/efl_ui_popup_private.h \
|
lib/elementary/efl_ui_popup_private.h \
|
||||||
|
lib/elementary/efl_ui_popup_alert_private.h \
|
||||||
lib/elementary/elm_widget_index.h \
|
lib/elementary/elm_widget_index.h \
|
||||||
lib/elementary/elm_widget_inwin.h \
|
lib/elementary/elm_widget_inwin.h \
|
||||||
lib/elementary/elm_widget_label.h \
|
lib/elementary/elm_widget_label.h \
|
||||||
|
@ -697,6 +699,7 @@ lib_elementary_libelementary_la_SOURCES = \
|
||||||
lib/elementary/efl_ui_box_layout.c \
|
lib/elementary/efl_ui_box_layout.c \
|
||||||
lib/elementary/efl_ui_box_private.h \
|
lib/elementary/efl_ui_box_private.h \
|
||||||
lib/elementary/efl_ui_popup.c \
|
lib/elementary/efl_ui_popup.c \
|
||||||
|
lib/elementary/efl_ui_popup_alert.c \
|
||||||
lib/elementary/efl_ui_grid.c \
|
lib/elementary/efl_ui_grid.c \
|
||||||
lib/elementary/efl_ui_grid_static.c \
|
lib/elementary/efl_ui_grid_static.c \
|
||||||
lib/elementary/efl_ui_grid_private.h \
|
lib/elementary/efl_ui_grid_private.h \
|
||||||
|
|
|
@ -275,6 +275,7 @@ void test_datetime(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_ui_clock(void *data, Evas_Object *obj, void *event_info);
|
void test_ui_clock(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_popup(void *data, Evas_Object *obj, void *event_info);
|
void test_popup(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_efl_ui_popup(void *data, Evas_Object *obj, void *event_info);
|
void test_efl_ui_popup(void *data, Evas_Object *obj, void *event_info);
|
||||||
|
void test_efl_ui_popup_alert(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_dayselector(void *data, Evas_Object *obj, void *event_info);
|
void test_dayselector(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_image(void *data, Evas_Object *obj, void *event_info);
|
void test_image(void *data, Evas_Object *obj, void *event_info);
|
||||||
void test_image_scale_type(void *data, Evas_Object *obj, void *event_info);
|
void test_image_scale_type(void *data, Evas_Object *obj, void *event_info);
|
||||||
|
@ -1044,6 +1045,7 @@ add_tests:
|
||||||
ADD_TEST(NULL, "Popups", "Tooltip 4", test_tooltip4);
|
ADD_TEST(NULL, "Popups", "Tooltip 4", test_tooltip4);
|
||||||
ADD_TEST(NULL, "Popups", "Popup", test_popup);
|
ADD_TEST(NULL, "Popups", "Popup", test_popup);
|
||||||
ADD_TEST(NULL, "Popups", "Efl UI Popup", test_efl_ui_popup);
|
ADD_TEST(NULL, "Popups", "Efl UI Popup", test_efl_ui_popup);
|
||||||
|
ADD_TEST(NULL, "Popups", "Efl UI Popup Alert", test_efl_ui_popup_alert);
|
||||||
|
|
||||||
//------------------------------//
|
//------------------------------//
|
||||||
ADD_TEST(NULL, "Times & Dates", "Calendar", test_calendar);
|
ADD_TEST(NULL, "Times & Dates", "Calendar", test_calendar);
|
||||||
|
|
|
@ -1092,3 +1092,47 @@ test_efl_ui_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev
|
||||||
|
|
||||||
efl_content_set(efl_ui_popup, btn);
|
efl_content_set(efl_ui_popup, btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
efl_ui_popup_alert_clicked_cb(void *data EINA_UNUSED, const Efl_Event *ev)
|
||||||
|
{
|
||||||
|
Efl_Ui_Popup_Alert_Button type = (Efl_Ui_Popup_Alert_Button)ev->info;
|
||||||
|
if (type == EFL_UI_POPUP_ALERT_BUTTON_POSITIVE)
|
||||||
|
printf("Positive Button is clicked\n");
|
||||||
|
else if(type == EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE)
|
||||||
|
printf("Negative Button is clicked\n");
|
||||||
|
else if(type == EFL_UI_POPUP_ALERT_BUTTON_USER)
|
||||||
|
printf("User Button is clicked\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
test_efl_ui_popup_alert(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Evas_Object *win;
|
||||||
|
char buf[PATH_MAX];
|
||||||
|
|
||||||
|
win = elm_win_util_standard_add("Efl UI Popup Alert", "Efl UI Popup Alert");
|
||||||
|
elm_win_autodel_set(win, EINA_TRUE);
|
||||||
|
|
||||||
|
evas_object_resize(win, 320, 320);
|
||||||
|
evas_object_show(win);
|
||||||
|
|
||||||
|
Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_ALERT_CLASS, win);
|
||||||
|
|
||||||
|
efl_ui_popup_alert_title_set(efl_ui_popup, "title");
|
||||||
|
|
||||||
|
evas_object_resize(efl_ui_popup, 160, 160);
|
||||||
|
evas_object_show(efl_ui_popup);
|
||||||
|
|
||||||
|
Evas_Object *layout = elm_layout_add(efl_ui_popup);
|
||||||
|
snprintf(buf, sizeof(buf), "%s/objects/test.edj", elm_app_data_dir_get());
|
||||||
|
elm_layout_file_set(layout, buf, "efl_ui_popup_scroll_content");
|
||||||
|
evas_object_show(layout);
|
||||||
|
|
||||||
|
efl_content_set(efl_ui_popup, layout);
|
||||||
|
efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_POSITIVE, "Yes");
|
||||||
|
efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE, "No");
|
||||||
|
efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_USER, "Cancel");
|
||||||
|
|
||||||
|
efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_ALERT_EVENT_CLICKED, efl_ui_popup_alert_clicked_cb, NULL);
|
||||||
|
}
|
||||||
|
|
|
@ -302,6 +302,7 @@ EAPI extern Elm_Version *elm_version;
|
||||||
# include <efl_ui_text_interactive.eo.h>
|
# include <efl_ui_text_interactive.eo.h>
|
||||||
# include <efl_ui_text.eo.h>
|
# include <efl_ui_text.eo.h>
|
||||||
# include <efl_ui_popup.eo.h>
|
# include <efl_ui_popup.eo.h>
|
||||||
|
# include <efl_ui_popup_alert.eo.h>
|
||||||
# include <efl_ui_text_editable.eo.h>
|
# include <efl_ui_text_editable.eo.h>
|
||||||
# include <efl_ui_text_async.eo.h>
|
# include <efl_ui_text_async.eo.h>
|
||||||
# include <efl_ui_clock.eo.h>
|
# include <efl_ui_clock.eo.h>
|
||||||
|
|
|
@ -0,0 +1,218 @@
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
# include "elementary_config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <Elementary.h>
|
||||||
|
|
||||||
|
#include "elm_priv.h"
|
||||||
|
#include "efl_ui_popup_alert_private.h"
|
||||||
|
|
||||||
|
#define MY_CLASS EFL_UI_POPUP_ALERT_CLASS
|
||||||
|
#define MY_CLASS_NAME "Efl.Ui.Popup.Alert"
|
||||||
|
|
||||||
|
EOLIAN static void
|
||||||
|
_efl_ui_popup_alert_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Popup_Alert_Data *pd EINA_UNUSED)
|
||||||
|
{
|
||||||
|
elm_layout_sizing_eval(efl_super(obj, MY_CLASS));
|
||||||
|
|
||||||
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
||||||
|
Evas_Coord minw = -1, minh = -1;
|
||||||
|
|
||||||
|
elm_coords_finger_size_adjust(1, &minw, 1, &minh);
|
||||||
|
edje_object_size_min_restricted_calc
|
||||||
|
(wd->resize_obj, &minw, &minh, minw, minh);
|
||||||
|
evas_object_size_hint_min_set(obj, minw, minh);
|
||||||
|
|
||||||
|
Evas_Coord w, h;
|
||||||
|
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
|
||||||
|
}
|
||||||
|
|
||||||
|
EOLIAN static void
|
||||||
|
_efl_ui_popup_alert_title_set(Eo *obj, Efl_Ui_Popup_Alert_Data *pd, const char *text)
|
||||||
|
{
|
||||||
|
if (pd->title_text)
|
||||||
|
{
|
||||||
|
eina_stringshare_del(pd->title_text);
|
||||||
|
pd->title_text = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pd->title_text = eina_stringshare_add(text);
|
||||||
|
elm_object_part_text_set(obj, "elm.text.title", text);
|
||||||
|
elm_layout_signal_emit(obj, "elm,title,show", "elm");
|
||||||
|
|
||||||
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
||||||
|
edje_object_message_signal_process(wd->resize_obj);
|
||||||
|
elm_layout_sizing_eval(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
EOLIAN static const char *
|
||||||
|
_efl_ui_popup_alert_title_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Alert_Data *pd)
|
||||||
|
{
|
||||||
|
if (pd->title_text)
|
||||||
|
return pd->title_text;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_positive_button_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||||
|
void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Eo *popup_obj = data;
|
||||||
|
efl_event_callback_call(popup_obj, EFL_UI_POPUP_ALERT_EVENT_CLICKED, (void *)(uintptr_t)EFL_UI_POPUP_ALERT_BUTTON_POSITIVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_negative_button_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||||
|
void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Eo *popup_obj = data;
|
||||||
|
efl_event_callback_call(popup_obj, EFL_UI_POPUP_ALERT_EVENT_CLICKED, (void *)(uintptr_t)EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_user_button_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||||
|
void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Eo *popup_obj = data;
|
||||||
|
efl_event_callback_call(popup_obj, EFL_UI_POPUP_ALERT_EVENT_CLICKED, (void *)(uintptr_t)EFL_UI_POPUP_ALERT_BUTTON_USER);
|
||||||
|
}
|
||||||
|
|
||||||
|
EOLIAN static void
|
||||||
|
_efl_ui_popup_alert_button_set(Eo *obj, Efl_Ui_Popup_Alert_Data *pd, Efl_Ui_Popup_Alert_Button type, const char *text)
|
||||||
|
{
|
||||||
|
if (pd->button[type])
|
||||||
|
{
|
||||||
|
evas_object_del(pd->button[type]);
|
||||||
|
pd->button[type] = NULL;
|
||||||
|
}
|
||||||
|
pd->button[type] = elm_button_add(obj);
|
||||||
|
elm_object_text_set(pd->button[type], text);
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case EFL_UI_POPUP_ALERT_BUTTON_POSITIVE:
|
||||||
|
evas_object_smart_callback_add(pd->button[type], "clicked",
|
||||||
|
_positive_button_clicked_cb,
|
||||||
|
obj);
|
||||||
|
break;
|
||||||
|
case EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE:
|
||||||
|
evas_object_smart_callback_add(pd->button[type], "clicked",
|
||||||
|
_negative_button_clicked_cb,
|
||||||
|
obj);
|
||||||
|
break;
|
||||||
|
case EFL_UI_POPUP_ALERT_BUTTON_USER:
|
||||||
|
evas_object_smart_callback_add(pd->button[type], "clicked",
|
||||||
|
_user_button_clicked_cb,
|
||||||
|
obj);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Evas_Object * cur_content = efl_content_unset(efl_part(obj, "buttons"));
|
||||||
|
if (cur_content)
|
||||||
|
{
|
||||||
|
efl_content_unset(efl_part(cur_content, "elm.swallow.button1"));
|
||||||
|
efl_content_unset(efl_part(cur_content, "elm.swallow.button2"));
|
||||||
|
efl_content_unset(efl_part(cur_content, "elm.swallow.button3"));
|
||||||
|
evas_object_del(cur_content);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pd->button[EFL_UI_POPUP_ALERT_BUTTON_POSITIVE]
|
||||||
|
&& pd->button[EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE]
|
||||||
|
&& pd->button[EFL_UI_POPUP_ALERT_BUTTON_USER])
|
||||||
|
{
|
||||||
|
pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_3] = elm_layout_add(obj);
|
||||||
|
elm_layout_theme_set(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_3], "popup", "base", "button3");
|
||||||
|
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]);
|
||||||
|
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]);
|
||||||
|
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]);
|
||||||
|
efl_content_set(efl_part(obj, "buttons"), pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_3]);
|
||||||
|
}
|
||||||
|
else if (pd->button[EFL_UI_POPUP_ALERT_BUTTON_POSITIVE]
|
||||||
|
&& pd->button[EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE])
|
||||||
|
{
|
||||||
|
pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2] = elm_layout_add(obj);
|
||||||
|
elm_layout_theme_set(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2], "popup", "base", "button2");
|
||||||
|
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]);
|
||||||
|
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]);
|
||||||
|
efl_content_set(efl_part(obj, "buttons"), pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2]);
|
||||||
|
}
|
||||||
|
else if (pd->button[EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE]
|
||||||
|
&& pd->button[EFL_UI_POPUP_ALERT_BUTTON_USER])
|
||||||
|
{
|
||||||
|
pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2] = elm_layout_add(obj);
|
||||||
|
elm_layout_theme_set(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2], "popup", "base", "button2");
|
||||||
|
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]);
|
||||||
|
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]);
|
||||||
|
efl_content_set(efl_part(obj, "buttons"), pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2]);
|
||||||
|
}
|
||||||
|
else if (pd->button[EFL_UI_POPUP_ALERT_BUTTON_POSITIVE]
|
||||||
|
&& pd->button[EFL_UI_POPUP_ALERT_BUTTON_USER])
|
||||||
|
{
|
||||||
|
pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2] = elm_layout_add(obj);
|
||||||
|
elm_layout_theme_set(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2], "popup", "base", "button2");
|
||||||
|
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]);
|
||||||
|
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]);
|
||||||
|
efl_content_set(efl_part(obj, "buttons"), pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_2]);
|
||||||
|
}
|
||||||
|
else if (pd->button[EFL_UI_POPUP_ALERT_BUTTON_POSITIVE])
|
||||||
|
{
|
||||||
|
pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1] = elm_layout_add(obj);
|
||||||
|
elm_layout_theme_set(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1], "popup", "base", "button1");
|
||||||
|
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]);
|
||||||
|
efl_content_set(efl_part(obj, "buttons"), pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1]);
|
||||||
|
}
|
||||||
|
else if (pd->button[EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE])
|
||||||
|
{
|
||||||
|
pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1] = elm_layout_add(obj);
|
||||||
|
elm_layout_theme_set(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1], "popup", "base", "button1");
|
||||||
|
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]);
|
||||||
|
efl_content_set(efl_part(obj, "buttons"), pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1]);
|
||||||
|
}
|
||||||
|
else if (pd->button[EFL_UI_POPUP_ALERT_BUTTON_USER])
|
||||||
|
{
|
||||||
|
pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1] = elm_layout_add(obj);
|
||||||
|
elm_layout_theme_set(pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1], "popup", "base", "button1");
|
||||||
|
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]);
|
||||||
|
efl_content_set(efl_part(obj, "buttons"), pd->button_layout[EFL_UI_POPUP_ALERT_BUTTON_1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
elm_layout_signal_emit(obj, "elm,buttons,show", "elm");
|
||||||
|
elm_layout_sizing_eval(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
EOLIAN static void
|
||||||
|
_efl_ui_popup_alert_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Alert_Data *pd EINA_UNUSED)
|
||||||
|
{
|
||||||
|
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
||||||
|
|
||||||
|
efl_canvas_group_add(efl_super(obj, MY_CLASS));
|
||||||
|
elm_widget_sub_object_parent_add(obj);
|
||||||
|
|
||||||
|
elm_layout_theme_set(efl_super(obj, MY_CLASS), "popup", "base", "alert");
|
||||||
|
}
|
||||||
|
|
||||||
|
EOLIAN static void
|
||||||
|
_efl_ui_popup_alert_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Popup_Alert_Data *pd)
|
||||||
|
{
|
||||||
|
if (pd->title_text)
|
||||||
|
{
|
||||||
|
eina_stringshare_del(pd->title_text);
|
||||||
|
pd->title_text = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
efl_canvas_group_del(efl_super(obj, MY_CLASS));
|
||||||
|
}
|
||||||
|
|
||||||
|
EOLIAN static void
|
||||||
|
_efl_ui_popup_alert_class_constructor(Efl_Class *klass)
|
||||||
|
{
|
||||||
|
evas_smart_legacy_type_register(MY_CLASS_NAME, klass);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define EFL_UI_POPUP_ALERT_EXTRA_OPS \
|
||||||
|
EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_popup_alert), \
|
||||||
|
ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_popup_alert)
|
||||||
|
|
||||||
|
#include "efl_ui_popup_alert.eo.c"
|
|
@ -0,0 +1,40 @@
|
||||||
|
enum Efl.Ui.Popup.Alert.Button {
|
||||||
|
[[Defines the type of the alert button.]]
|
||||||
|
positive = 0, [[Button having positive meaning. e.g. "Yes"]]
|
||||||
|
negative, [[Button having negative meaning. e.g. "No"]]
|
||||||
|
user [[Button having user-defined meaning. e.g. "Cancel"]]
|
||||||
|
}
|
||||||
|
|
||||||
|
class Efl.Ui.Popup.Alert(Efl.Ui.Popup)
|
||||||
|
{
|
||||||
|
methods {
|
||||||
|
@property title {
|
||||||
|
set {
|
||||||
|
[[Set the title of popup.]]
|
||||||
|
}
|
||||||
|
get {
|
||||||
|
[[Get the title of popup.]]
|
||||||
|
}
|
||||||
|
values {
|
||||||
|
text: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@property button {
|
||||||
|
set {
|
||||||
|
[[Set popup buttons.]]
|
||||||
|
}
|
||||||
|
keys {
|
||||||
|
type: Efl.Ui.Popup.Alert.Button;
|
||||||
|
}
|
||||||
|
values {
|
||||||
|
text: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
implements {
|
||||||
|
class.constructor;
|
||||||
|
}
|
||||||
|
events {
|
||||||
|
clicked;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
#ifndef EFL_UI_POPUP_ALERT_H
|
||||||
|
#define EFL_UI_POPUP_ALERT_H
|
||||||
|
|
||||||
|
#include "Elementary.h"
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
EFL_UI_POPUP_ALERT_BUTTON_1 = 0,
|
||||||
|
EFL_UI_POPUP_ALERT_BUTTON_2,
|
||||||
|
EFL_UI_POPUP_ALERT_BUTTON_3,
|
||||||
|
EFL_UI_POPUP_ALERT_BUTTON_COUNT
|
||||||
|
} Efl_Ui_Popup_Alert_Button_Type;
|
||||||
|
|
||||||
|
typedef struct _Efl_Ui_Popup_Alert_Data Efl_Ui_Popup_Alert_Data;
|
||||||
|
struct _Efl_Ui_Popup_Alert_Data
|
||||||
|
{
|
||||||
|
const char *title_text;
|
||||||
|
Evas_Object *button[EFL_UI_POPUP_ALERT_BUTTON_COUNT];
|
||||||
|
Evas_Object *button_layout[EFL_UI_POPUP_ALERT_BUTTON_COUNT];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue