forked from enlightenment/efl
edje: attaching viewport of camera to the image part
Summary: According to D3710 new field "camera" in edc was added for IMAGE parts. It is the name of the CAMERA part to set its viewport as a source of image if no image name is given. Reviewers: raster, Hermet, cedric Reviewed By: cedric Subscribers: jpeg, artem.popov Differential Revision: https://phab.enlightenment.org/D3777 Signed-off-by: Cedric Bail <cedric@osg.samsung.com>
This commit is contained in:
parent
a5216d4f79
commit
d200d483ef
|
@ -247,7 +247,6 @@ static void st_collections_base_scale(void);
|
|||
|
||||
static void ob_collections_group(void);
|
||||
static void st_collections_group_name(void);
|
||||
static void st_collections_group_scene_size(void);
|
||||
static void st_collections_group_inherit_only(void);
|
||||
static void st_collections_group_inherit(void);
|
||||
static void st_collections_group_program_source(void);
|
||||
|
@ -258,6 +257,7 @@ static void st_collections_group_script_recursion(void);
|
|||
static void st_collections_group_alias(void);
|
||||
static void st_collections_group_min(void);
|
||||
static void st_collections_group_max(void);
|
||||
static void st_collections_group_scene_size(void);
|
||||
static void st_collections_group_broadcast_signal(void);
|
||||
static void st_collections_group_data_item(void);
|
||||
static void st_collections_group_orientation(void);
|
||||
|
@ -705,7 +705,6 @@ New_Statement_Handler statement_handlers[] =
|
|||
{"collections.group.vibrations.sample.name", st_collections_group_vibration_sample_name}, /* dup */
|
||||
{"collections.group.vibrations.sample.source", st_collections_group_vibration_sample_source}, /* dup */
|
||||
{"collections.group.name", st_collections_group_name},
|
||||
{"collections.group.scene_size", st_collections_group_scene_size},
|
||||
{"collections.group.program_source", st_collections_group_program_source},
|
||||
{"collections.group.inherit", st_collections_group_inherit},
|
||||
{"collections.group.inherit_only", st_collections_group_inherit_only},
|
||||
|
@ -717,6 +716,7 @@ New_Statement_Handler statement_handlers[] =
|
|||
{"collections.group.alias", st_collections_group_alias},
|
||||
{"collections.group.min", st_collections_group_min},
|
||||
{"collections.group.max", st_collections_group_max},
|
||||
{"collections.group.scene_size", st_collections_group_scene_size},
|
||||
{"collections.group.broadcast_signal", st_collections_group_broadcast_signal},
|
||||
{"collections.group.orientation", st_collections_group_orientation},
|
||||
{"collections.group.mouse_events", st_collections_group_mouse_events},
|
||||
|
@ -3961,6 +3961,9 @@ ob_collections_group(void)
|
|||
pcp = (Edje_Part_Collection_Parser *)pc;
|
||||
pcp->default_mouse_events = 1;
|
||||
|
||||
pc->scene_size.width = 0;
|
||||
pc->scene_size.height = 0;
|
||||
|
||||
#ifdef HAVE_EPHYSICS
|
||||
pc->physics.world.gravity.x = 0;
|
||||
pc->physics.world.gravity.y = 294;
|
||||
|
@ -4033,28 +4036,6 @@ st_collections_group_name(void)
|
|||
_group_name(parse_str(0));
|
||||
}
|
||||
|
||||
/**
|
||||
@page edcref
|
||||
@property
|
||||
scene_size
|
||||
@parameters
|
||||
[scene size]
|
||||
@effect
|
||||
Height and width of scene
|
||||
@endproperty
|
||||
*/
|
||||
static void
|
||||
st_collections_group_scene_size(void)
|
||||
{
|
||||
Edje_Part_Collection *current_pc;
|
||||
|
||||
check_arg_count(2);
|
||||
|
||||
current_pc = eina_list_data_get(eina_list_last(edje_collections));
|
||||
current_pc->scene_size.width = parse_float(0);
|
||||
current_pc->scene_size.height = parse_float(1);
|
||||
}
|
||||
|
||||
typedef struct _Edje_List_Foreach_Data Edje_List_Foreach_Data;
|
||||
struct _Edje_List_Foreach_Data
|
||||
{
|
||||
|
@ -4691,6 +4672,28 @@ st_collections_group_max(void)
|
|||
pc->prop.max.h = parse_int_range(1, 0, 0x7fffffff);
|
||||
}
|
||||
|
||||
/**
|
||||
@page edcref
|
||||
@property
|
||||
scne_size
|
||||
@parameters
|
||||
[width] [height]
|
||||
@effect
|
||||
Size of scene.
|
||||
@endproperty
|
||||
*/
|
||||
static void
|
||||
st_collections_group_scene_size(void)
|
||||
{
|
||||
Edje_Part_Collection *pc;
|
||||
|
||||
check_arg_count(2);
|
||||
|
||||
pc = eina_list_data_get(eina_list_last(edje_collections));
|
||||
pc->scene_size.width = parse_float(0);
|
||||
pc->scene_size.height = parse_float(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@page edcref
|
||||
@property
|
||||
|
@ -6037,6 +6040,9 @@ st_collections_group_parts_part_type(void)
|
|||
"TABLE", EDJE_PART_TYPE_TABLE,
|
||||
"EXTERNAL", EDJE_PART_TYPE_EXTERNAL,
|
||||
"PROXY", EDJE_PART_TYPE_PROXY,
|
||||
"MESH_NODE", EDJE_PART_TYPE_MESH_NODE,
|
||||
"LIGHT", EDJE_PART_TYPE_LIGHT,
|
||||
"CAMERA", EDJE_PART_TYPE_CAMERA,
|
||||
"SPACER", EDJE_PART_TYPE_SPACER,
|
||||
"SNAPSHOT", EDJE_PART_TYPE_SNAPSHOT,
|
||||
NULL);
|
||||
|
|
|
@ -4658,10 +4658,25 @@ _edje_part_recalc(Edje *ed, Edje_Real_Part *ep, int flags, Edje_Calc_Params *sta
|
|||
break;
|
||||
case EDJE_PART_TYPE_CAMERA:
|
||||
{
|
||||
Evas_Object *viewport;
|
||||
Evas_Canvas3D_Camera *camera = NULL;
|
||||
Edje_Part_Description_Camera *pd_camera;
|
||||
|
||||
efl_gfx_size_set(ep->object, pf->req.w, pf->req.h);
|
||||
|
||||
pd_camera = (Edje_Part_Description_Camera*) ep->chosen_description;
|
||||
|
||||
efl_gfx_position_set(ep->object, ed->x + pf->final.x, ed->y + pf->final.y),
|
||||
efl_gfx_size_set(ep->object, pf->final.w, pf->final.h);
|
||||
|
||||
viewport = evas_object_image_source_get(ep->object);
|
||||
|
||||
efl_gfx_size_set(viewport, pf->req.w, pf->req.h);
|
||||
|
||||
evas_object_image_source_visible_set(ep->object, EINA_FALSE);
|
||||
evas_object_image_source_events_set(ep->object, EINA_TRUE);
|
||||
evas_object_show(ep->object);
|
||||
|
||||
camera = evas_canvas3d_node_camera_get(ep->node);
|
||||
|
||||
evas_canvas3d_camera_projection_perspective_set(camera, pd_camera->camera.camera.fovy, pd_camera->camera.camera.aspect, pd_camera->camera.camera.frustum_near, pd_camera->camera.camera.frustum_far);
|
||||
|
|
|
@ -1349,6 +1349,8 @@ _edje_edd_init(void)
|
|||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "id", id, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_HASH_STRING(_edje_edd_edje_part_collection, Edje_Part_Collection, "alias", alias);
|
||||
EET_DATA_DESCRIPTOR_ADD_HASH_STRING(_edje_edd_edje_part_collection, Edje_Part_Collection, "aliased", aliased);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "scene_size.width", scene_size.width, EDJE_T_FLOAT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "scene_size.height", scene_size.height, EDJE_T_FLOAT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.min.w", prop.min.w, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.min.h", prop.min.h, EET_T_INT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "prop.max.w", prop.max.w, EET_T_INT);
|
||||
|
@ -1367,8 +1369,6 @@ _edje_edd_init(void)
|
|||
#endif
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "physics_enabled", physics_enabled, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "script_recursion", script_recursion, EET_T_UCHAR);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "scene_size.width", scene_size.width, EDJE_T_FLOAT);
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_collection, Edje_Part_Collection, "scene_size.height", scene_size.height, EDJE_T_FLOAT);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
|
|
@ -470,6 +470,13 @@ _edje_programs_patterns_clean(Edje_Part_Collection *edc)
|
|||
edc->patterns.programs.u.programs.globing = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
_evas_object_viewport_del(void *data, Evas *_evas EINA_UNUSED, Evas_Object *eo EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Eo* viewport = (Eo*) data;
|
||||
evas_object_del(viewport);
|
||||
}
|
||||
|
||||
#ifdef HAVE_EPHYSICS
|
||||
static void
|
||||
_edje_physics_world_update_cb(void *data, EPhysics_World *world EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
|
@ -850,7 +857,12 @@ _edje_object_file_set_internal(Evas_Object *obj, const Eina_File *file, const ch
|
|||
evas_canvas3d_node_camera_set(rp->node, camera);
|
||||
|
||||
rp->object = evas_object_image_filled_add(ed->base->evas);
|
||||
evas_object_resize(rp->object, ed->collection->scene_size.width, ed->collection->scene_size.height);
|
||||
|
||||
Eo* viewport = evas_object_image_filled_add(ed->base->evas);
|
||||
evas_object_image_source_set(rp->object, viewport);
|
||||
evas_object_show(viewport);
|
||||
evas_object_event_callback_add(rp->object, EVAS_CALLBACK_DEL, _evas_object_viewport_del, viewport);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue