summaryrefslogtreecommitdiff
path: root/apps/gui
diff options
context:
space:
mode:
authorMagnus Holmgren <magnushol@gmail.com>2007-04-16 19:17:37 +0000
committerMagnus Holmgren <magnushol@gmail.com>2007-04-16 19:17:37 +0000
commit62994d42a7a6e3a02b241c0ec2d98e7d79c33d71 (patch)
tree40ec198a99830a2a41a98e69879719b129bae3d4 /apps/gui
parentfd951ab8d08ce5c959fdd3ed7ce933087b53d5c4 (diff)
downloadrockbox-62994d42a7a6e3a02b241c0ec2d98e7d79c33d71.tar.gz
rockbox-62994d42a7a6e3a02b241c0ec2d98e7d79c33d71.zip
Reduce code size a bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13185 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r--apps/gui/icon.c78
1 files changed, 39 insertions, 39 deletions
diff --git a/apps/gui/icon.c b/apps/gui/icon.c
index 6e4cd59059..93b1643cd9 100644
--- a/apps/gui/icon.c
+++ b/apps/gui/icon.c
@@ -39,8 +39,8 @@
39#include <remote_default_icons.h> 39#include <remote_default_icons.h>
40#endif 40#endif
41 41
42#define DEFAULT_VIEWER_BMP ICON_DIR "/viewers.bmp" 42#define DEFAULT_VIEWER_BMP "/viewers.bmp"
43#define DEFAULT_REMOTE_VIEWER_BMP ICON_DIR "/remote_viewers.bmp" 43#define DEFAULT_REMOTE_VIEWER_BMP "/remote_viewers.bmp"
44 44
45/* These should probably be moved to config-<target>.h */ 45/* These should probably be moved to config-<target>.h */
46#define MAX_ICON_HEIGHT 24 46#define MAX_ICON_HEIGHT 24
@@ -123,19 +123,20 @@ void screen_put_iconxy(struct screen * display,
123{ 123{
124 fb_data *data; 124 fb_data *data;
125 int screen = display->screen_type; 125 int screen = display->screen_type;
126 int width = ICON_WIDTH(screen);
127 int height = ICON_HEIGHT(screen);
126 lcd_draw_func draw_func = NULL; 128 lcd_draw_func draw_func = NULL;
127 129
128 if (icon == Icon_NOICON) 130 if (icon == Icon_NOICON)
129 { 131 {
130 screen_clear_area(display, xpos, ypos, 132 screen_clear_area(display, xpos, ypos, width, height);
131 ICON_WIDTH(screen), ICON_HEIGHT(screen));
132 return; 133 return;
133 } 134 }
134 else if (icon >= Icon_Last_Themeable) 135 else if (icon >= Icon_Last_Themeable)
135 { 136 {
136 icon -= Icon_Last_Themeable; 137 icon -= Icon_Last_Themeable;
137 if (!viewer_icons_loaded[screen] || 138 if (!viewer_icons_loaded[screen] ||
138 (icon*ICON_HEIGHT(screen) > viewer_iconset[screen].height)) 139 (icon * height > viewer_iconset[screen].height))
139 { 140 {
140#ifdef HAVE_REMOTE_LCD 141#ifdef HAVE_REMOTE_LCD
141 if (screen == SCREEN_REMOTE) 142 if (screen == SCREEN_REMOTE)
@@ -144,8 +145,7 @@ void screen_put_iconxy(struct screen * display,
144 return; 145 return;
145 } 146 }
146#endif 147#endif
147 screen_clear_area(display, xpos, ypos, 148 screen_clear_area(display, xpos, ypos, width, height);
148 ICON_WIDTH(screen), ICON_HEIGHT(screen));
149 return; 149 return;
150 } 150 }
151 data = (fb_data *)viewer_iconset[screen].data; 151 data = (fb_data *)viewer_iconset[screen].data;
@@ -177,9 +177,8 @@ void screen_put_iconxy(struct screen * display,
177#endif /* LCD_DEPTH == 16 */ 177#endif /* LCD_DEPTH == 16 */
178 178
179 draw_func( (const fb_data *)data, 179 draw_func( (const fb_data *)data,
180 0, ICON_HEIGHT(screen)*icon, 180 0, height * icon, width, xpos, ypos,
181 ICON_WIDTH(screen), xpos, ypos, 181 width, height);
182 ICON_WIDTH(screen), ICON_HEIGHT(screen));
183} 182}
184 183
185void screen_put_cursorxy(struct screen * display, int x, int y, bool on) 184void screen_put_cursorxy(struct screen * display, int x, int y, bool on)
@@ -200,12 +199,18 @@ enum Iconset {
200#endif 199#endif
201}; 200};
202 201
203static void load_icons(const char* filename, enum Iconset iconset) 202static void load_icons(const char* filename, enum Iconset iconset,
203 bool allow_disable)
204{ 204{
205 int size_read; 205 int size_read;
206 bool *loaded_ok = NULL; 206 bool *loaded_ok = NULL;
207 struct bitmap *bmp = NULL; 207 struct bitmap *bmp = NULL;
208 208
209 if (!(*filename))
210 {
211 return;
212 }
213
209 switch (iconset) 214 switch (iconset)
210 { 215 {
211 case Iconset_Mainscreen: 216 case Iconset_Mainscreen:
@@ -233,9 +238,12 @@ static void load_icons(const char* filename, enum Iconset iconset)
233 } 238 }
234 239
235 *loaded_ok = false; 240 *loaded_ok = false;
236 if (filename != NULL) 241 if (!allow_disable || *filename != '-')
237 { 242 {
238 size_read = read_bmp_file((char*)filename, bmp, IMG_BUFSIZE, 243 char path[MAX_PATH];
244
245 snprintf(path, sizeof(path), "%s/%s.bmp", ICON_DIR, filename);
246 size_read = read_bmp_file(path, bmp, IMG_BUFSIZE,
239 FORMAT_NATIVE | FORMAT_DITHER); 247 FORMAT_NATIVE | FORMAT_DITHER);
240 if (size_read > 0) 248 if (size_read > 0)
241 { 249 {
@@ -247,41 +255,33 @@ static void load_icons(const char* filename, enum Iconset iconset)
247 255
248void icons_init(void) 256void icons_init(void)
249{ 257{
250 char path[MAX_PATH]; 258 load_icons(global_settings.icon_file, Iconset_Mainscreen, true);
251 if (global_settings.icon_file[0]) 259
252 { 260 if (*global_settings.viewers_icon_file)
253 snprintf(path, MAX_PATH, "%s/%s.bmp",
254 ICON_DIR, global_settings.icon_file);
255 load_icons((global_settings.icon_file[0] == '-')?NULL:path,
256 Iconset_Mainscreen);
257 }
258 if (global_settings.viewers_icon_file[0])
259 { 261 {
260 snprintf(path, MAX_PATH, "%s/%s.bmp", 262 load_icons(global_settings.viewers_icon_file,
261 ICON_DIR, global_settings.viewers_icon_file); 263 Iconset_Mainscreen_viewers, true);
262 load_icons((global_settings.viewers_icon_file[0] == '-')?NULL:path,
263 Iconset_Mainscreen_viewers);
264 read_viewer_theme_file(); 264 read_viewer_theme_file();
265 } 265 }
266 else 266 else
267 load_icons(DEFAULT_VIEWER_BMP, Iconset_Mainscreen_viewers);
268#ifdef HAVE_REMOTE_LCD
269 if (global_settings.remote_icon_file[0])
270 { 267 {
271 snprintf(path, MAX_PATH, "%s/%s.bmp", 268 load_icons(DEFAULT_VIEWER_BMP, Iconset_Mainscreen_viewers, false);
272 ICON_DIR, global_settings.remote_icon_file);
273 load_icons((global_settings.remote_icon_file[0] == '-')?NULL:path,
274 Iconset_Remotescreen);
275 } 269 }
276 if (global_settings.remote_viewers_icon_file[0]) 270
271#ifdef HAVE_REMOTE_LCD
272 load_icons(global_settings.remote_icon_file,
273 Iconset_Remotescreen, true);
274
275 if (*global_settings.remote_viewers_icon_file)
277 { 276 {
278 snprintf(path, MAX_PATH, "%s/%s.bmp", 277 load_icons(global_settings.remote_viewers_icon_file,
279 ICON_DIR, global_settings.remote_viewers_icon_file); 278 Iconset_Remotescreen_viewers, true);
280 load_icons((global_settings.remote_viewers_icon_file[0] == '-')?NULL:path,
281 Iconset_Remotescreen_viewers);
282 } 279 }
283 else 280 else
284 load_icons(DEFAULT_REMOTE_VIEWER_BMP, Iconset_Remotescreen_viewers); 281 {
282 load_icons(DEFAULT_REMOTE_VIEWER_BMP,
283 Iconset_Remotescreen_viewers, false);
284 }
285#endif 285#endif
286} 286}
287 287