(GLUI) Make vertical centering of text independant of the line height. Fixes the vertical centering of the title in the header when header_height differs from line_height. Also fixes the vertical placement of help messages.

This commit is contained in:
Jean-André Santoni 2015-11-05 16:33:49 +07:00
parent 12bd612337
commit 67b47e29f0
1 changed files with 10 additions and 10 deletions

View File

@ -193,20 +193,16 @@ static void materialui_blit_line(float x, float y, unsigned width, unsigned heig
{ {
int font_size; int font_size;
void *fb_buf = NULL; void *fb_buf = NULL;
materialui_handle_t *materialui = NULL;
struct font_params params = {0}; struct font_params params = {0};
menu_handle_t *menu = menu_driver_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr();
if (!menu) if (!menu)
return; return;
materialui = (materialui_handle_t*)menu->userdata;
menu_display_ctl(MENU_DISPLAY_CTL_FONT_SIZE, &font_size); menu_display_ctl(MENU_DISPLAY_CTL_FONT_SIZE, &font_size);
params.x = x / width; params.x = x / width;
params.y = 1.0f - (y + materialui->line_height / 2 + font_size / 3) params.y = 1.0f - (y + font_size / 3) / height;
/ height;
params.scale = 1.0; params.scale = 1.0;
params.color = color; params.color = color;
params.full_screen = true; params.full_screen = true;
@ -437,7 +433,8 @@ static void materialui_render_label_value(materialui_handle_t *materialui,
menu_animation_ticker_str(label_str, ticker_limit, index, label, selected); menu_animation_ticker_str(label_str, ticker_limit, index, label, selected);
menu_animation_ticker_str(value_str, value_len, index, value, selected); menu_animation_ticker_str(value_str, value_len, index, value, selected);
materialui_blit_line(materialui->margin, y, width, height, label_str, color, TEXT_ALIGN_LEFT); materialui_blit_line(materialui->margin, y + materialui->line_height / 2,
width, height, label_str, color, TEXT_ALIGN_LEFT);
hash_value = menu_hash_calculate(value); hash_value = menu_hash_calculate(value);
@ -500,11 +497,14 @@ static void materialui_render_label_value(materialui_handle_t *materialui,
} }
if (do_draw_text) if (do_draw_text)
materialui_blit_line(width - materialui->margin, y, width, height, value_str, color, TEXT_ALIGN_RIGHT); materialui_blit_line(width - materialui->margin,
y + materialui->line_height / 2,
width, height, value_str, color, TEXT_ALIGN_RIGHT);
if (texture_switch) if (texture_switch)
materialui_draw_icon(materialui, texture_switch, materialui_draw_icon(materialui, texture_switch,
width - materialui->margin - materialui->icon_size, y, width, height, 0, 1, &pure_white[0]); width - materialui->margin - materialui->icon_size, y,
width, height, 0, 1, &pure_white[0]);
} }
@ -848,8 +848,8 @@ static void materialui_frame(void)
*frame_count / 100, title, true); *frame_count / 100, title, true);
/* Title */ /* Title */
materialui_blit_line(title_margin, 0, width, height, title_buf, materialui_blit_line(title_margin, header_height / 2, width, height,
title_color, TEXT_ALIGN_LEFT); title_buf, title_color, TEXT_ALIGN_LEFT);
materialui_draw_scrollbar(width, height, &grey_bg[0]); materialui_draw_scrollbar(width, height, &grey_bg[0]);