diff options
author | Taehyub Kim <taehyub.kim@samsung.com> | 2017-08-31 13:18:45 +0900 |
---|---|---|
committer | Jaehyun Cho <jae_hyun.cho@samsung.com> | 2017-08-31 15:11:07 +0900 |
commit | 18cedfe11be42a3c8692f92c30e38badba669435 (patch) | |
tree | 192f7cdeb52496bff91774a984086cb9095b0287 | |
parent | 169c2bd2872b28d46feb1147625614f238cba35e (diff) | |
download | efl-18cedfe11be42a3c8692f92c30e38badba669435.tar.gz |
Efl.Ui.Popup.Alert.Scroll: add initial code for Efl.Ui.Popup.Alert.Scroll
Summary:
Added 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.am | 3 | ||||
-rw-r--r-- | src/bin/elementary/test.c | 2 | ||||
-rw-r--r-- | src/bin/elementary/test_popup.c | 36 | ||||
-rw-r--r-- | src/lib/elementary/Elementary.h | 1 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_popup_alert_scroll.c | 192 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_popup_alert_scroll.eo | 29 | ||||
-rw-r--r-- | src/lib/elementary/efl_ui_popup_alert_scroll_private.h | 18 |
7 files changed, 281 insertions, 0 deletions
diff --git a/src/Makefile_Elementary.am b/src/Makefile_Elementary.am index e3d1732c25..4a4e70a1c2 100644 --- a/src/Makefile_Elementary.am +++ b/src/Makefile_Elementary.am @@ -121,6 +121,7 @@ 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_text_editable.eo \ lib/elementary/efl_config_global.eo \ lib/elementary/efl_ui_clock.eo \ @@ -252,6 +253,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 \ @@ -678,6 +680,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 85f45e4bd9..9516b00fad 100644 --- a/src/bin/elementary/test.c +++ b/src/bin/elementary/test.c @@ -270,6 +270,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_swallow_align(void *data, Evas_Object *obj, void *event_info); @@ -955,6 +956,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 366985ce02..a293cbd33d 100644 --- a/src/bin/elementary/test_popup.c +++ b/src/bin/elementary/test_popup.c @@ -1139,3 +1139,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, 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 9342aeb1f2..1d89b21ab6 100644 --- a/src/lib/elementary/Elementary.h +++ b/src/lib/elementary/Elementary.h @@ -273,6 +273,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_clock.eo.h> # include <efl_ui_image_factory.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..909f73b59a --- /dev/null +++ b/src/lib/elementary/efl_ui_popup_alert_scroll.c @@ -0,0 +1,192 @@ +#ifdef HAVE_CONFIG_H +# include "elementary_config.h" +#endif + +#define ELM_WIDGET_PROTECTED +#define ELM_WIDGET_ITEM_PROTECTED + +#include <Elementary.h> + +#include "elm_priv.h" +#include "efl_ui_popup_alert_scroll.eo.h" +#include "efl_ui_popup_alert_scroll_private.h" + +#define MY_CLASS EFL_UI_POPUP_ALERT_SCROLL_CLASS +#define MY_CLASS_NAME "Efl.Ui.Popup.Alert.Scroll" + + +EOLIAN static Efl_Object * +_efl_ui_popup_alert_scroll_efl_object_constructor(Eo *obj, Efl_Ui_Popup_Alert_Scroll_Data *pd) +{ + obj = efl_constructor(efl_super(obj, MY_CLASS)); + return obj; +} + +EOLIAN static Elm_Theme_Apply +_efl_ui_popup_alert_scroll_elm_widget_theme_apply(Eo *obj, Efl_Ui_Popup_Alert_Scroll_Data *pd EINA_UNUSED) +{ + Elm_Theme_Apply int_ret = ELM_THEME_APPLY_FAILED; + + int_ret = elm_obj_widget_theme_apply(efl_super(obj, MY_CLASS)); + if (!int_ret) return ELM_THEME_APPLY_FAILED; + + return int_ret; +} + +static void +_scroller_sizing_eval(Eo *obj, Efl_Ui_Popup_Alert_Scroll_Data *pd, int minw, int minh) +{ + int 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); +} + +EOLIAN static Eina_Bool +_efl_ui_popup_alert_scroll_efl_container_content_set(Eo *obj, Efl_Ui_Popup_Alert_Scroll_Data *pd, Efl_Gfx *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); + + return EINA_TRUE; +} + +Efl_Gfx * +_efl_ui_popup_alert_scroll_efl_container_content_get(Eo *obj, Efl_Ui_Popup_Alert_Scroll_Data *pd) +{ + return pd->content; +} + +static void +_efl_ui_popup_alert_scroll_expandable_set(Eo *obj, 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, int w, int h) +{ + efl_gfx_size_hint_max_set(efl_super(obj, MY_CLASS), w, h); + pd->max_scroll_w = w; + pd->max_scroll_h = 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_super(obj, MY_CLASS), 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) +{ + 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); +} + +#define EFL_UI_POPUP_ALERT_SCROLL_EXTRA_OPS \ + EFL_CANVAS_GROUP_ADD_DEL_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..03770296d6 --- /dev/null +++ b/src/lib/elementary/efl_ui_popup_alert_scroll.eo @@ -0,0 +1,29 @@ +import elm_general; + +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.Object.constructor; + Elm.Widget.theme_apply; + Efl.Container.content { set; get; } + Elm.Layout.sizing_eval; + Efl.Gfx.Size.Hint.hint_max { set;} + } +} 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..96c5b0f79f --- /dev/null +++ b/src/lib/elementary/efl_ui_popup_alert_scroll_private.h @@ -0,0 +1,18 @@ +#ifndef EFL_UI_POPUP_ALERT_SCROLL_H +#define EFL_UI_POPUP_ALERT_SCROLL_H + +#include "Elementary.h" +#include "elm_widget_layout.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; + int max_scroll_w; + int max_scroll_h; + Eina_Bool is_expandable_w; + Eina_Bool is_expandable_h; +}; + +#endif |