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_display.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_display.c')
-rw-r--r-- | apps/plugins/text_viewer/tv_display.c | 74 |
1 files changed, 35 insertions, 39 deletions
diff --git a/apps/plugins/text_viewer/tv_display.c b/apps/plugins/text_viewer/tv_display.c index 4de62855f9..d38f1b514c 100644 --- a/apps/plugins/text_viewer/tv_display.c +++ b/apps/plugins/text_viewer/tv_display.c | |||
@@ -81,14 +81,11 @@ struct tv_rect { | |||
81 | }; | 81 | }; |
82 | 82 | ||
83 | static struct viewport vp_info; | 83 | static struct viewport vp_info; |
84 | static struct viewport vp_text; | ||
84 | static bool is_initialized_vp = false; | 85 | static bool is_initialized_vp = false; |
85 | 86 | ||
86 | static struct screen* display; | 87 | static struct screen* display; |
87 | 88 | ||
88 | #ifdef HAVE_LCD_BITMAP | ||
89 | static int drawmode = DRMODE_SOLID; | ||
90 | #endif | ||
91 | |||
92 | /* layout */ | 89 | /* layout */ |
93 | #ifdef HAVE_LCD_BITMAP | 90 | #ifdef HAVE_LCD_BITMAP |
94 | static struct tv_rect header; | 91 | static struct tv_rect header; |
@@ -98,7 +95,6 @@ static struct tv_rect vertical_scrollbar; | |||
98 | #else | 95 | #else |
99 | static struct tv_rect bookmark; | 96 | static struct tv_rect bookmark; |
100 | #endif | 97 | #endif |
101 | static struct tv_rect drawarea; | ||
102 | 98 | ||
103 | static bool show_horizontal_scrollbar; | 99 | static bool show_horizontal_scrollbar; |
104 | static bool show_vertical_scrollbar; | 100 | static bool show_vertical_scrollbar; |
@@ -176,18 +172,23 @@ void tv_init_scrollbar(off_t total, bool show_scrollbar) | |||
176 | void tv_show_bookmarks(const int *rows, int count) | 172 | void tv_show_bookmarks(const int *rows, int count) |
177 | { | 173 | { |
178 | #ifdef HAVE_LCD_BITMAP | 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 | #endif | 177 | #endif |
181 | 178 | ||
182 | while (count--) | 179 | while (count--) |
183 | { | 180 | { |
184 | #ifdef HAVE_LCD_BITMAP | 181 | #ifdef HAVE_LCD_BITMAP |
185 | display->fillrect(drawarea.x, drawarea.y + rows[count] * row_height, | 182 | display->fillrect(0, rows[count] * row_height, |
186 | drawarea.w, row_height); | 183 | vp_text.width, row_height); |
187 | #else | 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 | #endif | 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 | void tv_update_extra(int window, int col, const struct tv_screen_pos *pos, int size) | 194 | void tv_update_extra(int window, int col, const struct tv_screen_pos *pos, int size) |
@@ -215,22 +216,23 @@ void tv_draw_text(int row, const unsigned char *text, int offset) | |||
215 | if (preferences->alignment == AL_RIGHT) | 216 | if (preferences->alignment == AL_RIGHT) |
216 | { | 217 | { |
217 | display->getstringsize(text, &text_width, NULL); | 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 | #ifdef HAVE_LCD_BITMAP | 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 | #else | 225 | #else |
224 | display->puts(drawarea.x + xpos, drawarea.y + row, text); | 226 | display->puts(xpos, row, text); |
225 | #endif | 227 | #endif |
228 | display->set_viewport(&vp_info); | ||
226 | } | 229 | } |
227 | 230 | ||
228 | void tv_start_display(void) | 231 | void tv_start_display(void) |
229 | { | 232 | { |
230 | display->set_viewport(&vp_info); | 233 | display->set_viewport(&vp_info); |
231 | #ifdef HAVE_LCD_BITMAP | 234 | #ifdef HAVE_LCD_BITMAP |
232 | drawmode = rb->lcd_get_drawmode(); | 235 | display->set_drawmode(DRMODE_SOLID); |
233 | rb->lcd_set_drawmode(DRMODE_SOLID); | ||
234 | #endif | 236 | #endif |
235 | 237 | ||
236 | #if LCD_DEPTH > 1 | 238 | #if LCD_DEPTH > 1 |
@@ -242,11 +244,6 @@ void tv_start_display(void) | |||
242 | void tv_end_display(void) | 244 | void tv_end_display(void) |
243 | { | 245 | { |
244 | display->update_viewport(); | 246 | display->update_viewport(); |
245 | |||
246 | #ifdef HAVE_LCD_BITMAP | ||
247 | rb->lcd_set_drawmode(drawmode); | ||
248 | #endif | ||
249 | |||
250 | display->set_viewport(NULL); | 247 | display->set_viewport(NULL); |
251 | } | 248 | } |
252 | 249 | ||
@@ -261,29 +258,30 @@ void tv_set_layout(bool show_scrollbar) | |||
261 | row_height = preferences->font->height; | 258 | row_height = preferences->font->height; |
262 | 259 | ||
263 | header.x = 0; | 260 | header.x = 0; |
264 | header.y = 1; | 261 | header.y = 0; |
265 | header.w = vp_info.width; | 262 | header.w = vp_info.width; |
266 | header.h = (preferences->header_mode)? row_height + 1 : 0; | 263 | header.h = (preferences->header_mode)? row_height + 1 : 0; |
267 | 264 | ||
268 | footer.x = 0; | 265 | footer.x = 0; |
269 | footer.w = vp_info.width; | 266 | footer.w = vp_info.width; |
270 | footer.h = (preferences->footer_mode)? row_height + 1 : 0; | 267 | footer.h = (preferences->footer_mode)? row_height + 1 : 0; |
271 | footer.y = vp_info.height - 1 - footer.h; | 268 | footer.y = vp_info.height - 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; | ||
277 | 269 | ||
278 | horizontal_scrollbar.x = drawarea.x; | 270 | horizontal_scrollbar.x = scrollbar_width; |
279 | horizontal_scrollbar.y = footer.y - scrollbar_height; | 271 | horizontal_scrollbar.y = footer.y - scrollbar_height; |
280 | horizontal_scrollbar.w = drawarea.w; | 272 | horizontal_scrollbar.w = vp_info.width - scrollbar_width; |
281 | horizontal_scrollbar.h = scrollbar_height; | 273 | horizontal_scrollbar.h = scrollbar_height; |
282 | 274 | ||
283 | vertical_scrollbar.x = 0; | 275 | vertical_scrollbar.x = 0; |
284 | vertical_scrollbar.y = drawarea.y; | 276 | vertical_scrollbar.y = header.y + header.h; |
285 | vertical_scrollbar.w = scrollbar_width; | 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 | #else | 285 | #else |
288 | (void) show_scrollbar; | 286 | (void) show_scrollbar; |
289 | 287 | ||
@@ -294,19 +292,18 @@ void tv_set_layout(bool show_scrollbar) | |||
294 | bookmark.w = 1; | 292 | bookmark.w = 1; |
295 | bookmark.h = vp_info.height; | 293 | bookmark.h = vp_info.height; |
296 | 294 | ||
297 | drawarea.x = 1; | 295 | vp_text = vp_info; |
298 | drawarea.y = 0; | 296 | vp_text.x += 1; |
299 | drawarea.w = vp_info.width - 1; | 297 | vp_text.width -= 1; |
300 | drawarea.h = vp_info.height; | ||
301 | #endif | 298 | #endif |
302 | 299 | ||
303 | display_columns = drawarea.w / col_width; | 300 | display_columns = vp_text.width / col_width; |
304 | display_rows = drawarea.h / row_height; | 301 | display_rows = vp_text.height / row_height; |
305 | } | 302 | } |
306 | 303 | ||
307 | void tv_get_drawarea_info(int *width, int *cols, int *rows) | 304 | void tv_get_drawarea_info(int *width, int *cols, int *rows) |
308 | { | 305 | { |
309 | *width = drawarea.w; | 306 | *width = vp_text.width; |
310 | *cols = display_columns; | 307 | *cols = display_columns; |
311 | *rows = display_rows; | 308 | *rows = display_rows; |
312 | } | 309 | } |
@@ -314,8 +311,7 @@ void tv_get_drawarea_info(int *width, int *cols, int *rows) | |||
314 | static void tv_change_viewport(void) | 311 | static void tv_change_viewport(void) |
315 | { | 312 | { |
316 | #ifdef HAVE_LCD_BITMAP | 313 | #ifdef HAVE_LCD_BITMAP |
317 | bool show_statusbar = (rb->global_settings->statusbar != STATUSBAR_OFF && | 314 | bool show_statusbar = preferences->statusbar; |
318 | preferences->statusbar); | ||
319 | 315 | ||
320 | if (is_initialized_vp) | 316 | if (is_initialized_vp) |
321 | rb->viewportmanager_theme_undo(SCREEN_MAIN, false); | 317 | rb->viewportmanager_theme_undo(SCREEN_MAIN, false); |