summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2006-02-02 20:42:56 +0000
committerDave Chapman <dave@dchapman.com>2006-02-02 20:42:56 +0000
commitd9e5b67b71cf246c11da8a9083af21752ac7bd15 (patch)
tree99ac1903b7b0a7197483fa64add73e6062d169af /apps/gui
parent9b4b4d0bf2366ebbbb3cbb14eeb457da9f2658eb (diff)
downloadrockbox-d9e5b67b71cf246c11da8a9083af21752ac7bd15.tar.gz
rockbox-d9e5b67b71cf246c11da8a9083af21752ac7bd15.zip
Patch #1421422 - Backdrop image patch started by Linus, finished by me. Adds ability to set backdrop images for file browser and menus (store full-screen bitmaps in /.rockbox/backdrops/) and also the ability to set a full-screen background image in a WPS using the %X|filename.bmp| WPS tag. Currently only implemented for targets with colour LCDs.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8536 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/gwps-common.c58
-rw-r--r--apps/gui/gwps.c44
2 files changed, 99 insertions, 3 deletions
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index ca839a9bfa..09c271b904 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -28,6 +28,7 @@
28#include "power.h" 28#include "power.h"
29#include "powermgmt.h" 29#include "powermgmt.h"
30#include "sound.h" 30#include "sound.h"
31#include "debug.h"
31#ifdef HAVE_LCD_CHARCELLS 32#ifdef HAVE_LCD_CHARCELLS
32#include "hwcompat.h" 33#include "hwcompat.h"
33#endif 34#endif
@@ -36,10 +37,11 @@
36#include "backlight.h" 37#include "backlight.h"
37#include "lang.h" 38#include "lang.h"
38#include "misc.h" 39#include "misc.h"
39 40#include "backdrop.h"
40#include "splash.h" 41#include "splash.h"
41#include "scrollbar.h" 42#include "scrollbar.h"
42#include "led.h" 43#include "led.h"
44#include "lcd.h"
43#ifdef HAVE_LCD_BITMAP 45#ifdef HAVE_LCD_BITMAP
44#include "peakmeter.h" 46#include "peakmeter.h"
45/* Image stuff */ 47/* Image stuff */
@@ -57,6 +59,10 @@ static void draw_player_fullbar(struct gui_wps *gwps,
57 /* 3% of 30min file == 54s step size */ 59 /* 3% of 30min file == 54s step size */
58#define MIN_FF_REWIND_STEP 500 60#define MIN_FF_REWIND_STEP 500
59 61
62#ifdef HAVE_LCD_COLOR
63extern bool wps_has_backdrop;
64#endif
65
60/* Skip leading UTF-8 BOM, if present. */ 66/* Skip leading UTF-8 BOM, if present. */
61static char* skip_utf8_bom(char* buf) 67static char* skip_utf8_bom(char* buf)
62{ 68{
@@ -88,6 +94,7 @@ static int get_image_id(int c)
88/* 94/*
89 * parse the given buffer for following static tags: 95 * parse the given buffer for following static tags:
90 * %x - load image for always display 96 * %x - load image for always display
97 * %X - load backdrop image
91 * %xl - preload image 98 * %xl - preload image
92 * %we - enable statusbar on wps regardless of the global setting 99 * %we - enable statusbar on wps regardless of the global setting
93 * %wd - disable statusbar on wps regardless of the global setting 100 * %wd - disable statusbar on wps regardless of the global setting
@@ -133,7 +140,54 @@ bool wps_data_preload_tags(struct wps_data *data, char *buf,
133 return true; 140 return true;
134 } 141 }
135 break; 142 break;
136 143
144#ifdef HAVE_LCD_COLOR
145 case 'X':
146 /* Backdrop image - must be the same size as the LCD */
147 {
148 int ret = 0;
149 struct bitmap bm;
150 char *ptr = buf+2;
151 char *pos = NULL;
152 char imgname[MAX_PATH];
153
154 /* format: %X|filename.bmp| */
155 {
156 /* get filename */
157 pos = strchr(ptr, '|');
158 if ((pos - ptr) <
159 (int)sizeof(imgname)-ROCKBOX_DIR_LEN-2)
160 {
161 memcpy(imgname, bmpdir, bmpdirlen);
162 imgname[bmpdirlen] = '/';
163 memcpy(&imgname[bmpdirlen+1],
164 ptr, pos - ptr);
165 imgname[bmpdirlen+1+pos-ptr] = 0;
166 }
167 else
168 /* filename too long */
169 imgname[0] = 0;
170
171 ptr = pos+1;
172
173 /* load the image */
174 bm.data=(char*)&wps_backdrop[0][0];
175 ret = read_bmp_file(imgname, &bm,
176 sizeof(wps_backdrop), FORMAT_NATIVE);
177
178 if ((ret > 0) && (bm.width == LCD_WIDTH)
179 && (bm.height == LCD_HEIGHT)) {
180 wps_has_backdrop=true;
181 return true;
182 } else {
183 return false;
184 }
185 }
186 }
187
188 break;
189#endif
190
137 case 'x': 191 case 'x':
138 /* Preload images so the %xd# tag can display it */ 192 /* Preload images so the %xd# tag can display it */
139 { 193 {
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c
index d7d436c089..00d7aaa507 100644
--- a/apps/gui/gwps.c
+++ b/apps/gui/gwps.c
@@ -52,7 +52,7 @@
52#include "onplay.h" 52#include "onplay.h"
53#include "abrepeat.h" 53#include "abrepeat.h"
54#include "playback.h" 54#include "playback.h"
55 55#include "backdrop.h"
56#include "splash.h" 56#include "splash.h"
57 57
58#define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps" 58#define WPS_DEFAULTCFG WPS_DIR "/rockbox_default.wps"
@@ -62,6 +62,11 @@ struct wps_state wps_state;
62struct gui_wps gui_wps[NB_SCREENS]; 62struct gui_wps gui_wps[NB_SCREENS];
63static struct wps_data wps_datas[NB_SCREENS]; 63static struct wps_data wps_datas[NB_SCREENS];
64 64
65#ifdef HAVE_LCD_COLOR
66bool wps_has_backdrop;
67fb_data* old_backdrop;
68#endif
69
65bool keys_locked = false; 70bool keys_locked = false;
66 71
67/* change the path to the current played track */ 72/* change the path to the current played track */
@@ -102,6 +107,12 @@ long gui_wps_show(void)
102 { 107 {
103 gui_wps_set_margin(&gui_wps[i]); 108 gui_wps_set_margin(&gui_wps[i]);
104 } 109 }
110#if HAVE_LCD_COLOR
111 old_backdrop = lcd_get_backdrop();
112 if (wps_has_backdrop) {
113 lcd_set_backdrop(&wps_backdrop[0][0]);
114 }
115#endif
105#endif 116#endif
106 117
107#ifdef AB_REPEAT_ENABLE 118#ifdef AB_REPEAT_ENABLE
@@ -225,7 +236,14 @@ long gui_wps_show(void)
225#ifdef WPS_RC_CONTEXT 236#ifdef WPS_RC_CONTEXT
226 case WPS_RC_CONTEXT: 237 case WPS_RC_CONTEXT:
227#endif 238#endif
239#ifdef HAVE_LCD_COLOR
240 lcd_set_backdrop(old_backdrop);
241#endif
228 onplay(wps_state.id3->path, TREE_ATTR_MPA, CONTEXT_WPS); 242 onplay(wps_state.id3->path, TREE_ATTR_MPA, CONTEXT_WPS);
243#ifdef HAVE_LCD_COLOR
244 if (wps_has_backdrop)
245 lcd_set_backdrop(&wps_backdrop[0][0]);
246#endif
229#ifdef HAVE_LCD_BITMAP 247#ifdef HAVE_LCD_BITMAP
230 FOR_NB_SCREENS(i) 248 FOR_NB_SCREENS(i)
231 { 249 {
@@ -510,8 +528,15 @@ long gui_wps_show(void)
510 FOR_NB_SCREENS(i) 528 FOR_NB_SCREENS(i)
511 gui_wps[i].display->stop_scroll(); 529 gui_wps[i].display->stop_scroll();
512 530
531#ifdef HAVE_LCD_COLOR
532 lcd_set_backdrop(old_backdrop);
533#endif
513 if (main_menu()) 534 if (main_menu())
514 return true; 535 return true;
536#ifdef HAVE_LCD_COLOR
537 if (wps_has_backdrop)
538 lcd_set_backdrop(&wps_backdrop[0][0]);
539#endif
515#ifdef HAVE_LCD_BITMAP 540#ifdef HAVE_LCD_BITMAP
516 FOR_NB_SCREENS(i) 541 FOR_NB_SCREENS(i)
517 { 542 {
@@ -540,8 +565,15 @@ long gui_wps_show(void)
540#ifdef WPS_RC_QUICK 565#ifdef WPS_RC_QUICK
541 case WPS_RC_QUICK: 566 case WPS_RC_QUICK:
542#endif 567#endif
568#ifdef HAVE_LCD_COLOR
569 lcd_set_backdrop(old_backdrop);
570#endif
543 if (quick_screen_quick(button)) 571 if (quick_screen_quick(button))
544 return SYS_USB_CONNECTED; 572 return SYS_USB_CONNECTED;
573#ifdef HAVE_LCD_COLOR
574 if (wps_has_backdrop)
575 lcd_set_backdrop(&wps_backdrop[0][0]);
576#endif
545#ifdef HAVE_LCD_BITMAP 577#ifdef HAVE_LCD_BITMAP
546 FOR_NB_SCREENS(i) 578 FOR_NB_SCREENS(i)
547 { 579 {
@@ -566,8 +598,15 @@ long gui_wps_show(void)
566 || CONFIG_KEYPAD == IRIVER_H300_PAD 598 || CONFIG_KEYPAD == IRIVER_H300_PAD
567 case BUTTON_ON | BUTTON_UP: 599 case BUTTON_ON | BUTTON_UP:
568 case BUTTON_ON | BUTTON_DOWN: 600 case BUTTON_ON | BUTTON_DOWN:
601#ifdef HAVE_LCD_COLOR
602 lcd_set_backdrop(old_backdrop);
603#endif
569 if (2 == pitch_screen()) 604 if (2 == pitch_screen())
570 return SYS_USB_CONNECTED; 605 return SYS_USB_CONNECTED;
606#ifdef HAVE_LCD_COLOR
607 if (wps_has_backdrop)
608 lcd_set_backdrop(&wps_backdrop[0][0]);
609#endif
571 restore = true; 610 restore = true;
572 break; 611 break;
573#endif 612#endif
@@ -981,4 +1020,7 @@ void gui_sync_wps_init(void)
981 gui_wps_set_data(&gui_wps[i], &wps_datas[i]); 1020 gui_wps_set_data(&gui_wps[i], &wps_datas[i]);
982 gui_wps_set_statusbar(&gui_wps[i], &statusbars.statusbars[i]); 1021 gui_wps_set_statusbar(&gui_wps[i], &statusbars.statusbars[i]);
983 } 1022 }
1023#ifdef HAVE_LCD_COLOR
1024 wps_has_backdrop = false;
1025#endif
984} 1026}