aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaehyub Kim <taehyub.kim@samsung.com>2017-08-31 13:18:45 +0900
committerJaehyun Cho <jae_hyun.cho@samsung.com>2017-11-21 14:01:48 +0900
commit7d5cb62d6c904c8335b4f0781f9ff97a6ee88cba (patch)
treedb246e0d7f9952ea82f4579654a8c95e41d04633
parentefl_ui_popup: cover the corner case of popup sizing evaluation (diff)
downloadefl-7d5cb62d6c904c8335b4f0781f9ff97a6ee88cba.tar.gz
efl_ui_popup_alert_scroll: add Efl.Ui.Popup.Alert.Scroll class
Summary: Add initial code for Efl.Ui.Popup.Alert.Scroll Class. It supports scrolling content. Test Plan: 1. run elementary_test -to efluipopupalertscroll Reviewers: Jaehyun_Cho, jpeg, thiepha, cedric, Blackmole, woohyun Reviewed By: Jaehyun_Cho Differential Revision: https://phab.enlightenment.org/D5123
-rw-r--r--src/Makefile_Elementary.am4
-rw-r--r--src/bin/elementary/test.c2
-rw-r--r--src/bin/elementary/test_popup.c36
-rw-r--r--src/lib/elementary/Elementary.h1
-rw-r--r--src/lib/elementary/efl_ui_popup_alert_scroll.c229
-rw-r--r--src/lib/elementary/efl_ui_popup_alert_scroll.eo24
-rw-r--r--src/lib/elementary/efl_ui_popup_alert_scroll_part.eo10
-rw-r--r--src/lib/elementary/efl_ui_popup_alert_scroll_private.h17
8 files changed, 323 insertions, 0 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am
index 2a14bc7fee..77a5b88f2b 100644
--- a/src/Makefile_Elementary.am
+++ b/src/Makefile_Elementary.am
@@ -33,6 +33,8 @@ elm_public_eolian_files = \
lib/elementary/efl_ui_text.eo \
lib/elementary/efl_ui_popup.eo \
lib/elementary/efl_ui_popup_alert.eo \
+ lib/elementary/efl_ui_popup_alert_scroll.eo \
+ lib/elementary/efl_ui_popup_alert_scroll_part.eo \
lib/elementary/efl_ui_text_editable.eo \
lib/elementary/efl_ui_text_async.eo \
lib/elementary/efl_ui_textpath.eo \
@@ -294,6 +296,7 @@ includesunstable_HEADERS = \
lib/elementary/efl_ui_widget_image.h \
lib/elementary/efl_ui_popup_private.h \
lib/elementary/efl_ui_popup_alert_private.h \
+ lib/elementary/efl_ui_popup_alert_scroll_private.h \
lib/elementary/elm_widget_index.h \
lib/elementary/elm_widget_inwin.h \
lib/elementary/elm_widget_label.h \
@@ -706,6 +709,7 @@ lib_elementary_libelementary_la_SOURCES = \
lib/elementary/efl_ui_box_private.h \
lib/elementary/efl_ui_popup.c \
lib/elementary/efl_ui_popup_alert.c \
+ lib/elementary/efl_ui_popup_alert_scroll.c \
lib/elementary/efl_ui_grid.c \
lib/elementary/efl_ui_grid_static.c \
lib/elementary/efl_ui_grid_private.h \
diff --git a/src/bin/elementary/test.c b/src/bin/elementary/test.c
index f746fabb71..c0f9cdad9e 100644
--- a/src/bin/elementary/test.c
+++ b/src/bin/elementary/test.c
@@ -276,6 +276,7 @@ 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_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_efl_ui_popup_alert_scroll(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_scale_type(void *data, Evas_Object *obj, void *event_info);
@@ -1010,6 +1011,7 @@ add_tests:
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 Alert", test_efl_ui_popup_alert);
+ ADD_TEST(NULL, "Popups", "Efl UI Popup Alert Scroll", test_efl_ui_popup_alert_scroll);
//------------------------------//
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 4074862175..299644f17d 100644
--- a/src/bin/elementary/test_popup.c
+++ b/src/bin/elementary/test_popup.c
@@ -1136,3 +1136,39 @@ test_efl_ui_popup_alert(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, vo
efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_ALERT_EVENT_CLICKED, efl_ui_popup_alert_clicked_cb, NULL);
}
+
+void
+test_efl_ui_popup_alert_scroll(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 Scroll", "Efl UI Popup Alert Scroll");
+ 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_SCROLL_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_ui_popup_alert_scroll_expandable_set(efl_ui_popup, EINA_TRUE, EINA_TRUE);
+ efl_gfx_size_hint_max_set(efl_ui_popup, EINA_SIZE2D(300, 180));
+
+ efl_event_callback_add(efl_ui_popup, EFL_UI_POPUP_ALERT_EVENT_CLICKED, efl_ui_popup_alert_clicked_cb, NULL);
+}
diff --git a/src/lib/elementary/Elementary.h b/src/lib/elementary/Elementary.h
index 8467673431..5dcff7b12d 100644
--- a/src/lib/elementary/Elementary.h
+++ b/src/lib/elementary/Elementary.h
@@ -283,6 +283,7 @@ EAPI extern Elm_Version *elm_version;
# include <efl_ui_text.eo.h>
# include <efl_ui_popup.eo.h>
# include <efl_ui_popup_alert.eo.h>
+# include <efl_ui_popup_alert_scroll.eo.h>
# include <efl_ui_text_editable.eo.h>
# include <efl_ui_text_async.eo.h>
# include <efl_ui_clock.eo.h>
diff --git a/src/lib/elementary/efl_ui_popup_alert_scroll.c b/src/lib/elementary/efl_ui_popup_alert_scroll.c
new file mode 100644
index 0000000000..ca0fe7663c
--- /dev/null
+++ b/src/lib/elementary/efl_ui_popup_alert_scroll.c
@@ -0,0 +1,229 @@
+#ifdef HAVE_CONFIG_H
+# include "elementary_config.h"
+#endif
+
+#include <Elementary.h>
+
+#include "elm_priv.h"
+#include "efl_ui_popup_alert_scroll_private.h"
+#include "efl_ui_popup_alert_scroll_part.eo.h"
+#include "elm_part_helper.h"
+
+#define MY_CLASS EFL_UI_POPUP_ALERT_SCROLL_CLASS
+#define MY_CLASS_NAME "Efl.Ui.Popup.Alert.Scroll"
+
+static void
+_scroller_sizing_eval(Eo *obj, Efl_Ui_Popup_Alert_Scroll_Data *pd, Evas_Coord minw, Evas_Coord minh)
+{
+ Evas_Coord w, h;
+ evas_object_geometry_get(obj, NULL, NULL, &w, &h);
+
+ if (pd->is_expandable_w && !pd->is_expandable_h)
+ {
+ if ((pd->max_scroll_w > -1) && (minw > pd->max_scroll_w))
+ {
+ elm_scroller_content_min_limit(pd->scroller, EINA_FALSE, EINA_FALSE);
+ evas_object_resize(obj, pd->max_scroll_w, h);
+ }
+ }
+ else if (!pd->is_expandable_w && pd->is_expandable_h)
+ {
+ if ((pd->max_scroll_h > -1) && (minh > pd->max_scroll_h))
+ {
+ elm_scroller_content_min_limit(pd->scroller, EINA_FALSE, EINA_FALSE);
+ evas_object_resize(obj, w, pd->max_scroll_h);
+ }
+ }
+ else if (pd->is_expandable_w && pd->is_expandable_h)
+ {
+ Eina_Bool wdir, hdir;
+ wdir = hdir = EINA_FALSE;
+
+ if ((pd->max_scroll_w > -1) && (minw > pd->max_scroll_w))
+ wdir = 1;
+ if ((pd->max_scroll_h > -1) && (minh > pd->max_scroll_h))
+ hdir = 1;
+ if (wdir && !hdir)
+ {
+ elm_scroller_content_min_limit(pd->scroller, EINA_FALSE, EINA_TRUE);
+ evas_object_resize(obj, pd->max_scroll_w, h);
+ }
+ else if (!wdir && hdir)
+ {
+ elm_scroller_content_min_limit(pd->scroller, EINA_TRUE, EINA_FALSE);
+ evas_object_resize(obj, w, pd->max_scroll_h);
+ }
+ else if(wdir && hdir)
+ {
+ elm_scroller_content_min_limit(pd->scroller, EINA_FALSE, EINA_FALSE);
+ evas_object_resize(obj, pd->max_scroll_w, pd->max_scroll_h);
+ }
+ }
+}
+
+EOLIAN static void
+_efl_ui_popup_alert_scroll_elm_layout_sizing_eval(Eo *obj, Efl_Ui_Popup_Alert_Scroll_Data *pd)
+{
+ 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);
+
+ _scroller_sizing_eval(obj, pd, minw, minh);
+}
+
+static Eina_Bool
+_efl_ui_popup_alert_scroll_content_set(Eo *obj, Efl_Ui_Popup_Alert_Scroll_Data *pd, const char *part, Evas_Object *content)
+{
+ //For efl_content_set()
+ if (part && !strcmp(part, "elm.swallow.content"))
+ {
+ pd->content = content;
+
+ //Content should have expand propeties since the scroller is not layout layer
+ evas_object_size_hint_weight_set(pd->content, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(pd->content, EVAS_HINT_FILL, EVAS_HINT_FILL);
+
+ efl_content_set(efl_part(pd->scroller, "default"), pd->content);
+ }
+ else
+ {
+ efl_content_set(efl_part(efl_super(obj, MY_CLASS), part), content);
+ }
+
+ return EINA_TRUE;
+}
+
+Evas_Object *
+_efl_ui_popup_alert_scroll_content_get(Eo *obj, Efl_Ui_Popup_Alert_Scroll_Data *pd, const char *part)
+{
+ //For efl_content_set()
+ if (part && !strcmp(part, "elm.swallow.content"))
+ return pd->content;
+
+ return efl_content_get(efl_part(efl_super(obj, MY_CLASS), part));
+}
+
+static Evas_Object *
+_efl_ui_popup_alert_scroll_content_unset(Eo *obj, Efl_Ui_Popup_Alert_Scroll_Data *pd, const char *part)
+{
+ //For efl_content_set()
+ if (part && !strcmp(part, "elm.swallow.content"))
+ {
+ Evas_Object *content = pd->content;
+ if (!content) return content;
+
+ pd->content = NULL;
+
+ return efl_content_unset(efl_part(pd->scroller, "default"));
+ }
+
+ return efl_content_unset(efl_part(efl_super(obj, MY_CLASS), part));
+}
+
+static Eina_Bool
+_efl_ui_popup_alert_scroll_text_set(Eo *obj, Efl_Ui_Popup_Alert_Scroll_Data *pd EINA_UNUSED, const char *part, const char *label)
+{
+ efl_text_set(efl_part(efl_super(obj, MY_CLASS), part), label);
+
+ return EINA_TRUE;
+}
+
+const char *
+_efl_ui_popup_alert_scroll_text_get(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Alert_Scroll_Data *pd EINA_UNUSED, const char *part)
+{
+ return efl_text_get(efl_part(efl_super(obj, MY_CLASS), part));
+}
+
+static void
+_efl_ui_popup_alert_scroll_expandable_set(Eo *obj EINA_UNUSED, Efl_Ui_Popup_Alert_Scroll_Data *pd, Eina_Bool is_expandable_w, Eina_Bool is_expandable_h)
+{
+ if (is_expandable_w && !is_expandable_h)
+ {
+ pd->is_expandable_w = EINA_TRUE;
+ pd->is_expandable_h = EINA_FALSE;
+ elm_scroller_content_min_limit(pd->scroller, EINA_TRUE, EINA_FALSE);
+ }
+ else if(!is_expandable_w && is_expandable_h)
+ {
+ pd->is_expandable_w = EINA_FALSE;
+ pd->is_expandable_h = EINA_TRUE;
+ elm_scroller_content_min_limit(pd->scroller, EINA_FALSE, EINA_TRUE);
+ }
+ else if(is_expandable_w && is_expandable_h)
+ {
+ pd->is_expandable_w = EINA_TRUE;
+ pd->is_expandable_h = EINA_TRUE;
+ elm_scroller_content_min_limit(pd->scroller, EINA_TRUE, EINA_TRUE);
+ }
+ else
+ {
+ pd->is_expandable_w = EINA_FALSE;
+ pd->is_expandable_h = EINA_FALSE;
+ elm_scroller_content_min_limit(pd->scroller, EINA_FALSE, EINA_FALSE);
+ }
+}
+
+static void
+_efl_ui_popup_alert_scroll_efl_gfx_size_hint_hint_max_set(Eo *obj, Efl_Ui_Popup_Alert_Scroll_Data *pd, Eina_Size2D size)
+{
+ efl_gfx_size_hint_max_set(efl_super(obj, MY_CLASS), size);
+ pd->max_scroll_w = size.w;
+ pd->max_scroll_h = size.h;
+ elm_layout_sizing_eval(obj);
+}
+
+EOLIAN static void
+_efl_ui_popup_alert_scroll_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Popup_Alert_Scroll_Data *pd)
+{
+ ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
+
+ efl_canvas_group_add(efl_super(obj, MY_CLASS));
+ elm_widget_sub_object_parent_add(obj);
+
+ pd->scroller = elm_scroller_add(obj);
+ elm_object_style_set(pd->scroller, "popup/no_inset_shadow");
+ elm_scroller_policy_set(pd->scroller, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_AUTO);
+
+ efl_content_set(efl_part(efl_super(obj, MY_CLASS), "elm.swallow.content"), pd->scroller);
+
+ pd->max_scroll_w = -1;
+ pd->max_scroll_h = -1;
+}
+
+EOLIAN static void
+_efl_ui_popup_alert_scroll_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Popup_Alert_Scroll_Data *pd EINA_UNUSED)
+{
+ efl_canvas_group_del(efl_super(obj, MY_CLASS));
+}
+
+EOLIAN static void
+_efl_ui_popup_alert_scroll_class_constructor(Efl_Class *klass)
+{
+ evas_smart_legacy_type_register(MY_CLASS_NAME, klass);
+}
+
+/* Efl.Part begin */
+
+ELM_PART_OVERRIDE(efl_ui_popup_alert_scroll, EFL_UI_POPUP_ALERT_SCROLL, Efl_Ui_Popup_Alert_Scroll_Data)
+ELM_PART_OVERRIDE_CONTENT_SET(efl_ui_popup_alert_scroll, EFL_UI_POPUP_ALERT_SCROLL, Efl_Ui_Popup_Alert_Scroll_Data)
+ELM_PART_OVERRIDE_CONTENT_GET(efl_ui_popup_alert_scroll, EFL_UI_POPUP_ALERT_SCROLL, Efl_Ui_Popup_Alert_Scroll_Data)
+ELM_PART_OVERRIDE_CONTENT_UNSET(efl_ui_popup_alert_scroll, EFL_UI_POPUP_ALERT_SCROLL, Efl_Ui_Popup_Alert_Scroll_Data)
+ELM_PART_OVERRIDE_TEXT_SET(efl_ui_popup_alert_scroll, EFL_UI_POPUP_ALERT_SCROLL, Efl_Ui_Popup_Alert_Scroll_Data)
+ELM_PART_OVERRIDE_TEXT_GET(efl_ui_popup_alert_scroll, EFL_UI_POPUP_ALERT_SCROLL, Efl_Ui_Popup_Alert_Scroll_Data)
+#include "efl_ui_popup_alert_scroll_part.eo.c"
+
+/* Efl.Part end */
+
+/* Internal EO APIs and hidden overrides */
+
+#define EFL_UI_POPUP_ALERT_SCROLL_EXTRA_OPS \
+ EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_popup_alert_scroll), \
+ ELM_LAYOUT_SIZING_EVAL_OPS(efl_ui_popup_alert_scroll)
+
+#include "efl_ui_popup_alert_scroll.eo.c"
diff --git a/src/lib/elementary/efl_ui_popup_alert_scroll.eo b/src/lib/elementary/efl_ui_popup_alert_scroll.eo
new file mode 100644
index 0000000000..00dadb3b54
--- /dev/null
+++ b/src/lib/elementary/efl_ui_popup_alert_scroll.eo
@@ -0,0 +1,24 @@
+class Efl.Ui.Popup.Alert.Scroll(Efl.Ui.Popup.Alert)
+{
+ methods {
+ @property expandable {
+ set {
+ [[Set the expandable of popup.
+
+ If the contents of the popup has min size, popup will be increased by min size.
+ If max hint is set, it will be increased to value of max hint,
+ and then scrolling will occur.
+ ]]
+ }
+ values {
+ is_expandable_w: bool;
+ is_expandable_h: bool;
+ }
+ }
+ }
+ implements {
+ class.constructor;
+ Efl.Gfx.Size.Hint.hint_max { set; }
+ Efl.Part.part;
+ }
+}
diff --git a/src/lib/elementary/efl_ui_popup_alert_scroll_part.eo b/src/lib/elementary/efl_ui_popup_alert_scroll_part.eo
new file mode 100644
index 0000000000..24d980893b
--- /dev/null
+++ b/src/lib/elementary/efl_ui_popup_alert_scroll_part.eo
@@ -0,0 +1,10 @@
+class Efl.Ui.Popup.Alert.Scroll.Part (Efl.Ui.Layout.Part_Content, Efl.Ui.Layout.Part_Text)
+{
+ [[Efl UI Popup Alert Scroll internal part class]]
+ data: null;
+ implements {
+ Efl.Container.content { get; set; }
+ Efl.Container.content_unset;
+ Efl.Text.text { set; get; }
+ }
+}
diff --git a/src/lib/elementary/efl_ui_popup_alert_scroll_private.h b/src/lib/elementary/efl_ui_popup_alert_scroll_private.h
new file mode 100644
index 0000000000..d72e359572
--- /dev/null
+++ b/src/lib/elementary/efl_ui_popup_alert_scroll_private.h
@@ -0,0 +1,17 @@
+#ifndef EFL_UI_POPUP_ALERT_SCROLL_H
+#define EFL_UI_POPUP_ALERT_SCROLL_H
+
+#include "Elementary.h"
+
+typedef struct _Efl_Ui_Popup_Alert_Scroll_Data Efl_Ui_Popup_Alert_Scroll_Data;
+struct _Efl_Ui_Popup_Alert_Scroll_Data
+{
+ Evas_Object *scroller;
+ Evas_Object *content;
+ Evas_Coord max_scroll_w;
+ Evas_Coord max_scroll_h;
+ Eina_Bool is_expandable_w;
+ Eina_Bool is_expandable_h;
+};
+
+#endif