summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBora Hwang <bora1.hwang@samsung.com>2014-02-09 18:11:47 +0900
committerDaniel Juyung Seo <seojuyung2@gmail.com>2014-02-09 18:11:47 +0900
commitf086ac9a971198d9991edee43d3c5db50a0db9da (patch)
tree6eff8c178138cc98d16c6e866b061fdb30d18009
parent625e63399da158d64ccf51a7e73a1ecb1dfd14f7 (diff)
ctxpopup: add a new api for ctxpopup which makes ctxpopup not to hide automatically
Summary: Developer can use this API for the case when he/she wants ctxpopup not to hide automatically when parent of ctxpopup is resized or language is changed. Default value of "disabled" is EINA_FALSE. So if user sets "disabled" EINA_TRUE and parent size changes, ctxpopup recalculates its size and position. Since size of bg is set when setting parent only, it should be resized again. Reviewers: Hermet, seoz, thiepha, raster CC: c Differential Revision: https://phab.enlightenment.org/D510
-rw-r--r--src/bin/test_ctxpopup.c29
-rw-r--r--src/lib/elc_ctxpopup.c63
-rw-r--r--src/lib/elc_ctxpopup_eo.h30
-rw-r--r--src/lib/elc_ctxpopup_legacy.h34
-rw-r--r--src/lib/elm_widget_ctxpopup.h1
5 files changed, 152 insertions, 5 deletions
diff --git a/src/bin/test_ctxpopup.c b/src/bin/test_ctxpopup.c
index 99f961eb7..4f807f6a7 100644
--- a/src/bin/test_ctxpopup.c
+++ b/src/bin/test_ctxpopup.c
@@ -35,6 +35,7 @@ _print_current_dir(Evas_Object *obj)
35 printf("ctxpopup direction: unknow!\n"); 35 printf("ctxpopup direction: unknow!\n");
36 break; 36 break;
37 } 37 }
38 printf(" [%s : %d] auto_hide_mode=%d\n", __func__, __LINE__, elm_ctxpopup_auto_hide_disabled_get(obj));
38} 39}
39 40
40static void 41static void
@@ -324,6 +325,32 @@ _list_item_cb7(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_U
324} 325}
325 326
326static void 327static void
328_list_item_cb8(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
329{
330 Evas_Object *ctxpopup;
331 Elm_Object_Item *it = NULL;
332 Evas_Coord x,y;
333
334 if (list_mouse_down > 0) return;
335
336 ctxpopup = elm_ctxpopup_add(obj);
337 evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed, NULL);
338 elm_ctxpopup_auto_hide_disabled_set(ctxpopup, EINA_TRUE);
339
340 _ctxpopup_item_new(ctxpopup, "Go to home folder", "home");
341 _ctxpopup_item_new(ctxpopup, "Save file", "file");
342 _ctxpopup_item_new(ctxpopup, "Delete file", "delete");
343 it = _ctxpopup_item_new(ctxpopup, "Navigate to folder", "folder");
344 elm_object_item_disabled_set(it, EINA_TRUE);
345 _ctxpopup_item_new(ctxpopup, "Edit entry", "edit");
346
347 evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
348 evas_object_move(ctxpopup, x, y);
349 evas_object_show(ctxpopup);
350 _print_current_dir(ctxpopup);
351}
352
353static void
327_list_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) 354_list_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
328{ 355{
329 elm_list_item_selected_set(event_info, EINA_FALSE); 356 elm_list_item_selected_set(event_info, EINA_FALSE);
@@ -380,6 +407,8 @@ test_ctxpopup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
380 _list_item_cb6, NULL); 407 _list_item_cb6, NULL);
381 elm_list_item_append(list, "Ctxpopup with callback function", NULL, NULL, 408 elm_list_item_append(list, "Ctxpopup with callback function", NULL, NULL,
382 _list_item_cb7, NULL); 409 _list_item_cb7, NULL);
410 elm_list_item_append(list, "Ctxpopup with auto hide disabled mode", NULL, NULL,
411 _list_item_cb8, NULL);
383 evas_object_show(list); 412 evas_object_show(list);
384 elm_list_go(list); 413 elm_list_go(list);
385 414
diff --git a/src/lib/elc_ctxpopup.c b/src/lib/elc_ctxpopup.c
index eb691c8d3..891fa490b 100644
--- a/src/lib/elc_ctxpopup.c
+++ b/src/lib/elc_ctxpopup.c
@@ -39,7 +39,7 @@ _elm_ctxpopup_smart_translate(Eo *obj, void *_pd, va_list *list)
39 Eina_List *l; 39 Eina_List *l;
40 Elm_Ctxpopup_Item *it; 40 Elm_Ctxpopup_Item *it;
41 41
42 evas_object_hide(obj); 42 if (sd->auto_hide) evas_object_hide(obj);
43 43
44 EINA_LIST_FOREACH(sd->items, l, it) 44 EINA_LIST_FOREACH(sd->items, l, it)
45 elm_widget_item_translate(it); 45 elm_widget_item_translate(it);
@@ -634,7 +634,7 @@ static void
634_elm_ctxpopup_smart_sizing_eval(Eo *obj, void *_pd, va_list *list EINA_UNUSED) 634_elm_ctxpopup_smart_sizing_eval(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
635{ 635{
636 Evas_Coord_Rectangle rect = { 0, 0, 1, 1 }; 636 Evas_Coord_Rectangle rect = { 0, 0, 1, 1 };
637 Evas_Coord_Point list_size = { 0, 0 }; 637 Evas_Coord_Point list_size = { 0, 0 }, parent_size = {0, 0};
638 638
639 Elm_Ctxpopup_Smart_Data *sd = _pd; 639 Elm_Ctxpopup_Smart_Data *sd = _pd;
640 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd); 640 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
@@ -660,6 +660,9 @@ _elm_ctxpopup_smart_sizing_eval(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
660 } 660 }
661 } 661 }
662 662
663 evas_object_geometry_get(sd->parent, NULL, NULL, &parent_size.x, &parent_size.y);
664 evas_object_resize(sd->bg, parent_size.x, parent_size.y);
665
663 evas_object_move(wd->resize_obj, rect.x, rect.y); 666 evas_object_move(wd->resize_obj, rect.x, rect.y);
664 evas_object_resize(wd->resize_obj, rect.w, rect.h); 667 evas_object_resize(wd->resize_obj, rect.w, rect.h);
665 668
@@ -696,10 +699,18 @@ _on_parent_resize(void *data,
696{ 699{
697 ELM_CTXPOPUP_DATA_GET(data, sd); 700 ELM_CTXPOPUP_DATA_GET(data, sd);
698 701
699 sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN; 702 if (sd->auto_hide)
703 {
704 sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
700 705
701 evas_object_hide(data); 706 evas_object_hide(data);
702 evas_object_smart_callback_call(data, SIG_DISMISSED, NULL); 707 evas_object_smart_callback_call(data, SIG_DISMISSED, NULL);
708 }
709 else
710 {
711 if (sd->visible)
712 elm_layout_sizing_eval(data);
713 }
703} 714}
704 715
705static void 716static void
@@ -1128,6 +1139,7 @@ _elm_ctxpopup_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
1128 priv->dir_priority[2] = ELM_CTXPOPUP_DIRECTION_RIGHT; 1139 priv->dir_priority[2] = ELM_CTXPOPUP_DIRECTION_RIGHT;
1129 priv->dir_priority[3] = ELM_CTXPOPUP_DIRECTION_DOWN; 1140 priv->dir_priority[3] = ELM_CTXPOPUP_DIRECTION_DOWN;
1130 priv->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN; 1141 priv->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
1142 priv->auto_hide = EINA_TRUE;
1131 1143
1132 priv->box = elm_box_add(obj); 1144 priv->box = elm_box_add(obj);
1133 evas_object_size_hint_weight_set 1145 evas_object_size_hint_weight_set
@@ -1478,6 +1490,43 @@ _dismiss(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
1478 _hide_signals_emit(obj, sd->dir); 1490 _hide_signals_emit(obj, sd->dir);
1479} 1491}
1480 1492
1493EAPI void
1494elm_ctxpopup_auto_hide_disabled_set(Evas_Object *obj, Eina_Bool disabled)
1495{
1496 ELM_CTXPOPUP_CHECK(obj);
1497 eo_do(obj, elm_obj_ctxpopup_auto_hide_disabled_set(disabled));
1498}
1499
1500static void
1501_auto_hide_disabled_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
1502{
1503 Eina_Bool disabled = va_arg(*list, int);
1504
1505 Elm_Ctxpopup_Smart_Data *sd = _pd;
1506
1507 disabled = !!disabled;
1508 if (sd->auto_hide == !disabled) return;
1509 sd->auto_hide = !disabled;
1510}
1511
1512EAPI Eina_Bool
1513elm_ctxpopup_auto_hide_disabled_get(const Evas_Object *obj)
1514{
1515 ELM_CTXPOPUP_CHECK(obj) EINA_FALSE;
1516 Eina_Bool ret = EINA_FALSE;
1517 eo_do((Eo *) obj, elm_obj_ctxpopup_auto_hide_disabled_get(&ret));
1518 return ret;
1519}
1520
1521static void
1522_auto_hide_disabled_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
1523{
1524 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
1525 Elm_Ctxpopup_Smart_Data *sd = _pd;
1526
1527 if (ret) *ret = sd->auto_hide;
1528}
1529
1481static void 1530static void
1482_class_constructor(Eo_Class *klass) 1531_class_constructor(Eo_Class *klass)
1483{ 1532{
@@ -1515,6 +1564,8 @@ _class_constructor(Eo_Class *klass)
1515 EO_OP_FUNC(ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_PRIORITY_GET), _direction_priority_get), 1564 EO_OP_FUNC(ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_PRIORITY_GET), _direction_priority_get),
1516 EO_OP_FUNC(ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_GET), _direction_get), 1565 EO_OP_FUNC(ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_GET), _direction_get),
1517 EO_OP_FUNC(ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_DISMISS), _dismiss), 1566 EO_OP_FUNC(ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_DISMISS), _dismiss),
1567 EO_OP_FUNC(ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_AUTO_HIDE_DISABLED_SET), _auto_hide_disabled_set),
1568 EO_OP_FUNC(ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_AUTO_HIDE_DISABLED_GET), _auto_hide_disabled_get),
1518 EO_OP_FUNC_SENTINEL 1569 EO_OP_FUNC_SENTINEL
1519 }; 1570 };
1520 eo_class_funcs_set(klass, func_desc); 1571 eo_class_funcs_set(klass, func_desc);
@@ -1532,6 +1583,8 @@ static const Eo_Op_Description op_desc[] = {
1532 EO_OP_DESCRIPTION(ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_PRIORITY_GET, "Get the direction priority of a ctxpopup."), 1583 EO_OP_DESCRIPTION(ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_PRIORITY_GET, "Get the direction priority of a ctxpopup."),
1533 EO_OP_DESCRIPTION(ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_GET, "Get the current direction of a ctxpopup."), 1584 EO_OP_DESCRIPTION(ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_GET, "Get the current direction of a ctxpopup."),
1534 EO_OP_DESCRIPTION(ELM_OBJ_CTXPOPUP_SUB_ID_DISMISS, "Dismiss a ctxpopup object."), 1585 EO_OP_DESCRIPTION(ELM_OBJ_CTXPOPUP_SUB_ID_DISMISS, "Dismiss a ctxpopup object."),
1586 EO_OP_DESCRIPTION(ELM_OBJ_CTXPOPUP_SUB_ID_AUTO_HIDE_DISABLED_SET, "Set ctxpopup auto hide mode triggered by ctxpopup policy"),
1587 EO_OP_DESCRIPTION(ELM_OBJ_CTXPOPUP_SUB_ID_AUTO_HIDE_DISABLED_GET, "Get ctxpopup auto hide mode triggered by ctxpopup policy"),
1535 EO_OP_DESCRIPTION_SENTINEL 1588 EO_OP_DESCRIPTION_SENTINEL
1536}; 1589};
1537static const Eo_Class_Description class_desc = { 1590static const Eo_Class_Description class_desc = {
diff --git a/src/lib/elc_ctxpopup_eo.h b/src/lib/elc_ctxpopup_eo.h
index a26d1919f..2bb93f40e 100644
--- a/src/lib/elc_ctxpopup_eo.h
+++ b/src/lib/elc_ctxpopup_eo.h
@@ -16,6 +16,8 @@ enum
16 ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_PRIORITY_GET, 16 ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_PRIORITY_GET,
17 ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_GET, 17 ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_GET,
18 ELM_OBJ_CTXPOPUP_SUB_ID_DISMISS, 18 ELM_OBJ_CTXPOPUP_SUB_ID_DISMISS,
19 ELM_OBJ_CTXPOPUP_SUB_ID_AUTO_HIDE_DISABLED_SET,
20 ELM_OBJ_CTXPOPUP_SUB_ID_AUTO_HIDE_DISABLED_GET,
19 ELM_OBJ_CTXPOPUP_SUB_ID_LAST 21 ELM_OBJ_CTXPOPUP_SUB_ID_LAST
20}; 22};
21 23
@@ -169,3 +171,31 @@ enum
169 * @ingroup Ctxpopup 171 * @ingroup Ctxpopup
170 */ 172 */
171#define elm_obj_ctxpopup_dismiss() ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_DISMISS) 173#define elm_obj_ctxpopup_dismiss() ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_DISMISS)
174
175/**
176 * @def elm_obj_ctxpopup_auto_hide_disabled_set
177 * @since 1.9
178 *
179 * @brief Set whether ctxpopup hide automatically or not by ctxpopup policy
180 *
181 * @param[in] disabled
182 *
183 * @see elm_ctxpopup_auto_hide_disabled_get
184 *
185 * @ingroup Ctxpopup
186 */
187#define elm_obj_ctxpopup_auto_hide_disabled_set(disabled) ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_AUTO_HIDE_DISABLED_SET), EO_TYPECHECK(Eina_Bool, disabled)
188
189/**
190 * @def elm_obj_ctxpopup_auto_hide_disabled_get
191 * @since 1.9
192 *
193 * @brief Get whether ctxpopup hide automatically or not by ctxpopup policy
194 *
195 * @param[out] ret
196 *
197 * @see elm_ctxpopup_auto_hide_disabled_set
198 *
199 * @ingroup Ctxpopup
200 */
201#define elm_obj_ctxpopup_auto_hide_disabled_get(ret) ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_AUTO_HIDE_DISABLED_GET), EO_TYPECHECK(Eina_Bool *, ret) \ No newline at end of file
diff --git a/src/lib/elc_ctxpopup_legacy.h b/src/lib/elc_ctxpopup_legacy.h
index 754182cbc..91aad2397 100644
--- a/src/lib/elc_ctxpopup_legacy.h
+++ b/src/lib/elc_ctxpopup_legacy.h
@@ -142,3 +142,37 @@ EAPI Elm_Ctxpopup_Direction elm_ctxpopup_direction_get(const Evas_Object *
142 * emitted. 142 * emitted.
143 */ 143 */
144EAPI void elm_ctxpopup_dismiss(Evas_Object *obj); 144EAPI void elm_ctxpopup_dismiss(Evas_Object *obj);
145
146/**
147 * @brief Set ctxpopup auto hide mode triggered by ctxpopup policy.
148 * @since 1.9
149 *
150 * @param obj The ctxpopup object
151 * @param disabled auto hide enable/disable.
152 *
153 * Use this function when user wants ctxpopup not to hide automatically.
154 * By default, ctxpopup is dismissed whenever mouse clicked its background area, language is changed,
155 * and its parent geometry is updated(changed).
156 * Not to hide ctxpopup automatically, disable auto hide function by calling this API,
157 * then ctxpopup won't be dismissed in those scenarios.
158 *
159 * Default value of disabled is @c EINA_FALSE.
160 *
161 * @see elm_ctxpopup_auto_hide_disabled_get()
162 *
163 * @ingroup Ctxpopup
164 */
165EAPI void elm_ctxpopup_auto_hide_disabled_set(Evas_Object *obj, Eina_Bool disabled);
166
167/**
168 * @brief Get ctxpopup auto hide mode triggered by ctxpopup policy.
169 * @since 1.9
170 *
171 * @param obj The ctxpopup object
172 * @return auto hide mode's state of a ctxpopup
173 *
174 * @see elm_ctxpopup_auto_hide_disabled_set() for more information.
175 *
176 * @ingroup Ctxpopup
177 */
178EAPI Eina_Bool elm_ctxpopup_auto_hide_disabled_get(const Evas_Object *obj);
diff --git a/src/lib/elm_widget_ctxpopup.h b/src/lib/elm_widget_ctxpopup.h
index ab681226c..cd10ffec5 100644
--- a/src/lib/elm_widget_ctxpopup.h
+++ b/src/lib/elm_widget_ctxpopup.h
@@ -53,6 +53,7 @@ struct _Elm_Ctxpopup_Smart_Data
53 Eina_Bool finished : 1; 53 Eina_Bool finished : 1;
54 Eina_Bool emitted : 1; 54 Eina_Bool emitted : 1;
55 Eina_Bool visible : 1; 55 Eina_Bool visible : 1;
56 Eina_Bool auto_hide : 1; /**< auto hide mode triggered by ctxpopup policy*/
56}; 57};
57 58
58/** 59/**