forked from enlightenment/efl
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
This commit is contained in:
parent
7899534662
commit
12a6a48e72
|
@ -35,6 +35,7 @@ _print_current_dir(Evas_Object *obj)
|
||||||
printf("ctxpopup direction: unknow!\n");
|
printf("ctxpopup direction: unknow!\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
printf(" [%s : %d] auto_hide_mode=%d\n", __func__, __LINE__, elm_ctxpopup_auto_hide_disabled_get(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -323,6 +324,32 @@ _list_item_cb7(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_U
|
||||||
_print_current_dir(ctxpopup);
|
_print_current_dir(ctxpopup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_list_item_cb8(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Evas_Object *ctxpopup;
|
||||||
|
Elm_Object_Item *it = NULL;
|
||||||
|
Evas_Coord x,y;
|
||||||
|
|
||||||
|
if (list_mouse_down > 0) return;
|
||||||
|
|
||||||
|
ctxpopup = elm_ctxpopup_add(obj);
|
||||||
|
evas_object_smart_callback_add(ctxpopup, "dismissed", _dismissed, NULL);
|
||||||
|
elm_ctxpopup_auto_hide_disabled_set(ctxpopup, EINA_TRUE);
|
||||||
|
|
||||||
|
_ctxpopup_item_new(ctxpopup, "Go to home folder", "home");
|
||||||
|
_ctxpopup_item_new(ctxpopup, "Save file", "file");
|
||||||
|
_ctxpopup_item_new(ctxpopup, "Delete file", "delete");
|
||||||
|
it = _ctxpopup_item_new(ctxpopup, "Navigate to folder", "folder");
|
||||||
|
elm_object_item_disabled_set(it, EINA_TRUE);
|
||||||
|
_ctxpopup_item_new(ctxpopup, "Edit entry", "edit");
|
||||||
|
|
||||||
|
evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
|
||||||
|
evas_object_move(ctxpopup, x, y);
|
||||||
|
evas_object_show(ctxpopup);
|
||||||
|
_print_current_dir(ctxpopup);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_list_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
|
_list_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||||
{
|
{
|
||||||
|
@ -380,6 +407,8 @@ test_ctxpopup(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
|
||||||
_list_item_cb6, NULL);
|
_list_item_cb6, NULL);
|
||||||
elm_list_item_append(list, "Ctxpopup with callback function", NULL, NULL,
|
elm_list_item_append(list, "Ctxpopup with callback function", NULL, NULL,
|
||||||
_list_item_cb7, NULL);
|
_list_item_cb7, NULL);
|
||||||
|
elm_list_item_append(list, "Ctxpopup with auto hide disabled mode", NULL, NULL,
|
||||||
|
_list_item_cb8, NULL);
|
||||||
evas_object_show(list);
|
evas_object_show(list);
|
||||||
elm_list_go(list);
|
elm_list_go(list);
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ _elm_ctxpopup_smart_translate(Eo *obj, void *_pd, va_list *list)
|
||||||
Eina_List *l;
|
Eina_List *l;
|
||||||
Elm_Ctxpopup_Item *it;
|
Elm_Ctxpopup_Item *it;
|
||||||
|
|
||||||
evas_object_hide(obj);
|
if (sd->auto_hide) evas_object_hide(obj);
|
||||||
|
|
||||||
EINA_LIST_FOREACH(sd->items, l, it)
|
EINA_LIST_FOREACH(sd->items, l, it)
|
||||||
elm_widget_item_translate(it);
|
elm_widget_item_translate(it);
|
||||||
|
@ -634,7 +634,7 @@ static void
|
||||||
_elm_ctxpopup_smart_sizing_eval(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
|
_elm_ctxpopup_smart_sizing_eval(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
|
||||||
{
|
{
|
||||||
Evas_Coord_Rectangle rect = { 0, 0, 1, 1 };
|
Evas_Coord_Rectangle rect = { 0, 0, 1, 1 };
|
||||||
Evas_Coord_Point list_size = { 0, 0 };
|
Evas_Coord_Point list_size = { 0, 0 }, parent_size = {0, 0};
|
||||||
|
|
||||||
Elm_Ctxpopup_Smart_Data *sd = _pd;
|
Elm_Ctxpopup_Smart_Data *sd = _pd;
|
||||||
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
evas_object_geometry_get(sd->parent, NULL, NULL, &parent_size.x, &parent_size.y);
|
||||||
|
evas_object_resize(sd->bg, parent_size.x, parent_size.y);
|
||||||
|
|
||||||
evas_object_move(wd->resize_obj, rect.x, rect.y);
|
evas_object_move(wd->resize_obj, rect.x, rect.y);
|
||||||
evas_object_resize(wd->resize_obj, rect.w, rect.h);
|
evas_object_resize(wd->resize_obj, rect.w, rect.h);
|
||||||
|
|
||||||
|
@ -696,10 +699,18 @@ _on_parent_resize(void *data,
|
||||||
{
|
{
|
||||||
ELM_CTXPOPUP_DATA_GET(data, sd);
|
ELM_CTXPOPUP_DATA_GET(data, sd);
|
||||||
|
|
||||||
|
if (sd->auto_hide)
|
||||||
|
{
|
||||||
sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
|
sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
|
||||||
|
|
||||||
evas_object_hide(data);
|
evas_object_hide(data);
|
||||||
evas_object_smart_callback_call(data, SIG_DISMISSED, NULL);
|
evas_object_smart_callback_call(data, SIG_DISMISSED, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (sd->visible)
|
||||||
|
elm_layout_sizing_eval(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1128,6 +1139,7 @@ _elm_ctxpopup_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
|
||||||
priv->dir_priority[2] = ELM_CTXPOPUP_DIRECTION_RIGHT;
|
priv->dir_priority[2] = ELM_CTXPOPUP_DIRECTION_RIGHT;
|
||||||
priv->dir_priority[3] = ELM_CTXPOPUP_DIRECTION_DOWN;
|
priv->dir_priority[3] = ELM_CTXPOPUP_DIRECTION_DOWN;
|
||||||
priv->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
|
priv->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
|
||||||
|
priv->auto_hide = EINA_TRUE;
|
||||||
|
|
||||||
priv->box = elm_box_add(obj);
|
priv->box = elm_box_add(obj);
|
||||||
evas_object_size_hint_weight_set
|
evas_object_size_hint_weight_set
|
||||||
|
@ -1478,6 +1490,43 @@ _dismiss(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
|
||||||
_hide_signals_emit(obj, sd->dir);
|
_hide_signals_emit(obj, sd->dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
elm_ctxpopup_auto_hide_disabled_set(Evas_Object *obj, Eina_Bool disabled)
|
||||||
|
{
|
||||||
|
ELM_CTXPOPUP_CHECK(obj);
|
||||||
|
eo_do(obj, elm_obj_ctxpopup_auto_hide_disabled_set(disabled));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_auto_hide_disabled_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
|
||||||
|
{
|
||||||
|
Eina_Bool disabled = va_arg(*list, int);
|
||||||
|
|
||||||
|
Elm_Ctxpopup_Smart_Data *sd = _pd;
|
||||||
|
|
||||||
|
disabled = !!disabled;
|
||||||
|
if (sd->auto_hide == !disabled) return;
|
||||||
|
sd->auto_hide = !disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI Eina_Bool
|
||||||
|
elm_ctxpopup_auto_hide_disabled_get(const Evas_Object *obj)
|
||||||
|
{
|
||||||
|
ELM_CTXPOPUP_CHECK(obj) EINA_FALSE;
|
||||||
|
Eina_Bool ret = EINA_FALSE;
|
||||||
|
eo_do((Eo *) obj, elm_obj_ctxpopup_auto_hide_disabled_get(&ret));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_auto_hide_disabled_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
|
||||||
|
{
|
||||||
|
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
|
||||||
|
Elm_Ctxpopup_Smart_Data *sd = _pd;
|
||||||
|
|
||||||
|
if (ret) *ret = sd->auto_hide;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_class_constructor(Eo_Class *klass)
|
_class_constructor(Eo_Class *klass)
|
||||||
{
|
{
|
||||||
|
@ -1515,6 +1564,8 @@ _class_constructor(Eo_Class *klass)
|
||||||
EO_OP_FUNC(ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_PRIORITY_GET), _direction_priority_get),
|
EO_OP_FUNC(ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_PRIORITY_GET), _direction_priority_get),
|
||||||
EO_OP_FUNC(ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_GET), _direction_get),
|
EO_OP_FUNC(ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_GET), _direction_get),
|
||||||
EO_OP_FUNC(ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_DISMISS), _dismiss),
|
EO_OP_FUNC(ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_DISMISS), _dismiss),
|
||||||
|
EO_OP_FUNC(ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_AUTO_HIDE_DISABLED_SET), _auto_hide_disabled_set),
|
||||||
|
EO_OP_FUNC(ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_AUTO_HIDE_DISABLED_GET), _auto_hide_disabled_get),
|
||||||
EO_OP_FUNC_SENTINEL
|
EO_OP_FUNC_SENTINEL
|
||||||
};
|
};
|
||||||
eo_class_funcs_set(klass, func_desc);
|
eo_class_funcs_set(klass, func_desc);
|
||||||
|
@ -1532,6 +1583,8 @@ static const Eo_Op_Description op_desc[] = {
|
||||||
EO_OP_DESCRIPTION(ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_PRIORITY_GET, "Get the direction priority of a ctxpopup."),
|
EO_OP_DESCRIPTION(ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_PRIORITY_GET, "Get the direction priority of a ctxpopup."),
|
||||||
EO_OP_DESCRIPTION(ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_GET, "Get the current direction of a ctxpopup."),
|
EO_OP_DESCRIPTION(ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_GET, "Get the current direction of a ctxpopup."),
|
||||||
EO_OP_DESCRIPTION(ELM_OBJ_CTXPOPUP_SUB_ID_DISMISS, "Dismiss a ctxpopup object."),
|
EO_OP_DESCRIPTION(ELM_OBJ_CTXPOPUP_SUB_ID_DISMISS, "Dismiss a ctxpopup object."),
|
||||||
|
EO_OP_DESCRIPTION(ELM_OBJ_CTXPOPUP_SUB_ID_AUTO_HIDE_DISABLED_SET, "Set ctxpopup auto hide mode triggered by ctxpopup policy"),
|
||||||
|
EO_OP_DESCRIPTION(ELM_OBJ_CTXPOPUP_SUB_ID_AUTO_HIDE_DISABLED_GET, "Get ctxpopup auto hide mode triggered by ctxpopup policy"),
|
||||||
EO_OP_DESCRIPTION_SENTINEL
|
EO_OP_DESCRIPTION_SENTINEL
|
||||||
};
|
};
|
||||||
static const Eo_Class_Description class_desc = {
|
static const Eo_Class_Description class_desc = {
|
||||||
|
|
|
@ -16,6 +16,8 @@ enum
|
||||||
ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_PRIORITY_GET,
|
ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_PRIORITY_GET,
|
||||||
ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_GET,
|
ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_GET,
|
||||||
ELM_OBJ_CTXPOPUP_SUB_ID_DISMISS,
|
ELM_OBJ_CTXPOPUP_SUB_ID_DISMISS,
|
||||||
|
ELM_OBJ_CTXPOPUP_SUB_ID_AUTO_HIDE_DISABLED_SET,
|
||||||
|
ELM_OBJ_CTXPOPUP_SUB_ID_AUTO_HIDE_DISABLED_GET,
|
||||||
ELM_OBJ_CTXPOPUP_SUB_ID_LAST
|
ELM_OBJ_CTXPOPUP_SUB_ID_LAST
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -169,3 +171,31 @@ enum
|
||||||
* @ingroup Ctxpopup
|
* @ingroup Ctxpopup
|
||||||
*/
|
*/
|
||||||
#define elm_obj_ctxpopup_dismiss() ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_DISMISS)
|
#define elm_obj_ctxpopup_dismiss() ELM_OBJ_CTXPOPUP_ID(ELM_OBJ_CTXPOPUP_SUB_ID_DISMISS)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def elm_obj_ctxpopup_auto_hide_disabled_set
|
||||||
|
* @since 1.9
|
||||||
|
*
|
||||||
|
* @brief Set whether ctxpopup hide automatically or not by ctxpopup policy
|
||||||
|
*
|
||||||
|
* @param[in] disabled
|
||||||
|
*
|
||||||
|
* @see elm_ctxpopup_auto_hide_disabled_get
|
||||||
|
*
|
||||||
|
* @ingroup Ctxpopup
|
||||||
|
*/
|
||||||
|
#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)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @def elm_obj_ctxpopup_auto_hide_disabled_get
|
||||||
|
* @since 1.9
|
||||||
|
*
|
||||||
|
* @brief Get whether ctxpopup hide automatically or not by ctxpopup policy
|
||||||
|
*
|
||||||
|
* @param[out] ret
|
||||||
|
*
|
||||||
|
* @see elm_ctxpopup_auto_hide_disabled_set
|
||||||
|
*
|
||||||
|
* @ingroup Ctxpopup
|
||||||
|
*/
|
||||||
|
#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)
|
|
@ -142,3 +142,37 @@ EAPI Elm_Ctxpopup_Direction elm_ctxpopup_direction_get(const Evas_Object *
|
||||||
* emitted.
|
* emitted.
|
||||||
*/
|
*/
|
||||||
EAPI void elm_ctxpopup_dismiss(Evas_Object *obj);
|
EAPI void elm_ctxpopup_dismiss(Evas_Object *obj);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set ctxpopup auto hide mode triggered by ctxpopup policy.
|
||||||
|
* @since 1.9
|
||||||
|
*
|
||||||
|
* @param obj The ctxpopup object
|
||||||
|
* @param disabled auto hide enable/disable.
|
||||||
|
*
|
||||||
|
* Use this function when user wants ctxpopup not to hide automatically.
|
||||||
|
* By default, ctxpopup is dismissed whenever mouse clicked its background area, language is changed,
|
||||||
|
* and its parent geometry is updated(changed).
|
||||||
|
* Not to hide ctxpopup automatically, disable auto hide function by calling this API,
|
||||||
|
* then ctxpopup won't be dismissed in those scenarios.
|
||||||
|
*
|
||||||
|
* Default value of disabled is @c EINA_FALSE.
|
||||||
|
*
|
||||||
|
* @see elm_ctxpopup_auto_hide_disabled_get()
|
||||||
|
*
|
||||||
|
* @ingroup Ctxpopup
|
||||||
|
*/
|
||||||
|
EAPI void elm_ctxpopup_auto_hide_disabled_set(Evas_Object *obj, Eina_Bool disabled);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get ctxpopup auto hide mode triggered by ctxpopup policy.
|
||||||
|
* @since 1.9
|
||||||
|
*
|
||||||
|
* @param obj The ctxpopup object
|
||||||
|
* @return auto hide mode's state of a ctxpopup
|
||||||
|
*
|
||||||
|
* @see elm_ctxpopup_auto_hide_disabled_set() for more information.
|
||||||
|
*
|
||||||
|
* @ingroup Ctxpopup
|
||||||
|
*/
|
||||||
|
EAPI Eina_Bool elm_ctxpopup_auto_hide_disabled_get(const Evas_Object *obj);
|
||||||
|
|
|
@ -53,6 +53,7 @@ struct _Elm_Ctxpopup_Smart_Data
|
||||||
Eina_Bool finished : 1;
|
Eina_Bool finished : 1;
|
||||||
Eina_Bool emitted : 1;
|
Eina_Bool emitted : 1;
|
||||||
Eina_Bool visible : 1;
|
Eina_Bool visible : 1;
|
||||||
|
Eina_Bool auto_hide : 1; /**< auto hide mode triggered by ctxpopup policy*/
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue