
From: Simon Glass <sjg@chromium.org> Sometimes we want to position items individually rather than relying on the automatic scene layout. Provide a flag for this, expanding the type to cope. Also add an assertion that the flags fit in the available space. Signed-off-by: Simon Glass <sjg@chromium.org> --- boot/scene.c | 14 ++++++++++++++ include/expo.h | 27 +++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index d7e0d008b56..96130f160fc 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -359,6 +359,18 @@ int scene_obj_set_hide(struct scene *scn, uint id, bool hide) return 0; } +int scene_obj_set_manual(struct scene *scn, uint id, bool manual) +{ + int ret; + + ret = scene_obj_flag_clrset(scn, id, SCENEOF_MANUAL, + manual ? SCENEOF_MANUAL : 0); + if (ret) + return log_msg_ret("fla", ret); + + return 0; +} + int scene_obj_flag_clrset(struct scene *scn, uint id, uint clr, uint set) { struct scene_obj *obj; @@ -810,6 +822,8 @@ int scene_arrange(struct scene *scn) handle_alignment(obj->horiz, obj->vert, &obj->bbox, &obj->dims, xsize, ysize, &obj->ofs); + if (obj->flags & SCENEOF_MANUAL) + continue; switch (obj->type) { case SCENEOBJT_NONE: case SCENEOBJT_IMAGE: diff --git a/include/expo.h b/include/expo.h index d6983ee77d4..e359da1343b 100644 --- a/include/expo.h +++ b/include/expo.h @@ -313,6 +313,8 @@ enum scene_obj_align { * @SCENEOF_SYNC_SIZE: object's size (width/height) has changed * @SCENEOF_SYNC_WIDTH: object's widget has changed * @SCENEOF_SYNC_BBOX: object's bounding box has changed + * @SCENEOF_MANUAL: manually arrange the items associated with this object + * @SCENEOF_LAST: used just as a check for the size of the flags mask */ enum scene_obj_flags_t { SCENEOF_HIDE = 1 << 0, @@ -323,6 +325,9 @@ enum scene_obj_flags_t { SCENEOF_SYNC_SIZE = BIT(5), SCENEOF_SYNC_WIDTH = BIT(6), SCENEOF_SYNC_BBOX = BIT(7), + SCENEOF_MANUAL = BIT(8), + + SCENEOF_LAST, /* check for size of flags below */ }; enum { @@ -361,12 +366,16 @@ struct scene_obj { struct scene_obj_dims dims; enum scene_obj_align horiz; enum scene_obj_align vert; - u8 flags; - u8 bit_length; + u16 flags; u16 start_bit; + u8 bit_length; struct list_head sibling; }; +/* Ensure the largest flag value fits in the flags field */ +_Static_assert(SCENEOF_LAST < BIT(sizeof(((struct scene_obj *)0)->flags) * 8), + "scene_obj flags exceed flags field capacity"); + /* object can be highlighted when moving around expo */ static inline bool scene_obj_can_highlight(const struct scene_obj *obj) { @@ -977,6 +986,20 @@ int scene_obj_set_valign(struct scene *scn, uint id, enum scene_obj_align aln); */ int scene_obj_set_hide(struct scene *scn, uint id, bool hide); +/** + * scene_obj_set_manual() - Set whether an object arranges its dependents + * + * When this is enabled, scene_arrange() will refrain from moving objects + * attached to this one. E.g. for a menu, normally it moves text objects + * associated with the menu. + * + * @scn: Scene to update + * @id: ID of object to update + * @manual: true to disable arrange dependents when this object is updated + * Returns: 0 if OK, -ENOENT if @id is invalid + */ +int scene_obj_set_manual(struct scene *scn, uint id, bool manual); + /** * scene_menu_set_title() - Set the title of a menu * -- 2.43.0