summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2006-05-21 11:00:02 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2006-05-21 11:00:02 +0000
commit93b899d0fe3426ed50de06d20cdefb6d288e5ec2 (patch)
tree0dd0af26a5797a02f9a1f0139fde9fb60e1844bb /apps
parent6ddb5f24294d68749e53c10a99ca09aca9f9f7eb (diff)
downloadrockbox-93b899d0fe3426ed50de06d20cdefb6d288e5ec2.tar.gz
rockbox-93b899d0fe3426ed50de06d20cdefb6d288e5ec2.tar.bz2
rockbox-93b899d0fe3426ed50de06d20cdefb6d288e5ec2.zip
Reworked backdrop handling. Fixes a bug that wasn't in the tracker yet ;)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9970 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/filetree.c8
-rw-r--r--apps/gui/gwps-common.c52
-rw-r--r--apps/gui/gwps.c55
-rw-r--r--apps/gui/gwps.h4
-rw-r--r--apps/onplay.c13
-rw-r--r--apps/recorder/backdrop.c63
-rw-r--r--apps/recorder/backdrop.h16
-rw-r--r--apps/screens.c7
-rw-r--r--apps/settings.c17
-rw-r--r--apps/settings_menu.c7
-rw-r--r--apps/tree.c17
11 files changed, 147 insertions, 112 deletions
diff --git a/apps/filetree.c b/apps/filetree.c
index 72a58c7fe1..acceb0b93b 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -53,6 +53,11 @@
static int boot_size = 0;
static int boot_cluster;
#endif
+
+#ifdef HAVE_LCD_COLOR
+#include "backdrop.h"
+#endif
+
extern bool boot_changed;
int ft_build_playlist(struct tree_context* c, int start_index)
@@ -461,6 +466,9 @@ int ft_enter(struct tree_context* c)
/* wps config file */
case TREE_ATTR_WPS:
gui_syncsplash(0, true, str(LANG_WAIT));
+#ifdef HAVE_LCD_COLOR
+ unload_wps_backdrop();
+#endif
wps_data_load(gui_wps[0].data, buf, true);
set_file(buf, (char *)global_settings.wps_file,
MAX_FILENAME);
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index 349c92b9a0..5ab6ce8c82 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -146,44 +146,31 @@ bool wps_data_preload_tags(struct wps_data *data, char *buf,
case 'X':
/* Backdrop image - must be the same size as the LCD */
{
- int ret = 0;
- struct bitmap bm;
char *ptr = buf+2;
char *pos = NULL;
char imgname[MAX_PATH];
/* format: %X|filename.bmp| */
- {
- /* get filename */
- pos = strchr(ptr, '|');
- if ((pos - ptr) <
- (int)sizeof(imgname)-ROCKBOX_DIR_LEN-2)
- {
- memcpy(imgname, bmpdir, bmpdirlen);
- imgname[bmpdirlen] = '/';
- memcpy(&imgname[bmpdirlen+1],
- ptr, pos - ptr);
- imgname[bmpdirlen+1+pos-ptr] = 0;
- }
- else
- /* filename too long */
- imgname[0] = 0;
-
- ptr = pos+1;
- /* load the image */
- bm.data=(char*)&wps_backdrop[0][0];
- ret = read_bmp_file(imgname, &bm,
- sizeof(wps_backdrop), FORMAT_NATIVE);
-
- if ((ret > 0) && (bm.width == LCD_WIDTH)
- && (bm.height == LCD_HEIGHT)) {
- data->has_backdrop=true;
- return true;
- } else {
- return false;
- }
+ /* get filename */
+ pos = strchr(ptr, '|');
+ if ((pos - ptr) <
+ (int)sizeof(imgname)-ROCKBOX_DIR_LEN-2)
+ {
+ memcpy(imgname, bmpdir, bmpdirlen);
+ imgname[bmpdirlen] = '/';
+ memcpy(&imgname[bmpdirlen+1],
+ ptr, pos - ptr);
+ imgname[bmpdirlen+1+pos-ptr] = 0;
}
+ else
+ {
+ /* filename too long */
+ imgname[0] = 0;
+ }
+
+ /* load the image */
+ return load_wps_backdrop(imgname);
}
break;
@@ -2460,6 +2447,9 @@ bool gui_wps_display(void)
if(i == 0)
{
#ifdef HAVE_LCD_BITMAP
+#ifdef HAVE_LCD_COLOR
+ unload_wps_backdrop();
+#endif
wps_data_load(gui_wps[i].data,
"%s%?it<%?in<%in. |>%it|%fn>\n"
"%s%?ia<%ia|%?d2<%d2|(root)>>\n"
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c
index b84027c61c..d7a27e8eb9 100644
--- a/apps/gui/gwps.c
+++ b/apps/gui/gwps.c
@@ -105,18 +105,8 @@ long gui_wps_show(void)
gui_wps_set_margin(&gui_wps[i]);
}
#ifdef HAVE_LCD_COLOR
- gui_wps[SCREEN_MAIN].data->old_backdrop = lcd_get_backdrop();
- if (gui_wps[SCREEN_MAIN].data->has_backdrop)
- {
- lcd_set_backdrop(&wps_backdrop[0][0]);
- }
- else
- {
- /* wps has no backdrop, so clear it in case we're switching wps */
- lcd_set_backdrop(gui_wps[SCREEN_MAIN].data->old_backdrop);
- }
-
-#endif
+ show_wps_backdrop();
+#endif /* HAVE_LCD_COLOR */
#endif
#ifdef AB_REPEAT_ENABLE
@@ -241,12 +231,11 @@ long gui_wps_show(void)
case WPS_RC_CONTEXT:
#endif
#ifdef HAVE_LCD_COLOR
- lcd_set_backdrop(gui_wps[SCREEN_MAIN].data->old_backdrop);
+ show_main_backdrop();
#endif
onplay(wps_state.id3->path, TREE_ATTR_MPA, CONTEXT_WPS);
#ifdef HAVE_LCD_COLOR
- if (gui_wps[SCREEN_MAIN].data->has_backdrop)
- lcd_set_backdrop(&wps_backdrop[0][0]);
+ show_wps_backdrop();
#endif
#ifdef HAVE_LCD_BITMAP
FOR_NB_SCREENS(i)
@@ -557,16 +546,12 @@ long gui_wps_show(void)
gui_wps[i].display->stop_scroll();
#ifdef HAVE_LCD_COLOR
- lcd_set_backdrop(gui_wps[SCREEN_MAIN].data->old_backdrop);
+ show_main_backdrop();
#endif
if (main_menu())
return true;
#ifdef HAVE_LCD_COLOR
- if(global_settings.backdrop_file[0] == 0)
- gui_wps[SCREEN_MAIN].data->old_backdrop = NULL;
-
- if (gui_wps[SCREEN_MAIN].data->has_backdrop)
- lcd_set_backdrop(&wps_backdrop[0][0]);
+ show_wps_backdrop();
#endif
#ifdef HAVE_LCD_BITMAP
FOR_NB_SCREENS(i)
@@ -596,13 +581,12 @@ long gui_wps_show(void)
case WPS_RC_QUICK:
#endif
#ifdef HAVE_LCD_COLOR
- lcd_set_backdrop(gui_wps[SCREEN_MAIN].data->old_backdrop);
+ show_main_backdrop();
#endif
if (quick_screen_quick(button))
return SYS_USB_CONNECTED;
#ifdef HAVE_LCD_COLOR
- if (gui_wps[SCREEN_MAIN].data->has_backdrop)
- lcd_set_backdrop(&wps_backdrop[0][0]);
+ show_wps_backdrop();
#endif
#ifdef HAVE_LCD_BITMAP
FOR_NB_SCREENS(i)
@@ -629,13 +613,12 @@ long gui_wps_show(void)
case BUTTON_ON | BUTTON_UP:
case BUTTON_ON | BUTTON_DOWN:
#ifdef HAVE_LCD_COLOR
- lcd_set_backdrop(gui_wps[SCREEN_MAIN].data->old_backdrop);
+ show_main_backdrop();
#endif
if (1 == pitch_screen())
return SYS_USB_CONNECTED;
#ifdef HAVE_LCD_COLOR
- if (gui_wps[SCREEN_MAIN].data->has_backdrop)
- lcd_set_backdrop(&wps_backdrop[0][0]);
+ show_wps_backdrop();
#endif
restore = true;
break;
@@ -730,12 +713,11 @@ long gui_wps_show(void)
#ifdef WPS_ID3
case WPS_ID3:
#ifdef HAVE_LCD_COLOR
- lcd_set_backdrop(gui_wps[SCREEN_MAIN].data->old_backdrop);
+ show_main_backdrop();
#endif
browse_id3();
#ifdef HAVE_LCD_COLOR
- if (gui_wps[SCREEN_MAIN].data->has_backdrop)
- lcd_set_backdrop(&wps_backdrop[0][0]);
+ show_wps_backdrop();
#endif
#ifdef HAVE_LCD_BITMAP
FOR_NB_SCREENS(i)
@@ -754,19 +736,14 @@ long gui_wps_show(void)
case SYS_POWEROFF:
bookmark_autobookmark();
#ifdef HAVE_LCD_COLOR
- lcd_set_backdrop(gui_wps[SCREEN_MAIN].data->old_backdrop);
+ show_main_backdrop();
#endif
default_event_handler(SYS_POWEROFF);
break;
default:
if(default_event_handler(button) == SYS_USB_CONNECTED)
- {
-#ifdef HAVE_LCD_COLOR
- lcd_set_backdrop(gui_wps[SCREEN_MAIN].data->old_backdrop);
-#endif
return SYS_USB_CONNECTED;
- }
update_track = true;
break;
}
@@ -887,9 +864,6 @@ void wps_data_init(struct wps_data *wps_data)
wps_data->format_buffer[0] = '\0';
wps_data->wps_loaded = false;
wps_data->peak_meter_enabled = false;
-#ifdef HAVE_LCD_COLOR
- wps_data->has_backdrop = false;
-#endif
}
static void wps_reset(struct wps_data *data)
@@ -1075,4 +1049,7 @@ void gui_sync_wps_init(void)
gui_wps_set_data(&gui_wps[i], &wps_datas[i]);
gui_wps_set_statusbar(&gui_wps[i], &statusbars.statusbars[i]);
}
+#ifdef HAVE_LCD_COLOR
+ unload_wps_backdrop();
+#endif
}
diff --git a/apps/gui/gwps.h b/apps/gui/gwps.h
index 08299acbfc..3911ad1825 100644
--- a/apps/gui/gwps.h
+++ b/apps/gui/gwps.h
@@ -367,10 +367,6 @@ struct wps_data
int progress_end;
bool wps_loaded;
bool peak_meter_enabled;
-#ifdef HAVE_LCD_COLOR
- bool has_backdrop;
- fb_data* old_backdrop;
-#endif
};
/* initial setup of wps_data */
diff --git a/apps/onplay.c b/apps/onplay.c
index 6ff99d7dd1..bc486d1a38 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -433,22 +433,13 @@ static bool delete_dir(void)
#ifdef HAVE_LCD_COLOR
static bool set_backdrop(void)
{
- struct bitmap bm;
- int ret;
-
/* load the image */
- bm.data=(char*)&main_backdrop[0][0];
- ret = read_bmp_file(selected_file, &bm,
- sizeof(main_backdrop), FORMAT_NATIVE);
-
- if ((ret > 0) && (bm.width == LCD_WIDTH)
- && (bm.height == LCD_HEIGHT)) {
- lcd_set_backdrop(&main_backdrop[0][0]);
+ if(load_main_backdrop(selected_file)) {
gui_syncsplash(HZ, true, str(LANG_BACKDROP_LOADED));
set_file(selected_file, (char *)global_settings.backdrop_file, MAX_FILENAME);
+ show_main_backdrop();
return true;
} else {
- lcd_set_backdrop(NULL);
gui_syncsplash(HZ, true, str(LANG_BACKDROP_FAILED));
return false;
}
diff --git a/apps/recorder/backdrop.c b/apps/recorder/backdrop.c
index 6fc5e24118..d230a6ec5a 100644
--- a/apps/recorder/backdrop.c
+++ b/apps/recorder/backdrop.c
@@ -21,25 +21,74 @@
#include "config.h"
#include "lcd.h"
#include "backdrop.h"
+#include "splash.h" /* debugging */
fb_data main_backdrop[LCD_HEIGHT][LCD_WIDTH];
fb_data wps_backdrop[LCD_HEIGHT][LCD_WIDTH];
+bool main_backdrop_valid = false;
+bool wps_backdrop_valid = false;
-bool load_main_backdrop(char* filename)
+/* load a backdrop into a buffer */
+bool load_backdrop(char* filename, fb_data* backdrop_buffer)
{
struct bitmap bm;
int ret;
/* load the image */
- bm.data=(char*)&main_backdrop[0][0];
+ bm.data=(char*)backdrop_buffer;
ret = read_bmp_file(filename, &bm, sizeof(main_backdrop), FORMAT_NATIVE);
- if ((ret > 0) && (bm.width == LCD_WIDTH)
- && (bm.height == LCD_HEIGHT)) {
- lcd_set_backdrop(&main_backdrop[0][0]);
+ if ((ret > 0) && (bm.width == LCD_WIDTH) && (bm.height == LCD_HEIGHT))
+ {
return true;
- } else {
- lcd_set_backdrop(NULL);
+ }
+ else
+ {
return false;
}
}
+
+bool load_main_backdrop(char* filename)
+{
+ main_backdrop_valid = load_backdrop(filename, &main_backdrop[0][0]);
+/* gui_syncsplash(100, true, "MAIN backdrop load: %s", main_backdrop_valid ? "OK" : "FAIL");*/
+ return main_backdrop_valid;
+}
+
+bool load_wps_backdrop(char* filename)
+{
+ wps_backdrop_valid = load_backdrop(filename, &wps_backdrop[0][0]);
+/* gui_syncsplash(100, true, "WPS backdrop load: %s", main_backdrop_valid ? "OK" : "FAIL");*/
+ return wps_backdrop_valid;
+}
+
+void unload_main_backdrop(void)
+{
+ main_backdrop_valid = false;
+/* gui_syncsplash(100, true, "MAIN backdrop unload");*/
+}
+
+void unload_wps_backdrop(void)
+{
+ wps_backdrop_valid = false;
+/* gui_syncsplash(100, true, "WPS backdrop unload");*/
+}
+
+void show_main_backdrop(void)
+{
+ lcd_set_backdrop(main_backdrop_valid ? &main_backdrop[0][0] : NULL);
+}
+
+void show_wps_backdrop(void)
+{
+ /* if no wps backdrop, fall back to main backdrop */
+ if(wps_backdrop_valid)
+ {
+ lcd_set_backdrop(&wps_backdrop[0][0]);
+ }
+ else
+ {
+/* gui_syncsplash(100, true, "WPS backdrop show: fallback to MAIN");*/
+ show_main_backdrop();
+ }
+}
diff --git a/apps/recorder/backdrop.h b/apps/recorder/backdrop.h
index d77985cf28..da515af261 100644
--- a/apps/recorder/backdrop.h
+++ b/apps/recorder/backdrop.h
@@ -25,14 +25,20 @@
#include "lcd.h"
#include "bmp.h"
#include "backdrop.h"
-
-#ifdef HAVE_LCD_COLOR
+/*
extern fb_data main_backdrop[LCD_HEIGHT][LCD_WIDTH];
extern fb_data wps_backdrop[LCD_HEIGHT][LCD_WIDTH];
-#endif
+*/
bool load_main_backdrop(char* filename);
+bool load_wps_backdrop(char* filename);
+
+void unload_main_backdrop(void);
+void unload_wps_backdrop(void);
+
+void show_main_backdrop(void);
+void show_wps_backdrop(void);
-#endif
+#endif /* HAVE_LCD_COLOR */
-#endif
+#endif /* _BACKDROP_H */
diff --git a/apps/screens.c b/apps/screens.c
index 1507b6dd74..b7e4575534 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -64,6 +64,10 @@
#include "dsp.h"
#endif
+#ifdef HAVE_LCD_COLOR
+#include "backdrop.h"
+#endif
+
#ifdef HAVE_LCD_BITMAP
#define SCROLLBAR_WIDTH 6
#endif
@@ -74,6 +78,9 @@ void usb_screen(void)
/* nothing here! */
#else
int i;
+#ifdef HAVE_LCD_COLOR
+ show_main_backdrop();
+#endif
FOR_NB_SCREENS(i) {
screens[i].backlight_on();
gui_logo_draw(&usb_logos[i], &screens[i]);
diff --git a/apps/settings.c b/apps/settings.c
index f1b6f29957..1a6b4c3199 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -1055,6 +1055,9 @@ void settings_apply(void)
global_settings.peak_meter_clip_hold);
#endif
+#ifdef HAVE_LCD_COLOR
+ unload_wps_backdrop();
+#endif
if ( global_settings.wps_file[0] &&
global_settings.wps_file[0] != 0xff ) {
snprintf(buf, sizeof buf, WPS_DIR "/%s.wps",
@@ -1062,18 +1065,21 @@ void settings_apply(void)
wps_data_load(gui_wps[0].data, buf, true);
}
else
+ {
wps_data_init(gui_wps[0].data);
+ }
#ifdef HAVE_LCD_COLOR
if ( global_settings.backdrop_file[0] &&
global_settings.backdrop_file[0] != 0xff ) {
snprintf(buf, sizeof buf, BACKDROP_DIR "/%s.bmp",
global_settings.backdrop_file);
-
load_main_backdrop(buf);
} else {
- lcd_set_backdrop(NULL);
+ unload_main_backdrop();
}
+ show_main_backdrop();
+
screens[SCREEN_MAIN].set_foreground(global_settings.fg_color);
screens[SCREEN_MAIN].set_background(global_settings.bg_color);
#endif
@@ -1415,6 +1421,9 @@ bool settings_load_config(const char* file)
/* check for the string values */
if (!strcasecmp(name, "wps")) {
+#ifdef HAVE_LCD_COLOR
+ unload_wps_backdrop();
+#endif
if (wps_data_load(gui_wps[0].data, value, true))
set_file(value, (char *)global_settings.wps_file, MAX_FILENAME);
}
@@ -1444,8 +1453,10 @@ bool settings_load_config(const char* file)
#endif
#ifdef HAVE_LCD_COLOR
else if (!strcasecmp(name, "backdrop")) {
- if (load_main_backdrop(value))
+ if (load_main_backdrop(value)) {
set_file(value, (char *)global_settings.backdrop_file, MAX_FILENAME);
+ show_main_backdrop();
+ }
}
#endif
#ifdef HAVE_LCD_BITMAP
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 4d80ed8c73..c15eb6cf91 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -78,6 +78,10 @@ void dac_line_in(bool enable);
#include "dsp.h"
#endif
+#ifdef HAVE_LCD_COLOR
+#include "backdrop.h"
+#endif
+
#ifdef HAVE_CHARGING
static bool car_adapter_mode(void)
{
@@ -323,7 +327,8 @@ static bool invert_cursor(void)
static bool clear_main_backdrop(void)
{
global_settings.backdrop_file[0]=0;
- lcd_set_backdrop(NULL);
+ unload_main_backdrop();
+ show_main_backdrop();
return false;
}
diff --git a/apps/tree.c b/apps/tree.c
index 6141a000bd..8eaff87fd8 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -75,6 +75,10 @@
#include "widgets.h"
#endif
+#ifdef HAVE_LCD_COLOR
+#include "backdrop.h"
+#endif
+
/* a table for the know file types */
const struct filetype filetypes[] = {
{ "mp3", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA },
@@ -877,23 +881,14 @@ static bool dirbrowse(void)
if (start_wps && audio_status() )
{
int i;
-#ifdef HAVE_LCD_COLOR
- fb_data* old_backdrop;
-#endif
FOR_NB_SCREENS(i)
screens[i].stop_scroll();
-#ifdef HAVE_LCD_COLOR
- old_backdrop = lcd_get_backdrop();
-#endif
+
if (gui_wps_show() == SYS_USB_CONNECTED)
reload_dir = true;
#ifdef HAVE_LCD_COLOR
- /* check if the backdrop hasn't been cleared */
- if(global_settings.backdrop_file[0])
- lcd_set_backdrop(old_backdrop);
- else
- lcd_set_backdrop(NULL);
+ show_main_backdrop();
#endif
#ifdef HAVE_HOTSWAP
else