forked from enlightenment/efl
elementary/naviframe - add elm_naviframe_item_pop_cb_set()
This commit is contained in:
parent
99ad5779de
commit
02cd629c71
|
@ -1118,3 +1118,7 @@
|
|||
|
||||
* Add the config ELM_THUMBSCROLL_HOLD_THRESHOLD.
|
||||
This is the number of pixels the range which can be scrolled, while the scroller is holed.
|
||||
|
||||
2013-03-07 ChunEon Park (Hermet)
|
||||
|
||||
* Add elm_naviframe_item_pop_cb_set().
|
||||
|
|
|
@ -47,6 +47,7 @@ Additions:
|
|||
* Add edje_object_message_signal_process before edje_object_size_min_restricted_calc.
|
||||
* Add elm_object_item_signal_callback_add(), elm_object_item_signal_callback_del().
|
||||
* Add the config ELM_THUMBSCROLL_HOLD_THRESHOLD.
|
||||
* Add elm_naviframe_item_pop_cb_set().
|
||||
|
||||
Improvements:
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
|||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static const char SIG_CLICKED[] = "clicked";
|
||||
|
||||
static void
|
||||
_item_content_del_cb(void *data,
|
||||
Evas *e __UNUSED__,
|
||||
|
@ -840,7 +842,7 @@ _on_item_back_btn_clicked(void *data,
|
|||
multiple times on some heavy environment. This callback del will
|
||||
prevent those scenario and guarantee only one clicked for it's own
|
||||
page. */
|
||||
evas_object_smart_callback_del(obj, "clicked", _on_item_back_btn_clicked);
|
||||
evas_object_smart_callback_del(obj, SIG_CLICKED, _on_item_back_btn_clicked);
|
||||
elm_naviframe_item_pop(data);
|
||||
}
|
||||
|
||||
|
@ -854,7 +856,7 @@ _back_btn_new(Evas_Object *obj, const char *title_label)
|
|||
|
||||
if (!btn) return NULL;
|
||||
evas_object_smart_callback_add
|
||||
(btn, "clicked", _on_item_back_btn_clicked, obj);
|
||||
(btn, SIG_CLICKED, _on_item_back_btn_clicked, obj);
|
||||
snprintf
|
||||
(buf, sizeof(buf), "naviframe/back_btn/%s", elm_widget_style_get(obj));
|
||||
elm_object_style_set(btn, buf);
|
||||
|
@ -1257,7 +1259,7 @@ _elm_naviframe_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
|
|||
|
||||
evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
||||
_on_obj_size_hints_changed, obj);
|
||||
elm_widget_can_focus_set(obj, EINA_FALSE);
|
||||
elm_widget_can_focus_set(obj, EINA_TRUE);
|
||||
|
||||
if (!elm_widget_sub_object_add(eo_parent_get(obj), obj))
|
||||
ERR("could not add %p as sub object of %p", obj, eo_parent_get(obj));
|
||||
|
@ -1311,6 +1313,31 @@ _elm_naviframe_smart_del(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
|
|||
eo_do_super(obj, evas_obj_smart_del());
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_naviframe_smart_event(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
|
||||
{
|
||||
Evas_Object *source = va_arg(*list, Evas_Object *);
|
||||
Evas_Callback_Type type = va_arg(*list, Evas_Callback_Type);
|
||||
Evas_Event_Key_Down *ev = va_arg(*list, Evas_Event_Key_Down *);
|
||||
Eina_Bool *ret = va_arg(*list, Eina_Bool *);
|
||||
Elm_Naviframe_Item *it;
|
||||
(void) source;
|
||||
|
||||
if (ret) *ret = EINA_FALSE;
|
||||
if (elm_widget_disabled_get(obj)) return;
|
||||
if (type != EVAS_CALLBACK_KEY_DOWN) return;
|
||||
if (strcmp(ev->keyname, "BackSpace")) return;
|
||||
|
||||
eo_do(obj, elm_obj_naviframe_top_item_get((Elm_Object_Item **)&it));
|
||||
if (!it) return;
|
||||
|
||||
if (it->title_prev_btn)
|
||||
evas_object_smart_callback_call(it->title_prev_btn, SIG_CLICKED, NULL);
|
||||
|
||||
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
|
||||
if (ret) *ret = EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_naviframe_smart_access(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
|
||||
{
|
||||
|
@ -1564,6 +1591,8 @@ _item_pop(Eo *obj, void *_pd, va_list *list)
|
|||
it = (Elm_Naviframe_Item *)elm_naviframe_top_item_get(obj);
|
||||
if (!it) return;
|
||||
|
||||
if (it->pop_cb) it->pop_cb(it->pop_data, (Elm_Object_Item *)it);
|
||||
|
||||
if (sd->preserve)
|
||||
content = it->content;
|
||||
|
||||
|
@ -1859,6 +1888,17 @@ elm_naviframe_item_title_visible_get(const Elm_Object_Item *it)
|
|||
return nit->title_visible;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_naviframe_item_pop_cb_set(Elm_Object_Item *it, Elm_Naviframe_Item_Pop_Cb func, void *data)
|
||||
{
|
||||
Elm_Naviframe_Item *nit = (Elm_Naviframe_Item *)it;
|
||||
|
||||
ELM_NAVIFRAME_ITEM_CHECK_OR_RETURN(it);
|
||||
|
||||
nit->pop_cb = func;
|
||||
nit->pop_data = data;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_naviframe_prev_btn_auto_pushed_set(Evas_Object *obj,
|
||||
Eina_Bool auto_pushed)
|
||||
|
@ -1973,6 +2013,7 @@ _class_constructor(Eo_Class *klass)
|
|||
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_FOCUS_NEXT), _elm_naviframe_smart_focus_next),
|
||||
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_THEME), _elm_naviframe_smart_theme),
|
||||
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_ACCESS), _elm_naviframe_smart_access),
|
||||
EO_OP_FUNC(ELM_WIDGET_ID(ELM_WIDGET_SUB_ID_EVENT), _elm_naviframe_smart_event),
|
||||
|
||||
EO_OP_FUNC(ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_SET), _elm_naviframe_smart_content_set),
|
||||
EO_OP_FUNC(ELM_OBJ_CONTAINER_ID(ELM_OBJ_CONTAINER_SUB_ID_CONTENT_GET), _elm_naviframe_smart_content_get),
|
||||
|
|
|
@ -286,6 +286,18 @@ enum
|
|||
*/
|
||||
#define elm_obj_naviframe_event_enabled_get(ret) ELM_OBJ_NAVIFRAME_ID(ELM_OBJ_NAVIFRAME_SUB_ID_EVENT_ENABLED_GET), EO_TYPECHECK(Eina_Bool *, ret)
|
||||
|
||||
/**
|
||||
* @typedef Elm_Naviframe_Item_Pop_Cb
|
||||
*
|
||||
* Pop callback called when @c it is going to be popped. @c data is user
|
||||
* specific data.
|
||||
*
|
||||
* @see elm_naviframe_item_pop_cb_set()
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
typedef void (*Elm_Naviframe_Item_Pop_Cb)(void *data, Elm_Object_Item *it);
|
||||
|
||||
/**
|
||||
* @addtogroup Naviframe
|
||||
* @{
|
||||
|
@ -408,6 +420,7 @@ EAPI Elm_Object_Item *elm_naviframe_item_insert_after(Evas_Object *obj, Elm_Obje
|
|||
* stack will become visible.
|
||||
*
|
||||
* @see also elm_naviframe_content_preserve_on_pop_get()
|
||||
* @see also elm_naviframe_item_pop_cb_set()
|
||||
*
|
||||
* @ingroup Naviframe
|
||||
*/
|
||||
|
@ -534,6 +547,22 @@ EAPI void elm_naviframe_item_title_visible_set(Elm_Object_Item *it,
|
|||
*/
|
||||
EAPI Eina_Bool elm_naviframe_item_title_visible_get(const Elm_Object_Item *it);
|
||||
|
||||
/**
|
||||
* @brief Set a function to be called when @c it of the naviframe is going to be
|
||||
* popped.
|
||||
*
|
||||
* @param it The item to set the callback on
|
||||
* @param func the callback function.
|
||||
*
|
||||
* @warning Don't set "clicked" callback to the prev button additionally if the
|
||||
* function does a exact same logic with this @c func. When hardware back key is
|
||||
* pressed then both callbacks will be called.
|
||||
*
|
||||
* @since 1.8
|
||||
* @ingroup Naviframe
|
||||
*/
|
||||
EAPI void elm_naviframe_item_pop_cb_set(Elm_Object_Item *it, Elm_Naviframe_Item_Pop_Cb func, void *data);
|
||||
|
||||
/**
|
||||
* @brief Set creating prev button automatically or not
|
||||
*
|
||||
|
|
|
@ -45,6 +45,8 @@ struct _Elm_Naviframe_Item
|
|||
Evas_Object *title_icon;
|
||||
Ecore_Animator *animator;
|
||||
Evas_Display_Mode dispmode;
|
||||
Elm_Naviframe_Item_Pop_Cb pop_cb;
|
||||
void *pop_data;
|
||||
const char *style;
|
||||
const char *title_label;
|
||||
const char *subtitle_label;
|
||||
|
|
Loading…
Reference in New Issue