diff options
author | Teruaki Kawashima <teru@rockbox.org> | 2010-10-06 12:35:37 +0000 |
---|---|---|
committer | Teruaki Kawashima <teru@rockbox.org> | 2010-10-06 12:35:37 +0000 |
commit | 53a936ab833ea3cfd460d4713f45a8ab98e6620a (patch) | |
tree | e46f4cdea3b31eb355b60ba97969894c9c3f5314 /apps/plugins/text_viewer/tv_bookmark.c | |
parent | 90e8815673bc949c3ef1dbf8904b50c8dfd023f6 (diff) | |
download | rockbox-53a936ab833ea3cfd460d4713f45a8ab98e6620a.tar.gz rockbox-53a936ab833ea3cfd460d4713f45a8ab98e6620a.zip |
text viewer:
-remove 1px gap at the top and bottom of the screen to maximize the draw erea, especially for small screens.
-fix trashes on the vertical scrollbar when scrolled the column left/right.
-fix bug that vertical scrllbar sometimes goes up while scrolling down.
-don't chage displayed line after closing menu.
-use simplelist to select bookmark to make it work better.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28213 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/text_viewer/tv_bookmark.c')
-rw-r--r-- | apps/plugins/text_viewer/tv_bookmark.c | 54 |
1 files changed, 32 insertions, 22 deletions
diff --git a/apps/plugins/text_viewer/tv_bookmark.c b/apps/plugins/text_viewer/tv_bookmark.c index c6574dbb6f..815e7a1f91 100644 --- a/apps/plugins/text_viewer/tv_bookmark.c +++ b/apps/plugins/text_viewer/tv_bookmark.c | |||
@@ -166,6 +166,30 @@ void tv_create_system_bookmark(void) | |||
166 | } | 166 | } |
167 | } | 167 | } |
168 | 168 | ||
169 | static const char* get_bookmark_name(int selected, void * data, | ||
170 | char * buffer, size_t buffer_len) | ||
171 | { | ||
172 | (void)data; | ||
173 | struct tv_bookmark_info *bookmark = &bookmarks[selected]; | ||
174 | rb->snprintf(buffer, buffer_len, | ||
175 | #ifdef HAVE_LCD_BITMAP | ||
176 | "%cPage: %d Line: %d", | ||
177 | #else | ||
178 | "%cP:%d L:%d", | ||
179 | #endif | ||
180 | (bookmark->flag & TV_BOOKMARK_SYSTEM)? '*' : ' ', | ||
181 | bookmark->pos.page + 1, bookmark->pos.line + 1); | ||
182 | return buffer; | ||
183 | } | ||
184 | |||
185 | static int list_action_callback(int action, struct gui_synclist *lists) | ||
186 | { | ||
187 | (void) lists; | ||
188 | if (action == ACTION_STD_OK) | ||
189 | return ACTION_STD_CANCEL; | ||
190 | return action; | ||
191 | } | ||
192 | |||
169 | void tv_select_bookmark(void) | 193 | void tv_select_bookmark(void) |
170 | { | 194 | { |
171 | int i; | 195 | int i; |
@@ -185,32 +209,18 @@ void tv_select_bookmark(void) | |||
185 | select_pos = bookmarks[0].pos; | 209 | select_pos = bookmarks[0].pos; |
186 | else | 210 | else |
187 | { | 211 | { |
188 | int selected = -1; | 212 | struct simplelist_info info; |
189 | struct opt_items items[bookmark_count]; | ||
190 | unsigned char names[bookmark_count][24]; | ||
191 | 213 | ||
192 | rb->qsort(bookmarks, bookmark_count, sizeof(struct tv_bookmark_info), bm_comp); | 214 | rb->qsort(bookmarks, bookmark_count, sizeof(struct tv_bookmark_info), bm_comp); |
193 | 215 | ||
194 | for (i = 0; i < bookmark_count; i++) | 216 | rb->simplelist_info_init(&info, "Select bookmark", |
195 | { | 217 | bookmark_count, bookmarks); |
196 | rb->snprintf(names[i], sizeof(names[0]), | 218 | info.get_name = get_bookmark_name; |
197 | #if CONFIG_KEYPAD != PLAYER_PAD | 219 | info.action_callback = list_action_callback; |
198 | "%cPage: %d Line: %d", | 220 | rb->simplelist_show_list(&info); |
199 | #else | ||
200 | "%cP:%d L:%d", | ||
201 | #endif | ||
202 | (bookmarks[i].flag & TV_BOOKMARK_SYSTEM)? '*' : ' ', | ||
203 | bookmarks[i].pos.page + 1, | ||
204 | bookmarks[i].pos.line + 1); | ||
205 | items[i].string = names[i]; | ||
206 | items[i].voice_id = -1; | ||
207 | } | ||
208 | |||
209 | rb->set_option("Select bookmark", &selected, INT, items, | ||
210 | bookmark_count, NULL); | ||
211 | 221 | ||
212 | if (selected >= 0 && selected < bookmark_count) | 222 | if (info.selection >= 0 && info.selection < bookmark_count) |
213 | select_pos = bookmarks[selected].pos; | 223 | select_pos = bookmarks[info.selection].pos; |
214 | else | 224 | else |
215 | { | 225 | { |
216 | /* when does not select any bookmarks, move to the current page */ | 226 | /* when does not select any bookmarks, move to the current page */ |