diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2010-04-25 11:32:51 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2010-04-25 11:32:51 +0000 |
commit | 4c65a1970e25ef1b6eaa91f614eef64d0efe5779 (patch) | |
tree | 6d748c7650b42441409f5573161f24c674fd37b1 | |
parent | cbc65befa8b3fbb53e7e2603f838a79b5fa5fcbc (diff) |
Make battery level (%bl) work with the bmp bars drawer like %pb and %pv
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25710 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/gui/skin_engine/skin_display.c | 12 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 9 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_tokens.h | 1 |
3 files changed, 17 insertions, 5 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index 9cef12a690..a0b3497683 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c @@ -27,6 +27,7 @@ #include "system.h" #include "rbunicode.h" #include "sound.h" +#include "powermgmt.h" #ifdef DEBUG #include "debug.h" #endif @@ -145,6 +146,11 @@ static void draw_progressbar(struct gui_wps *gwps, length = maxvol-minvol; elapsed = global_settings.volume-minvol; } + else if (pb->type == WPS_TOKEN_BATTERY_PERCENTBAR) + { + length = 100; + elapsed = battery_level(); + } else if (id3 && id3->length) { length = id3->length; @@ -608,8 +614,9 @@ static bool evaluate_conditional(struct gui_wps *gwps, int *token_index) /* clear all pictures in the conditional and nested ones */ if (data->tokens[i].type == WPS_TOKEN_IMAGE_PRELOAD_DISPLAY) clear_image_pos(gwps, find_image(data->tokens[i].value.i&0xFF, data)); - else if (data->tokens[i].type == WPS_TOKEN_VOLUMEBAR || - data->tokens[i].type == WPS_TOKEN_PROGRESSBAR) + else if (data->tokens[i].type == WPS_TOKEN_VOLUMEBAR || + data->tokens[i].type == WPS_TOKEN_PROGRESSBAR || + data->tokens[i].type == WPS_TOKEN_BATTERY_PERCENTBAR ) { struct progressbar *bar = (struct progressbar*)data->tokens[i].value.data; bar->draw = false; @@ -677,6 +684,7 @@ static bool get_line(struct gui_wps *gwps, #ifdef HAVE_LCD_BITMAP case WPS_TOKEN_VOLUMEBAR: + case WPS_TOKEN_BATTERY_PERCENTBAR: case WPS_TOKEN_PROGRESSBAR: { struct progressbar *bar = (struct progressbar*)data->tokens[i].value.data; diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index eb63ac56e9..6ea0180534 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -202,7 +202,7 @@ static const struct wps_tag all_tags[] = { { WPS_TOKEN_ALIGN_RIGHT_RTL, "aR", 0, NULL }, { WPS_NO_TOKEN, "ax", 0, parse_languagedirection }, - { WPS_TOKEN_BATTERY_PERCENT, "bl", WPS_REFRESH_DYNAMIC, NULL }, + { WPS_TOKEN_BATTERY_PERCENT, "bl", WPS_REFRESH_DYNAMIC, parse_progressbar }, { WPS_TOKEN_BATTERY_VOLTS, "bv", WPS_REFRESH_DYNAMIC, NULL }, { WPS_TOKEN_BATTERY_TIME, "bt", WPS_REFRESH_DYNAMIC, NULL }, { WPS_TOKEN_BATTERY_SLEEPTIME, "bs", WPS_REFRESH_DYNAMIC, NULL }, @@ -1166,7 +1166,7 @@ static int parse_progressbar(const char *wps_bufptr, pb->width = vp->width; pb->height = SYSFONT_HEIGHT-2; pb->y = -line_num - 1; /* Will be computed during the rendering */ - if (token->type == WPS_TOKEN_VOLUME) + if (token->type == WPS_TOKEN_VOLUME || token->type == WPS_TOKEN_BATTERY_PERCENT) return 0; /* dont add it, let the regular token handling do the work */ add_to_ll_chain(&wps_data->progressbars, item); return 0; @@ -1233,12 +1233,15 @@ static int parse_progressbar(const char *wps_bufptr, add_to_ll_chain(&wps_data->progressbars, item); if (token->type == WPS_TOKEN_VOLUME) token->type = WPS_TOKEN_VOLUMEBAR; + else if (token->type == WPS_TOKEN_BATTERY_PERCENT) + token->type = WPS_TOKEN_BATTERY_PERCENTBAR; pb->type = token->type; return ptr+1-wps_bufptr; #else (void)wps_bufptr; - if (token->type != WPS_TOKEN_VOLUME) + if (token->type != WPS_TOKEN_VOLUME && + token->type != WPS_TOKEN_BATTERY_PERCENTBAR) { wps_data->full_line_progressbar = token->type == WPS_TOKEN_PLAYER_PROGRESSBAR; diff --git a/apps/gui/skin_engine/skin_tokens.h b/apps/gui/skin_engine/skin_tokens.h index e727c255a1..3b155509f9 100644 --- a/apps/gui/skin_engine/skin_tokens.h +++ b/apps/gui/skin_engine/skin_tokens.h @@ -59,6 +59,7 @@ enum wps_token_type { /* Battery */ TOKEN_MARKER_BATTERY, WPS_TOKEN_BATTERY_PERCENT, + WPS_TOKEN_BATTERY_PERCENTBAR, WPS_TOKEN_BATTERY_VOLTS, WPS_TOKEN_BATTERY_TIME, WPS_TOKEN_BATTERY_CHARGER_CONNECTED, |