mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-05-05 20:56:12 +02:00
expo: Support setting the size and bounds of an object
Add a function to allow the size of an object to be set independently of its position. Also add a function to permit the object's bounding box to be set independently of its dimensions. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
baaf090734
commit
e3c3f83cb6
29
boot/scene.c
29
boot/scene.c
@ -235,6 +235,35 @@ int scene_obj_set_size(struct scene *scn, uint id, int w, int h)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int scene_obj_set_width(struct scene *scn, uint id, int w)
|
||||
{
|
||||
struct scene_obj *obj;
|
||||
|
||||
obj = scene_obj_find(scn, id, SCENEOBJT_NONE);
|
||||
if (!obj)
|
||||
return log_msg_ret("find", -ENOENT);
|
||||
obj->bbox.x1 = obj->bbox.x0 + w;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int scene_obj_set_bbox(struct scene *scn, uint id, int x0, int y0, int x1,
|
||||
int y1)
|
||||
{
|
||||
struct scene_obj *obj;
|
||||
|
||||
obj = scene_obj_find(scn, id, SCENEOBJT_NONE);
|
||||
if (!obj)
|
||||
return log_msg_ret("find", -ENOENT);
|
||||
obj->bbox.x0 = x0;
|
||||
obj->bbox.y0 = y0;
|
||||
obj->bbox.x1 = x1;
|
||||
obj->bbox.y1 = y1;
|
||||
obj->flags |= SCENEOF_SIZE_VALID;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int scene_obj_set_hide(struct scene *scn, uint id, bool hide)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -673,6 +673,30 @@ int scene_obj_set_pos(struct scene *scn, uint id, int x, int y);
|
||||
*/
|
||||
int scene_obj_set_size(struct scene *scn, uint id, int w, int h);
|
||||
|
||||
/**
|
||||
* scene_obj_set_width() - Set the width of an object
|
||||
*
|
||||
* @scn: Scene to update
|
||||
* @id: ID of object to update
|
||||
* @w: width in pixels
|
||||
* Returns: 0 if OK, -ENOENT if @id is invalid
|
||||
*/
|
||||
int scene_obj_set_width(struct scene *scn, uint id, int w);
|
||||
|
||||
/**
|
||||
* scene_obj_set_bbox() - Set the bounding box of an object
|
||||
*
|
||||
* @scn: Scene to update
|
||||
* @id: ID of object to update
|
||||
* @x0: x position, in pixels from left side
|
||||
* @y0: y position, in pixels from top
|
||||
* @x1: ending x position (right side)
|
||||
* @y1: ending y position (botton side)
|
||||
* Returns: 0 if OK, -ENOENT if @id is invalid
|
||||
*/
|
||||
int scene_obj_set_bbox(struct scene *scn, uint id, int x0, int y0, int x1,
|
||||
int y1);
|
||||
|
||||
/**
|
||||
* scene_obj_set_hide() - Set whether an object is hidden
|
||||
*
|
||||
|
||||
@ -584,6 +584,17 @@ static int expo_render_image(struct unit_test_state *uts)
|
||||
ut_asserteq(50 + 160, obj->bbox.x1);
|
||||
ut_asserteq(400 + 160, obj->bbox.y1);
|
||||
|
||||
scene_obj_set_width(scn, OBJ_MENU, 170);
|
||||
ut_asserteq(50 + 170, obj->bbox.x1);
|
||||
scene_obj_set_bbox(scn, OBJ_MENU, 60, 410, 50 + 160, 400 + 160);
|
||||
ut_asserteq(60, obj->bbox.x0);
|
||||
ut_asserteq(410, obj->bbox.y0);
|
||||
ut_asserteq(50 + 160, obj->bbox.x1);
|
||||
ut_asserteq(400 + 160, obj->bbox.y1);
|
||||
|
||||
/* reset back to normal */
|
||||
scene_obj_set_bbox(scn, OBJ_MENU, 50, 400, 50 + 160, 400 + 160);
|
||||
|
||||
/* render it */
|
||||
expo_set_scene_id(exp, SCENE1);
|
||||
ut_assertok(expo_render(exp));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user