From e309695a09c0b91f7c32dd8bc354472b18c3506b Mon Sep 17 00:00:00 2001 From: uchida Date: Sun, 27 Jun 2010 08:08:33 +0000 Subject: [PATCH] text viewer: simplify display functions. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27152 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/text_viewer/tv_display.c | 43 ++++++++++++-------------- apps/plugins/text_viewer/tv_display.h | 58 +++++++++++++---------------------- apps/plugins/text_viewer/tv_window.c | 25 +++++---------- 3 files changed, 48 insertions(+), 78 deletions(-) diff --git a/apps/plugins/text_viewer/tv_display.c b/apps/plugins/text_viewer/tv_display.c index 8d85ae2a7..05f968dc9 100644 --- a/apps/plugins/text_viewer/tv_display.c +++ b/apps/plugins/text_viewer/tv_display.c @@ -169,18 +169,24 @@ void tv_show_scrollbar(int window, int col, off_t cur_pos, int size) } } -void tv_fillrect(int col, int row, int rows) -{ - display->fillrect(drawarea.x + col * col_width, drawarea.y + row * row_height, - drawarea.w - col * col_width, rows * row_height); -} +#endif -void tv_set_drawmode(int mode) +void tv_show_bookmarks(const int *rows, int count) { - rb->lcd_set_drawmode(mode); -} +#ifdef HAVE_LCD_BITMAP + rb->lcd_set_drawmode(DRMODE_COMPLEMENT); +#endif + while (count--) + { +#ifdef HAVE_LCD_BITMAP + display->fillrect(drawarea.x, drawarea.y + rows[count] * row_height, + drawarea.w, row_height); +#else + display->putchar(bookmark.x, drawarea.y + rows[count], TV_BOOKMARK_ICON); #endif + } +} void tv_draw_text(int row, const unsigned char *text, int offset) { @@ -203,13 +209,6 @@ void tv_draw_text(int row, const unsigned char *text, int offset) #endif } -#ifndef HAVE_LCD_BITMAP -void tv_put_bookmark_icon(int row) -{ - display->putchar(bookmark.x, drawarea.y + row, TV_BOOKMARK_ICON); -} -#endif - void tv_init_display(void) { display = rb->screens[SCREEN_MAIN]; @@ -221,7 +220,13 @@ void tv_start_display(void) display->set_viewport(&vp_info); #ifdef HAVE_LCD_BITMAP drawmode = rb->lcd_get_drawmode(); + rb->lcd_set_drawmode(DRMODE_SOLID); #endif + +#if LCD_DEPTH > 1 + rb->lcd_set_backdrop(NULL); +#endif + display->clear_viewport(); } void tv_end_display(void) @@ -232,14 +237,6 @@ void tv_end_display(void) display->set_viewport(NULL); } -void tv_clear_display(void) -{ -#if LCD_DEPTH > 1 - rb->lcd_set_backdrop(NULL); -#endif - display->clear_viewport(); -} - void tv_update_display(void) { display->update_viewport(); diff --git a/apps/plugins/text_viewer/tv_display.h b/apps/plugins/text_viewer/tv_display.h index 005011c75..aa30436c4 100644 --- a/apps/plugins/text_viewer/tv_display.h +++ b/apps/plugins/text_viewer/tv_display.h @@ -66,18 +66,18 @@ void tv_init_scrollbar(off_t total, bool show_scrollbar); * the size of text in displayed. */ void tv_show_scrollbar(int window, int col, off_t cur_pos, int size); - -#else +#endif /* - * put the bookmark icon + * show bookmark * - * [In] row - * the row where the bookmark icon is put + * [In] rows + * the array of row where the bookmark + * + * [In] count + * want to show bookmark count */ -void tv_put_bookmark_icon(int row); - -#endif +void tv_show_bookmarks(const int *rows, int count); /* common display functons */ @@ -90,38 +90,9 @@ void tv_start_display(void); /* end the display processing */ void tv_end_display(void); -/* clear the display */ -void tv_clear_display(void); - /*update the display */ void tv_update_display(void); -#ifdef HAVE_LCD_BITMAP - -/* - * set the drawmode - * - * [In] mode - * new drawmode - */ -void tv_set_drawmode(int mode); - -/* - * draw the rectangle that paints out inside - * - * [In] col - * the column of the upper left - * - * [In] row - * the row of the upper left - * - * [In] row - * draw rows - */ -void tv_fillrect(int col, int row, int rows); - -#endif - /* * draw the text * @@ -162,6 +133,19 @@ void tv_set_layout(int col_w, bool show_scrollbar); void tv_set_layout(int col_w); #endif + +/* + * get the draw area info + * + * [Out] width + * width of the draw area + * + * [Out] cols + * column count of the draw area + * + * [Out] width + * row count of the draw area + */ void tv_get_drawarea_info(int *width, int *cols, int *rows); /* viewport functions */ diff --git a/apps/plugins/text_viewer/tv_window.c b/apps/plugins/text_viewer/tv_window.c index 16be8845e..c83c6080b 100644 --- a/apps/plugins/text_viewer/tv_window.c +++ b/apps/plugins/text_viewer/tv_window.c @@ -54,29 +54,23 @@ static bool tv_set_font(const unsigned char *font) } #endif -static void tv_show_bookmarks(const struct tv_screen_pos *top_pos) +static void tv_draw_bookmarks(const struct tv_screen_pos *top_pos) { struct tv_screen_pos bookmarks[TV_MAX_BOOKMARKS]; + int disp_bookmarks[TV_MAX_BOOKMARKS]; int count = tv_get_bookmark_positions(bookmarks); + int disp_count = 0; int line; -#ifdef HAVE_LCD_BITMAP - tv_set_drawmode(DRMODE_COMPLEMENT); -#endif - while (count--) { line = (bookmarks[count].page - top_pos->page) * display_lines + (bookmarks[count].line - top_pos->line); if (line >= 0 && line < display_lines) - { -#ifdef HAVE_LCD_BITMAP - tv_fillrect(0, line, 1); -#else - tv_put_bookmark_icon(line); -#endif - } + disp_bookmarks[disp_count++] = line; } + + tv_show_bookmarks(disp_bookmarks, disp_count); } void tv_draw_window(void) @@ -90,11 +84,6 @@ void tv_draw_window(void) tv_start_display(); -#ifdef HAVE_LCD_BITMAP - tv_set_drawmode(DRMODE_SOLID); -#endif - tv_clear_display(); - tv_read_start(cur_window, (cur_column > 0)); for (line = 0; line < display_lines; line++) @@ -112,7 +101,7 @@ void tv_draw_window(void) tv_show_header(); tv_show_footer(&pos); #endif - tv_show_bookmarks(&pos); + tv_draw_bookmarks(&pos); tv_update_display(); tv_end_display(); -- 2.11.4.GIT