text viewer: simplify display functions.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27152 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Yoshihisa Uchida 2010-06-27 08:08:33 +00:00
parent 4b18976496
commit 1ed3aba4f2
3 changed files with 51 additions and 81 deletions

View file

@ -169,19 +169,25 @@ 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);
}
void tv_set_drawmode(int mode)
{
rb->lcd_set_drawmode(mode);
}
#endif
void tv_show_bookmarks(const int *rows, int count)
{
#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)
{
int xpos = -offset * col_width;
@ -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();

View file

@ -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 */

View file

@ -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();