aboutsummaryrefslogtreecommitdiffstats
path: root/screen_ui.cpp
diff options
context:
space:
mode:
authorDoug Zongker <dougz@android.com>2013-03-06 15:01:11 -0800
committerDoug Zongker <dougz@android.com>2013-03-07 13:34:24 -0800
commit6fd59ac07d91eb373f4269a40e688aa82a6ccc6e (patch)
tree64807edcb65fd2abd80c19c79cad6986f99ca396 /screen_ui.cpp
parent55a36ac1e01205f2cd461cd2f89d92e3b64cddd2 (diff)
downloadbootable_recovery-6fd59ac07d91eb373f4269a40e688aa82a6ccc6e.zip
bootable_recovery-6fd59ac07d91eb373f4269a40e688aa82a6ccc6e.tar.gz
bootable_recovery-6fd59ac07d91eb373f4269a40e688aa82a6ccc6e.tar.bz2
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
Diffstat (limited to 'screen_ui.cpp')
-rw-r--r--screen_ui.cpp48
1 files changed, 31 insertions, 17 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp
index 12af082..222de00 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -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);
-
- for (; i < text_rows; ++i) {
- draw_text_line(i, text[(i+text_top) % text_rows]);
+ gr_color(C_LOG, 255);
+
+ // 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;
}
}
}