diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2007-04-16 09:14:36 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2007-04-16 09:14:36 +0000 |
commit | 6a5cc0bd25bd468c79e453fa49f353edd824141a (patch) | |
tree | 8b406e8390550ff8b87eae3214309867574657f0 /apps/gui | |
parent | 7afe2e86931313653d4dedb6d5167c79c2822aba (diff) | |
download | rockbox-6a5cc0bd25bd468c79e453fa49f353edd824141a.tar.gz rockbox-6a5cc0bd25bd468c79e453fa49f353edd824141a.zip |
Customizable icons for all bitmap targets. (FS#7013)
http://www.rockbox.org/twiki/bin/view/Main/CustomIcons for info on format and how to load them
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13177 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/color_picker.c | 14 | ||||
-rw-r--r-- | apps/gui/icon.c | 261 | ||||
-rw-r--r-- | apps/gui/icon.h | 80 | ||||
-rw-r--r-- | apps/gui/list.c | 49 | ||||
-rw-r--r-- | apps/gui/list.h | 8 |
5 files changed, 347 insertions, 65 deletions
diff --git a/apps/gui/color_picker.c b/apps/gui/color_picker.c index 2d0dba1221..1739f3fd61 100644 --- a/apps/gui/color_picker.c +++ b/apps/gui/color_picker.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include "lang.h" | 31 | #include "lang.h" |
32 | #include "splash.h" | 32 | #include "splash.h" |
33 | #include "action.h" | 33 | #include "action.h" |
34 | #include "icons.h" | 34 | #include "icon.h" |
35 | 35 | ||
36 | /* structure for color info */ | 36 | /* structure for color info */ |
37 | struct rgb_pick | 37 | struct rgb_pick |
@@ -220,13 +220,11 @@ static void draw_screen(struct screen *display, char *title, | |||
220 | /* Draw "> <" around sliders */ | 220 | /* Draw "> <" around sliders */ |
221 | int top = text_top + (display->char_height - | 221 | int top = text_top + (display->char_height - |
222 | SELECTOR_HEIGHT) / 2; | 222 | SELECTOR_HEIGHT) / 2; |
223 | display->mono_bitmap(bitmap_icons_6x8[Icon_Cursor], | 223 | screen_put_iconxy(display, MARGIN_LEFT, top, Icon_Cursor); |
224 | MARGIN_LEFT, top, | 224 | screen_put_iconxy(display, |
225 | SELECTOR_WIDTH, SELECTOR_HEIGHT); | 225 | display->width - MARGIN_RIGHT - |
226 | display->mono_bitmap(bitmap_icons_6x8[Icon_Reverse_Cursor], | 226 | get_icon_width(display->screen_type), |
227 | display->width - MARGIN_RIGHT - | 227 | top, Icon_Cursor); |
228 | SELECTOR_WIDTH, top, SELECTOR_WIDTH, | ||
229 | SELECTOR_HEIGHT); | ||
230 | } | 228 | } |
231 | 229 | ||
232 | if (display->depth >= 16) | 230 | if (display->depth >= 16) |
diff --git a/apps/gui/icon.c b/apps/gui/icon.c index ef6f61f94e..2cb0035ad7 100644 --- a/apps/gui/icon.c +++ b/apps/gui/icon.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) Robert E. Hak(2002) | 10 | * Copyright (C) 2007 Jonathan Gordon |
11 | * | 11 | * |
12 | * All files in this archive are subject to the GNU General Public License. | 12 | * All files in this archive are subject to the GNU General Public License. |
13 | * See the file COPYING in the source tree root for full license agreement. | 13 | * See the file COPYING in the source tree root for full license agreement. |
@@ -16,42 +16,265 @@ | |||
16 | * KIND, either express or implied. | 16 | * KIND, either express or implied. |
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | 19 | #include <stdio.h> | |
20 | #include <stdlib.h> | ||
21 | #include <string.h> | ||
22 | #include "inttypes.h" | ||
20 | #include "config.h" | 23 | #include "config.h" |
21 | #include "icon.h" | 24 | #include "icon.h" |
22 | #include "screen_access.h" | 25 | #include "screen_access.h" |
23 | #include "icons.h" | 26 | #include "icons.h" |
27 | #include "settings.h" | ||
28 | #include "bmp.h" | ||
29 | #include "filetypes.h" | ||
30 | |||
31 | /* Quick and Dirty hack untill lcd bitmap drawing is fixed */ | ||
32 | #ifdef HAVE_REMOTE_LCD | ||
33 | #include "lcd-remote.h" | ||
34 | #endif | ||
35 | |||
36 | |||
37 | #include <default_icons.h> | ||
38 | #ifdef HAVE_REMOTE_LCD | ||
39 | #include <remote_default_icons.h> | ||
40 | #endif | ||
41 | |||
42 | #define DEFAULT_VIEWER_BMP ICON_DIR "/viewers.bmp" | ||
43 | #define DEFAULT_REMOTE_VIEWER_BMP ICON_DIR "/remote_viewers.bmp" | ||
44 | |||
45 | /* These should robably be moved to config-<target>.h */ | ||
46 | #define MAX_ICON_HEIGHT 24 | ||
47 | #define MAX_ICON_WIDTH 24 | ||
48 | |||
49 | |||
50 | /* We dont actually do anything with these pointers, | ||
51 | but they need to be grouped like this to save code | ||
52 | so storing them as void* is ok. (stops compile warning) */ | ||
53 | static const void * inbuilt_icons[NB_SCREENS] = { | ||
54 | (void*)default_icons | ||
55 | #ifdef HAVE_REMOTE_LCD | ||
56 | , (void*)remote_default_icons | ||
57 | #endif | ||
58 | }; | ||
24 | 59 | ||
25 | /* Count in letter positions, NOT pixels */ | 60 | static const int default_width[NB_SCREENS] = { |
26 | void screen_put_iconxy(struct screen * display, int x, int y, ICON icon) | 61 | BMPWIDTH_default_icons |
62 | #ifdef HAVE_REMOTE_LCD | ||
63 | , BMPWIDTH_remote_default_icons | ||
64 | #endif | ||
65 | }; | ||
66 | |||
67 | /* height of whole file */ | ||
68 | static const int default_height[NB_SCREENS] = { | ||
69 | BMPHEIGHT_default_icons | ||
70 | #ifdef HAVE_REMOTE_LCD | ||
71 | , BMPHEIGHT_remote_default_icons | ||
72 | #endif | ||
73 | }; | ||
74 | |||
75 | #define IMG_BUFSIZE (MAX_ICON_HEIGHT * MAX_ICON_WIDTH * \ | ||
76 | Icon_Last_Themeable *LCD_DEPTH/8) | ||
77 | static unsigned char icon_buffer[IMG_BUFSIZE][NB_SCREENS]; | ||
78 | static bool custom_icons_loaded[NB_SCREENS] = {false}; | ||
79 | static struct bitmap user_iconset[NB_SCREENS]; | ||
80 | |||
81 | static unsigned char viewer_icon_buffer[IMG_BUFSIZE][NB_SCREENS]; | ||
82 | static bool viewer_icons_loaded[NB_SCREENS] = {false}; | ||
83 | static struct bitmap viewer_iconset[NB_SCREENS]; | ||
84 | |||
85 | |||
86 | #define ICON_HEIGHT(screen) (!custom_icons_loaded[screen]? \ | ||
87 | default_height[screen] : \ | ||
88 | user_iconset[screen].height) \ | ||
89 | / Icon_Last_Themeable | ||
90 | |||
91 | #define ICON_WIDTH(screen) (!custom_icons_loaded[screen]? \ | ||
92 | default_width[screen] : \ | ||
93 | user_iconset[screen].width) | ||
94 | |||
95 | /* x,y in letters, not pixles */ | ||
96 | void screen_put_icon(struct screen * display, | ||
97 | int x, int y, enum themable_icons icon) | ||
98 | { | ||
99 | screen_put_icon_with_offset(display, x, y, 0, 0, icon); | ||
100 | } | ||
101 | |||
102 | void screen_put_icon_with_offset(struct screen * display, | ||
103 | int x, int y, int off_x, int off_y, | ||
104 | enum themable_icons icon) | ||
27 | { | 105 | { |
28 | #ifdef HAVE_LCD_BITMAP | ||
29 | int width, height; | ||
30 | int xpos, ypos; | 106 | int xpos, ypos; |
107 | int width, height; | ||
108 | int screen = display->screen_type; | ||
31 | display->getstringsize((unsigned char *)"M", &width, &height); | 109 | display->getstringsize((unsigned char *)"M", &width, &height); |
32 | xpos = x*CURSOR_WIDTH; | 110 | xpos = x*ICON_WIDTH(screen) + off_x; |
33 | ypos = y*height + display->getymargin(); | 111 | ypos = y*height + display->getymargin() + off_y; |
112 | |||
113 | if ( height > ICON_HEIGHT(screen) )/* center the cursor */ | ||
114 | ypos += (height - ICON_HEIGHT(screen)) / 2; | ||
115 | screen_put_iconxy(display, xpos, ypos, icon); | ||
116 | } | ||
34 | 117 | ||
35 | if ( height > CURSOR_HEIGHT )/* center the cursor */ | 118 | /* x,y in pixels */ |
36 | ypos += (height - CURSOR_HEIGHT) / 2; | 119 | typedef void (*lcd_draw_func)(const fb_data *src, int src_x, int src_y, |
37 | if(icon==0)/* Don't display invalid icons */ | 120 | int stride, int x, int y, int width, int height); |
38 | screen_clear_area(display, xpos, ypos, CURSOR_WIDTH, CURSOR_HEIGHT); | 121 | void screen_put_iconxy(struct screen * display, |
122 | int xpos, int ypos, enum themable_icons icon) | ||
123 | { | ||
124 | fb_data *data; | ||
125 | int screen = display->screen_type; | ||
126 | lcd_draw_func draw_func = NULL; | ||
127 | |||
128 | if (icon == Icon_NOICON) | ||
129 | { | ||
130 | screen_clear_area(display, xpos, ypos, | ||
131 | ICON_WIDTH(screen), ICON_HEIGHT(screen)); | ||
132 | return; | ||
133 | } | ||
134 | else if (icon >= Icon_Last_Themeable) | ||
135 | { | ||
136 | icon -= Icon_Last_Themeable; | ||
137 | if (!viewer_icons_loaded[screen] || | ||
138 | (icon*ICON_HEIGHT(screen) > viewer_iconset[screen].height)) | ||
139 | { | ||
140 | screen_clear_area(display, xpos, ypos, | ||
141 | ICON_WIDTH(screen), ICON_HEIGHT(screen)); | ||
142 | return; | ||
143 | } | ||
144 | data = (fb_data *)viewer_iconset[screen].data; | ||
145 | } | ||
146 | else if (custom_icons_loaded[screen]) | ||
147 | { | ||
148 | data = (fb_data *)user_iconset[screen].data; | ||
149 | } | ||
39 | else | 150 | else |
40 | display->mono_bitmap(icon, xpos, ypos, CURSOR_WIDTH, CURSOR_HEIGHT); | 151 | { |
41 | #else | 152 | data = (fb_data *)inbuilt_icons[screen]; |
42 | if(icon==-1) | 153 | } |
43 | display->putc(x, y, ' '); | 154 | /* add some left padding to the icons if they are on the edge */ |
155 | if (xpos == 0) | ||
156 | xpos++; | ||
157 | |||
158 | #ifdef HAVE_REMOTE_LCD | ||
159 | if (display->screen_type == SCREEN_REMOTE) | ||
160 | { | ||
161 | /* Quick and Dirty hack untill lcd bitmap drawing is fixed */ | ||
162 | draw_func = (lcd_draw_func)lcd_remote_bitmap_part; | ||
163 | } | ||
44 | else | 164 | else |
45 | display->putc(x, y, icon); | ||
46 | #endif | 165 | #endif |
166 | #if LCD_DEPTH == 16 | ||
167 | draw_func = display->transparent_bitmap_part; | ||
168 | #else /* LCD_DEPTH < 16 */ | ||
169 | draw_func = display->bitmap_part; | ||
170 | #endif /* LCD_DEPTH == 16 */ | ||
171 | |||
172 | draw_func( (const fb_data *)data, | ||
173 | 0, ICON_HEIGHT(screen)*icon, | ||
174 | ICON_WIDTH(screen), xpos, ypos, | ||
175 | ICON_WIDTH(screen), ICON_HEIGHT(screen)); | ||
47 | } | 176 | } |
48 | 177 | ||
49 | void screen_put_cursorxy(struct screen * display, int x, int y, bool on) | 178 | void screen_put_cursorxy(struct screen * display, int x, int y, bool on) |
50 | { | 179 | { |
51 | #ifdef HAVE_LCD_BITMAP | 180 | #ifdef HAVE_LCD_BITMAP |
52 | screen_put_iconxy(display, x, y, on?bitmap_icons_6x8[Icon_Cursor]:0); | 181 | screen_put_icon(display, x, y, on?Icon_Cursor:0); |
53 | #else | 182 | #else |
54 | screen_put_iconxy(display, x, y, on?CURSOR_CHAR:-1); | 183 | screen_put_icon(display, x, y, on?CURSOR_CHAR:-1); |
55 | #endif | 184 | #endif |
56 | 185 | ||
57 | } | 186 | } |
187 | enum Iconset { | ||
188 | Iconset_Mainscreen, | ||
189 | Iconset_Mainscreen_viewers, | ||
190 | #ifdef HAVE_REMOTE_LCD | ||
191 | Iconset_Remotescreen, | ||
192 | Iconset_Remotescreen_viewers, | ||
193 | #endif | ||
194 | }; | ||
195 | |||
196 | static void load_icons(const char* filename, enum Iconset iconset) | ||
197 | { | ||
198 | int size_read; | ||
199 | bool *loaded_ok = NULL; | ||
200 | struct bitmap *bmp = NULL; | ||
201 | |||
202 | switch (iconset) | ||
203 | { | ||
204 | case Iconset_Mainscreen: | ||
205 | loaded_ok = &custom_icons_loaded[SCREEN_MAIN]; | ||
206 | bmp = &user_iconset[SCREEN_MAIN]; | ||
207 | bmp->data = icon_buffer[SCREEN_MAIN]; | ||
208 | break; | ||
209 | case Iconset_Mainscreen_viewers: | ||
210 | loaded_ok = &viewer_icons_loaded[SCREEN_MAIN]; | ||
211 | bmp = &viewer_iconset[SCREEN_MAIN]; | ||
212 | bmp->data = viewer_icon_buffer[SCREEN_MAIN]; | ||
213 | break; | ||
214 | #ifdef HAVE_REMOTE_LCD | ||
215 | case Iconset_Remotescreen: | ||
216 | loaded_ok = &custom_icons_loaded[SCREEN_MAIN]; | ||
217 | bmp = &user_iconset[SCREEN_MAIN]; | ||
218 | bmp->data = icon_buffer[SCREEN_MAIN]; | ||
219 | break; | ||
220 | case Iconset_Remotescreen_viewers: | ||
221 | loaded_ok = &viewer_icons_loaded[SCREEN_REMOTE]; | ||
222 | bmp = &viewer_iconset[SCREEN_REMOTE]; | ||
223 | bmp->data = viewer_icon_buffer[SCREEN_REMOTE]; | ||
224 | break; | ||
225 | #endif | ||
226 | } | ||
227 | |||
228 | *loaded_ok = false; | ||
229 | if (filename != NULL) | ||
230 | { | ||
231 | size_read = read_bmp_file((char*)filename, bmp, IMG_BUFSIZE, | ||
232 | FORMAT_NATIVE | FORMAT_DITHER); | ||
233 | if (size_read > 0) | ||
234 | { | ||
235 | *loaded_ok = true; | ||
236 | } | ||
237 | } | ||
238 | } | ||
239 | |||
240 | |||
241 | void icons_init(void) | ||
242 | { | ||
243 | char path[MAX_PATH]; | ||
244 | if (global_settings.icon_file[0]) | ||
245 | { | ||
246 | snprintf(path, MAX_PATH, "%s/%s.bmp", | ||
247 | ICON_DIR, global_settings.icon_file); | ||
248 | load_icons(path, Iconset_Mainscreen); | ||
249 | } | ||
250 | if (global_settings.viewers_icon_file[0]) | ||
251 | { | ||
252 | snprintf(path, MAX_PATH, "%s/%s.bmp", | ||
253 | ICON_DIR, global_settings.viewers_icon_file); | ||
254 | load_icons(path, Iconset_Mainscreen_viewers); | ||
255 | read_viewer_theme_file(); | ||
256 | } | ||
257 | else | ||
258 | load_icons(DEFAULT_VIEWER_BMP, Iconset_Mainscreen_viewers); | ||
259 | #ifdef HAVE_REMOTE_LCD | ||
260 | if (global_settings.remote_icon_file[0]) | ||
261 | { | ||
262 | snprintf(path, MAX_PATH, "%s/%s.bmp", | ||
263 | ICON_DIR, global_settings.remote_icon_file); | ||
264 | load_icons(path, Iconset_Remotescreen); | ||
265 | } | ||
266 | if (global_settings.remote_viewers_icon_file[0]) | ||
267 | { | ||
268 | snprintf(path, MAX_PATH, "%s/%s.bmp", | ||
269 | ICON_DIR, global_settings.remote_viewers_icon_file); | ||
270 | load_icons(path, Iconset_Remotescreen_viewers); | ||
271 | } | ||
272 | else | ||
273 | load_icons(DEFAULT_REMOTE_VIEWER_BMP, Iconset_Mainscreen_viewers); | ||
274 | #endif | ||
275 | } | ||
276 | |||
277 | int get_icon_width(enum screen_type screen_type) | ||
278 | { | ||
279 | return ICON_WIDTH(screen_type); | ||
280 | } | ||
diff --git a/apps/gui/icon.h b/apps/gui/icon.h index c717bbc6ea..fa6919030f 100644 --- a/apps/gui/icon.h +++ b/apps/gui/icon.h | |||
@@ -24,19 +24,51 @@ | |||
24 | * char-based displays and bitmap displays */ | 24 | * char-based displays and bitmap displays */ |
25 | #ifdef HAVE_LCD_BITMAP | 25 | #ifdef HAVE_LCD_BITMAP |
26 | typedef const unsigned char * ICON; | 26 | typedef const unsigned char * ICON; |
27 | typedef unsigned char * ICON_NO_CONST; | 27 | #define NOICON Icon_NOICON |
28 | #define NOICON NULL | ||
29 | #else | 28 | #else |
30 | typedef long ICON; | 29 | typedef long ICON; |
31 | #define ICON_NO_CONST ICON | 30 | #define NOICON Icon_NOICON |
32 | #define NOICON -1 | ||
33 | #endif | 31 | #endif |
34 | 32 | ||
35 | #define Icon_NOICON -1 | 33 | #define FORCE_INBUILT_ICON 0x80000000 |
36 | 34 | /* Don't #ifdef icon values, or we wont be able to use the same | |
37 | #define CURSOR_CHAR 0xe10c | 35 | cmp for every target. */ |
38 | #define CURSOR_WIDTH 6 | 36 | enum themable_icons { |
39 | #define CURSOR_HEIGHT 8 | 37 | Icon_NOICON = -1, /* Dont put this in a .bmp */ |
38 | Icon_Audio, | ||
39 | Icon_Folder, | ||
40 | Icon_Playlist, | ||
41 | Icon_Cursor, | ||
42 | Icon_Wps, | ||
43 | Icon_Firmware, | ||
44 | Icon_Font, | ||
45 | Icon_Language, | ||
46 | Icon_Config, | ||
47 | Icon_Plugin, | ||
48 | Icon_Bookmark, | ||
49 | Icon_Preset, | ||
50 | Icon_Queued, | ||
51 | Icon_Moving, | ||
52 | Icon_Keyboard, | ||
53 | Icon_Reverse_Cursor, | ||
54 | Icon_Questionmark, | ||
55 | Icon_Menu_setting, | ||
56 | Icon_Menu_functioncall, | ||
57 | Icon_Submenu, | ||
58 | Icon_Submenu_Entered, | ||
59 | Icon_Recording, | ||
60 | Icon_Voice, | ||
61 | Icon_General_settings_menu, | ||
62 | Icon_System_menu, | ||
63 | Icon_Playback_menu, | ||
64 | Icon_Display_menu, | ||
65 | Icon_Remote_Display_menu, | ||
66 | Icon_Radio_screen, | ||
67 | Icon_file_view_menu, | ||
68 | Icon_EQ, | ||
69 | Icon_Rockbox, | ||
70 | Icon_Last_Themeable, | ||
71 | }; | ||
40 | 72 | ||
41 | /* | 73 | /* |
42 | * Draws a cursor at a given position, if th | 74 | * Draws a cursor at a given position, if th |
@@ -49,12 +81,36 @@ extern void screen_put_cursorxy(struct screen * screen, int x, int y, bool on); | |||
49 | /* | 81 | /* |
50 | * Put an icon on a screen at a given position | 82 | * Put an icon on a screen at a given position |
51 | * (the position is given in characters) | 83 | * (the position is given in characters) |
52 | * If the given icon is null (HAVE_LCD_BITMAP) or -1 otherwise, the icon | 84 | * If the given icon is Icon_blank, the icon |
53 | * at the given position will be erased | 85 | * at the given position will be erased |
54 | * - screen : the screen where we put our icon | 86 | * - screen : the screen where we put our icon |
55 | * - x, y : the position, in character, not in pixel !! | 87 | * - x, y : the position, pixel value !! |
56 | * - icon : the icon to put | 88 | * - icon : the icon to put |
57 | */ | 89 | */ |
58 | extern void screen_put_iconxy(struct screen * screen, int x, int y, ICON icon); | 90 | extern void screen_put_iconxy(struct screen * screen, |
91 | int x, int y, enum themable_icons icon); | ||
92 | #ifdef HAVE_LCD_CHARCELLS | ||
93 | # define screen_put_icon(s, x, y, i) screen_put_iconxy(s, x, y, i) | ||
94 | # define screen_put_icon_with_offset(s, x, y, w, h, i) screen_put_icon(s, x, y, i) | ||
95 | #else | ||
96 | /* For both of these, the icon will be placed in the center of the rectangle */ | ||
97 | /* as above, but x,y are letter position, NOT PIXEL */ | ||
98 | extern void screen_put_icon(struct screen * screen, | ||
99 | int x, int y, enum themable_icons icon); | ||
100 | /* as above (x,y are letter pos), but with a pxiel offset for both */ | ||
101 | extern void screen_put_icon_with_offset(struct screen * display, | ||
102 | int x, int y, int off_x, int off_y, | ||
103 | enum themable_icons icon); | ||
104 | #endif | ||
105 | |||
106 | void icons_init(void); | ||
107 | |||
108 | |||
109 | #ifdef HAVE_LCD_CHARCELLS | ||
110 | # define CURSOR_CHAR 0xe10c | ||
111 | # define get_icon_width(a) 6 | ||
112 | #else | ||
113 | int get_icon_width(enum screen_type screen_type); | ||
114 | #endif | ||
59 | 115 | ||
60 | #endif /*_GUI_ICON_H_*/ | 116 | #endif /*_GUI_ICON_H_*/ |
diff --git a/apps/gui/list.c b/apps/gui/list.c index e3b0d6afe5..c93210e0eb 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c | |||
@@ -92,7 +92,7 @@ static void gui_list_init(struct gui_list * gui_list, | |||
92 | gui_list->selected_size=selected_size; | 92 | gui_list->selected_size=selected_size; |
93 | gui_list->title = NULL; | 93 | gui_list->title = NULL; |
94 | gui_list->title_width = 0; | 94 | gui_list->title_width = 0; |
95 | gui_list->title_icon = NOICON; | 95 | gui_list->title_icon = Icon_NOICON; |
96 | 96 | ||
97 | gui_list->last_displayed_selected_item = -1 ; | 97 | gui_list->last_displayed_selected_item = -1 ; |
98 | gui_list->last_displayed_start_item = -1 ; | 98 | gui_list->last_displayed_start_item = -1 ; |
@@ -230,8 +230,6 @@ static int gui_list_get_item_offset(struct gui_list * gui_list, int item_width, | |||
230 | static void gui_list_draw_smart(struct gui_list *gui_list) | 230 | static void gui_list_draw_smart(struct gui_list *gui_list) |
231 | { | 231 | { |
232 | struct screen * display=gui_list->display; | 232 | struct screen * display=gui_list->display; |
233 | int cursor_pos = 0; | ||
234 | int icon_pos = 1; | ||
235 | int text_pos; | 233 | int text_pos; |
236 | bool draw_icons = (gui_list->callback_get_item_icon != NULL && global_settings.show_icons); | 234 | bool draw_icons = (gui_list->callback_get_item_icon != NULL && global_settings.show_icons); |
237 | bool draw_cursor; | 235 | bool draw_cursor; |
@@ -288,9 +286,9 @@ static void gui_list_draw_smart(struct gui_list *gui_list) | |||
288 | { | 286 | { |
289 | if (gui_list->title_icon != NOICON && draw_icons) | 287 | if (gui_list->title_icon != NOICON && draw_icons) |
290 | { | 288 | { |
291 | screen_put_iconxy(display, 0, 0, gui_list->title_icon); | 289 | screen_put_icon(display, 0, 0, gui_list->title_icon); |
292 | #ifdef HAVE_LCD_BITMAP | 290 | #ifdef HAVE_LCD_BITMAP |
293 | text_pos = 8; /* pixels */ | 291 | text_pos = get_icon_width(display->screen_type)+2; /* pixels */ |
294 | #else | 292 | #else |
295 | text_pos = 1; /* chars */ | 293 | text_pos = 1; /* chars */ |
296 | #endif | 294 | #endif |
@@ -327,17 +325,13 @@ static void gui_list_draw_smart(struct gui_list *gui_list) | |||
327 | if(draw_scrollbar || SHOW_LIST_TITLE) /* indent if there's | 325 | if(draw_scrollbar || SHOW_LIST_TITLE) /* indent if there's |
328 | a title */ | 326 | a title */ |
329 | { | 327 | { |
330 | cursor_pos++; | ||
331 | icon_pos++; | ||
332 | text_pos += SCROLLBAR_WIDTH; | 328 | text_pos += SCROLLBAR_WIDTH; |
333 | } | 329 | } |
334 | if(!draw_cursor) | 330 | if(draw_cursor) |
335 | icon_pos--; | 331 | text_pos += get_icon_width(display->screen_type) + 2; |
336 | else | ||
337 | text_pos += CURSOR_WIDTH; | ||
338 | 332 | ||
339 | if(draw_icons) | 333 | if(draw_icons) |
340 | text_pos += 8; | 334 | text_pos += get_icon_width(display->screen_type) + 2; |
341 | #else | 335 | #else |
342 | draw_cursor = true; | 336 | draw_cursor = true; |
343 | if(draw_icons) | 337 | if(draw_icons) |
@@ -413,7 +407,12 @@ static void gui_list_draw_smart(struct gui_list *gui_list) | |||
413 | #endif | 407 | #endif |
414 | 408 | ||
415 | if (draw_cursor) | 409 | if (draw_cursor) |
416 | screen_put_cursorxy(display, cursor_pos, i, true); | 410 | { |
411 | screen_put_icon_with_offset(display, 0, i, | ||
412 | (draw_scrollbar || SHOW_LIST_TITLE)? | ||
413 | SCROLLBAR_WIDTH: 0, | ||
414 | 0, Icon_Cursor); | ||
415 | } | ||
417 | } | 416 | } |
418 | else | 417 | else |
419 | {/* normal item */ | 418 | {/* normal item */ |
@@ -437,12 +436,19 @@ static void gui_list_draw_smart(struct gui_list *gui_list) | |||
437 | /* Icons display */ | 436 | /* Icons display */ |
438 | if(draw_icons) | 437 | if(draw_icons) |
439 | { | 438 | { |
440 | ICON icon; | 439 | enum themable_icons icon; |
441 | gui_list->callback_get_item_icon(current_item, | 440 | icon = gui_list->callback_get_item_icon(current_item, gui_list->data); |
442 | gui_list->data, | 441 | if(icon > Icon_NOICON) |
443 | &icon); | 442 | { |
444 | if(icon) | 443 | #ifdef HAVE_LCD_BITMAP |
445 | screen_put_iconxy(display, icon_pos, i, icon); | 444 | int x = draw_cursor?1:0; |
445 | int x_off = (draw_scrollbar || SHOW_LIST_TITLE) ? SCROLLBAR_WIDTH: 0; | ||
446 | screen_put_icon_with_offset(display, x, i, | ||
447 | x_off, 0, icon); | ||
448 | #else | ||
449 | screen_put_icon(display, 1, i, icon); | ||
450 | #endif | ||
451 | } | ||
446 | } | 452 | } |
447 | } | 453 | } |
448 | 454 | ||
@@ -737,7 +743,8 @@ void gui_list_screen_scroll_out_of_view(bool enable) | |||
737 | * Set the title and title icon of the list. Setting title to NULL disables | 743 | * Set the title and title icon of the list. Setting title to NULL disables |
738 | * both the title and icon. Use NOICON if there is no icon. | 744 | * both the title and icon. Use NOICON if there is no icon. |
739 | */ | 745 | */ |
740 | static void gui_list_set_title(struct gui_list * gui_list, char * title, ICON icon) | 746 | static void gui_list_set_title(struct gui_list * gui_list, |
747 | char * title, enum themable_icons icon) | ||
741 | { | 748 | { |
742 | gui_list->title = title; | 749 | gui_list->title = title; |
743 | gui_list->title_icon = icon; | 750 | gui_list->title_icon = icon; |
@@ -870,7 +877,7 @@ void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll) | |||
870 | } | 877 | } |
871 | 878 | ||
872 | void gui_synclist_set_title(struct gui_synclist * lists, | 879 | void gui_synclist_set_title(struct gui_synclist * lists, |
873 | char * title, ICON icon) | 880 | char * title, enum themable_icons icon) |
874 | { | 881 | { |
875 | int i; | 882 | int i; |
876 | FOR_NB_SCREENS(i) | 883 | FOR_NB_SCREENS(i) |
diff --git a/apps/gui/list.h b/apps/gui/list.h index bd43edf7ef..283676d631 100644 --- a/apps/gui/list.h +++ b/apps/gui/list.h | |||
@@ -49,9 +49,7 @@ enum list_wrap { | |||
49 | * the icon after the function returns. | 49 | * the icon after the function returns. |
50 | * Note : we use the ICON type because the real type depends of the plateform | 50 | * Note : we use the ICON type because the real type depends of the plateform |
51 | */ | 51 | */ |
52 | typedef void list_get_icon(int selected_item, | 52 | typedef enum themable_icons list_get_icon(int selected_item, void * data); |
53 | void * data, | ||
54 | ICON * icon); | ||
55 | /* | 53 | /* |
56 | * Text callback | 54 | * Text callback |
57 | * - selected_item : an integer that tells the number of the item to display | 55 | * - selected_item : an integer that tells the number of the item to display |
@@ -101,7 +99,7 @@ struct gui_list | |||
101 | /* The optional title, set to NULL for none */ | 99 | /* The optional title, set to NULL for none */ |
102 | char * title; | 100 | char * title; |
103 | /* Optional title icon */ | 101 | /* Optional title icon */ |
104 | ICON title_icon; | 102 | enum themable_icons title_icon; |
105 | }; | 103 | }; |
106 | 104 | ||
107 | /* | 105 | /* |
@@ -190,7 +188,7 @@ extern void gui_synclist_del_item(struct gui_synclist * lists); | |||
190 | extern void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll); | 188 | extern void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll); |
191 | extern void gui_synclist_flash(struct gui_synclist * lists); | 189 | extern void gui_synclist_flash(struct gui_synclist * lists); |
192 | extern void gui_synclist_set_title(struct gui_synclist * lists, char * title, | 190 | extern void gui_synclist_set_title(struct gui_synclist * lists, char * title, |
193 | ICON icon); | 191 | int icon); |
194 | 192 | ||
195 | /* | 193 | /* |
196 | * Do the action implied by the given button, | 194 | * Do the action implied by the given button, |