A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

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

+71 -66
+1 -1
apps/plugins/text_viewer/text_viewer.c
··· 60 60 atexit(tv_exit); 61 61 while (!done) { 62 62 #ifdef HAVE_LCD_BITMAP 63 - if (rb->global_settings->statusbar != STATUSBAR_OFF && preferences->statusbar) 63 + if (preferences->statusbar) 64 64 rb->send_event(GUI_EVENT_ACTIONUPDATE, NULL); 65 65 #endif 66 66
-2
apps/plugins/text_viewer/tv_action.c
··· 174 174 if (res == TV_MENU_RESULT_EXIT_MENU) 175 175 { 176 176 tv_convert_fpos(cur_file_pos, &cur_pos); 177 - if (preferences->vertical_scroll_mode == VS_PAGE) 178 - cur_pos.line = 0; 179 177 180 178 tv_move_screen(cur_pos.page, cur_pos.line, SEEK_SET); 181 179 }
+32 -22
apps/plugins/text_viewer/tv_bookmark.c
··· 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 193 void tv_select_bookmark(void) 170 194 { 171 195 int i; ··· 185 209 select_pos = bookmarks[0].pos; 186 210 else 187 211 { 188 - int selected = -1; 189 - struct opt_items items[bookmark_count]; 190 - unsigned char names[bookmark_count][24]; 212 + struct simplelist_info info; 191 213 192 214 rb->qsort(bookmarks, bookmark_count, sizeof(struct tv_bookmark_info), bm_comp); 193 215 194 - for (i = 0; i < bookmark_count; i++) 195 - { 196 - rb->snprintf(names[i], sizeof(names[0]), 197 - #if CONFIG_KEYPAD != PLAYER_PAD 198 - "%cPage: %d Line: %d", 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 - } 216 + rb->simplelist_info_init(&info, "Select bookmark", 217 + bookmark_count, bookmarks); 218 + info.get_name = get_bookmark_name; 219 + info.action_callback = list_action_callback; 220 + rb->simplelist_show_list(&info); 208 221 209 - rb->set_option("Select bookmark", &selected, INT, items, 210 - bookmark_count, NULL); 211 - 212 - if (selected >= 0 && selected < bookmark_count) 213 - select_pos = bookmarks[selected].pos; 222 + if (info.selection >= 0 && info.selection < bookmark_count) 223 + select_pos = bookmarks[info.selection].pos; 214 224 else 215 225 { 216 226 /* when does not select any bookmarks, move to the current page */
+35 -39
apps/plugins/text_viewer/tv_display.c
··· 81 81 }; 82 82 83 83 static struct viewport vp_info; 84 + static struct viewport vp_text; 84 85 static bool is_initialized_vp = false; 85 86 86 87 static struct screen* display; 87 - 88 - #ifdef HAVE_LCD_BITMAP 89 - static int drawmode = DRMODE_SOLID; 90 - #endif 91 88 92 89 /* layout */ 93 90 #ifdef HAVE_LCD_BITMAP ··· 98 95 #else 99 96 static struct tv_rect bookmark; 100 97 #endif 101 - static struct tv_rect drawarea; 102 98 103 99 static bool show_horizontal_scrollbar; 104 100 static bool show_vertical_scrollbar; ··· 176 172 void tv_show_bookmarks(const int *rows, int count) 177 173 { 178 174 #ifdef HAVE_LCD_BITMAP 179 - rb->lcd_set_drawmode(DRMODE_COMPLEMENT); 175 + display->set_viewport(&vp_text); 176 + display->set_drawmode(DRMODE_COMPLEMENT); 180 177 #endif 181 178 182 179 while (count--) 183 180 { 184 181 #ifdef HAVE_LCD_BITMAP 185 - display->fillrect(drawarea.x, drawarea.y + rows[count] * row_height, 186 - drawarea.w, row_height); 182 + display->fillrect(0, rows[count] * row_height, 183 + vp_text.width, row_height); 187 184 #else 188 - display->putchar(bookmark.x, drawarea.y + rows[count], TV_BOOKMARK_ICON); 185 + display->putchar(bookmark.x, bookmark.y + rows[count], TV_BOOKMARK_ICON); 189 186 #endif 190 187 } 188 + #ifdef HAVE_LCD_BITMAP 189 + display->set_drawmode(DRMODE_SOLID); 190 + display->set_viewport(&vp_info); 191 + #endif 191 192 } 192 193 193 194 void tv_update_extra(int window, int col, const struct tv_screen_pos *pos, int size) ··· 215 216 if (preferences->alignment == AL_RIGHT) 216 217 { 217 218 display->getstringsize(text, &text_width, NULL); 218 - xpos += ((offset > 0)? drawarea.w * 2 : drawarea.w) - text_width; 219 + xpos += ((offset > 0)? vp_text.width * 2 : vp_text.width) - text_width; 219 220 } 220 221 222 + display->set_viewport(&vp_text); 221 223 #ifdef HAVE_LCD_BITMAP 222 - display->putsxy(drawarea.x + xpos, drawarea.y + row * row_height, text); 224 + display->putsxy(xpos, row * row_height, text); 223 225 #else 224 - display->puts(drawarea.x + xpos, drawarea.y + row, text); 226 + display->puts(xpos, row, text); 225 227 #endif 228 + display->set_viewport(&vp_info); 226 229 } 227 230 228 231 void tv_start_display(void) 229 232 { 230 233 display->set_viewport(&vp_info); 231 234 #ifdef HAVE_LCD_BITMAP 232 - drawmode = rb->lcd_get_drawmode(); 233 - rb->lcd_set_drawmode(DRMODE_SOLID); 235 + display->set_drawmode(DRMODE_SOLID); 234 236 #endif 235 237 236 238 #if LCD_DEPTH > 1 ··· 242 244 void tv_end_display(void) 243 245 { 244 246 display->update_viewport(); 245 - 246 - #ifdef HAVE_LCD_BITMAP 247 - rb->lcd_set_drawmode(drawmode); 248 - #endif 249 - 250 247 display->set_viewport(NULL); 251 248 } 252 249 ··· 261 258 row_height = preferences->font->height; 262 259 263 260 header.x = 0; 264 - header.y = 1; 261 + header.y = 0; 265 262 header.w = vp_info.width; 266 263 header.h = (preferences->header_mode)? row_height + 1 : 0; 267 264 268 265 footer.x = 0; 269 266 footer.w = vp_info.width; 270 267 footer.h = (preferences->footer_mode)? row_height + 1 : 0; 271 - footer.y = vp_info.height - 1 - footer.h; 272 - 273 - drawarea.x = scrollbar_width; 274 - drawarea.y = header.y + header.h; 275 - drawarea.w = vp_info.width - scrollbar_width; 276 - drawarea.h = footer.y - drawarea.y - scrollbar_height; 268 + footer.y = vp_info.height - footer.h; 277 269 278 - horizontal_scrollbar.x = drawarea.x; 270 + horizontal_scrollbar.x = scrollbar_width; 279 271 horizontal_scrollbar.y = footer.y - scrollbar_height; 280 - horizontal_scrollbar.w = drawarea.w; 272 + horizontal_scrollbar.w = vp_info.width - scrollbar_width; 281 273 horizontal_scrollbar.h = scrollbar_height; 282 274 283 275 vertical_scrollbar.x = 0; 284 - vertical_scrollbar.y = drawarea.y; 276 + vertical_scrollbar.y = header.y + header.h; 285 277 vertical_scrollbar.w = scrollbar_width; 286 - vertical_scrollbar.h = drawarea.h; 278 + vertical_scrollbar.h = footer.y - vertical_scrollbar.y - scrollbar_height; 279 + 280 + vp_text = vp_info; 281 + vp_text.x += horizontal_scrollbar.x; 282 + vp_text.y += vertical_scrollbar.y; 283 + vp_text.width = horizontal_scrollbar.w; 284 + vp_text.height = vertical_scrollbar.h; 287 285 #else 288 286 (void) show_scrollbar; 289 287 ··· 294 292 bookmark.w = 1; 295 293 bookmark.h = vp_info.height; 296 294 297 - drawarea.x = 1; 298 - drawarea.y = 0; 299 - drawarea.w = vp_info.width - 1; 300 - drawarea.h = vp_info.height; 295 + vp_text = vp_info; 296 + vp_text.x += 1; 297 + vp_text.width -= 1; 301 298 #endif 302 299 303 - display_columns = drawarea.w / col_width; 304 - display_rows = drawarea.h / row_height; 300 + display_columns = vp_text.width / col_width; 301 + display_rows = vp_text.height / row_height; 305 302 } 306 303 307 304 void tv_get_drawarea_info(int *width, int *cols, int *rows) 308 305 { 309 - *width = drawarea.w; 306 + *width = vp_text.width; 310 307 *cols = display_columns; 311 308 *rows = display_rows; 312 309 } ··· 314 311 static void tv_change_viewport(void) 315 312 { 316 313 #ifdef HAVE_LCD_BITMAP 317 - bool show_statusbar = (rb->global_settings->statusbar != STATUSBAR_OFF && 318 - preferences->statusbar); 314 + bool show_statusbar = preferences->statusbar; 319 315 320 316 if (is_initialized_vp) 321 317 rb->viewportmanager_theme_undo(SCREEN_MAIN, false);
+3 -1
apps/plugins/text_viewer/tv_pager.c
··· 220 220 while (tv_create_line_positions() && cur_pos.file_pos < fpos) 221 221 rb->splashf(0, "converting %ld%%...", 100 * cur_pos.file_pos / fpos); 222 222 223 - if (cur_pos.page < max_page) 223 + if (i < max_page) 224 224 cur_pos.page--; 225 225 tv_seek_page(cur_pos.page, SEEK_SET); 226 226 for (i = 0; i < lines_per_page; i++) ··· 296 296 if (cur_pos.page < max_page && new_pos.line == lines_per_page) 297 297 { 298 298 tv_seek(line_pos[lines_per_page], SEEK_CUR); 299 + cur_pos.file_pos += line_pos[lines_per_page]; 300 + 299 301 for (i = 0; i < parse_lines; i++) 300 302 line_pos[i] = line_pos[i + lines_per_page] - line_pos[lines_per_page]; 301 303
-1
apps/plugins/text_viewer/tv_reader.c
··· 111 111 return; 112 112 } 113 113 file_pos += buf_pos; 114 - whence = SEEK_SET; 115 114 break; 116 115 117 116 default: