mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-13 15:03:58 +03:00
expo: Support simple themes
It is a pain to manually set the fonts of all objects to be consistent. Some spacing settings are also better set globally than by manually positioning each object. Add a 'theme' to the expo, to hold this information. For now it includes only the font size. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
20
boot/expo.c
20
boot/expo.c
@@ -231,3 +231,23 @@ int expo_action_get(struct expo *exp, struct expo_action *act)
|
||||
|
||||
return act->type == EXPOACT_NONE ? -EAGAIN : 0;
|
||||
}
|
||||
|
||||
int expo_apply_theme(struct expo *exp, ofnode node)
|
||||
{
|
||||
struct scene *scn;
|
||||
struct expo_theme *theme = &exp->theme;
|
||||
int ret;
|
||||
|
||||
log_debug("Applying theme %s\n", ofnode_get_name(node));
|
||||
|
||||
memset(theme, '\0', sizeof(struct expo_theme));
|
||||
ofnode_read_u32(node, "font-size", &theme->font_size);
|
||||
|
||||
list_for_each_entry(scn, &exp->scene_head, sibling) {
|
||||
ret = scene_apply_theme(scn, theme);
|
||||
if (ret)
|
||||
return log_msg_ret("app", ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
28
boot/scene.c
28
boot/scene.c
@@ -466,3 +466,31 @@ int scene_calc_dims(struct scene *scn, bool do_menus)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int scene_apply_theme(struct scene *scn, struct expo_theme *theme)
|
||||
{
|
||||
struct scene_obj *obj;
|
||||
int ret;
|
||||
|
||||
/* Avoid error-checking optional items */
|
||||
scene_txt_set_font(scn, scn->title_id, NULL, theme->font_size);
|
||||
|
||||
list_for_each_entry(obj, &scn->obj_head, sibling) {
|
||||
switch (obj->type) {
|
||||
case SCENEOBJT_NONE:
|
||||
case SCENEOBJT_IMAGE:
|
||||
case SCENEOBJT_MENU:
|
||||
break;
|
||||
case SCENEOBJT_TEXT:
|
||||
scene_txt_set_font(scn, obj->id, NULL,
|
||||
theme->font_size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ret = scene_arrange(scn);
|
||||
if (ret)
|
||||
return log_msg_ret("arr", ret);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -89,6 +89,15 @@ int scene_calc_dims(struct scene *scn, bool do_menus);
|
||||
*/
|
||||
int scene_menu_arrange(struct scene *scn, struct scene_obj_menu *menu);
|
||||
|
||||
/**
|
||||
* scene_apply_theme() - Apply a theme to a scene
|
||||
*
|
||||
* @scn: Scene to update
|
||||
* @theme: Theme to apply
|
||||
* Returns: 0 if OK, -ve on error
|
||||
*/
|
||||
int scene_apply_theme(struct scene *scn, struct expo_theme *theme);
|
||||
|
||||
/**
|
||||
* scene_menu_send_key() - Send a key to a menu for processing
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user