diff options
author | Michael W <baddaemon87@gmail.com> | 2016-08-16 13:06:45 +0200 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-09-03 06:37:09 -0700 |
commit | 756ec88512e0d3ed0c15a5d44e4d8d0fe500885f (patch) | |
tree | 0ee55c04725ea5ad0fd8c7619349c8a76d737512 /charger | |
parent | e900dddb9ec5a48cc02f118610360cf1d5b182e8 (diff) | |
download | vendor_replicant-756ec88512e0d3ed0c15a5d44e4d8d0fe500885f.zip vendor_replicant-756ec88512e0d3ed0c15a5d44e4d8d0fe500885f.tar.gz vendor_replicant-756ec88512e0d3ed0c15a5d44e4d8d0fe500885f.tar.bz2 |
cm: charger: Center capacity and vertical offset
* What the title says :). Looks way better
* Use half a vertical font size as offset
Change-Id: I3e5cc039932a1016d419c4dbe5af5f7673631733
Diffstat (limited to 'charger')
-rw-r--r-- | charger/healthd_board_cm.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/charger/healthd_board_cm.cpp b/charger/healthd_board_cm.cpp index 10dfddf..f5e0ed1 100644 --- a/charger/healthd_board_cm.cpp +++ b/charger/healthd_board_cm.cpp @@ -79,16 +79,19 @@ static int draw_surface_centered(GRSurface* surface) #define STR_LEN 64 static void draw_capacity(int capacity) { + char cap_str[STR_LEN]; + snprintf(cap_str, (STR_LEN - 1), "%d%%", capacity); + struct frame *f = &anim.frames[0]; - int w = gr_get_width(f->surface); + int font_x, font_y; + gr_font_size(&font_x, &font_y); + int w = gr_measure(cap_str); int h = gr_get_height(f->surface); - int x = (gr_fb_width() - w) / 2 ; + int x = (gr_fb_width() - w) / 2; int y = (gr_fb_height() + h) / 2; - char cap_str[STR_LEN]; - snprintf(cap_str, (STR_LEN - 1), "%d%%", capacity); gr_color(255, 255, 255, 255); - gr_text(x, y * 1.05, cap_str, 0); + gr_text(x, y + font_y / 2, cap_str, 0); } #ifdef QCOM_HARDWARE |