printf("ctxpopup direction: unknow!\n");
break;
}
+ printf(" [%s : %d] auto_hide_mode=%d\n", __func__, __LINE__, elm_ctxpopup_auto_hide_disabled_get(obj));
}
static void
}
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
_list_clicked(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
{
elm_list_item_selected_set(event_info, EINA_FALSE);
_list_item_cb6, NULL);
elm_list_item_append(list, "Ctxpopup with callback function", NULL, 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);
elm_list_go(list);
Eina_List *l;
Elm_Ctxpopup_Item *it;
- evas_object_hide(obj);
+ if (sd->auto_hide) evas_object_hide(obj);
EINA_LIST_FOREACH(sd->items, l, it)
elm_widget_item_translate(it);
_elm_ctxpopup_smart_sizing_eval(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
{
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_WIDGET_DATA_GET_OR_RETURN(obj, wd);
}
}
+ 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_resize(wd->resize_obj, rect.w, rect.h);
{
ELM_CTXPOPUP_DATA_GET(data, sd);
- sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+ if (sd->auto_hide)
+ {
+ sd->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
- evas_object_hide(data);
- evas_object_smart_callback_call(data, SIG_DISMISSED, NULL);
+ evas_object_hide(data);
+ evas_object_smart_callback_call(data, SIG_DISMISSED, NULL);
+ }
+ else
+ {
+ if (sd->visible)
+ elm_layout_sizing_eval(data);
+ }
}
static void
priv->dir_priority[2] = ELM_CTXPOPUP_DIRECTION_RIGHT;
priv->dir_priority[3] = ELM_CTXPOPUP_DIRECTION_DOWN;
priv->dir = ELM_CTXPOPUP_DIRECTION_UNKNOWN;
+ priv->auto_hide = EINA_TRUE;
priv->box = elm_box_add(obj);
evas_object_size_hint_weight_set
_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
_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_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_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_class_funcs_set(klass, func_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_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_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
};
static const Eo_Class_Description class_desc = {
ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_PRIORITY_GET,
ELM_OBJ_CTXPOPUP_SUB_ID_DIRECTION_GET,
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
};
* @ingroup Ctxpopup
*/
#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)
\ No newline at end of file
* emitted.
*/
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);