more font improvements and cleanup
Get rid of the notion of a font's "ascent"; the reference point for drawing is the top-left corner of the character box rather than the baseline. Add some more space between the menu entries and make the highlight bar around the text. Replace the default font.png with two images; the build system will include one or the other based on the resolutions of the device. Restore the original compiled-in bitmap font, to fall back on when font.png can't be found (eg, in the charger binary). Add support for bold text (when a font.png image is used). Change-Id: I6d211a486a3636f20208502b1cd2aeae8b9f5b02
This commit is contained in:
+30
-16
@@ -192,11 +192,9 @@ void ScreenRecoveryUI::draw_progress_locked()
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenRecoveryUI::draw_text_line(int row, const char* t) {
|
||||
if (t[0] != '\0') {
|
||||
gr_text(0, (row+1)*char_height-1, t);
|
||||
}
|
||||
}
|
||||
#define C_HEADER 247,0,6
|
||||
#define C_MENU 0,106,157
|
||||
#define C_LOG 249,194,0
|
||||
|
||||
// Redraw everything on the screen. Does not flip pages.
|
||||
// Should only be called with updateMutex locked.
|
||||
@@ -209,30 +207,46 @@ void ScreenRecoveryUI::draw_screen_locked()
|
||||
gr_color(0, 0, 0, 160);
|
||||
gr_fill(0, 0, gr_fb_width(), gr_fb_height());
|
||||
|
||||
int y = 0;
|
||||
int i = 0;
|
||||
if (show_menu) {
|
||||
gr_color(64, 96, 255, 255);
|
||||
gr_fill(0, (menu_top+menu_sel) * char_height,
|
||||
gr_fb_width(), (menu_top+menu_sel+1)*char_height+1);
|
||||
gr_color(C_HEADER, 255);
|
||||
|
||||
for (; i < menu_top + menu_items; ++i) {
|
||||
if (i == menu_top) gr_color(C_MENU, 255);
|
||||
|
||||
if (i == menu_top + menu_sel) {
|
||||
// draw the highlight bar
|
||||
gr_fill(0, y-2, gr_fb_width(), y+char_height+2);
|
||||
// white text of selected item
|
||||
gr_color(255, 255, 255, 255);
|
||||
draw_text_line(i, menu[i]);
|
||||
gr_color(64, 96, 255, 255);
|
||||
if (menu[i][0]) gr_text(4, y, menu[i], 1);
|
||||
gr_color(C_MENU, 255);
|
||||
} else {
|
||||
draw_text_line(i, menu[i]);
|
||||
if (menu[i][0]) gr_text(4, y, menu[i], i < menu_top);
|
||||
}
|
||||
y += char_height+4;
|
||||
}
|
||||
gr_fill(0, i*char_height+char_height/2-1,
|
||||
gr_fb_width(), i*char_height+char_height/2+1);
|
||||
gr_color(C_MENU, 255);
|
||||
y += 4;
|
||||
gr_fill(0, y, gr_fb_width(), y+2);
|
||||
y += 4;
|
||||
++i;
|
||||
}
|
||||
|
||||
gr_color(255, 255, 0, 255);
|
||||
gr_color(C_LOG, 255);
|
||||
|
||||
for (; i < text_rows; ++i) {
|
||||
draw_text_line(i, text[(i+text_top) % text_rows]);
|
||||
// display from the bottom up, until we hit the top of the
|
||||
// screen, the bottom of the menu, or we've displayed the
|
||||
// entire text buffer.
|
||||
int ty;
|
||||
int row = (text_top+text_rows-1) % text_rows;
|
||||
for (int ty = gr_fb_height() - char_height, count = 0;
|
||||
ty > y+2 && count < text_rows;
|
||||
ty -= char_height, ++count) {
|
||||
gr_text(4, ty, text[row], 0);
|
||||
--row;
|
||||
if (row < 0) row = text_rows-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user