summaryrefslogtreecommitdiff
path: root/apps/gui/skin_engine
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/skin_engine')
-rw-r--r--apps/gui/skin_engine/skin_buffer.c11
-rw-r--r--apps/gui/skin_engine/skin_display.c4
-rw-r--r--apps/gui/skin_engine/skin_engine.h9
-rw-r--r--apps/gui/skin_engine/skin_parser.c113
-rw-r--r--apps/gui/skin_engine/wps_internals.h3
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 @@
#include "buffer.h"
#include "settings.h"
#include "screen_access.h"
+#include "skin_engine.h"
#include "wps_internals.h"
#include "skin_tokens.h"
#include "skin_buffer.h"
@@ -46,7 +47,7 @@
* items with unknown sizes get allocated from the start (0->) (data)
* items with known sizes get allocated from the end (<-buf_size) (tokens)
* After loading 2 skins the buffer will look like this:
- * |tokens skin1|images skin2|---SPACE---|data skin2|data skin1|
+ * |tokens skin1|images skin1|tokens s2|images s2|---SPACE---|data skin2|data skin1|
* Make sure to never start allocating from the beginning before letting us know
* how much was used. and RESPECT THE buf_free RETURN VALUES!
*
@@ -54,12 +55,12 @@
#ifdef HAVE_LCD_BITMAP
-#define MAIN_BUFFER ((LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \
- + (2*LCD_HEIGHT*LCD_WIDTH/8))
+#define MAIN_BUFFER ((2*LCD_HEIGHT*LCD_WIDTH*LCD_DEPTH/8) \
+ + (SKINNABLE_SCREENS_COUNT * LCD_BACKDROP_BYTES))
#if (NB_SCREENS > 1)
-#define REMOTE_BUFFER ((LCD_REMOTE_HEIGHT*LCD_REMOTE_WIDTH*LCD_REMOTE_DEPTH/8) \
- + (2*LCD_REMOTE_HEIGHT*LCD_REMOTE_WIDTH/8))
+#define REMOTE_BUFFER (2*(LCD_REMOTE_HEIGHT*LCD_REMOTE_WIDTH*LCD_REMOTE_DEPTH/8) \
+ + (SKINNABLE_SCREENS_COUNT * REMOTE_LCD_BACKDROP_BYTES))
#else
#define REMOTE_BUFFER 0
#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)
{
struct skin_line *line;
struct skin_viewport *skin_viewport = find_viewport(VP_DEFAULT_LABEL, data);
+
+#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1)
+ display->backdrop_show(data->backdrop);
+#endif
if (!(skin_viewport->hidden_flags & VP_NEVER_VISIBLE))
{
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 @@
#include "wps_internals.h" /* TODO: remove this line.. shoudlnt be needed */
+enum skinnable_screens {
+ CUSTOM_STATUSBAR,
+ WPS,
+
+
+ SKINNABLE_SCREENS_COUNT
+};
+
+
#ifdef HAVE_TOUCHSCREEN
int wps_get_touchaction(struct wps_data *data);
#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 @@
#endif
#include "backdrop.h"
+#include "statusbar-skinned.h"
#define WPS_ERROR_INVALID_PARAM -1
@@ -92,22 +93,6 @@ static struct skin_line *curr_line;
static int follow_lang_direction = 0;
-#ifdef HAVE_LCD_BITMAP
-
-#if LCD_DEPTH > 1
-#define MAX_BITMAPS (MAX_IMAGES+MAX_PROGRESSBARS+1) /* WPS images + pbar bitmap + backdrop */
-#else
-#define MAX_BITMAPS (MAX_IMAGES+MAX_PROGRESSBARS) /* WPS images + pbar bitmap */
-#endif
-
-#define PROGRESSBAR_BMP MAX_IMAGES
-#define BACKDROP_BMP (MAX_BITMAPS-1)
-
-/* pointers to the bitmap filenames in the WPS source */
-static const char *bmp_names[MAX_BITMAPS];
-
-#endif /* HAVE_LCD_BITMAP */
-
#if defined(DEBUG) || defined(SIMULATOR)
/* debugging function */
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,
(void)token;
const char *pos = NULL;
const char *newline;
+ bool error = false;
pos = strchr(wps_bufptr + 1, '|');
newline = strchr(wps_bufptr, '\n');
+
+ error = (pos > newline);
+
- if (pos > newline)
- return WPS_ERROR_INVALID_PARAM;
#if LCD_DEPTH > 1
if (token->type == WPS_TOKEN_IMAGE_BACKDROP)
{
- /* format: %X|filename.bmp| */
- bmp_names[BACKDROP_BMP] = wps_bufptr + 1;
+ /* format: %X|filename.bmp| or %Xd */
+ if (*(wps_bufptr) == 'd')
+ {
+ wps_data->backdrop = NULL;
+ return skip_end_of_line(wps_bufptr);
+ }
+ else if (!error)
+ wps_data->backdrop = (char*)wps_bufptr + 1;
}
#endif
-
+ if (error)
+ return WPS_ERROR_INVALID_PARAM;
/* Skip the rest of the line */
return skip_end_of_line(wps_bufptr);
}
@@ -1657,6 +1651,14 @@ static bool wps_parse(struct wps_data *data, const char *wps_bufptr, bool debug)
return false;
skin_buffer_increment(max_tokens * sizeof(struct wps_token), false);
data->num_tokens = 0;
+
+#if LCD_DEPTH > 1
+ /* Backdrop defaults to the setting unless %X is used, so set it now */
+ if (global_settings.backdrop_file[0])
+ {
+ data->backdrop = "-";
+ }
+#endif
while (*wps_bufptr && !fail)
{
@@ -1899,6 +1901,9 @@ static void skin_data_reset(struct wps_data *wps_data)
wps_data->images = NULL;
wps_data->progressbars = NULL;
#endif
+#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
+ wps_data->backdrop = NULL;
+#endif
#ifdef HAVE_TOUCHSCREEN
wps_data->touchregions = NULL;
#endif
@@ -1996,12 +2001,51 @@ static bool load_skin_bitmaps(struct wps_data *wps_data, char *bmpdir)
}
#if (LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1))
- if (bmp_names[BACKDROP_BMP])
+ /* Backdrop load scheme:
+ * 1) %X|filename|
+ * 2) load the backdrop from settings
+ */
+ if (wps_data->backdrop)
{
char img_path[MAX_PATH];
- get_image_filename(bmp_names[BACKDROP_BMP], bmpdir,
- img_path, sizeof(img_path));
- screens[curr_screen].backdrop_load(BACKDROP_SKIN_WPS, img_path);
+ bool loaded = false;
+ size_t buf_size;
+#if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
+ if (curr_screen == SCREEN_REMOTE)
+ buf_size = REMOTE_LCD_BACKDROP_BYTES;
+ else
+#endif
+ buf_size = LCD_BACKDROP_BYTES;
+ if (wps_data->backdrop[0] == '-')
+ {
+#if NB_SCREENS > 1
+ if (curr_screen == SCREEN_REMOTE)
+ {
+ wps_data->backdrop = NULL;
+ return true;
+ }
+ else
+#endif
+ {
+ if (!global_settings.backdrop_file[0])
+ {
+ wps_data->backdrop = NULL;
+ return true;
+ }
+ snprintf(img_path, sizeof(img_path), "%s/%s.bmp",
+ BACKDROP_DIR, global_settings.backdrop_file);
+ }
+ }
+ else
+ {
+ get_image_filename(wps_data->backdrop, bmpdir,
+ img_path, sizeof(img_path));
+ }
+ char *buffer = skin_buffer_alloc(buf_size);
+ if (!buffer)
+ return false;
+ loaded = screens[curr_screen].backdrop_load(img_path, buffer);
+ wps_data->backdrop = loaded ? buffer : NULL;
}
#endif /* has backdrop support */
@@ -2059,7 +2103,18 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
if (!isfile)
{
- return wps_parse(wps_data, buf, false);
+ if (wps_parse(wps_data, buf, false))
+ {
+#ifdef HAVE_LCD_BITMAP
+ /* load the backdrop */
+ if (!load_skin_bitmaps(wps_data, BACKDROP_DIR)) {
+ skin_data_reset(wps_data);
+ return false;
+ }
+#endif
+ return true;
+ }
+ return false;
}
else
{
@@ -2093,11 +2148,6 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
if (start <= 0)
return false;
-#ifdef HAVE_LCD_BITMAP
- /* Set all filename pointers to NULL */
- memset(bmp_names, 0, sizeof(bmp_names));
-#endif
-
/* parse the WPS source */
if (!wps_parse(wps_data, wps_buffer, true)) {
skin_data_reset(wps_data);
@@ -2116,6 +2166,7 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
/* load the bitmaps that were found by the parsing */
if (!load_skin_bitmaps(wps_data, bmpdir)) {
skin_data_reset(wps_data);
+ wps_data->wps_loaded = false;
return false;
}
#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
struct skin_token_list *images;
struct skin_token_list *progressbars;
#endif
+#if LCD_DEPTH > 1 || defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
+ char *backdrop;
+#endif
#ifdef HAVE_TOUCHSCREEN
struct skin_token_list *touchregions;