forked from enlightenment/efl
multibuttonentry: Add item long pressed callback.
Summary: Add long pressed callback for application. test code changed to following this change as well. @feature Reviewers: seoz, woohyun, Jaehyun, Hermet Differential Revision: https://phab.enlightenment.org/D2103 Conflicts: src/lib/elc_multibuttonentry.c
This commit is contained in:
parent
f6cd88650a
commit
93a4b8b4e3
|
@ -120,6 +120,16 @@ _shrink_state_changed_cb(void *data EINA_UNUSED,
|
||||||
printf("contracted state changed! \n");
|
printf("contracted state changed! \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "longpressed" smart callback
|
||||||
|
static void
|
||||||
|
_longpressed_cb(void *data EINA_UNUSED,
|
||||||
|
Evas_Object *obj EINA_UNUSED,
|
||||||
|
void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
printf("longpressed! \n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// "item verified" confirm callback
|
// "item verified" confirm callback
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_item_filter_cb(Evas_Object *obj EINA_UNUSED,
|
_item_filter_cb(Evas_Object *obj EINA_UNUSED,
|
||||||
|
@ -198,6 +208,7 @@ _add_multibuttonentry(Evas_Object *parent)
|
||||||
evas_object_smart_callback_add(mbe, "expanded", _expanded_cb, NULL);
|
evas_object_smart_callback_add(mbe, "expanded", _expanded_cb, NULL);
|
||||||
evas_object_smart_callback_add(mbe, "contracted", _contracted_cb, NULL);
|
evas_object_smart_callback_add(mbe, "contracted", _contracted_cb, NULL);
|
||||||
evas_object_smart_callback_add(mbe, "shrink,state,changed", _shrink_state_changed_cb, NULL);
|
evas_object_smart_callback_add(mbe, "shrink,state,changed", _shrink_state_changed_cb, NULL);
|
||||||
|
evas_object_smart_callback_add(mbe, "longpressed", _longpressed_cb, NULL);
|
||||||
|
|
||||||
btn = _format_change_btn_add(mbe);
|
btn = _format_change_btn_add(mbe);
|
||||||
elm_object_part_content_set(parent, "box", btn);
|
elm_object_part_content_set(parent, "box", btn);
|
||||||
|
|
|
@ -28,6 +28,7 @@ static const char SIG_UNFOCUSED[] = "unfocused";
|
||||||
static const char SIG_EXPANDED[] = "expanded";
|
static const char SIG_EXPANDED[] = "expanded";
|
||||||
static const char SIG_CONTRACTED[] = "contracted";
|
static const char SIG_CONTRACTED[] = "contracted";
|
||||||
static const char SIG_EXPAND_STATE_CHANGED[] = "expand,state,changed";
|
static const char SIG_EXPAND_STATE_CHANGED[] = "expand,state,changed";
|
||||||
|
static const char SIG_LONGPRESSED[] = "longpressed";
|
||||||
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
||||||
{SIG_ITEM_SELECTED, ""},
|
{SIG_ITEM_SELECTED, ""},
|
||||||
{SIG_ITEM_ADDED, ""},
|
{SIG_ITEM_ADDED, ""},
|
||||||
|
@ -39,6 +40,7 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
||||||
{SIG_EXPANDED, ""},
|
{SIG_EXPANDED, ""},
|
||||||
{SIG_CONTRACTED, ""},
|
{SIG_CONTRACTED, ""},
|
||||||
{SIG_EXPAND_STATE_CHANGED, ""},
|
{SIG_EXPAND_STATE_CHANGED, ""},
|
||||||
|
{SIG_LONGPRESSED, ""},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -513,6 +515,51 @@ _on_item_deleted(void *data,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_long_press_cb(void *data)
|
||||||
|
{
|
||||||
|
Elm_Multibuttonentry_Item_Data *it = data;
|
||||||
|
|
||||||
|
ELM_MULTIBUTTONENTRY_DATA_GET(WIDGET(it), sd);
|
||||||
|
|
||||||
|
sd->longpress_timer = NULL;
|
||||||
|
|
||||||
|
evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, EO_OBJ(it));
|
||||||
|
|
||||||
|
return ECORE_CALLBACK_CANCEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_mouse_down_cb(void *data,
|
||||||
|
Evas *evas EINA_UNUSED,
|
||||||
|
Evas_Object *obj EINA_UNUSED,
|
||||||
|
void *event_info)
|
||||||
|
{
|
||||||
|
Elm_Multibuttonentry_Item_Data *it = data;
|
||||||
|
Evas_Event_Mouse_Down *ev = event_info;
|
||||||
|
|
||||||
|
ELM_MULTIBUTTONENTRY_DATA_GET_OR_RETURN(WIDGET(it), sd);
|
||||||
|
|
||||||
|
if (ev->button != 1) return;
|
||||||
|
|
||||||
|
ecore_timer_del(sd->longpress_timer);
|
||||||
|
sd->longpress_timer = ecore_timer_add
|
||||||
|
(_elm_config->longpress_timeout, _long_press_cb, it);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_mouse_up_cb(void *data,
|
||||||
|
Evas *evas EINA_UNUSED,
|
||||||
|
Evas_Object *obj EINA_UNUSED,
|
||||||
|
void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
Elm_Multibuttonentry_Item_Data *it = data;
|
||||||
|
|
||||||
|
ELM_MULTIBUTTONENTRY_DATA_GET_OR_RETURN(WIDGET(it), sd);
|
||||||
|
|
||||||
|
ELM_SAFE_FREE(sd->longpress_timer, ecore_timer_del);
|
||||||
|
}
|
||||||
|
|
||||||
EOLIAN static void
|
EOLIAN static void
|
||||||
_elm_multibuttonentry_item_elm_widget_item_signal_emit(Eo *eo_item EINA_UNUSED,
|
_elm_multibuttonentry_item_elm_widget_item_signal_emit(Eo *eo_item EINA_UNUSED,
|
||||||
Elm_Multibuttonentry_Item_Data *item,
|
Elm_Multibuttonentry_Item_Data *item,
|
||||||
|
@ -664,6 +711,13 @@ _item_new(Elm_Multibuttonentry_Data *sd,
|
||||||
(VIEW(item), "mouse,clicked,1", "*", _on_item_clicked, EO_OBJ(item));
|
(VIEW(item), "mouse,clicked,1", "*", _on_item_clicked, EO_OBJ(item));
|
||||||
elm_layout_signal_callback_add
|
elm_layout_signal_callback_add
|
||||||
(VIEW(item), "elm,deleted", "elm", _on_item_deleted, EO_OBJ(item));
|
(VIEW(item), "elm,deleted", "elm", _on_item_deleted, EO_OBJ(item));
|
||||||
|
evas_object_event_callback_add
|
||||||
|
(VIEW(item),
|
||||||
|
EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, item);
|
||||||
|
evas_object_event_callback_add
|
||||||
|
(VIEW(item),
|
||||||
|
EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb, item);
|
||||||
|
|
||||||
evas_object_show(VIEW(item));
|
evas_object_show(VIEW(item));
|
||||||
|
|
||||||
evas_object_smart_calculate(VIEW(item));
|
evas_object_smart_calculate(VIEW(item));
|
||||||
|
@ -1466,6 +1520,7 @@ _elm_multibuttonentry_evas_object_smart_del(Eo *obj, Elm_Multibuttonentry_Data *
|
||||||
evas_object_del(sd->label);
|
evas_object_del(sd->label);
|
||||||
evas_object_del(sd->guide_text);
|
evas_object_del(sd->guide_text);
|
||||||
evas_object_del(sd->end);
|
evas_object_del(sd->end);
|
||||||
|
ecore_timer_del(sd->longpress_timer);
|
||||||
|
|
||||||
eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
|
eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
* - @c "contracted" - when multi-button entry is contracted.
|
* - @c "contracted" - when multi-button entry is contracted.
|
||||||
* - @c "expand,state,changed" - when shrink mode state of
|
* - @c "expand,state,changed" - when shrink mode state of
|
||||||
* multi-button entry is changed.
|
* multi-button entry is changed.
|
||||||
|
* - @c "longpressed" - when multi-button entry is pressed for a long time.
|
||||||
*
|
*
|
||||||
* Default text parts of the multi-button entry widget that you can use are:
|
* Default text parts of the multi-button entry widget that you can use are:
|
||||||
* @li "default" - A label of the multi-button entry
|
* @li "default" - A label of the multi-button entry
|
||||||
|
|
|
@ -280,6 +280,7 @@ class Elm_Multibuttonentry (Elm_Layout)
|
||||||
expanded;
|
expanded;
|
||||||
contracted;
|
contracted;
|
||||||
expand,state,changed;
|
expand,state,changed;
|
||||||
|
longpressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,14 +105,19 @@ struct _Elm_Multibuttonentry_Data
|
||||||
Eina_Bool last_it_select : 1;
|
Eina_Bool last_it_select : 1;
|
||||||
Eina_Bool editable : 1;
|
Eina_Bool editable : 1;
|
||||||
Eina_Bool focused : 1;
|
Eina_Bool focused : 1;
|
||||||
|
|
||||||
|
Ecore_Timer *longpress_timer;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define ELM_MULTIBUTTONENTRY_DATA_GET(o, sd) \
|
||||||
|
Elm_Multibuttonentry_Data *sd = eo_data_scope_get(o, ELM_MULTIBUTTONENTRY_CLASS);
|
||||||
|
|
||||||
#define ELM_MULTIBUTTONENTRY_DATA_GET_OR_RETURN(o, ptr) \
|
#define ELM_MULTIBUTTONENTRY_DATA_GET_OR_RETURN(o, ptr) \
|
||||||
Elm_Multibuttonentry_Data *ptr = eo_data_scope_get(o, ELM_MULTIBUTTONENTRY_CLASS); \
|
ELM_MULTIBUTTONENTRY_DATA_GET(o, ptr); \
|
||||||
if (EINA_UNLIKELY(!ptr)) \
|
if (EINA_UNLIKELY(!ptr)) \
|
||||||
{ \
|
{ \
|
||||||
CRI("No widget data for object %p (%s)", \
|
CRI("No widget data for object %p (%s)", \
|
||||||
|
|
Loading…
Reference in New Issue