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
This commit is contained in:
parent
6ddb5f2429
commit
93b899d0fe
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
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"
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
#endif
|
||||
void unload_main_backdrop(void);
|
||||
void unload_wps_backdrop(void);
|
||||
|
||||
#endif
|
||||
void show_main_backdrop(void);
|
||||
void show_wps_backdrop(void);
|
||||
|
||||
#endif /* HAVE_LCD_COLOR */
|
||||
|
||||
#endif /* _BACKDROP_H */
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
17
apps/tree.c
17
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user