summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2015-08-12 19:04:46 +0530
committerAmitesh Singh <amitesh.sh@samsung.com>2015-08-12 23:32:26 +0530
commit7d8d31056de2b0b344aaa12792e27c1c5fd4126c (patch)
tree886242f6fd2364e604dc5097ca157c8a23ee8ea5
parentf9e7fcc8536ac1562569042db4cc1cd071ad25e5 (diff)
downloadelementary-devs/ami/popup-scroll.tar.gz
popup: add scroll option in popup.devs/ami/popup-scroll
-rw-r--r--data/themes/edc/elm/popup.edc1
-rw-r--r--data/themes/edc/elm/scroller.edc22
-rw-r--r--src/bin/test_popup.c43
-rw-r--r--src/lib/elc_popup.c117
-rw-r--r--src/lib/elm_popup.eo21
-rw-r--r--src/lib/elm_widget_popup.h1
6 files changed, 189 insertions, 16 deletions
diff --git a/data/themes/edc/elm/popup.edc b/data/themes/edc/elm/popup.edc
index 1892423a1..ade8664d3 100644
--- a/data/themes/edc/elm/popup.edc
+++ b/data/themes/edc/elm/popup.edc
@@ -370,6 +370,7 @@ group { name: "elm/popup/content/popup/default";
parts {
part { name:"elm.swallow.content"; type: SWALLOW;
description { state: "default" 0.0;
+ min: 240 0;
}
}
}
diff --git a/data/themes/edc/elm/scroller.edc b/data/themes/edc/elm/scroller.edc
index 10f1c2bae..2f3d699cc 100644
--- a/data/themes/edc/elm/scroller.edc
+++ b/data/themes/edc/elm/scroller.edc
@@ -1304,3 +1304,25 @@ group { name: "elm/scroller/contents/default";
}
}
}
+
+group { name: "elm/scroller/base/popup/no_inset_shadow";
+ inherit: "elm/scroller/base/default";
+ parts {
+ part { name: "elm.swallow.content"; type: SWALLOW;
+ description { state: "default" 0.0;
+ rel1.offset: 0 0;
+ rel2.offset: 0 0;
+ }
+ }
+ part { name: "inset";
+ description { state: "default" 0.0;
+ visible: 0;
+ }
+ }
+ part { name: "shadow";
+ description { state: "default" 0.0;
+ visible: 0;
+ }
+ }
+ }
+}
diff --git a/src/bin/test_popup.c b/src/bin/test_popup.c
index a2e576c1d..dcfba0eeb 100644
--- a/src/bin/test_popup.c
+++ b/src/bin/test_popup.c
@@ -13,6 +13,7 @@ typedef struct
static Evas_Object *g_popup = NULL;
static int times = 0;
+static Eina_Bool is_popup_scroll;
static Evas_Rel_Coord_Point _popup_point[POPUP_POINT_MAX] =
{
{ 0.01, 0.01 },
@@ -122,6 +123,7 @@ _popup_center_text_cb(void *data, Evas_Object *obj EINA_UNUSED,
Evas_Object *popup;
popup = elm_popup_add(data);
+ elm_popup_scrollable_set(popup, is_popup_scroll);
elm_object_text_set(popup, "This Popup has content area and "
"timeout value is 3 seconds");
elm_popup_timeout_set(popup, 3.0);
@@ -142,6 +144,7 @@ _popup_center_text_1button_cb(void *data, Evas_Object *obj EINA_UNUSED,
Evas_Object *btn;
popup = elm_popup_add(data);
+ elm_popup_scrollable_set(popup, is_popup_scroll);
elm_object_text_set(popup, "This Popup has content area and "
"action area set, action area has one button Close");
@@ -164,6 +167,7 @@ _popup_center_title_text_1button_cb(void *data, Evas_Object *obj EINA_UNUSED,
Evas_Object *btn;
popup = elm_popup_add(data);
+ elm_popup_scrollable_set(popup, is_popup_scroll);
// popup text
elm_object_text_set(popup, "This Popup has title area, content area and "
@@ -190,6 +194,7 @@ _popup_center_title_text_block_clicked_event_cb(void *data,
Evas_Object *popup;
popup = elm_popup_add(data);
+ elm_popup_scrollable_set(popup, is_popup_scroll);
evas_object_smart_callback_add(popup, "block,clicked", _block_clicked_cb,
NULL);
@@ -219,6 +224,7 @@ _popup_center_title_text_block_clicked_event_with_parent_cb(void *data,
evas_object_show(bg);
popup = elm_popup_add(bg);
+ elm_popup_scrollable_set(popup, is_popup_scroll);
evas_object_smart_callback_add(popup, "block,clicked",
_block_clicked_cb, bg);
@@ -244,6 +250,7 @@ _popup_bottom_title_text_3button_cb(void *data, Evas_Object *obj EINA_UNUSED,
char buf[256];
popup = elm_popup_add(data);
+ elm_popup_scrollable_set(popup, is_popup_scroll);
elm_popup_orient_set(popup, ELM_POPUP_ORIENT_BOTTOM);
// popup text
@@ -292,6 +299,8 @@ _popup_center_title_content_3button_cb(void *data, Evas_Object *obj EINA_UNUSED,
char buf[256];
popup = elm_popup_add(data);
+ if (is_popup_scroll)
+ elm_popup_scrollable_set(popup, is_popup_scroll);
// popup title
elm_object_part_text_set(popup, "title,text", "Title");
@@ -352,6 +361,8 @@ _popup_center_title_item_3button_cb(void *data, Evas_Object *obj EINA_UNUSED,
Evas_Object *popup, *icon1, *btn1, *btn2, *btn3;
popup = elm_popup_add(data);
+ if (is_popup_scroll)
+ elm_popup_scrollable_set(popup, is_popup_scroll);
// popup title
elm_object_part_text_set(popup, "title,text", "Title");
@@ -423,6 +434,8 @@ _popup_center_title_text_2button_restack_cb(void *data, Evas_Object *obj EINA_UN
Evas_Object *btn, *btn2;
popup = elm_popup_add(data);
+ if (is_popup_scroll)
+ elm_popup_scrollable_set(popup, is_popup_scroll);
evas_object_smart_callback_add(popup, "block,clicked",
_restack_block_clicked_cb, NULL);
@@ -466,6 +479,8 @@ _popup_center_text_1button_hide_show_cb(void *data, Evas_Object *obj EINA_UNUSED
}
g_popup = elm_popup_add(data);
+ if (is_popup_scroll)
+ elm_popup_scrollable_set(g_popup, is_popup_scroll);
elm_object_text_set(g_popup, "Hide this popup by using the button."
"When you click list item again, you can see this popup.");
@@ -513,6 +528,8 @@ _popup_center_text_3button_add_remove_button_cb(void *data,
int i;
popup = elm_popup_add(data);
+ if (is_popup_scroll)
+ elm_popup_scrollable_set(popup, is_popup_scroll);
// popup title
elm_object_part_text_set(popup, "title,text",
@@ -547,6 +564,8 @@ _popup_transparent_cb(void *data, Evas_Object *obj EINA_UNUSED,
Evas_Object *btn;
popup = elm_popup_add(data);
+ if (is_popup_scroll)
+ elm_popup_scrollable_set(popup, is_popup_scroll);
elm_object_style_set(popup, "transparent");
elm_object_text_set(popup, "This Popup has transparent background");
@@ -569,6 +588,8 @@ _popup_transparent_align_cb(void *data, Evas_Object *obj EINA_UNUSED,
Evas_Object *btn, *btn1;
popup = elm_popup_add(data);
+ if (is_popup_scroll)
+ elm_popup_scrollable_set(popup, is_popup_scroll);
elm_object_style_set(popup, "transparent");
elm_object_text_set(popup, "This Popup has transparent background");
@@ -610,6 +631,8 @@ _popup_center_title_list_content_1button_cb(void *data, Evas_Object *obj EINA_UN
Evas_Object *btn;
popup = elm_popup_add(data);
+ if (is_popup_scroll)
+ elm_popup_scrollable_set(popup, is_popup_scroll);
elm_object_part_text_set(popup, "title,text", "Title");
// list as a popup content
@@ -640,6 +663,8 @@ _popup_center_title_genlist_content_1button_cb(void *data, Evas_Object *obj EINA
int i;
popup = elm_popup_add(data);
+ if (is_popup_scroll)
+ elm_popup_scrollable_set(popup, is_popup_scroll);
elm_object_part_text_set(popup, "title,text", "Title");
Elm_Genlist_Item_Class *itc1 = elm_genlist_item_class_new();
@@ -686,6 +711,8 @@ _subpopup_cb(void *data, Evas_Object *obj EINA_UNUSED,
Evas_Object *btn, *btnclose;
popup = elm_popup_add(data);
+ if (is_popup_scroll)
+ elm_popup_scrollable_set(popup, is_popup_scroll);
elm_object_style_set(popup, "subpopup");
elm_object_part_text_set(popup, "title,text", "Title");
@@ -720,6 +747,8 @@ _popup_content_only_cb(void *data, Evas_Object *obj EINA_UNUSED,
Evas_Object *win = data;
popup = elm_popup_add(win);
+ if (is_popup_scroll)
+ elm_popup_scrollable_set(popup, is_popup_scroll);
bx = elm_box_add(popup);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -774,6 +803,12 @@ _focus_changed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
elm_win_focus_highlight_animate_set(data, check);
}
+static void
+_popup_scroll_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
+{
+ is_popup_scroll = elm_check_state_get(obj);
+}
+
void
test_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
@@ -849,6 +884,14 @@ test_popup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
evas_object_show(check);
evas_object_smart_callback_add(check, "changed", _focus_changed_cb, win);
+ check = elm_check_add(box);
+ elm_object_text_set(check, "Enable popup scroll");
+ evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, 0.0);
+ evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_box_pack_end(box, check);
+ evas_object_show(check);
+ evas_object_smart_callback_add(check, "changed", _popup_scroll_cb, NULL);
+
evas_object_resize(win, 480, 400);
evas_object_show(win);
}
diff --git a/src/lib/elc_popup.c b/src/lib/elc_popup.c
index aaeea80c1..c7926eed8 100644
--- a/src/lib/elc_popup.c
+++ b/src/lib/elc_popup.c
@@ -134,7 +134,7 @@ _scroller_size_calc(Evas_Object *obj)
ELM_POPUP_DATA_GET(obj, sd);
- if (!sd->items) return;
+ if (!sd->scroll && !sd->items) return;
sd->scr_size_recalc = EINA_FALSE;
sd->max_sc_h = -1;
@@ -348,7 +348,6 @@ _elm_popup_elm_widget_theme_apply(Eo *obj, Elm_Popup_Data *sd)
elm_layout_edje_get(VIEW(it)));
}
}
- _scroller_size_calc(obj);
}
if (sd->title_text)
{
@@ -359,6 +358,7 @@ _elm_popup_elm_widget_theme_apply(Eo *obj, Elm_Popup_Data *sd)
elm_layout_signal_emit(sd->main_layout, "elm,state,title,icon,visible", "elm");
_visuals_set(obj);
+ _scroller_size_calc(obj);
elm_layout_sizing_eval(obj);
/* access */
@@ -402,6 +402,31 @@ _elm_popup_elm_layout_sizing_eval(Eo *obj, Elm_Popup_Data *sd)
evas_object_size_hint_min_get(sd->scr, &minw, &minh);
evas_object_size_hint_max_get(sd->scr, &minw, &minh);
}
+ else if (sd->scroll && (sd->content || sd->text_content_obj))
+ {
+ double horizontal, vertical;
+ Evas_Coord w, h;
+
+ edje_object_message_signal_process(elm_layout_edje_get(sd->content_area));
+
+ elm_popup_align_get(obj, &horizontal, &vertical);
+ evas_object_geometry_get(elm_widget_parent_get(obj), NULL, NULL, &w, &h);
+
+ if (horizontal == ELM_NOTIFY_ALIGN_FILL)
+ minw = w;
+ if (vertical == ELM_NOTIFY_ALIGN_FILL)
+ minh = h;
+ edje_object_size_min_restricted_calc(elm_layout_edje_get(sd->content_area),
+ &minw, &minh, minw, minh);
+ evas_object_size_hint_min_set(sd->content_area, minw, minh);
+
+ if (minh > sd->max_sc_h)
+ evas_object_size_hint_min_set(sd->spacer, minw, sd->max_sc_h);
+ else
+ evas_object_size_hint_min_set(sd->spacer, minw, minh);
+
+ return;
+ }
edje_object_size_min_calc(elm_layout_edje_get(sd->main_layout), &minw, &minh);
@@ -560,38 +585,55 @@ _layout_change_cb(void *data EINA_UNUSED,
}
static void
-_list_add(Evas_Object *obj)
+_create_scroller(Evas_Object *obj)
{
char style[1024];
ELM_POPUP_DATA_GET(obj, sd);
- //Table
+ //table
sd->tbl = elm_table_add(sd->main_layout);
evas_object_event_callback_add(sd->tbl, EVAS_CALLBACK_DEL,
_on_table_del, obj);
- eo_do(sd->main_layout, elm_obj_container_content_set(CONTENT_PART, sd->tbl));
- evas_object_show(sd->tbl);
+ if (!sd->scroll)
+ {
+ eo_do(sd->content_area, elm_obj_container_content_set(CONTENT_PART, sd->tbl));
+ eo_do(sd->main_layout, elm_obj_container_content_set(CONTENT_PART, sd->content_area));
+ }
- //Spacer
+ //spacer
sd->spacer = evas_object_rectangle_add(evas_object_evas_get(obj));
evas_object_color_set(sd->spacer, 0, 0, 0, 0);
elm_table_pack(sd->tbl, sd->spacer, 0, 0, 1, 1);
//Scroller
- snprintf(style, sizeof(style), "popup/%s", elm_widget_style_get(obj));
sd->scr = elm_scroller_add(sd->tbl);
- elm_widget_style_set(sd->scr, style);
+ if (!sd->scroll)
+ {
+ snprintf(style, sizeof(style), "popup/%s", elm_widget_style_get(obj));
+ elm_object_style_set(sd->scr, style);
+ }
+ else
+ elm_object_style_set(sd->scr, "popup/no_inset_shadow");
+ evas_object_size_hint_weight_set(sd->scr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(sd->scr, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_scroller_policy_set(sd->scr, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
elm_scroller_content_min_limit(sd->scr, EINA_TRUE, EINA_FALSE);
elm_scroller_bounce_set(sd->scr, EINA_FALSE, EINA_TRUE);
- evas_object_size_hint_weight_set(sd->scr,
- EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(sd->scr, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_event_callback_add(sd->scr, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
- _size_hints_changed_cb, sd->main_layout);
+ _size_hints_changed_cb, obj);
elm_table_pack(sd->tbl, sd->scr, 0, 0, 1, 1);
evas_object_show(sd->scr);
+}
+
+static void
+_list_add(Evas_Object *obj)
+{
+ ELM_POPUP_DATA_GET(obj, sd);
+
+ if (!sd->scroll)
+ _create_scroller(obj);
//Box
sd->box = elm_box_add(sd->scr);
evas_object_size_hint_weight_set(sd->box, EVAS_HINT_EXPAND, 0.0);
@@ -889,7 +931,13 @@ _content_text_set(Evas_Object *obj,
_items_remove(sd);
_list_del(sd);
}
- else eo_do(sd->main_layout, elm_obj_container_content_set(CONTENT_PART, sd->content_area));
+ else
+ {
+ if (!sd->scroll)
+ eo_do(sd->main_layout, elm_obj_container_content_set(CONTENT_PART, sd->content_area));
+ else
+ elm_object_content_set(sd->scr, sd->content_area);
+ }
if (!text) goto end;
if (sd->text_content_obj)
@@ -1027,8 +1075,11 @@ _content_set(Evas_Object *obj,
sd->content = content;
if (content)
{
- eo_do(sd->main_layout, elm_obj_container_content_set
- (CONTENT_PART, sd->content_area));
+ if (!sd->scroll)
+ eo_do(sd->main_layout, elm_obj_container_content_set
+ (CONTENT_PART, sd->content_area));
+ else
+ elm_object_content_set(sd->scr, sd->content_area);
eo_do(sd->content_area, elm_obj_container_content_set
(CONTENT_PART, content));
@@ -1687,6 +1738,40 @@ _elm_popup_item_append(Eo *obj, Elm_Popup_Data *sd, const char *label, Evas_Obje
return eo_it;
}
+EOLIAN void
+_elm_popup_scrollable_set(Eo *obj, Elm_Popup_Data *pd, Eina_Bool scroll)
+{
+ scroll = !!scroll;
+ if (pd->scroll == scroll) return;
+ pd->scroll = scroll;
+
+ if (!pd->scr)
+ _create_scroller(obj);
+ else
+ {
+ elm_layout_content_unset(pd->scr, "elm.swallow.content");
+ ELM_SAFE_FREE(pd->tbl, evas_object_del);
+ _create_scroller(obj);
+ }
+
+ if (!pd->scroll)
+ {
+ eo_do(pd->content_area, elm_obj_container_content_set(CONTENT_PART, pd->tbl));
+ eo_do(pd->main_layout, elm_obj_container_content_set(CONTENT_PART, pd->content_area));
+ }
+ else
+ eo_do(pd->main_layout, elm_obj_container_content_set(CONTENT_PART, pd->tbl));
+
+ _scroller_size_calc(obj);
+ elm_layout_sizing_eval(obj);
+}
+
+EOLIAN Eina_Bool
+_elm_popup_scrollable_get(Eo *obj EINA_UNUSED, Elm_Popup_Data *pd)
+{
+ return pd->scroll;
+}
+
static void
_elm_popup_class_constructor(Eo_Class *klass)
{
diff --git a/src/lib/elm_popup.eo b/src/lib/elm_popup.eo
index 9ce41e5a0..67323e9d0 100644
--- a/src/lib/elm_popup.eo
+++ b/src/lib/elm_popup.eo
@@ -116,6 +116,27 @@ class Elm.Popup (Elm.Layout, Elm_Interface_Atspi_Widget_Action)
timeout: double; [[The timeout in seconds.]]
}
}
+ @property scrollable {
+ set {
+ [[Enable or disable scroller in popup content area
+
+ Normally content area does not contain scroller.
+
+ @since 1.16
+ ]]
+ }
+ get {
+ [[Get the scrollable state of popup content area
+
+ Normally content area does not contain scroller.
+
+ @since 1.16
+ ]]
+ }
+ values {
+ scroll: bool; [[$true if it is to be scrollable, $false otherwise.]]
+ }
+ }
item_append {
[[Add a new item to a Popup object
diff --git a/src/lib/elm_widget_popup.h b/src/lib/elm_widget_popup.h
index 6ffee43a3..6f13b0d76 100644
--- a/src/lib/elm_widget_popup.h
+++ b/src/lib/elm_widget_popup.h
@@ -53,6 +53,7 @@ struct _Elm_Popup_Data
Eina_Bool visible : 1;
Eina_Bool scr_size_recalc : 1;
+ Eina_Bool scroll : 1;
};
typedef struct _Elm_Popup_Item_Data Elm_Popup_Item_Data;