summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaehyub Kim <taehyub.kim@samsung.com>2017-08-31 13:20:05 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-11-27 16:09:18 +0900
commiteb8e8003aca5f6001a41a8f477633fea21b8e030 (patch)
treec396221ddad8f9217771dc8cbf0e4dd4a004064a
parent0760e60411ada7697899c2640d023ea2591cdb7d (diff)
efl_ui_popup_alert_text: add Efl.Ui.Popup.Alert.Text Class
Summary: Add initial code for Efl.Ui.Popup.Alert.Text Class. It supports setting texts on the content area. Test Plan: 1. run elementary_text -to efluipopupalerttext Reviewers: Jaehyun_Cho, jpeg, thiepha, cedric, woohyun, Blackmole Reviewed By: Jaehyun_Cho Differential Revision: https://phab.enlightenment.org/D5124
-rw-r--r--src/Makefile_Elementary.am4
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_popup.c33
-rw-r--r--src/lib/elementary/Elementary.h1
-rw-r--r--src/lib/elementary/efl_ui_popup_alert_text.c182
-rw-r--r--src/lib/elementary/efl_ui_popup_alert_text.eo24
-rw-r--r--src/lib/elementary/efl_ui_popup_alert_text_part.eo10
-rw-r--r--src/lib/elementary/efl_ui_popup_alert_text_private.h15
8 files changed, 271 insertions, 0 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 5ced4a9663..5b04e89d35 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -35,6 +35,8 @@ elm_public_eolian_files = \
35 lib/elementary/efl_ui_popup_alert.eo \ 35 lib/elementary/efl_ui_popup_alert.eo \
36 lib/elementary/efl_ui_popup_alert_scroll.eo \ 36 lib/elementary/efl_ui_popup_alert_scroll.eo \
37 lib/elementary/efl_ui_popup_alert_scroll_part.eo \ 37 lib/elementary/efl_ui_popup_alert_scroll_part.eo \
38 lib/elementary/efl_ui_popup_alert_text.eo \
39 lib/elementary/efl_ui_popup_alert_text_part.eo \
38 lib/elementary/efl_ui_text_editable.eo \ 40 lib/elementary/efl_ui_text_editable.eo \
39 lib/elementary/efl_ui_text_async.eo \ 41 lib/elementary/efl_ui_text_async.eo \
40 lib/elementary/efl_ui_textpath.eo \ 42 lib/elementary/efl_ui_textpath.eo \
@@ -290,6 +292,7 @@ includesunstable_HEADERS = \
290 lib/elementary/efl_ui_popup_private.h \ 292 lib/elementary/efl_ui_popup_private.h \
291 lib/elementary/efl_ui_popup_alert_private.h \ 293 lib/elementary/efl_ui_popup_alert_private.h \
292 lib/elementary/efl_ui_popup_alert_scroll_private.h \ 294 lib/elementary/efl_ui_popup_alert_scroll_private.h \
295 lib/elementary/efl_ui_popup_alert_text_private.h \
293 lib/elementary/elm_widget_index.h \ 296 lib/elementary/elm_widget_index.h \
294 lib/elementary/elm_widget_inwin.h \ 297 lib/elementary/elm_widget_inwin.h \
295 lib/elementary/elm_widget_label.h \ 298 lib/elementary/elm_widget_label.h \
@@ -698,6 +701,7 @@ lib_elementary_libelementary_la_SOURCES = \
698 lib/elementary/efl_ui_popup.c \ 701 lib/elementary/efl_ui_popup.c \
699 lib/elementary/efl_ui_popup_alert.c \ 702 lib/elementary/efl_ui_popup_alert.c \
700 lib/elementary/efl_ui_popup_alert_scroll.c \ 703 lib/elementary/efl_ui_popup_alert_scroll.c \
704 lib/elementary/efl_ui_popup_alert_text.c \
701 lib/elementary/efl_ui_grid.c \ 705 lib/elementary/efl_ui_grid.c \
702 lib/elementary/efl_ui_grid_static.c \ 706 lib/elementary/efl_ui_grid_static.c \
703 lib/elementary/efl_ui_grid_private.h \ 707 lib/elementary/efl_ui_grid_private.h \
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index 5362ae37b2..20a6422476 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -275,6 +275,7 @@ void test_popup(void *data, Evas_Object *obj, void *event_info);
275void test_efl_ui_popup(void *data, Evas_Object *obj, void *event_info); 275void test_efl_ui_popup(void *data, Evas_Object *obj, void *event_info);
276void test_efl_ui_popup_alert(void *data, Evas_Object *obj, void *event_info); 276void test_efl_ui_popup_alert(void *data, Evas_Object *obj, void *event_info);
277void test_efl_ui_popup_alert_scroll(void *data, Evas_Object *obj, void *event_info); 277void test_efl_ui_popup_alert_scroll(void *data, Evas_Object *obj, void *event_info);
278void test_efl_ui_popup_alert_text(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);
@@ -1043,6 +1044,7 @@ add_tests:
1043 ADD_TEST(NULL, "Popups", "Efl UI Popup", test_efl_ui_popup); 1044 ADD_TEST(NULL, "Popups", "Efl UI Popup", test_efl_ui_popup);
1044 ADD_TEST(NULL, "Popups", "Efl UI Popup Alert", test_efl_ui_popup_alert); 1045 ADD_TEST(NULL, "Popups", "Efl UI Popup Alert", test_efl_ui_popup_alert);
1045 ADD_TEST(NULL, "Popups", "Efl UI Popup Alert Scroll", test_efl_ui_popup_alert_scroll); 1046 ADD_TEST(NULL, "Popups", "Efl UI Popup Alert Scroll", test_efl_ui_popup_alert_scroll);
1047 ADD_TEST(NULL, "Popups", "Efl UI Popup Alert Text", test_efl_ui_popup_alert_text);
1046 1048
1047 //------------------------------// 1049 //------------------------------//
1048 ADD_TEST(NULL, "Times & Dates", "Calendar", test_calendar); 1050 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 299644f17d..afc29a5858 100644
--- a/src/bin/elementary/test_popup.c
+++ b/src/bin/elementary/test_popup.c
@@ -1172,3 +1172,36 @@ test_efl_ui_popup_alert_scroll(void *data EINA_UNUSED, Evas_Object *obj EINA_UNU
1172 1172
1173 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_ALERT_EVENT_CLICKED, efl_ui_popup_alert_clicked_cb, NULL); 1173 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_ALERT_EVENT_CLICKED, efl_ui_popup_alert_clicked_cb, NULL);
1174} 1174}
1175
1176void
1177test_efl_ui_popup_alert_text(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1178{
1179 Evas_Object *win;
1180
1181 win = elm_win_util_standard_add("Efl UI Popup Alert Text", "Efl UI Popup Alert Text");
1182 elm_win_autodel_set(win, EINA_TRUE);
1183
1184 evas_object_resize(win, 320, 320);
1185 evas_object_show(win);
1186
1187 Evas_Object *efl_ui_popup= efl_add(EFL_UI_POPUP_ALERT_TEXT_CLASS, win);
1188
1189 efl_ui_popup_alert_title_set(efl_ui_popup, "title");
1190
1191 evas_object_resize(efl_ui_popup, 160, 160);
1192 evas_object_show(efl_ui_popup);
1193
1194 efl_text_set(efl_ui_popup,
1195 "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"
1196 "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"
1197 "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");
1198
1199 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_POSITIVE, "Yes");
1200 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_NEGATIVE, "No");
1201 efl_ui_popup_alert_button_set(efl_ui_popup, EFL_UI_POPUP_ALERT_BUTTON_USER, "Cancel");
1202
1203 efl_ui_popup_alert_text_expandable_set(efl_ui_popup, EINA_TRUE);
1204 efl_gfx_size_hint_max_set(efl_ui_popup, EINA_SIZE2D(100, 180));
1205
1206 efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_ALERT_EVENT_CLICKED, efl_ui_popup_alert_clicked_cb, NULL);
1207}
diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h
index 9e6f5d432b..24909a207f 100644
--- a/src/lib/elementary/Elementary.h
+++ b/src/lib/elementary/Elementary.h
@@ -304,6 +304,7 @@ EAPI extern Elm_Version *elm_version;
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_popup_alert.eo.h>
306# include <efl_ui_popup_alert_scroll.eo.h> 306# include <efl_ui_popup_alert_scroll.eo.h>
307# include <efl_ui_popup_alert_text.eo.h>
307# include <efl_ui_text_editable.eo.h> 308# include <efl_ui_text_editable.eo.h>
308# include <efl_ui_text_async.eo.h> 309# include <efl_ui_text_async.eo.h>
309# include <efl_ui_clock.eo.h> 310# include <efl_ui_clock.eo.h>
diff --git a/src/lib/elementary/efl_ui_popup_alert_text.c b/src/lib/elementary/efl_ui_popup_alert_text.c
new file mode 100644
index 0000000000..808aa7a8cb
--- /dev/null
+++ b/src/lib/elementary/efl_ui_popup_alert_text.c
@@ -0,0 +1,182 @@
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_text_private.h"
9#include "efl_ui_popup_alert_text_part.eo.h"
10#include "elm_part_helper.h"
11
12#define MY_CLASS EFL_UI_POPUP_ALERT_TEXT_CLASS
13#define MY_CLASS_NAME "Efl.Ui.Popup.Alert.Text"
14
15static void
16_scroller_sizing_eval(Eo *obj, Efl_Ui_Popup_Alert_Text_Data *pd, Evas_Coord minh)
17{
18 Evas_Coord w, h;
19 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
20
21 if (pd->is_expandable_h)
22 {
23 if ((pd->max_scroll_h > -1) && (minh > pd->max_scroll_h))
24 {
25 elm_scroller_content_min_limit(pd->scroller, EINA_FALSE, EINA_FALSE);
26 evas_object_resize(obj, w, pd->max_scroll_h);
27 }
28 }
29}
30
31EOLIAN static void
32_efl_ui_popup_alert_text_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Popup_Alert_Text_Data *pd)
33{
34 elm_layout_sizing_eval(efl_super(obj, MY_CLASS));
35
36 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
37 Evas_Coord minw = -1, minh = -1;
38
39 elm_coords_finger_size_adjust(1, &minw, 1, &minh);
40 edje_object_size_min_restricted_calc(wd->resize_obj, &minw, &minh, minw, minh);
41 evas_object_size_hint_min_set(obj, minw, minh);
42
43 _scroller_sizing_eval(obj, pd, minh);
44}
45
46static Eina_Bool
47_efl_ui_popup_alert_text_content_set(Eo *obj, Efl_Ui_Popup_Alert_Text_Data *pd EINA_UNUSED, const char *part, Evas_Object *content)
48{
49 return efl_content_set(efl_part(efl_super(obj, MY_CLASS), part), content);
50}
51
52Evas_Object *
53_efl_ui_popup_alert_text_content_get(Eo *obj, Efl_Ui_Popup_Alert_Text_Data *pd EINA_UNUSED, const char *part)
54{
55 return efl_content_get(efl_part(efl_super(obj, MY_CLASS), part));
56}
57
58static Evas_Object *
59_efl_ui_popup_alert_text_content_unset(Eo *obj, Efl_Ui_Popup_Alert_Text_Data *pd EINA_UNUSED, const char *part)
60{
61 return efl_content_unset(efl_part(efl_super(obj, MY_CLASS), part));
62}
63
64static Eina_Bool
65_efl_ui_popup_alert_text_text_set(Eo *obj, Efl_Ui_Popup_Alert_Text_Data *pd, const char *part, const char *label)
66{
67 if (part && !strcmp(part, "elm.text"))
68 {
69 if (!pd->message)
70 {
71 pd->message = elm_label_add(obj);
72 elm_label_line_wrap_set(pd->message, ELM_WRAP_MIXED);
73 evas_object_size_hint_weight_set(pd->message, EVAS_HINT_EXPAND,
74 EVAS_HINT_EXPAND);
75 efl_content_set(efl_part(pd->scroller, "default"), pd->message);
76 }
77 elm_object_text_set(pd->message, label);
78 elm_layout_sizing_eval(obj);
79 }
80 else
81 efl_text_set(efl_part(efl_super(obj, MY_CLASS), part), label);
82
83 return EINA_TRUE;
84}
85
86const char *
87_efl_ui_popup_alert_text_text_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Alert_Text_Data *pd, const char *part)
88{
89 if (part && !strcmp(part, "elm.text"))
90 {
91 if (pd->message)
92 return elm_object_text_get(pd->message);
93
94 return NULL;
95 }
96
97 return efl_text_get(efl_part(efl_super(obj, MY_CLASS), part));
98}
99
100EOLIAN static void
101_efl_ui_popup_alert_text_efl_text_text_set(Eo *obj, Efl_Ui_Popup_Alert_Text_Data *pd, const char *label)
102{
103 _efl_ui_popup_alert_text_text_set(obj, pd, "elm.text", label);
104}
105
106EOLIAN static const char*
107_efl_ui_popup_alert_text_efl_text_text_get(Eo *obj, Efl_Ui_Popup_Alert_Text_Data *pd)
108{
109 return _efl_ui_popup_alert_text_text_get(obj, pd, "elm.text");
110}
111
112static void
113_efl_ui_popup_alert_text_expandable_set(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Alert_Text_Data *pd, Eina_Bool is_expandable_h)
114{
115 if (is_expandable_h)
116 {
117 pd->is_expandable_h = EINA_TRUE;
118 elm_scroller_content_min_limit(pd->scroller, EINA_FALSE, EINA_TRUE);
119 }
120 else
121 {
122 pd->is_expandable_h = EINA_FALSE;
123 elm_scroller_content_min_limit(pd->scroller, EINA_FALSE, EINA_FALSE);
124 }
125}
126
127static void
128_efl_ui_popup_alert_text_efl_gfx_size_hint_hint_max_set(Eo *obj, Efl_Ui_Popup_Alert_Text_Data *pd, Eina_Size2D size)
129{
130 efl_gfx_size_hint_max_set(efl_super(obj, MY_CLASS), size);
131 pd->max_scroll_h = size.h;
132 elm_layout_sizing_eval(obj);
133}
134
135EOLIAN static void
136_efl_ui_popup_alert_text_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Alert_Text_Data *pd)
137{
138 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
139
140 efl_canvas_group_add(efl_super(obj, MY_CLASS));
141 elm_widget_sub_object_parent_add(obj);
142
143 pd->scroller = elm_scroller_add(obj);
144 elm_object_style_set(pd->scroller, "popup/no_inset_shadow");
145 elm_scroller_policy_set(pd->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
146
147 efl_content_set(efl_part(efl_super(obj, MY_CLASS), "elm.swallow.content"), pd->scroller);
148
149 pd->max_scroll_h = -1;
150}
151
152EOLIAN static void
153_efl_ui_popup_alert_text_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Popup_Alert_Text_Data *pd EINA_UNUSED)
154{
155 efl_canvas_group_del(efl_super(obj, MY_CLASS));
156}
157
158EOLIAN static void
159_efl_ui_popup_alert_text_class_constructor(Efl_Class *klass)
160{
161 evas_smart_legacy_type_register(MY_CLASS_NAME, klass);
162}
163
164/* Efl.Part begin */
165
166ELM_PART_OVERRIDE(efl_ui_popup_alert_text, EFL_UI_POPUP_ALERT_TEXT, Efl_Ui_Popup_Alert_Text_Data)
167ELM_PART_OVERRIDE_CONTENT_SET(efl_ui_popup_alert_text, EFL_UI_POPUP_ALERT_TEXT, Efl_Ui_Popup_Alert_Text_Data)
168ELM_PART_OVERRIDE_CONTENT_GET(efl_ui_popup_alert_text, EFL_UI_POPUP_ALERT_TEXT, Efl_Ui_Popup_Alert_Text_Data)
169ELM_PART_OVERRIDE_CONTENT_UNSET(efl_ui_popup_alert_text, EFL_UI_POPUP_ALERT_TEXT, Efl_Ui_Popup_Alert_Text_Data)
170ELM_PART_OVERRIDE_TEXT_SET(efl_ui_popup_alert_text, EFL_UI_POPUP_ALERT_TEXT, Efl_Ui_Popup_Alert_Text_Data)
171ELM_PART_OVERRIDE_TEXT_GET(efl_ui_popup_alert_text, EFL_UI_POPUP_ALERT_TEXT, Efl_Ui_Popup_Alert_Text_Data)
172#include "efl_ui_popup_alert_text_part.eo.c"
173
174/* Efl.Part end */
175
176/* Internal EO APIs and hidden overrides */
177
178#define EFL_UI_POPUP_ALERT_TEXT_EXTRA_OPS \
179 EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_popup_alert_text), \
180 ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_popup_alert_text)
181
182#include "efl_ui_popup_alert_text.eo.c"
diff --git a/src/lib/elementary/efl_ui_popup_alert_text.eo b/src/lib/elementary/efl_ui_popup_alert_text.eo
new file mode 100644
index 0000000000..5c2539f8b1
--- /dev/null
+++ b/src/lib/elementary/efl_ui_popup_alert_text.eo
@@ -0,0 +1,24 @@
1class Efl.Ui.Popup.Alert.Text(Efl.Ui.Popup.Alert, Efl.Text)
2{
3 methods {
4 @property expandable {
5 set {
6 [[Set the expandable of popup.
7
8 If the contents of the popup has min size, popup will be increased by min size to the y direction.
9 If max hint is set, it will be increased to value of max hint,
10 and then scrolling will occur.
11 ]]
12 }
13 values {
14 is_expandable: bool;
15 }
16 }
17 }
18 implements {
19 class.constructor;
20 Efl.Gfx.Size.Hint.hint_max { set;}
21 Efl.Text.text { get; set; }
22 Efl.Part.part;
23 }
24}
diff --git a/src/lib/elementary/efl_ui_popup_alert_text_part.eo b/src/lib/elementary/efl_ui_popup_alert_text_part.eo
new file mode 100644
index 0000000000..f9e5fda8a3
--- /dev/null
+++ b/src/lib/elementary/efl_ui_popup_alert_text_part.eo
@@ -0,0 +1,10 @@
1class Efl.Ui.Popup.Alert.Text.Part (Efl.Ui.Layout.Part_Content, Efl.Ui.Layout.Part_Text)
2{
3 [[Efl UI Popup Alert Text internal part class]]
4 data: null;
5 implements {
6 Efl.Container.content { get; set; }
7 Efl.Container.content_unset;
8 Efl.Text.text { get; set; }
9 }
10}
diff --git a/src/lib/elementary/efl_ui_popup_alert_text_private.h b/src/lib/elementary/efl_ui_popup_alert_text_private.h
new file mode 100644
index 0000000000..d15f1b8e2d
--- /dev/null
+++ b/src/lib/elementary/efl_ui_popup_alert_text_private.h
@@ -0,0 +1,15 @@
1#ifndef EFL_UI_POPUP_ALERT_TEXT_H
2#define EFL_UI_POPUP_ALERT_TEXT_H
3
4#include "Elementary.h"
5
6typedef struct _Efl_Ui_Popup_Alert_Text_Data Efl_Ui_Popup_Alert_Text_Data;
7struct _Efl_Ui_Popup_Alert_Text_Data
8{
9 Evas_Object *scroller;
10 Evas_Object *message;
11 Evas_Coord max_scroll_h;
12 Eina_Bool is_expandable_h;
13};
14
15#endif