diff options
Diffstat (limited to 'apps/plugins/text_viewer/tv_window.c')
-rw-r--r-- | apps/plugins/text_viewer/tv_window.c | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/apps/plugins/text_viewer/tv_window.c b/apps/plugins/text_viewer/tv_window.c index bf27e2cfd5..72faf23565 100644 --- a/apps/plugins/text_viewer/tv_window.c +++ b/apps/plugins/text_viewer/tv_window.c | |||
@@ -27,7 +27,8 @@ | |||
27 | #include "tv_text_reader.h" | 27 | #include "tv_text_reader.h" |
28 | #include "tv_window.h" | 28 | #include "tv_window.h" |
29 | 29 | ||
30 | #define TV_SCROLLBAR_WIDTH rb->global_settings->scrollbar_width | 30 | #define TV_SCROLLBAR_WIDTH rb->global_settings->scrollbar_width |
31 | #define TV_SCROLLBAR_HEIGHT 4 | ||
31 | 32 | ||
32 | #ifndef HAVE_LCD_BITMAP | 33 | #ifndef HAVE_LCD_BITMAP |
33 | #define TV_BOOKMARK_ICON 0xe101 | 34 | #define TV_BOOKMARK_ICON 0xe101 |
@@ -36,7 +37,7 @@ | |||
36 | #ifdef HAVE_LCD_BITMAP | 37 | #ifdef HAVE_LCD_BITMAP |
37 | static int header_height; | 38 | static int header_height; |
38 | static int footer_height; | 39 | static int footer_height; |
39 | static bool need_scrollbar = false; | 40 | static bool need_vertical_scrollbar = false; |
40 | #endif | 41 | #endif |
41 | 42 | ||
42 | static int start_width; | 43 | static int start_width; |
@@ -123,27 +124,41 @@ static void tv_show_scrollbar(off_t cur_pos, int size) | |||
123 | int items; | 124 | int items; |
124 | int min_shown; | 125 | int min_shown; |
125 | int max_shown; | 126 | int max_shown; |
126 | int sb_begin_y; | 127 | int sb_width; |
127 | int sb_height; | 128 | int sb_height; |
128 | 129 | ||
129 | if (!need_scrollbar) | 130 | sb_height = LCD_HEIGHT - header_height - footer_height; |
130 | return; | 131 | if (prefs->horizontal_scrollbar) |
131 | 132 | { | |
132 | items = (int) tv_get_total_text_size(); | 133 | items = prefs->windows * window_columns; |
133 | min_shown = (int) cur_pos; | 134 | min_shown = cur_window * window_columns + cur_column; |
134 | 135 | max_shown = min_shown + window_columns; | |
135 | max_shown = min_shown + size; | 136 | sb_width = (need_vertical_scrollbar)? TV_SCROLLBAR_WIDTH : 0; |
137 | sb_height -= TV_SCROLLBAR_HEIGHT; | ||
138 | |||
139 | rb->gui_scrollbar_draw(rb->screens[SCREEN_MAIN], | ||
140 | sb_width, | ||
141 | LCD_HEIGHT - footer_height - TV_SCROLLBAR_HEIGHT, | ||
142 | LCD_WIDTH - sb_width, TV_SCROLLBAR_HEIGHT, | ||
143 | items, min_shown, max_shown, HORIZONTAL); | ||
144 | } | ||
136 | 145 | ||
137 | sb_begin_y = header_height; | 146 | if (need_vertical_scrollbar) |
138 | sb_height = LCD_HEIGHT - header_height - footer_height; | 147 | { |
148 | items = (int) tv_get_total_text_size(); | ||
149 | min_shown = (int) cur_pos; | ||
150 | max_shown = min_shown + size; | ||
139 | 151 | ||
140 | rb->gui_scrollbar_draw(rb->screens[SCREEN_MAIN],0, sb_begin_y, | 152 | rb->gui_scrollbar_draw(rb->screens[SCREEN_MAIN], 0, header_height, |
141 | TV_SCROLLBAR_WIDTH-1, sb_height, | 153 | TV_SCROLLBAR_WIDTH-1, sb_height, |
142 | items, min_shown, max_shown, VERTICAL); | 154 | items, min_shown, max_shown, VERTICAL); |
155 | } | ||
143 | } | 156 | } |
144 | 157 | ||
145 | static int tv_calc_display_lines(void) | 158 | static int tv_calc_display_lines(void) |
146 | { | 159 | { |
160 | int scrollbar_height = (prefs->horizontal_scrollbar)? TV_SCROLLBAR_HEIGHT : 0; | ||
161 | |||
147 | header_height = (prefs->header_mode == HD_SBAR || prefs->header_mode == HD_BOTH)? | 162 | header_height = (prefs->header_mode == HD_SBAR || prefs->header_mode == HD_BOTH)? |
148 | STATUSBAR_HEIGHT : 0; | 163 | STATUSBAR_HEIGHT : 0; |
149 | 164 | ||
@@ -160,7 +175,7 @@ static int tv_calc_display_lines(void) | |||
160 | if (prefs->footer_mode == FT_PAGE || prefs->footer_mode == FT_BOTH) | 175 | if (prefs->footer_mode == FT_PAGE || prefs->footer_mode == FT_BOTH) |
161 | footer_height += prefs->font->height; | 176 | footer_height += prefs->font->height; |
162 | 177 | ||
163 | return (LCD_HEIGHT - header_height - footer_height) / prefs->font->height; | 178 | return (LCD_HEIGHT - header_height - footer_height - scrollbar_height) / prefs->font->height; |
164 | } | 179 | } |
165 | #endif | 180 | #endif |
166 | 181 | ||
@@ -314,13 +329,13 @@ static void tv_change_preferences(const struct tv_preferences *oldp) | |||
314 | 329 | ||
315 | window_width = LCD_WIDTH; | 330 | window_width = LCD_WIDTH; |
316 | #ifdef HAVE_LCD_BITMAP | 331 | #ifdef HAVE_LCD_BITMAP |
317 | need_scrollbar = false; | 332 | need_vertical_scrollbar = false; |
318 | start_width = 0; | 333 | start_width = 0; |
319 | tv_seek_top(); | 334 | tv_seek_top(); |
320 | tv_set_read_conditions(prefs->windows, window_width); | 335 | tv_set_read_conditions(prefs->windows, window_width); |
321 | if (tv_traverse_lines() && prefs->scrollbar_mode) | 336 | if (tv_traverse_lines() && prefs->vertical_scrollbar) |
322 | { | 337 | { |
323 | need_scrollbar = true; | 338 | need_vertical_scrollbar = true; |
324 | start_width = TV_SCROLLBAR_WIDTH; | 339 | start_width = TV_SCROLLBAR_WIDTH; |
325 | } | 340 | } |
326 | tv_seek_top(); | 341 | tv_seek_top(); |