mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-16 09:54:35 +00:00
expo: Allow rendering the background of any object
So far only menus have a background. When other object types are rendered, they may have a background too. Make this code more generic so it will be usable by new object types. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
8bc69b4b24
commit
94598d5b0a
3 changed files with 39 additions and 37 deletions
40
boot/scene.c
40
boot/scene.c
|
@ -314,6 +314,44 @@ int scene_obj_get_hw(struct scene *scn, uint id, int *widthp)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* scene_render_background() - Render the background for an object
|
||||
*
|
||||
* @obj: Object to render
|
||||
*/
|
||||
static void scene_render_background(struct scene_obj *obj)
|
||||
{
|
||||
struct expo *exp = obj->scene->expo;
|
||||
const struct expo_theme *theme = &exp->theme;
|
||||
struct vidconsole_bbox bbox, label_bbox;
|
||||
struct udevice *dev = exp->display;
|
||||
struct video_priv *vid_priv;
|
||||
struct udevice *cons = exp->cons;
|
||||
struct vidconsole_colour old;
|
||||
enum colour_idx fore, back;
|
||||
uint inset = theme->menu_inset;
|
||||
|
||||
/* draw a background for the object */
|
||||
if (CONFIG_IS_ENABLED(SYS_WHITE_ON_BLACK)) {
|
||||
fore = VID_BLACK;
|
||||
back = VID_WHITE;
|
||||
} else {
|
||||
fore = VID_LIGHT_GRAY;
|
||||
back = VID_BLACK;
|
||||
}
|
||||
|
||||
/* see if this object wants to render a background */
|
||||
if (scene_obj_calc_bbox(obj, &bbox, &label_bbox))
|
||||
return;
|
||||
|
||||
vidconsole_push_colour(cons, fore, back, &old);
|
||||
vid_priv = dev_get_uclass_priv(dev);
|
||||
video_fill_part(dev, label_bbox.x0 - inset, label_bbox.y0 - inset,
|
||||
label_bbox.x1 + inset, label_bbox.y1 + inset,
|
||||
vid_priv->colour_fg);
|
||||
vidconsole_pop_colour(cons, &old);
|
||||
}
|
||||
|
||||
/**
|
||||
* scene_obj_render() - Render an object
|
||||
*
|
||||
|
@ -397,7 +435,7 @@ static int scene_obj_render(struct scene_obj *obj, bool text_mode)
|
|||
return -ENOTSUPP;
|
||||
|
||||
/* draw a background behind the menu items */
|
||||
scene_menu_render(menu);
|
||||
scene_render_background(obj);
|
||||
}
|
||||
/*
|
||||
* With a vidconsole, the text and item pointer are rendered as
|
||||
|
|
|
@ -165,13 +165,6 @@ int scene_render(struct scene *scn);
|
|||
*/
|
||||
int scene_send_key(struct scene *scn, int key, struct expo_action *event);
|
||||
|
||||
/**
|
||||
* scene_menu_render() - Render the background behind a menu
|
||||
*
|
||||
* @menu: Menu to render
|
||||
*/
|
||||
void scene_menu_render(struct scene_obj_menu *menu);
|
||||
|
||||
/**
|
||||
* scene_render_deps() - Render an object and its dependencies
|
||||
*
|
||||
|
|
|
@ -516,35 +516,6 @@ int scene_menu_display(struct scene_obj_menu *menu)
|
|||
return -ENOTSUPP;
|
||||
}
|
||||
|
||||
void scene_menu_render(struct scene_obj_menu *menu)
|
||||
{
|
||||
struct expo *exp = menu->obj.scene->expo;
|
||||
const struct expo_theme *theme = &exp->theme;
|
||||
struct vidconsole_bbox bbox, label_bbox;
|
||||
struct udevice *dev = exp->display;
|
||||
struct video_priv *vid_priv;
|
||||
struct udevice *cons = exp->cons;
|
||||
struct vidconsole_colour old;
|
||||
enum colour_idx fore, back;
|
||||
|
||||
if (CONFIG_IS_ENABLED(SYS_WHITE_ON_BLACK)) {
|
||||
fore = VID_BLACK;
|
||||
back = VID_WHITE;
|
||||
} else {
|
||||
fore = VID_LIGHT_GRAY;
|
||||
back = VID_BLACK;
|
||||
}
|
||||
|
||||
scene_menu_calc_bbox(menu, &bbox, &label_bbox);
|
||||
vidconsole_push_colour(cons, fore, back, &old);
|
||||
vid_priv = dev_get_uclass_priv(dev);
|
||||
video_fill_part(dev, label_bbox.x0 - theme->menu_inset,
|
||||
label_bbox.y0 - theme->menu_inset,
|
||||
label_bbox.x1, label_bbox.y1 + theme->menu_inset,
|
||||
vid_priv->colour_fg);
|
||||
vidconsole_pop_colour(cons, &old);
|
||||
}
|
||||
|
||||
int scene_menu_render_deps(struct scene *scn, struct scene_obj_menu *menu)
|
||||
{
|
||||
struct scene_menitem *item;
|
||||
|
|
Loading…
Add table
Reference in a new issue