forked from len0rd/rockbox
text viewer: tv_window doesn't depend on the layout of the text viewer.
And display functions change the following. - some functions change to static functions. - fix the problem that font_changing flag is invalid value. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27165 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
31cf6d5013
commit
cf6554d891
3 changed files with 124 additions and 125 deletions
|
@ -82,14 +82,12 @@ struct tv_rect {
|
||||||
static struct viewport vp_info;
|
static struct viewport vp_info;
|
||||||
static bool is_initialized_vp = false;
|
static bool is_initialized_vp = false;
|
||||||
|
|
||||||
|
static struct screen* display;
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
static int drawmode = DRMODE_SOLID;
|
static int drawmode = DRMODE_SOLID;
|
||||||
static int totalsize;
|
|
||||||
static bool show_vertical_scrollbar;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct screen* display;
|
|
||||||
|
|
||||||
/* layout */
|
/* layout */
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
static struct tv_rect header;
|
static struct tv_rect header;
|
||||||
|
@ -101,15 +99,19 @@ static struct tv_rect bookmark;
|
||||||
#endif
|
#endif
|
||||||
static struct tv_rect drawarea;
|
static struct tv_rect drawarea;
|
||||||
|
|
||||||
|
static bool show_vertical_scrollbar;
|
||||||
|
|
||||||
static int display_columns;
|
static int display_columns;
|
||||||
static int display_rows;
|
static int display_rows;
|
||||||
|
|
||||||
static int col_width = 1;
|
static int col_width = 1;
|
||||||
static int row_height = 1;
|
static int row_height = 1;
|
||||||
|
|
||||||
|
static int totalsize;
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
|
||||||
void tv_show_header(void)
|
static void tv_show_header(void)
|
||||||
{
|
{
|
||||||
unsigned header_mode = header_mode;
|
unsigned header_mode = header_mode;
|
||||||
|
|
||||||
|
@ -117,7 +119,7 @@ void tv_show_header(void)
|
||||||
display->putsxy(header.x, header.y, preferences->file_name);
|
display->putsxy(header.x, header.y, preferences->file_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tv_show_footer(const struct tv_screen_pos *pos)
|
static void tv_show_footer(const struct tv_screen_pos *pos)
|
||||||
{
|
{
|
||||||
unsigned char buf[12];
|
unsigned char buf[12];
|
||||||
unsigned footer_mode = preferences->footer_mode;
|
unsigned footer_mode = preferences->footer_mode;
|
||||||
|
@ -132,13 +134,7 @@ void tv_show_footer(const struct tv_screen_pos *pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tv_init_scrollbar(off_t total, bool show_scrollbar)
|
static void tv_show_scrollbar(int window, int col, off_t cur_pos, int size)
|
||||||
{
|
|
||||||
totalsize = total;
|
|
||||||
show_vertical_scrollbar = show_scrollbar;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tv_show_scrollbar(int window, int col, off_t cur_pos, int size)
|
|
||||||
{
|
{
|
||||||
int items;
|
int items;
|
||||||
int min_shown;
|
int min_shown;
|
||||||
|
@ -171,6 +167,12 @@ void tv_show_scrollbar(int window, int col, off_t cur_pos, int size)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void tv_init_scrollbar(off_t total, bool show_scrollbar)
|
||||||
|
{
|
||||||
|
totalsize = total;
|
||||||
|
show_vertical_scrollbar = show_scrollbar;
|
||||||
|
}
|
||||||
|
|
||||||
void tv_show_bookmarks(const int *rows, int count)
|
void tv_show_bookmarks(const int *rows, int count)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
@ -188,6 +190,20 @@ void tv_show_bookmarks(const int *rows, int count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tv_update_extra(int window, int col, const struct tv_screen_pos *pos, int size)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
tv_show_scrollbar(window, col, pos->file_pos, size);
|
||||||
|
tv_show_header();
|
||||||
|
tv_show_footer(pos);
|
||||||
|
#else
|
||||||
|
(void)window;
|
||||||
|
(void)col;
|
||||||
|
(void)pos;
|
||||||
|
(void)size;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void tv_draw_text(int row, const unsigned char *text, int offset)
|
void tv_draw_text(int row, const unsigned char *text, int offset)
|
||||||
{
|
{
|
||||||
int xpos = -offset * col_width;
|
int xpos = -offset * col_width;
|
||||||
|
@ -225,15 +241,13 @@ void tv_start_display(void)
|
||||||
|
|
||||||
void tv_end_display(void)
|
void tv_end_display(void)
|
||||||
{
|
{
|
||||||
|
display->update_viewport();
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
#ifdef HAVE_LCD_BITMAP
|
||||||
rb->lcd_set_drawmode(drawmode);
|
rb->lcd_set_drawmode(drawmode);
|
||||||
#endif
|
#endif
|
||||||
display->set_viewport(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tv_update_display(void)
|
display->set_viewport(NULL);
|
||||||
{
|
|
||||||
display->update_viewport();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tv_set_layout(bool show_scrollbar)
|
void tv_set_layout(bool show_scrollbar)
|
||||||
|
@ -295,27 +309,29 @@ void tv_get_drawarea_info(int *width, int *cols, int *rows)
|
||||||
*rows = display_rows;
|
*rows = display_rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
|
||||||
static void tv_undo_viewport(void)
|
|
||||||
{
|
|
||||||
if (is_initialized_vp)
|
|
||||||
rb->viewportmanager_theme_undo(SCREEN_MAIN, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void tv_change_viewport(void)
|
static void tv_change_viewport(void)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_LCD_BITMAP
|
||||||
struct viewport vp;
|
struct viewport vp;
|
||||||
|
|
||||||
if (is_initialized_vp)
|
if (is_initialized_vp)
|
||||||
tv_undo_viewport();
|
rb->viewportmanager_theme_undo(SCREEN_MAIN, false);
|
||||||
else
|
else
|
||||||
is_initialized_vp = true;
|
is_initialized_vp = true;
|
||||||
|
|
||||||
rb->viewportmanager_theme_enable(SCREEN_MAIN, preferences->statusbar, &vp);
|
rb->viewportmanager_theme_enable(SCREEN_MAIN, preferences->statusbar, &vp);
|
||||||
vp_info = vp;
|
vp_info = vp;
|
||||||
vp_info.flags &= ~VP_FLAG_ALIGNMENT_MASK;
|
vp_info.flags &= ~VP_FLAG_ALIGNMENT_MASK;
|
||||||
|
#else
|
||||||
|
if (!is_initialized_vp)
|
||||||
|
{
|
||||||
|
rb->viewport_set_defaults(&vp_info, SCREEN_MAIN);
|
||||||
|
is_initialized_vp = true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_LCD_BITMAP
|
||||||
static bool tv_set_font(const unsigned char *font)
|
static bool tv_set_font(const unsigned char *font)
|
||||||
{
|
{
|
||||||
unsigned char path[MAX_PATH];
|
unsigned char path[MAX_PATH];
|
||||||
|
@ -351,21 +367,14 @@ static void tv_change_preferences(const struct tv_preferences *oldp)
|
||||||
tv_copy_preferences(&new_prefs);
|
tv_copy_preferences(&new_prefs);
|
||||||
rb->strlcpy(new_prefs.font_name, font_str, MAX_PATH);
|
rb->strlcpy(new_prefs.font_name, font_str, MAX_PATH);
|
||||||
tv_set_preferences(&new_prefs);
|
tv_set_preferences(&new_prefs);
|
||||||
font_changing = false;
|
|
||||||
}
|
}
|
||||||
col_width = 2 * rb->font_get_width(preferences->font, ' ');
|
col_width = 2 * rb->font_get_width(preferences->font, ' ');
|
||||||
|
font_changing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
tv_change_viewport();
|
|
||||||
#else
|
#else
|
||||||
(void)oldp;
|
(void)oldp;
|
||||||
|
|
||||||
if (!is_initialized_vp)
|
|
||||||
{
|
|
||||||
rb->viewport_set_defaults(&vp_info, SCREEN_MAIN);
|
|
||||||
is_initialized_vp = true;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
tv_change_viewport();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tv_init_display(unsigned char **buf, size_t *size)
|
bool tv_init_display(unsigned char **buf, size_t *size)
|
||||||
|
@ -391,6 +400,15 @@ void tv_finalize_display(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* undo viewport */
|
/* undo viewport */
|
||||||
tv_undo_viewport();
|
rb->viewportmanager_theme_undo(SCREEN_MAIN, false);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool tv_exist_scrollbar(void)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_LCD_BITMAP
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,75 +44,6 @@ bool tv_init_display(unsigned char **buf, size_t *size);
|
||||||
/* finalize the display module */
|
/* finalize the display module */
|
||||||
void tv_finalize_display(void);
|
void tv_finalize_display(void);
|
||||||
|
|
||||||
|
|
||||||
/* layout parts accessing functions */
|
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
|
||||||
|
|
||||||
/* show headaer */
|
|
||||||
void tv_show_header(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* show footer
|
|
||||||
*
|
|
||||||
* [In] pos
|
|
||||||
* the current position
|
|
||||||
*/
|
|
||||||
void tv_show_footer(const struct tv_screen_pos *pos);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* initialize the scrollbar
|
|
||||||
*
|
|
||||||
* [In] total
|
|
||||||
* total text size
|
|
||||||
*
|
|
||||||
* [In] show_scrollbar
|
|
||||||
* true: show the vertical scrollbar
|
|
||||||
* false: does not show the vertical scrollbar
|
|
||||||
*/
|
|
||||||
void tv_init_scrollbar(off_t total, bool show_scrollbar);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* show horizontal/vertical scrollbar
|
|
||||||
*
|
|
||||||
* [In] window
|
|
||||||
* the current window
|
|
||||||
*
|
|
||||||
* [In] col
|
|
||||||
* the current column
|
|
||||||
*
|
|
||||||
* [In] cur_pos
|
|
||||||
* the current text position
|
|
||||||
*
|
|
||||||
* [In] size
|
|
||||||
* the size of text in displayed.
|
|
||||||
*/
|
|
||||||
void tv_show_scrollbar(int window, int col, off_t cur_pos, int size);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* show bookmark
|
|
||||||
*
|
|
||||||
* [In] rows
|
|
||||||
* the array of row where the bookmark
|
|
||||||
*
|
|
||||||
* [In] count
|
|
||||||
* want to show bookmark count
|
|
||||||
*/
|
|
||||||
void tv_show_bookmarks(const int *rows, int count);
|
|
||||||
|
|
||||||
/* common display functons */
|
|
||||||
|
|
||||||
/* start the display processing */
|
|
||||||
void tv_start_display(void);
|
|
||||||
|
|
||||||
/* end the display processing */
|
|
||||||
void tv_end_display(void);
|
|
||||||
|
|
||||||
/*update the display */
|
|
||||||
void tv_update_display(void);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* draw the text
|
* draw the text
|
||||||
*
|
*
|
||||||
|
@ -127,6 +58,52 @@ void tv_update_display(void);
|
||||||
*/
|
*/
|
||||||
void tv_draw_text(int row, const unsigned char *text, int offset);
|
void tv_draw_text(int row, const unsigned char *text, int offset);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* show bookmark
|
||||||
|
*
|
||||||
|
* [In] rows
|
||||||
|
* the array of row where the bookmark
|
||||||
|
*
|
||||||
|
* [In] count
|
||||||
|
* want to show bookmark count
|
||||||
|
*/
|
||||||
|
void tv_show_bookmarks(const int *rows, int count);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* update extra parts (header, footer, scrollbar, etc.)
|
||||||
|
*
|
||||||
|
* [In] window
|
||||||
|
* current window
|
||||||
|
*
|
||||||
|
* [In] col
|
||||||
|
* current column
|
||||||
|
*
|
||||||
|
* [In] pos
|
||||||
|
* current screen position (file position, page, line)
|
||||||
|
*
|
||||||
|
* [In] size
|
||||||
|
* the size of text which is displayed.
|
||||||
|
*/
|
||||||
|
void tv_update_extra(int window, int col, const struct tv_screen_pos *pos, int size);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* initialize the scrollbar
|
||||||
|
*
|
||||||
|
* [In] total
|
||||||
|
* total text size
|
||||||
|
*
|
||||||
|
* [In] show_scrollbar
|
||||||
|
* true: show the vertical scrollbar
|
||||||
|
* false: does not show the vertical scrollbar
|
||||||
|
*/
|
||||||
|
void tv_init_scrollbar(off_t total, bool show_scrollbar);
|
||||||
|
|
||||||
|
/* start the display processing */
|
||||||
|
void tv_start_display(void);
|
||||||
|
|
||||||
|
/* end the display processing */
|
||||||
|
void tv_end_display(void);
|
||||||
|
|
||||||
|
|
||||||
/* layout functions */
|
/* layout functions */
|
||||||
|
|
||||||
|
@ -153,4 +130,13 @@ void tv_set_layout(bool show_scrollbar);
|
||||||
*/
|
*/
|
||||||
void tv_get_drawarea_info(int *width, int *cols, int *rows);
|
void tv_get_drawarea_info(int *width, int *cols, int *rows);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* whether exist scrollbar
|
||||||
|
*
|
||||||
|
* return
|
||||||
|
* true exist scrollbar
|
||||||
|
* false does not exist scrollbar
|
||||||
|
*/
|
||||||
|
bool tv_exist_scrollbar(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -77,14 +77,10 @@ void tv_draw_window(void)
|
||||||
|
|
||||||
size = tv_read_end();
|
size = tv_read_end();
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
|
||||||
tv_show_scrollbar(cur_window, cur_column, pos.file_pos, size);
|
|
||||||
tv_show_header();
|
|
||||||
tv_show_footer(&pos);
|
|
||||||
#endif
|
|
||||||
tv_draw_bookmarks(&pos);
|
tv_draw_bookmarks(&pos);
|
||||||
|
|
||||||
tv_update_display();
|
tv_update_extra(cur_window, cur_column, &pos, size);
|
||||||
|
|
||||||
tv_end_display();
|
tv_end_display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,27 +111,26 @@ static void tv_change_preferences(const struct tv_preferences *oldp)
|
||||||
tv_set_layout(need_vertical_scrollbar);
|
tv_set_layout(need_vertical_scrollbar);
|
||||||
tv_get_drawarea_info(&window_width, &window_columns, &display_lines);
|
tv_get_drawarea_info(&window_width, &window_columns, &display_lines);
|
||||||
|
|
||||||
#ifdef HAVE_LCD_BITMAP
|
if (tv_exist_scrollbar())
|
||||||
tv_seek_top();
|
|
||||||
tv_set_read_conditions(preferences->windows, window_width);
|
|
||||||
if (tv_traverse_lines() && preferences->vertical_scrollbar)
|
|
||||||
{
|
{
|
||||||
need_vertical_scrollbar = true;
|
tv_seek_top();
|
||||||
tv_set_layout(need_vertical_scrollbar);
|
tv_set_read_conditions(preferences->windows, window_width);
|
||||||
tv_get_drawarea_info(&window_width, &window_columns, &display_lines);
|
if (tv_traverse_lines() && preferences->vertical_scrollbar)
|
||||||
|
{
|
||||||
|
need_vertical_scrollbar = true;
|
||||||
|
tv_set_layout(need_vertical_scrollbar);
|
||||||
|
tv_get_drawarea_info(&window_width, &window_columns, &display_lines);
|
||||||
|
}
|
||||||
|
tv_seek_top();
|
||||||
|
tv_init_scrollbar(tv_get_total_text_size(), need_vertical_scrollbar);
|
||||||
}
|
}
|
||||||
tv_seek_top();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cur_column = 0;
|
|
||||||
|
|
||||||
if (cur_window >= preferences->windows)
|
if (cur_window >= preferences->windows)
|
||||||
cur_window = 0;
|
cur_window = 0;
|
||||||
|
|
||||||
|
cur_column = 0;
|
||||||
|
|
||||||
tv_set_read_conditions(preferences->windows, window_width);
|
tv_set_read_conditions(preferences->windows, window_width);
|
||||||
#ifdef HAVE_LCD_BITMAP
|
|
||||||
tv_init_scrollbar(tv_get_total_text_size(), need_vertical_scrollbar);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tv_init_window(unsigned char **buf, size_t *size)
|
bool tv_init_window(unsigned char **buf, size_t *size)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue