diff options
Diffstat (limited to 'apps/gui/skin_engine')
-rw-r--r-- | apps/gui/skin_engine/skin_buffer.c | 11 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_display.c | 4 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_engine.h | 9 | ||||
-rw-r--r-- | apps/gui/skin_engine/skin_parser.c | 113 | ||||
-rw-r--r-- | apps/gui/skin_engine/wps_internals.h | 3 |
5 files changed, 104 insertions, 36 deletions
diff --git a/apps/gui/skin_engine/skin_buffer.c b/apps/gui/skin_engine/skin_buffer.c index e647fc3f1d..a15ad10bee 100644 --- a/apps/gui/skin_engine/skin_buffer.c +++ b/apps/gui/skin_engine/skin_buffer.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "buffer.h" | 27 | #include "buffer.h" |
28 | #include "settings.h" | 28 | #include "settings.h" |
29 | #include "screen_access.h" | 29 | #include "screen_access.h" |
30 | #include "skin_engine.h" | ||
30 | #include "wps_internals.h" | 31 | #include "wps_internals.h" |
31 | #include "skin_tokens.h" | 32 | #include "skin_tokens.h" |
32 | #include "skin_buffer.h" | 33 | #include "skin_buffer.h" |
@@ -46,7 +47,7 @@ | |||
46 | * items with unknown sizes get allocated from the start (0->) (data) | 47 | * items with unknown sizes get allocated from the start (0->) (data) |
47 | * items with known sizes get allocated from the end (<-buf_size) (tokens) | 48 | * items with known sizes get allocated from the end (<-buf_size) (tokens) |
48 | * After loading 2 skins the buffer will look like this: | 49 | * After loading 2 skins the buffer will look like this: |
49 | * |tokens skin1|images skin2|---SPACE---|data skin2|data skin1| | 50 | * |tokens skin1|images skin1|tokens s2|images s2|---SPACE---|data skin2|data skin1| |
50 | * Make sure to never start allocating from the beginning before letting us know | 51 | * Make sure to never start allocating from the beginning before letting us know |
51 | * how much was used. and RESPECT THE buf_free RETURN VALUES! | 52 | * how much was used. and RESPECT THE buf_free RETURN VALUES! |
52 | * | 53 | * |
@@ -54,12 +55,12 @@ | |||
54 | 55 | ||
55 | 56 | ||
56 | #ifdef HAVE_LCD_BITMAP | 57 | #ifdef HAVE_LCD_BITMAP |
57 | #define MAIN_BUFFER ((LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \ | 58 | #define MAIN_BUFFER ((2*LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \ |
58 | + (2*LCD_HEIGHT*LCD_WIDTH/8)) | 59 | + (SKINNABLE_SCREENS_COUNT * LCD_BACKDROP_BYTES)) |
59 | 60 | ||
60 | #if (NB_SCREENS > 1) | 61 | #if (NB_SCREENS > 1) |
61 | #define REMOTE_BUFFER ((LCD_REMOTE_HEIGHT*LCD_REMOTE_WIDTH*LCD_REMOTE_DEPTH/8) \ | 62 | #define REMOTE_BUFFER (2*(LCD_REMOTE_HEIGHT*LCD_REMOTE_WIDTH*LCD_REMOTE_DEPTH/8) \ |
62 | + (2*LCD_REMOTE_HEIGHT*LCD_REMOTE_WIDTH/8)) | 63 | + (SKINNABLE_SCREENS_COUNT * REMOTE_LCD_BACKDROP_BYTES)) |
63 | #else | 64 | #else |
64 | #define REMOTE_BUFFER 0 | 65 | #define REMOTE_BUFFER 0 |
65 | #endif | 66 | #endif |
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index e90ac4c4ce..1a056291bc 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c | |||
@@ -1011,6 +1011,10 @@ static bool skin_redraw(struct gui_wps *gwps, unsigned refresh_mode) | |||
1011 | { | 1011 | { |
1012 | struct skin_line *line; | 1012 | struct skin_line *line; |
1013 | struct skin_viewport *skin_viewport = find_viewport(VP_DEFAULT_LABEL, data); | 1013 | struct skin_viewport *skin_viewport = find_viewport(VP_DEFAULT_LABEL, data); |
1014 | |||
1015 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1) | ||
1016 | display->backdrop_show(data->backdrop); | ||
1017 | #endif | ||
1014 | 1018 | ||
1015 | if (!(skin_viewport->hidden_flags & VP_NEVER_VISIBLE)) | 1019 | if (!(skin_viewport->hidden_flags & VP_NEVER_VISIBLE)) |
1016 | { | 1020 | { |
diff --git a/apps/gui/skin_engine/skin_engine.h b/apps/gui/skin_engine/skin_engine.h index 5216e9338b..c5afe3e9f5 100644 --- a/apps/gui/skin_engine/skin_engine.h +++ b/apps/gui/skin_engine/skin_engine.h | |||
@@ -27,6 +27,15 @@ | |||
27 | 27 | ||
28 | #include "wps_internals.h" /* TODO: remove this line.. shoudlnt be needed */ | 28 | #include "wps_internals.h" /* TODO: remove this line.. shoudlnt be needed */ |
29 | 29 | ||
30 | enum skinnable_screens { | ||
31 | CUSTOM_STATUSBAR, | ||
32 | WPS, | ||
33 | |||
34 | |||
35 | SKINNABLE_SCREENS_COUNT | ||
36 | }; | ||
37 | |||
38 | |||
30 | #ifdef HAVE_TOUCHSCREEN | 39 | #ifdef HAVE_TOUCHSCREEN |
31 | int wps_get_touchaction(struct wps_data *data); | 40 | int wps_get_touchaction(struct wps_data *data); |
32 | #endif | 41 | #endif |
diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index c70a9759ee..4655bf0dff 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c | |||
@@ -62,6 +62,7 @@ | |||
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | #include "backdrop.h" | 64 | #include "backdrop.h" |
65 | #include "statusbar-skinned.h" | ||
65 | 66 | ||
66 | #define WPS_ERROR_INVALID_PARAM -1 | 67 | #define WPS_ERROR_INVALID_PARAM -1 |
67 | 68 | ||
@@ -92,22 +93,6 @@ static struct skin_line *curr_line; | |||
92 | 93 | ||
93 | static int follow_lang_direction = 0; | 94 | static int follow_lang_direction = 0; |
94 | 95 | ||
95 | #ifdef HAVE_LCD_BITMAP | ||
96 | |||
97 | #if LCD_DEPTH > 1 | ||
98 | #define MAX_BITMAPS (MAX_IMAGES+MAX_PROGRESSBARS+1) /* WPS images + pbar bitmap + backdrop */ | ||
99 | #else | ||
100 | #define MAX_BITMAPS (MAX_IMAGES+MAX_PROGRESSBARS) /* WPS images + pbar bitmap */ | ||
101 | #endif | ||
102 | |||
103 | #define PROGRESSBAR_BMP MAX_IMAGES | ||
104 | #define BACKDROP_BMP (MAX_BITMAPS-1) | ||
105 | |||
106 | /* pointers to the bitmap filenames in the WPS source */ | ||
107 | static const char *bmp_names[MAX_BITMAPS]; | ||
108 | |||
109 | #endif /* HAVE_LCD_BITMAP */ | ||
110 | |||
111 | #if defined(DEBUG) || defined(SIMULATOR) | 96 | #if defined(DEBUG) || defined(SIMULATOR) |
112 | /* debugging function */ | 97 | /* debugging function */ |
113 | extern void print_debug_info(struct wps_data *data, int fail, int line); | 98 | extern void print_debug_info(struct wps_data *data, int fail, int line); |
@@ -925,20 +910,29 @@ static int parse_image_special(const char *wps_bufptr, | |||
925 | (void)token; | 910 | (void)token; |
926 | const char *pos = NULL; | 911 | const char *pos = NULL; |
927 | const char *newline; | 912 | const char *newline; |
913 | bool error = false; | ||
928 | 914 | ||
929 | pos = strchr(wps_bufptr + 1, '|'); | 915 | pos = strchr(wps_bufptr + 1, '|'); |
930 | newline = strchr(wps_bufptr, '\n'); | 916 | newline = strchr(wps_bufptr, '\n'); |
917 | |||
918 | error = (pos > newline); | ||
919 | |||
931 | 920 | ||
932 | if (pos > newline) | ||
933 | return WPS_ERROR_INVALID_PARAM; | ||
934 | #if LCD_DEPTH > 1 | 921 | #if LCD_DEPTH > 1 |
935 | if (token->type == WPS_TOKEN_IMAGE_BACKDROP) | 922 | if (token->type == WPS_TOKEN_IMAGE_BACKDROP) |
936 | { | 923 | { |
937 | /* format: %X|filename.bmp| */ | 924 | /* format: %X|filename.bmp| or %Xd */ |
938 | bmp_names[BACKDROP_BMP] = wps_bufptr + 1; | 925 | if (*(wps_bufptr) == 'd') |
926 | { | ||
927 | wps_data->backdrop = NULL; | ||
928 | return skip_end_of_line(wps_bufptr); | ||
929 | } | ||
930 | else if (!error) | ||
931 | wps_data->backdrop = (char*)wps_bufptr + 1; | ||
939 | } | 932 | } |
940 | #endif | 933 | #endif |
941 | 934 | if (error) | |
935 | return WPS_ERROR_INVALID_PARAM; | ||
942 | /* Skip the rest of the line */ | 936 | /* Skip the rest of the line */ |
943 | return skip_end_of_line(wps_bufptr); | 937 | return skip_end_of_line(wps_bufptr); |
944 | } | 938 | } |
@@ -1657,6 +1651,14 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr, bool debug) | |||
1657 | return false; | 1651 | return false; |
1658 | skin_buffer_increment(max_tokens * sizeof(struct wps_token), false); | 1652 | skin_buffer_increment(max_tokens * sizeof(struct wps_token), false); |
1659 | data->num_tokens = 0; | 1653 | data->num_tokens = 0; |
1654 | |||
1655 | #if LCD_DEPTH > 1 | ||
1656 | /* Backdrop defaults to the setting unless %X is used, so set it now */ | ||
1657 | if (global_settings.backdrop_file[0]) | ||
1658 | { | ||
1659 | data->backdrop = "-"; | ||
1660 | } | ||
1661 | #endif | ||
1660 | 1662 | ||
1661 | while (*wps_bufptr && !fail) | 1663 | while (*wps_bufptr && !fail) |
1662 | { | 1664 | { |
@@ -1899,6 +1901,9 @@ static void skin_data_reset(struct wps_data *wps_data) | |||
1899 | wps_data->images = NULL; | 1901 | wps_data->images = NULL; |
1900 | wps_data->progressbars = NULL; | 1902 | wps_data->progressbars = NULL; |
1901 | #endif | 1903 | #endif |
1904 | #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | ||
1905 | wps_data->backdrop = NULL; | ||
1906 | #endif | ||
1902 | #ifdef HAVE_TOUCHSCREEN | 1907 | #ifdef HAVE_TOUCHSCREEN |
1903 | wps_data->touchregions = NULL; | 1908 | wps_data->touchregions = NULL; |
1904 | #endif | 1909 | #endif |
@@ -1996,12 +2001,51 @@ static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir) | |||
1996 | } | 2001 | } |
1997 | 2002 | ||
1998 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) | 2003 | #if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)) |
1999 | if (bmp_names[BACKDROP_BMP]) | 2004 | /* Backdrop load scheme: |
2005 | * 1) %X|filename| | ||
2006 | * 2) load the backdrop from settings | ||
2007 | */ | ||
2008 | if (wps_data->backdrop) | ||
2000 | { | 2009 | { |
2001 | char img_path[MAX_PATH]; | 2010 | char img_path[MAX_PATH]; |
2002 | get_image_filename(bmp_names[BACKDROP_BMP], bmpdir, | 2011 | bool loaded = false; |
2003 | img_path, sizeof(img_path)); | 2012 | size_t buf_size; |
2004 | screens[curr_screen].backdrop_load(BACKDROP_SKIN_WPS, img_path); | 2013 | #if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1) |
2014 | if (curr_screen == SCREEN_REMOTE) | ||
2015 | buf_size = REMOTE_LCD_BACKDROP_BYTES; | ||
2016 | else | ||
2017 | #endif | ||
2018 | buf_size = LCD_BACKDROP_BYTES; | ||
2019 | if (wps_data->backdrop[0] == '-') | ||
2020 | { | ||
2021 | #if NB_SCREENS > 1 | ||
2022 | if (curr_screen == SCREEN_REMOTE) | ||
2023 | { | ||
2024 | wps_data->backdrop = NULL; | ||
2025 | return true; | ||
2026 | } | ||
2027 | else | ||
2028 | #endif | ||
2029 | { | ||
2030 | if (!global_settings.backdrop_file[0]) | ||
2031 | { | ||
2032 | wps_data->backdrop = NULL; | ||
2033 | return true; | ||
2034 | } | ||
2035 | snprintf(img_path, sizeof(img_path), "%s/%s.bmp", | ||
2036 | BACKDROP_DIR, global_settings.backdrop_file); | ||
2037 | } | ||
2038 | } | ||
2039 | else | ||
2040 | { | ||
2041 | get_image_filename(wps_data->backdrop, bmpdir, | ||
2042 | img_path, sizeof(img_path)); | ||
2043 | } | ||
2044 | char *buffer = skin_buffer_alloc(buf_size); | ||
2045 | if (!buffer) | ||
2046 | return false; | ||
2047 | loaded = screens[curr_screen].backdrop_load(img_path, buffer); | ||
2048 | wps_data->backdrop = loaded ? buffer : NULL; | ||
2005 | } | 2049 | } |
2006 | #endif /* has backdrop support */ | 2050 | #endif /* has backdrop support */ |
2007 | 2051 | ||
@@ -2059,7 +2103,18 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data, | |||
2059 | 2103 | ||
2060 | if (!isfile) | 2104 | if (!isfile) |
2061 | { | 2105 | { |
2062 | return wps_parse(wps_data, buf, false); | 2106 | if (wps_parse(wps_data, buf, false)) |
2107 | { | ||
2108 | #ifdef HAVE_LCD_BITMAP | ||
2109 | /* load the backdrop */ | ||
2110 | if (!load_skin_bitmaps(wps_data, BACKDROP_DIR)) { | ||
2111 | skin_data_reset(wps_data); | ||
2112 | return false; | ||
2113 | } | ||
2114 | #endif | ||
2115 | return true; | ||
2116 | } | ||
2117 | return false; | ||
2063 | } | 2118 | } |
2064 | else | 2119 | else |
2065 | { | 2120 | { |
@@ -2093,11 +2148,6 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data, | |||
2093 | if (start <= 0) | 2148 | if (start <= 0) |
2094 | return false; | 2149 | return false; |
2095 | 2150 | ||
2096 | #ifdef HAVE_LCD_BITMAP | ||
2097 | /* Set all filename pointers to NULL */ | ||
2098 | memset(bmp_names, 0, sizeof(bmp_names)); | ||
2099 | #endif | ||
2100 | |||
2101 | /* parse the WPS source */ | 2151 | /* parse the WPS source */ |
2102 | if (!wps_parse(wps_data, wps_buffer, true)) { | 2152 | if (!wps_parse(wps_data, wps_buffer, true)) { |
2103 | skin_data_reset(wps_data); | 2153 | skin_data_reset(wps_data); |
@@ -2116,6 +2166,7 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data, | |||
2116 | /* load the bitmaps that were found by the parsing */ | 2166 | /* load the bitmaps that were found by the parsing */ |
2117 | if (!load_skin_bitmaps(wps_data, bmpdir)) { | 2167 | if (!load_skin_bitmaps(wps_data, bmpdir)) { |
2118 | skin_data_reset(wps_data); | 2168 | skin_data_reset(wps_data); |
2169 | wps_data->wps_loaded = false; | ||
2119 | return false; | 2170 | return false; |
2120 | } | 2171 | } |
2121 | #endif | 2172 | #endif |
diff --git a/apps/gui/skin_engine/wps_internals.h b/apps/gui/skin_engine/wps_internals.h index 837e56eab1..e659f08d35 100644 --- a/apps/gui/skin_engine/wps_internals.h +++ b/apps/gui/skin_engine/wps_internals.h | |||
@@ -271,6 +271,9 @@ struct wps_data | |||
271 | struct skin_token_list *images; | 271 | struct skin_token_list *images; |
272 | struct skin_token_list *progressbars; | 272 | struct skin_token_list *progressbars; |
273 | #endif | 273 | #endif |
274 | #if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | ||
275 | char *backdrop; | ||
276 | #endif | ||
274 | 277 | ||
275 | #ifdef HAVE_TOUCHSCREEN | 278 | #ifdef HAVE_TOUCHSCREEN |
276 | struct skin_token_list *touchregions; | 279 | struct skin_token_list *touchregions; |