forked from enlightenment/efl
edje: add "mask_flags" instruction for "part" block
Summary: Elementary widgets dealing with Evas Events usually mask event_flags with EVAS_EVENT_FLAG_ON_HOLD, to show that this event is already handled. However, widget like Elm_Button, it does not handle EVAS_CALLBACK_MOUSE_DOWN directly, but it handles Edje_Signal instead, so there's no chance to mask event_flags. Developers can block event propagation by putting rectangle the very last part of EDC, but this instruction can help the case making elementary widget with only Edje_Signal handling. This is not required essentially, so please check the necessity of this function. Reviewers: Hermet, cedric Reviewed By: cedric Subscribers: cedric, Hermet Differential Revision: https://phab.enlightenment.org/D2764 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
ef491e697e
commit
2b29f4dfbf
|
@ -253,6 +253,7 @@ static void st_collections_group_parts_part_mouse_events(void);
|
|||
static void st_collections_group_parts_part_anti_alias(void);
|
||||
static void st_collections_group_parts_part_repeat_events(void);
|
||||
static void st_collections_group_parts_part_ignore_flags(void);
|
||||
static void st_collections_group_parts_part_mask_flags(void);
|
||||
static void st_collections_group_parts_part_scale(void);
|
||||
static void st_collections_group_parts_part_pointer_mode(void);
|
||||
static void st_collections_group_parts_part_precise_is_inside(void);
|
||||
|
@ -691,6 +692,7 @@ New_Statement_Handler statement_handlers[] =
|
|||
{"collections.group.parts.part.anti_alias", st_collections_group_parts_part_anti_alias},
|
||||
{"collections.group.parts.part.repeat_events", st_collections_group_parts_part_repeat_events},
|
||||
{"collections.group.parts.part.ignore_flags", st_collections_group_parts_part_ignore_flags},
|
||||
{"collections.group.parts.part.mask_flags", st_collections_group_parts_part_mask_flags},
|
||||
{"collections.group.parts.part.scale", st_collections_group_parts_part_scale},
|
||||
{"collections.group.parts.part.pointer_mode", st_collections_group_parts_part_pointer_mode},
|
||||
{"collections.group.parts.part.precise_is_inside", st_collections_group_parts_part_precise_is_inside},
|
||||
|
@ -983,6 +985,7 @@ New_Statement_Handler statement_handlers[] =
|
|||
before -> insert_before
|
||||
after -> insert_after
|
||||
ignore -> ignore_flags
|
||||
mask -> mask_flags
|
||||
pointer -> pointer_mode
|
||||
alt_font -> use_alternate_font_metrics
|
||||
clip -> clip_to
|
||||
|
@ -1006,6 +1009,7 @@ New_Statement_Handler statement_handlers_short[] =
|
|||
{"collections.group.parts.part.before", st_collections_group_parts_part_insert_before},
|
||||
{"collections.group.parts.part.after", st_collections_group_parts_part_insert_after},
|
||||
{"collections.group.parts.part.ignore", st_collections_group_parts_part_ignore_flags},
|
||||
{"collections.group.parts.part.mask", st_collections_group_parts_part_mask_flags},
|
||||
{"collections.group.parts.part.pointer", st_collections_group_parts_part_pointer_mode},
|
||||
{"collections.group.parts.part.alt_font", st_collections_group_parts_part_use_alternate_font_metrics},
|
||||
{"collections.group.parts.part.clip", st_collections_group_parts_part_clip_to_id},
|
||||
|
@ -3433,6 +3437,7 @@ _part_copy(Edje_Part *ep, Edje_Part *ep2)
|
|||
ep->anti_alias = ep2->anti_alias;
|
||||
ep->repeat_events = ep2->repeat_events;
|
||||
ep->ignore_flags = ep2->ignore_flags;
|
||||
ep->mask_flags = ep2->mask_flags;
|
||||
ep->scale = ep2->scale;
|
||||
ep->pointer_mode = ep2->pointer_mode;
|
||||
ep->precise_is_inside = ep2->precise_is_inside;
|
||||
|
@ -4422,6 +4427,7 @@ st_collections_group_parts_alias(void)
|
|||
mouse_events: 1;
|
||||
repeat_events: 0;
|
||||
ignore_flags: NONE;
|
||||
mask_flags: NONE;
|
||||
clip_to: "anotherpart";
|
||||
source: "groupname";
|
||||
pointer_mode: AUTOGRAB;
|
||||
|
@ -4473,6 +4479,7 @@ edje_cc_handlers_part_make(int id)
|
|||
ep->anti_alias = 1;
|
||||
ep->repeat_events = 0;
|
||||
ep->ignore_flags = EVAS_EVENT_FLAG_NONE;
|
||||
ep->mask_flags = EVAS_EVENT_FLAG_NONE;
|
||||
ep->scale = 0;
|
||||
ep->pointer_mode = EVAS_OBJECT_POINTER_MODE_AUTOGRAB;
|
||||
ep->precise_is_inside = 0;
|
||||
|
@ -5261,6 +5268,31 @@ st_collections_group_parts_part_ignore_flags(void)
|
|||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@page edcref
|
||||
@property
|
||||
mask_flags
|
||||
@parameters
|
||||
[FLAG] ...
|
||||
@effect
|
||||
Masks event flags with the given value, so event propagating from this part
|
||||
will go with masked flags. Other library, like Elementary, can determine
|
||||
whether it handles this event. Possible flags:
|
||||
@li NONE (default value, no event will be masked)
|
||||
@li ON_HOLD
|
||||
@endproperty
|
||||
*/
|
||||
static void
|
||||
st_collections_group_parts_part_mask_flags(void)
|
||||
{
|
||||
check_min_arg_count(1);
|
||||
|
||||
current_part->mask_flags = parse_flags(0,
|
||||
"NONE", EVAS_EVENT_FLAG_NONE,
|
||||
"ON_HOLD", EVAS_EVENT_FLAG_ON_HOLD,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@page edcref
|
||||
@property
|
||||
|
|
|
@ -351,6 +351,7 @@ _edje_collection_convert(Eet_File *ef, Edje_Part_Collection_Directory_Entry *ce,
|
|||
replacement->mouse_events = part->mouse_events;
|
||||
replacement->repeat_events = part->repeat_events;
|
||||
replacement->ignore_flags = part->ignore_flags;
|
||||
replacement->mask_flags = part->mask_flags;
|
||||
replacement->scale = part->scale;
|
||||
replacement->precise_is_inside = part->precise_is_inside;
|
||||
replacement->use_alternate_font_metrics = part->use_alternate_font_metrics;
|
||||
|
|
|
@ -102,6 +102,7 @@ struct _Old_Edje_Part
|
|||
unsigned char mouse_events; /* it will affect/respond to mouse events */
|
||||
unsigned char repeat_events; /* it will repeat events to objects below */
|
||||
Evas_Event_Flags ignore_flags;
|
||||
Evas_Event_Flags mask_flags;
|
||||
unsigned char scale; /* should certain properties scale with edje scale factor? */
|
||||
unsigned char precise_is_inside;
|
||||
unsigned char use_alternate_font_metrics;
|
||||
|
|
|
@ -399,6 +399,7 @@ _edje_edd_old_init(void)
|
|||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "anti_alias", anti_alias, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "repeat_events", repeat_events, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "ignore_flags", ignore_flags, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "mask_flags", mask_flags, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "scale", scale, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "pointer_mode", pointer_mode, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_old_edje_part, Old_Edje_Part, "precise_is_inside", precise_is_inside, EET_T_UCHAR);
|
||||
|
|
|
@ -1592,6 +1592,25 @@ EAPI Evas_Event_Flags edje_edit_part_ignore_flags_get(Evas_Object *obj, const ch
|
|||
*/
|
||||
EAPI Eina_Bool edje_edit_part_ignore_flags_set(Evas_Object *obj, const char *part, Evas_Event_Flags ignore_flags);
|
||||
|
||||
/** Get mask_flags for part.
|
||||
*
|
||||
* @param obj Object being edited.
|
||||
* @param part Part to get which event_flags are being masked.
|
||||
*
|
||||
* @return The Event flags set to the part.
|
||||
*/
|
||||
EAPI Evas_Event_Flags edje_edit_part_mask_flags_get(Evas_Object *obj, const char *part);
|
||||
|
||||
/** Set mask_flags for part.
|
||||
*
|
||||
* @param obj Object being edited.
|
||||
* @param part Part to set which event flags will be masked.
|
||||
* @param mask_flags The Event flags to be masked by the part.
|
||||
*
|
||||
* @return @c EINA_TRUE in case of success, @c EINA_FALSE otherwise.
|
||||
*/
|
||||
EAPI Eina_Bool edje_edit_part_mask_flags_set(Evas_Object *obj, const char *part, Evas_Event_Flags mask_flags);
|
||||
|
||||
/** Get pointer_mode of a part.
|
||||
*
|
||||
* @param obj Object being edited.
|
||||
|
|
|
@ -61,11 +61,14 @@ _edje_mouse_in_signal_cb(void *data, Eo *obj, const Eo_Event_Description *desc E
|
|||
ev = event_info;
|
||||
ed = data;
|
||||
rp = evas_object_data_get(obj, "real_part");
|
||||
if ((!rp) ||
|
||||
((ev->event_flags) &&
|
||||
(rp->part->ignore_flags & ev->event_flags))) return EO_CALLBACK_CONTINUE;
|
||||
if (rp)
|
||||
{
|
||||
if (!(ev->event_flags) || !(rp->part->ignore_flags & ev->event_flags))
|
||||
_edje_emit(ed, "mouse,in", rp->part->name);
|
||||
|
||||
ev->event_flags |= rp->part->mask_flags;
|
||||
}
|
||||
|
||||
return EO_CALLBACK_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -79,11 +82,14 @@ _edje_mouse_out_signal_cb(void *data, Eo *obj, const Eo_Event_Description *desc
|
|||
ev = event_info;
|
||||
ed = data;
|
||||
rp = evas_object_data_get(obj, "real_part");
|
||||
if ((!rp) ||
|
||||
((ev->event_flags) &&
|
||||
(rp->part->ignore_flags & ev->event_flags))) return EO_CALLBACK_CONTINUE;
|
||||
if (rp)
|
||||
{
|
||||
if (!(ev->event_flags) || !(rp->part->ignore_flags & ev->event_flags))
|
||||
_edje_emit(ed, "mouse,out", rp->part->name);
|
||||
|
||||
ev->event_flags |= rp->part->mask_flags;
|
||||
}
|
||||
|
||||
return EO_CALLBACK_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -153,6 +159,8 @@ _edje_mouse_down_signal_cb(void *data, Eo *obj, const Eo_Event_Description *desc
|
|||
_edje_util_thaw(ed);
|
||||
_edje_unref(ed);
|
||||
|
||||
ev->event_flags |= rp->part->mask_flags;
|
||||
|
||||
return EO_CALLBACK_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -226,6 +234,8 @@ _edje_mouse_up_signal_cb(void *data, Eo *obj, const Eo_Event_Description *desc E
|
|||
_edje_util_thaw(ed);
|
||||
_edje_unref(ed);
|
||||
|
||||
ev->event_flags |= rp->part->mask_flags;
|
||||
|
||||
return EO_CALLBACK_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -323,6 +333,8 @@ _edje_mouse_move_signal_cb(void *data, Eo *obj, const Eo_Event_Description *desc
|
|||
_edje_unref(ed);
|
||||
_edje_util_thaw(ed);
|
||||
|
||||
ev->event_flags |= rp->part->mask_flags;
|
||||
|
||||
return EO_CALLBACK_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -337,12 +349,16 @@ _edje_mouse_wheel_signal_cb(void *data, Eo *obj, const Eo_Event_Description *des
|
|||
ev = event_info;
|
||||
ed = data;
|
||||
rp = evas_object_data_get(obj, "real_part");
|
||||
if ((!rp) ||
|
||||
((ev->event_flags) &&
|
||||
(!(rp->part->ignore_flags & ev->event_flags)))) return EO_CALLBACK_CONTINUE;
|
||||
|
||||
if (rp)
|
||||
{
|
||||
if (!(ev->event_flags) || !(rp->part->ignore_flags & ev->event_flags))
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "mouse,wheel,%i,%i", ev->direction, (ev->z < 0) ? (-1) : (1));
|
||||
_edje_emit(ed, buf, rp->part->name);
|
||||
}
|
||||
|
||||
ev->event_flags |= rp->part->mask_flags;
|
||||
}
|
||||
|
||||
return EO_CALLBACK_CONTINUE;
|
||||
}
|
||||
|
|
|
@ -392,6 +392,7 @@ case EDJE_PART_TYPE_##Tp: \
|
|||
replacement->mouse_events = part->mouse_events;
|
||||
replacement->repeat_events = part->repeat_events;
|
||||
replacement->ignore_flags = part->ignore_flags;
|
||||
replacement->mask_flags = part->mask_flags;
|
||||
replacement->scale = part->scale;
|
||||
replacement->precise_is_inside = part->precise_is_inside;
|
||||
replacement->use_alternate_font_metrics = part->use_alternate_font_metrics;
|
||||
|
|
|
@ -127,6 +127,7 @@ struct _Old_Edje_Part
|
|||
unsigned char mouse_events; /**< it will affect/respond to mouse events */
|
||||
unsigned char repeat_events; /**< it will repeat events to objects below */
|
||||
Evas_Event_Flags ignore_flags; /**< ignore flags */
|
||||
Evas_Event_Flags mask_flags; /**< mask flags */
|
||||
unsigned char scale; /**< should certain properties scale with edje scale factor? */
|
||||
unsigned char precise_is_inside; /**< whether is precisely inside */
|
||||
unsigned char use_alternate_font_metrics; /**< use alternate font metrics */
|
||||
|
|
|
@ -1222,6 +1222,7 @@ _edje_edd_init(void)
|
|||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "anti_alias", anti_alias, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "repeat_events", repeat_events, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "ignore_flags", ignore_flags, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "mask_flags", mask_flags, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "scale", scale, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_SUB_NESTED(_edje_edd_edje_part, Edje_Part, "scale_3d", scale_3d, _edje_edd_edje_part_description_3d_vec);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part, Edje_Part, "precise_is_inside", precise_is_inside, EET_T_UCHAR);
|
||||
|
|
|
@ -3094,6 +3094,7 @@ _edje_edit_real_part_add(Evas_Object *obj, const char *name, Edje_Part_Type type
|
|||
ep->repeat_events = 0;
|
||||
ep->anti_alias = 1;
|
||||
ep->ignore_flags = EVAS_EVENT_FLAG_NONE;
|
||||
ep->mask_flags = EVAS_EVENT_FLAG_NONE;
|
||||
ep->pointer_mode = EVAS_OBJECT_POINTER_MODE_AUTOGRAB;
|
||||
ep->precise_is_inside = 0;
|
||||
ep->use_alternate_font_metrics = 0;
|
||||
|
@ -3366,6 +3367,7 @@ edje_edit_part_copy(Evas_Object *obj, const char *part, const char *new_copy)
|
|||
_PARAM_PART_COPY(mouse_events)
|
||||
_PARAM_PART_COPY(repeat_events)
|
||||
_PARAM_PART_COPY(ignore_flags)
|
||||
_PARAM_PART_COPY(mask_flags)
|
||||
_PARAM_PART_COPY(pointer_mode)
|
||||
_PARAM_PART_COPY(precise_is_inside)
|
||||
_PARAM_PART_COPY(use_alternate_font_metrics)
|
||||
|
@ -3878,6 +3880,25 @@ edje_edit_part_ignore_flags_set(Evas_Object *obj, const char *part, Evas_Event_F
|
|||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Evas_Event_Flags
|
||||
edje_edit_part_mask_flags_get(Evas_Object *obj, const char *part)
|
||||
{
|
||||
GET_RP_OR_RETURN(0);
|
||||
|
||||
return rp->part->mask_flags;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
edje_edit_part_mask_flags_set(Evas_Object *obj, const char *part, Evas_Event_Flags mask_flags)
|
||||
{
|
||||
GET_RP_OR_RETURN(EINA_FALSE);
|
||||
|
||||
if (!rp->object) return EINA_FALSE;
|
||||
|
||||
rp->part->mask_flags = mask_flags;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Evas_Object_Pointer_Mode
|
||||
edje_edit_part_pointer_mode_get(Evas_Object *obj, const char *part)
|
||||
{
|
||||
|
@ -11354,6 +11375,8 @@ _edje_generate_source_of_part(Evas_Object *obj, Edje_Part *ep, Eina_Strbuf *buf)
|
|||
|
||||
if (rp->part->ignore_flags)
|
||||
BUF_APPENDF(I4 "ignore_flags: \"ON_HOLD\";\n");
|
||||
if (rp->part->mask_flags)
|
||||
BUF_APPENDF(I4 "mask_flags: \"ON_HOLD\";\n");
|
||||
if (rp->part->pointer_mode == EVAS_OBJECT_POINTER_MODE_NOGRAB)
|
||||
BUF_APPEND(I4 "pointer_mode: NOGRAB;\n");
|
||||
if (rp->part->precise_is_inside)
|
||||
|
|
|
@ -746,6 +746,7 @@ _edje_anchor_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EIN
|
|||
snprintf(buf, len, "anchor,mouse,down,%i,%s", ev->button, n);
|
||||
_edje_emit(ed, buf, rp->part->name);
|
||||
}
|
||||
ev->event_flags |= rp->part->mask_flags;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -783,6 +784,7 @@ _edje_anchor_mouse_up_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
|
|||
snprintf(buf, len, "anchor,mouse,clicked,%i,%s", ev->button, n);
|
||||
_edje_emit(ed, buf, rp->part->name);
|
||||
}
|
||||
ev->event_flags |= rp->part->mask_flags;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -814,6 +816,7 @@ _edje_anchor_mouse_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EIN
|
|||
snprintf(buf, len, "anchor,mouse,move,%s", n);
|
||||
_edje_emit(ed, buf, rp->part->name);
|
||||
}
|
||||
ev->event_flags |= rp->part->mask_flags;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -841,6 +844,7 @@ _edje_anchor_mouse_in_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_
|
|||
snprintf(buf, len, "anchor,mouse,in,%s", n);
|
||||
_edje_emit(ed, buf, rp->part->name);
|
||||
}
|
||||
ev->event_flags |= rp->part->mask_flags;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -868,6 +872,7 @@ _edje_anchor_mouse_out_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA
|
|||
snprintf(buf, len, "anchor,mouse,out,%s", n);
|
||||
_edje_emit(ed, buf, rp->part->name);
|
||||
}
|
||||
ev->event_flags |= rp->part->mask_flags;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -1130,6 +1130,7 @@ struct _Edje_Part
|
|||
unsigned char repeat_events; /* it will repeat events to objects below */
|
||||
unsigned char anti_alias;
|
||||
Evas_Event_Flags ignore_flags;
|
||||
Evas_Event_Flags mask_flags;
|
||||
unsigned char scale; /* should certain properties scale with edje scale factor? */
|
||||
Edje_3D_Vec scale_3d;
|
||||
unsigned char precise_is_inside;
|
||||
|
|
Loading…
Reference in New Issue