From 6c00e38665fbe7e4aa724667cf1105596a8495a6 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Wed, 24 Aug 2005 00:09:42 +0000 Subject: Icon code cleanup, optimisation & policeing. Removed unused icons. Applied uniform icon naming scheme. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7396 a1c6a512-1295-4272-9138-f99709370657 --- apps/dbtree.c | 4 ++-- apps/filetypes.c | 8 ++++---- apps/menu.c | 2 +- apps/player/icons.h | 14 ++++++++++--- apps/playlist_viewer.c | 4 ++-- apps/recorder/icons.c | 55 +++++++++++++++++--------------------------------- apps/recorder/icons.h | 25 ++++++++++++++--------- apps/tree.c | 42 +++++++++++++++++++------------------- 8 files changed, 74 insertions(+), 80 deletions(-) diff --git a/apps/dbtree.c b/apps/dbtree.c index 263abf4082..1121ea4070 100644 --- a/apps/dbtree.c +++ b/apps/dbtree.c @@ -527,11 +527,11 @@ int db_get_icon(struct tree_context* c) case songs4album: case songs4artist: case searchsongs: - icon = File; + icon = Icon_Audio; break; default: - icon = Folder; + icon = Icon_Folder; break; } diff --git a/apps/filetypes.c b/apps/filetypes.c index b1cda40d5d..31852b1aba 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c @@ -105,10 +105,10 @@ void filetype_init(void) /* The special filetype folder must always be stored at index 0 */ #ifdef HAVE_LCD_BITMAP if (!filetypes[0].icon) - filetypes[0].icon = bitmap_icons_6x8[Folder]; + filetypes[0].icon = bitmap_icons_6x8[Icon_Folder]; #else if (!filetypes[0].icon) - filetypes[0].icon = Folder; + filetypes[0].icon = Icon_Folder; for (i=1; i < MAX_FILETYPES; i++) filetypes[i].icon = -1; #endif @@ -370,9 +370,9 @@ static void scan_plugins(void) exttypes[cnt_exttypes].extension=cp; exttypes[cnt_exttypes].type=&filetypes[cnt_filetypes]; #ifdef HAVE_LCD_BITMAP - exttypes[cnt_exttypes].type->icon = bitmap_icons_6x8[Plugin]; + exttypes[cnt_exttypes].type->icon = bitmap_icons_6x8[Icon_Plugin]; #else - exttypes[cnt_exttypes].type->icon = Plugin; + exttypes[cnt_exttypes].type->icon = Icon_Plugin; #endif cnt_exttypes++; diff --git a/apps/menu.c b/apps/menu.c index cdcafec770..ad22047b9d 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -116,7 +116,7 @@ void put_cursorxy(int x, int y, bool on) /* place the cursor */ if(on) { #ifdef HAVE_LCD_BITMAP - lcd_mono_bitmap(bitmap_icons_6x8[Cursor], xpos, ypos, 4, 8); + lcd_mono_bitmap(bitmap_icons_6x8[Icon_Cursor], xpos, ypos, 4, 8); #else lcd_putc(x, y, CURSOR_CHAR); #endif diff --git a/apps/player/icons.h b/apps/player/icons.h index f5842eca40..dbce79586b 100644 --- a/apps/player/icons.h +++ b/apps/player/icons.h @@ -28,9 +28,17 @@ #ifdef HAVE_LCD_CHARCELLS enum { - Unknown = 0x90, - Bookmark = 0x16, - Plugin, Folder, Mod_Ajz, Language, File, Wps, Playlist, Text, Config, + Icon_Unknown = 0x90, + Icon_Bookmark = 0x16, + Icon_Plugin, + Icon_Folder, + Icon_Firmware, + Icon_Language, + Icon_Audio, + Icon_Wps, + Icon_Playlist, + Icon_Text, + Icon_Config, }; #endif diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index 32cc6035e0..b7a042733e 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c @@ -461,11 +461,11 @@ static void display_playlist(void) int offset=0; if ( viewer.line_height > 8 ) offset = (viewer.line_height - 8) / 2; - lcd_mono_bitmap(bitmap_icons_6x8[File], + lcd_mono_bitmap(bitmap_icons_6x8[Icon_Audio], CURSOR_X * 6 + CURSOR_WIDTH, MARGIN_Y+(i*viewer.line_height) + offset, 6, 8); #else - lcd_putc(LINE_X-1, i, File); + lcd_putc(LINE_X-1, i, Icon_Audio); #endif } else if (tracks[INDEX(i)].index == viewer.move_track) diff --git a/apps/recorder/icons.c b/apps/recorder/icons.c index 78f3039df2..148235f040 100644 --- a/apps/recorder/icons.c +++ b/apps/recorder/icons.c @@ -36,15 +36,9 @@ const unsigned char bitmap_icons_5x8[][5] = const unsigned char bitmap_icons_6x8[LastIcon][6] = { - { 0x00, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f }, /* Box_Filled */ - { 0x00, 0x7f, 0x41, 0x41, 0x41, 0x7f }, /* Box_Empty */ - { 0x00, 0x3e, 0x7f, 0x63, 0x7f, 0x3e }, /* Slider_Horizontal */ { 0x60, 0x7f, 0x03, 0x33, 0x3f, 0x00 }, /* Musical note */ { 0x7e, 0x41, 0x41, 0x42, 0x7e, 0x00 }, /* Folder */ - { 0x3e, 0x26, 0x26, 0x24, 0x3c, 0x00 }, /* Directory */ { 0x55, 0x00, 0x55, 0x55, 0x55, 0x55 }, /* Playlist */ - { 0x39, 0x43, 0x47, 0x71, 0x61, 0x4e }, /* Repeat */ - { 0x00, 0x1c, 0x3e, 0x3e, 0x3e, 0x1c }, /* Selected */ { 0x3e, 0x1c, 0x08, 0x00, 0x00, 0x00 }, /* Cursor / Marker */ { 0x58, 0x5f, 0x42, 0x50, 0x55, 0x55 }, /* WPS file */ { 0x63, 0x7f, 0x3a, 0x7f, 0x63, 0x00 }, /* Mod or ajz file */ @@ -59,7 +53,6 @@ const unsigned char bitmap_icons_7x8[][7] = { {0x08,0x1c,0x3e,0x3e,0x3e,0x14,0x14}, /* Power plug */ {0x1c,0x14,0x3e,0x2a,0x22,0x1c,0x08}, /* USB plug */ - {0x00,0x1c,0x1c,0x3e,0x7f,0x00,0x00}, /* Speaker */ {0x01,0x1e,0x1c,0x3e,0x7f,0x20,0x40}, /* Speaker mute */ {0x00,0x7f,0x7f,0x3e,0x1c,0x08,0x00}, /* Play */ {0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f}, /* Stop */ @@ -82,7 +75,8 @@ const unsigned char bitmap_icon_disk[12] = {0x15,0x3f,0x7d,0x7B,0x77,0x67,0x79,0x7b,0x57,0x4f,0x47,0x7f}; #endif -#if LCD_WIDTH == 112 || LCD_WIDTH == 128 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_WIDTH == 128) +#if LCD_WIDTH == 112 || LCD_WIDTH == 128 \ + || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_WIDTH == 128) /* Archos Jukebox/ Ondio + Gmini LCD width / remote lcd of iriver*/ const unsigned char rockbox112x37[]={ @@ -347,29 +341,24 @@ const unsigned char rockbox160x53x2[] = { */ void statusbar_icon_battery(int percent) { - int i; int fill; char buffer[5]; unsigned int width, height; /* fill battery */ - fill=percent; + fill = percent; if (fill < 0) fill = 0; if (fill > 100) fill = 100; -#ifdef SIMULATOR - if (global_settings.battery_display && (percent > -1)) { -#else -#ifdef HAVE_CHARGE_CTRL /* Recorder */ +#if defined(HAVE_CHARGE_CTRL) && !defined(SIMULATOR) /* Rec v1 target only */ /* show graphical animation when charging instead of numbers */ if ((global_settings.battery_display) && (charge_state != 1) && (percent > -1)) { -#else /* FM */ +#else /* all others */ if (global_settings.battery_display && (percent > -1)) { -#endif /* HAVE_CHARGE_CTRL */ #endif /* Numeric display */ snprintf(buffer, sizeof(buffer), "%3d", fill); @@ -384,11 +373,10 @@ void statusbar_icon_battery(int percent) else { /* draw battery */ lcd_drawrect(ICON_BATTERY_X_POS, STATUSBAR_Y_POS, 17, 7); - for (i=2; i < 5; i++) - lcd_drawpixel(ICON_BATTERY_X_POS + 17, STATUSBAR_Y_POS + i); + lcd_vline(ICON_BATTERY_X_POS + 17, STATUSBAR_Y_POS + 2, + STATUSBAR_Y_POS + 4); fill = fill * 15 / 100; - lcd_fillrect(ICON_BATTERY_X_POS + 1, STATUSBAR_Y_POS + 1, fill, 5); } @@ -405,17 +393,13 @@ void statusbar_icon_battery(int percent) */ bool statusbar_icon_volume(int percent) { - int i,j; + int i; int volume; int vol; - int step=0; char buffer[4]; unsigned int width, height; bool needs_redraw = false; int type = global_settings.volume_type; -#if defined(LOADABLE_FONTS) - unsigned char *font; -#endif static long switch_tick; static int last_volume = -1; /* -1 means "first update ever" */ @@ -425,7 +409,7 @@ bool statusbar_icon_volume(int percent) if (volume > 100) volume = 100; - if (volume==0) { + if (volume == 0) { lcd_mono_bitmap(bitmap_icons_7x8[Icon_Mute], ICON_VOLUME_X_POS + ICON_VOLUME_WIDTH / 2 - 4, STATUSBAR_Y_POS, 7, STATUSBAR_HEIGHT); @@ -438,7 +422,7 @@ bool statusbar_icon_volume(int percent) /* If the timeout hasn't yet been reached, we show it numerically and tell the caller that we want to be called again */ - if(TIME_BEFORE(current_tick,switch_tick)) { + if (TIME_BEFORE(current_tick,switch_tick)) { type = 1; needs_redraw = true; } @@ -457,11 +441,8 @@ bool statusbar_icon_volume(int percent) /* display volume bar */ vol = volume * 14 / 100; for(i=0; i < vol; i++) { - if(i%2 == 0) - step++; - for(j=1; j <= step; j++) - lcd_drawpixel(ICON_VOLUME_X_POS + i, - STATUSBAR_Y_POS + 7 - j); + lcd_vline(ICON_VOLUME_X_POS + i, STATUSBAR_Y_POS + 6 - i / 2, + STATUSBAR_Y_POS + 6); } } } @@ -475,8 +456,8 @@ bool statusbar_icon_volume(int percent) */ void statusbar_icon_play_state(int state) { - lcd_mono_bitmap(bitmap_icons_7x8[state], ICON_PLAY_STATE_X_POS, STATUSBAR_Y_POS, - ICON_PLAY_STATE_WIDTH, STATUSBAR_HEIGHT); + lcd_mono_bitmap(bitmap_icons_7x8[state], ICON_PLAY_STATE_X_POS, + STATUSBAR_Y_POS, ICON_PLAY_STATE_WIDTH, STATUSBAR_HEIGHT); } /* @@ -484,8 +465,8 @@ void statusbar_icon_play_state(int state) */ void statusbar_icon_play_mode(int mode) { - lcd_mono_bitmap(bitmap_icons_7x8[mode], ICON_PLAY_MODE_X_POS, STATUSBAR_Y_POS, - ICON_PLAY_MODE_WIDTH, STATUSBAR_HEIGHT); + lcd_mono_bitmap(bitmap_icons_7x8[mode], ICON_PLAY_MODE_X_POS, + STATUSBAR_Y_POS, ICON_PLAY_MODE_WIDTH, STATUSBAR_HEIGHT); } /* @@ -512,7 +493,7 @@ void statusbar_icon_lock(void) */ void statusbar_led(void) { - lcd_mono_bitmap(bitmap_icon_disk, ICON_DISK_X_POS, + lcd_mono_bitmap(bitmap_icon_disk, ICON_DISK_X_POS, STATUSBAR_Y_POS, ICON_DISK_WIDTH, STATUSBAR_HEIGHT); } #endif @@ -533,7 +514,7 @@ void statusbar_time(int hour, int minute) if ( global_settings.timeformat ) { /* 12 hour clock */ hour %= 12; if ( hour == 0 ) { - hour +=12; + hour += 12; } } snprintf(buffer, sizeof(buffer), "%02d:%02d", hour, minute); diff --git a/apps/recorder/icons.h b/apps/recorder/icons.h index 0ea29bb324..17605ef490 100644 --- a/apps/recorder/icons.h +++ b/apps/recorder/icons.h @@ -27,24 +27,29 @@ #ifdef HAVE_LCD_BITMAP -enum icons_6x8 { - Box_Filled, Box_Empty, Slider_Horizontal, File, - Folder, Directory, Playlist, Repeat, - Selected, Cursor, Wps, Mod_Ajz, - Font, Language, Config, Plugin, - Bookmark, - LastIcon -}; - /* Symbolic names for icons */ enum icons_5x8 { Icon_Lock }; +enum icons_6x8 { + Icon_Audio, + Icon_Folder, + Icon_Playlist, + Icon_Cursor, + Icon_Wps, + Icon_Firmware, + Icon_Font, + Icon_Language, + Icon_Config, + Icon_Plugin, + Icon_Bookmark, + LastIcon +}; + enum icons_7x8 { Icon_Plug, Icon_USBPlug, - Icon_Speaker, Icon_Mute, Icon_Play, Icon_Stop, diff --git a/apps/tree.c b/apps/tree.c index 8e1afb8b67..5e0d63435b 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -68,32 +68,32 @@ /* a table for the know file types */ const struct filetype filetypes[] = { - { ".mp3", TREE_ATTR_MPA, File, VOICE_EXT_MPA }, - { ".mp2", TREE_ATTR_MPA, File, VOICE_EXT_MPA }, - { ".mpa", TREE_ATTR_MPA, File, VOICE_EXT_MPA }, + { ".mp3", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, + { ".mp2", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, + { ".mpa", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, #if CONFIG_HWCODEC == MASNONE /* Temporary hack to allow playlist creation */ - { ".mp1", TREE_ATTR_MPA, File, VOICE_EXT_MPA }, - { ".ogg", TREE_ATTR_MPA, File, VOICE_EXT_MPA }, - { ".wma", TREE_ATTR_MPA, File, VOICE_EXT_MPA }, - { ".wav", TREE_ATTR_MPA, File, VOICE_EXT_MPA }, - { ".flac", TREE_ATTR_MPA, File, VOICE_EXT_MPA }, - { ".ac3", TREE_ATTR_MPA, File, VOICE_EXT_MPA }, - { ".a52", TREE_ATTR_MPA, File, VOICE_EXT_MPA }, - { ".mpc", TREE_ATTR_MPA, File, VOICE_EXT_MPA }, - { ".wv", TREE_ATTR_MPA, File, VOICE_EXT_MPA }, + { ".mp1", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, + { ".ogg", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, + { ".wma", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, + { ".wav", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, + { ".flac", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, + { ".ac3", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, + { ".a52", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, + { ".mpc", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, + { ".wv", TREE_ATTR_MPA, Icon_Audio, VOICE_EXT_MPA }, #endif - { ".m3u", TREE_ATTR_M3U, Playlist, LANG_PLAYLIST }, - { ".cfg", TREE_ATTR_CFG, Config, VOICE_EXT_CFG }, - { ".wps", TREE_ATTR_WPS, Wps, VOICE_EXT_WPS }, - { ".lng", TREE_ATTR_LNG, Language, LANG_LANGUAGE }, - { ".rock",TREE_ATTR_ROCK,Plugin, VOICE_EXT_ROCK }, + { ".m3u", TREE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST }, + { ".cfg", TREE_ATTR_CFG, Icon_Config, VOICE_EXT_CFG }, + { ".wps", TREE_ATTR_WPS, Icon_Wps, VOICE_EXT_WPS }, + { ".lng", TREE_ATTR_LNG, Icon_Language, LANG_LANGUAGE }, + { ".rock",TREE_ATTR_ROCK,Icon_Plugin, VOICE_EXT_ROCK }, #ifdef HAVE_LCD_BITMAP - { ".fnt", TREE_ATTR_FONT,Font, VOICE_EXT_FONT }, + { ".fnt", TREE_ATTR_FONT,Icon_Font, VOICE_EXT_FONT }, #endif - { ".bmark",TREE_ATTR_BMARK, Bookmark, VOICE_EXT_BMARK }, + { ".bmark",TREE_ATTR_BMARK, Icon_Bookmark, VOICE_EXT_BMARK }, #ifdef BOOTFILE_EXT - { BOOTFILE_EXT, TREE_ATTR_MOD, Mod_Ajz, VOICE_EXT_AJZ }, + { BOOTFILE_EXT, TREE_ATTR_MOD, Icon_Firmware, VOICE_EXT_AJZ }, #endif /* #ifndef SIMULATOR */ }; @@ -400,7 +400,7 @@ static int showdir(void) MARGIN_Y+(i-start)*line_height + offset, 6, 8); #else if (icon < 0 ) - icon = Unknown; + icon = Icon_Unknown; lcd_putc(LINE_X-1, i-start, icon); #endif } -- cgit v1.2.3