edje: Add support for map zoom to use other part center.

Summary:
Current:
In edc, zoom is supposed to happen from object center, there is no way to
change the center of the zoom.

Changes:
Adding support to change the center of zooming just like map rotation by using
other part's center.

@feature

Reviewers: cedric, zmike

Reviewed By: zmike

Subscribers: zmike, cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9115
This commit is contained in:
Subodh Kumar 2019-07-12 11:58:35 -04:00 committed by Mike Blumenkrantz
parent a9504b9e75
commit 2854702f8e
8 changed files with 199 additions and 8 deletions

View File

@ -497,6 +497,7 @@ static void st_collections_group_parts_part_description_map_perspective_on
static void st_collections_group_parts_part_description_map_color(void);
static void st_collections_group_parts_part_description_map_zoom_x(void);
static void st_collections_group_parts_part_description_map_zoom_y(void);
static void st_collections_group_parts_part_description_map_zoom_center(void);
static void st_collections_group_parts_part_description_perspective_zplane(void);
static void st_collections_group_parts_part_description_perspective_focal(void);
static void st_collections_group_parts_part_api(void);
@ -1029,6 +1030,7 @@ New_Statement_Handler statement_handlers[] =
{"collections.group.parts.part.description.map.color", st_collections_group_parts_part_description_map_color},
{"collections.group.parts.part.description.map.zoom.x", st_collections_group_parts_part_description_map_zoom_x},
{"collections.group.parts.part.description.map.zoom.y", st_collections_group_parts_part_description_map_zoom_y},
{"collections.group.parts.part.description.map.zoom.center", st_collections_group_parts_part_description_map_zoom_center},
{"collections.group.parts.part.description.perspective.zplane", st_collections_group_parts_part_description_perspective_zplane},
{"collections.group.parts.part.description.perspective.focal", st_collections_group_parts_part_description_perspective_focal},
{"collections.group.parts.part.description.params.int", st_collections_group_parts_part_description_params_int},
@ -6447,6 +6449,7 @@ _part_desc_free(Edje_Part_Collection *pc,
part_lookup_del(pc, &(ed->map.id_persp));
part_lookup_del(pc, &(ed->map.id_light));
part_lookup_del(pc, &(ed->map.rot.id_center));
part_lookup_del(pc, &(ed->map.zoom.id_center));
switch (ep->type)
{
@ -8600,6 +8603,7 @@ ob_collections_group_parts_part_description(void)
ed->map.id_persp = -1;
ed->map.id_light = -1;
ed->map.rot.id_center = -1;
ed->map.zoom.id_center = -1;
ed->map.rot.x = FROM_DOUBLE(0.0);
ed->map.rot.y = FROM_DOUBLE(0.0);
ed->map.rot.z = FROM_DOUBLE(0.0);
@ -8759,6 +8763,7 @@ st_collections_group_parts_part_description_inherit(void)
data_queue_copied_part_lookup(pc, &parent->map.id_persp, &ed->map.id_persp);
data_queue_copied_part_lookup(pc, &parent->map.id_light, &ed->map.id_light);
data_queue_copied_part_lookup(pc, &parent->map.rot.id_center, &ed->map.rot.id_center);
data_queue_copied_part_lookup(pc, &parent->map.zoom.id_center, &ed->map.zoom.id_center);
/* make sure all the allocated memory is getting copied, not just
* referenced
@ -14294,6 +14299,57 @@ st_collections_group_parts_part_description_map_light(void)
}
}
/** @edcsubsection{collections_group_parts_description_map_zoom,
* Group.Parts.Part.Description.Map.Zoom} */
/**
@page edcref
@block
rotation
@context
map {
..
zoom {
center: "name";
x: 1.0;
y: 1.0;
}
..
}
@description
Zooms the part, optionally from the center on another part.
@endblock
@property
center
@parameters
[another part's name]
@effect
This sets the part that is used as the center of zoom when
zooming the part with this description. The part's center point
is used as the zoom center when applying zoom from the
x and y axes. If no center is given, the parts original center
itself is used for the zoom center.
@endproperty
*/
static void
st_collections_group_parts_part_description_map_zoom_center(void)
{
Edje_Part_Collection *pc;
check_arg_count(1);
pc = eina_list_data_get(eina_list_last(edje_collections));
{
char *name;
name = parse_str(0);
data_queue_part_lookup(pc, name, &(current_desc->map.zoom.id_center));
free(name);
}
}
/**
@page edcref
@property

View File

@ -48,7 +48,8 @@ edje/swallow.edc \
edje/table.edc \
edje/text.edc \
edje/textblock-hyphen.edc \
edje/toggle_using_filter.edc
edje/toggle_using_filter.edc \
edje/center_zoom.edc
MULTISENSE_EDCS = edje/multisense.edc
if ENABLE_MULTISENSE

View File

@ -0,0 +1,105 @@
collections {
group { name: "center_zoom_example";
min: 360 360;
max: 360 360;
parts {
part {
name: "bg";
type: RECT;
description {
state: "default" 0.0;
color: 0 0 0 255;
}
}
part {
name: "center_part";
type: RECT;
description {
state: "default" 0.0;
min: 25 25;
max: 25 25;
rel1.to:"bg";
rel2 {
relative: 1.0 0.5;
to: "bg";
}
}
}
part {
name: "rectangle";
type: RECT;
description {
state: "default" 0.0;
color: 0 0 255 128;
max: 150 150;
rel1 {
to: "bg";
}
rel2 {
to: "bg";
}
map {
on: 1;
zoom {
center: "center_part";
x: 0.0;
y: 0.0;
}
}
}
description {
state: "zoom" 0.0;
inherit: "default" 0.0;
map {
on: 1;
zoom {
center: "center_part";
x: 1;
y: 1;
}
}
}
}
part {
name: "title";
type: TEXT;
description {
state: "default" 0.0;
color: 200 200 200 255;
align: 0.5 0.0;
rel1.to:"bg";
rel2 {
relative: 1.0 0.0;
to: "bg";
}
text {
text: "Center Zoom Example";
font: "Sans";
size: 16;
min: 1 1;
}
}
}
part {
name: "event";
type: RECT;
mouse_events: 1;
description {
state: "default" 0.0;
color: 0 0 0 0;
}
}
}
programs {
program {
name: "move,bottom";
signal: "mouse,up,1";
source: "event";
action: STATE_SET "zoom" 0.0;
transition: LINEAR 1.0;
target: "rectangle";
}
}
}
}

View File

@ -44,6 +44,7 @@ edc_files = [
'textblock-hyphen.edc',
'toggle_using_filter.edc',
'multisense.edc',
'center_zoom.edc',
]
if (get_option('physics'))

View File

@ -8,8 +8,11 @@ static void _edje_part_make_rtl(Edje_Part_Description_C
static Edje_Part_Description_Common *_edje_get_description_by_orientation(Edje *ed, Edje_Part_Description_Common *src, Edje_Part_Description_Common **dst, unsigned char type);
static void _edje_part_recalc_single(Edje *ed, Edje_Real_Part *ep,
Edje_Part_Description_Common *desc, Edje_Part_Description_Common *chosen_desc,
Edje_Real_Part *center, Edje_Real_Part *light, Edje_Real_Part *persp,
Edje_Part_Description_Common *desc,
Edje_Part_Description_Common *chosen_desc,
Edje_Real_Part *center,
Edje_Real_Part *zoom_center,
Edje_Real_Part *light, Edje_Real_Part *persp,
Edje_Real_Part *rel1_to_x, Edje_Real_Part *rel1_to_y,
Edje_Real_Part *rel2_to_x, Edje_Real_Part *rel2_to_y,
Edje_Real_Part *clip_to,
@ -2279,6 +2282,7 @@ static void
_edje_part_recalc_single_map(Edje *ed,
Edje_Real_Part *ep EINA_UNUSED,
Edje_Real_Part *center,
Edje_Real_Part *zoom_center,
Edje_Real_Part *light,
Edje_Real_Part *persp,
Edje_Part_Description_Common *desc,
@ -2293,6 +2297,7 @@ _edje_part_recalc_single_map(Edje *ed,
EINA_COW_CALC_MAP_BEGIN(params, params_write)
{
//rotation center
if (center)
{
params_write->center.x = ed->x + center->x + (center->w / 2);
@ -2304,6 +2309,17 @@ _edje_part_recalc_single_map(Edje *ed,
params_write->center.y = ed->y + params->final.y + (params->final.h / 2);
}
params_write->center.z = 0;
//zoom center
if (zoom_center)
{
params_write->zoom_center.x = ed->x + zoom_center->x + (zoom_center->w / 2);
params_write->zoom_center.y = ed->y + zoom_center->y + (zoom_center->h / 2);
}
else
{
params_write->zoom_center.x = ed->x + params->final.x + (params->final.w / 2);
params_write->zoom_center.y = ed->y + params->final.y + (params->final.h / 2);
}
params_write->rotation.x = desc->map.rot.x;
params_write->rotation.y = desc->map.rot.y;
@ -2680,6 +2696,7 @@ _edje_part_recalc_single(Edje *ed,
Edje_Part_Description_Common *desc,
Edje_Part_Description_Common *chosen_desc,
Edje_Real_Part *center,
Edje_Real_Part *zoom_center,
Edje_Real_Part *light,
Edje_Real_Part *persp,
Edje_Real_Part *rel1_to_x,
@ -3056,7 +3073,7 @@ _edje_part_recalc_single(Edje *ed,
EINA_COW_CALC_PHYSICS_END(params, params_write);
}
#endif
_edje_part_recalc_single_map(ed, ep, center, light, persp, desc, chosen_desc, params);
_edje_part_recalc_single_map(ed, ep, center, zoom_center, light, persp, desc, chosen_desc, params);
}
static void
@ -3616,7 +3633,7 @@ _edje_map_prop_set(Evas_Map *map, const Edje_Calc_Params *pf,
//zoom
evas_map_util_zoom(map,
pf->ext->map->zoom.x, pf->ext->map->zoom.y,
pf->ext->map->center.x, pf->ext->map->center.y);
pf->ext->map->zoom_center.x, pf->ext->map->zoom_center.y);
//rotate
evas_map_util_3d_rotate(map,
@ -3853,6 +3870,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
int statep2 = -1;
int statecl = -1;
Edje_Real_Part *center[2] = { NULL, NULL };
Edje_Real_Part *zoom_center[2] = { NULL, NULL };
Edje_Real_Part *light[2] = { NULL, NULL };
Edje_Real_Part *persp[2] = { NULL, NULL };
Edje_Real_Part *rp1[4] = { NULL, NULL, NULL, NULL };
@ -4172,6 +4190,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
if (ep->param1.description->map.on)
{
center[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.rot.id_center, &statec1);
zoom_center[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.zoom.id_center, &statec1);
light[0] = _edje_real_part_state_get(ed, ep, flags, ep->param1.description->map.id_light, &statel1);
if (chosen_desc->map.persp_on)
@ -4183,6 +4202,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
if (ep->param2 && ep->param2->description->map.on)
{
center[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.rot.id_center, &statec2);
zoom_center[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.zoom.id_center, &statec2);
light[1] = _edje_real_part_state_get(ed, ep, flags, ep->param2->description->map.id_light, &statel2);
if (chosen_desc->map.persp_on)
@ -4218,7 +4238,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
#endif
{
_edje_part_recalc_single(ed, ep, ep->param1.description,
chosen_desc, center[0], light[0],
chosen_desc, center[0], zoom_center[0], light[0],
persp[0], rp1[Rel1X], rp1[Rel1Y],
rp1[Rel2X], rp1[Rel2Y], clip1, confine_to,
threshold, p1, mmw, mmh,
@ -4264,7 +4284,7 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
#endif
{
_edje_part_recalc_single(ed, ep, ep->param2->description,
chosen_desc, center[1], light[1],
chosen_desc, center[1], zoom_center[1], light[1],
persp[1], rp2[Rel1X], rp2[Rel1Y],
rp2[Rel2X], rp2[Rel2Y], clip2, confine_to,
threshold, p2, mmw, mmh,
@ -4549,6 +4569,8 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
p3_write->center.x = INTP(p1->ext->map->center.x, p2->ext->map->center.x, pos);
p3_write->center.y = INTP(p1->ext->map->center.y, p2->ext->map->center.y, pos);
p3_write->center.z = INTP(p1->ext->map->center.z, p2->ext->map->center.z, pos);
p3_write->zoom_center.x = INTP(p1->ext->map->zoom_center.x, p2->ext->map->zoom_center.x, pos);
p3_write->zoom_center.y = INTP(p1->ext->map->zoom_center.y, p2->ext->map->zoom_center.y, pos);
p3_write->rotation.x = FFP(p1->ext->map->rotation.x, p2->ext->map->rotation.x, pos);
p3_write->rotation.y = FFP(p1->ext->map->rotation.y, p2->ext->map->rotation.y, pos);
p3_write->rotation.z = FFP(p1->ext->map->rotation.z, p2->ext->map->rotation.z, pos);

View File

@ -797,6 +797,7 @@ _edje_edd_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.id_persp", map.id_persp, EET_T_INT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.id_light", map.id_light, EET_T_INT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.id_center", map.rot.id_center, EET_T_INT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.zoom.id_center", map.zoom.id_center, EET_T_INT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.x", map.rot.x, EDJE_T_FLOAT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.y", map.rot.y, EDJE_T_FLOAT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.z", map.rot.z, EDJE_T_FLOAT); \
@ -891,6 +892,7 @@ _edje_edd_init(void)
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.id_persp", Dec.map.id_persp, EET_T_INT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.id_light", Dec.map.id_light, EET_T_INT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.id_center", Dec.map.rot.id_center, EET_T_INT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.zoom.id_center", Dec.map.zoom.id_center, EET_T_INT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.x", Dec.map.rot.x, EDJE_T_FLOAT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.y", Dec.map.rot.y, EDJE_T_FLOAT); \
EET_DATA_DESCRIPTOR_ADD_BASIC(Edd, Type, "map.rot.z", Dec.map.rot.z, EDJE_T_FLOAT); \

View File

@ -16,7 +16,7 @@ Eina_Cow *_edje_calc_params_physics_cow = NULL;
Edje_Global *_edje_global_obj = NULL;
static const Edje_Calc_Params_Map default_calc_map = {
{ 0, 0, 0 }, { 0.0, 0.0, 0.0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0.0, 0.0 }, NULL, 0
{ 0, 0, 0 }, { 0, 0 }, { 0.0, 0.0, 0.0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0.0, 0.0 }, NULL, 0
};
static const Edje_Calc_Params_Physics default_calc_physics = {

View File

@ -1302,6 +1302,7 @@ struct _Edje_Part_Description_Common
} rot;
struct {
FLOAT_T x, y;
int id_center;
} zoom;
Edje_Map_Color **colors; /* List of the Edje_Map_Color */
unsigned int colors_count;
@ -1802,6 +1803,9 @@ struct _Edje_Calc_Params_Map
struct {
int x, y, z;
} center; // 12
struct {
int x, y;
} zoom_center; // 12
struct {
FLOAT_T x, y, z;
} rotation; // 24