summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Ferrare <kevin@rockbox.org>2005-11-01 23:56:03 +0000
committerKevin Ferrare <kevin@rockbox.org>2005-11-01 23:56:03 +0000
commit4158ba1ff13d623ee32b91efedd4d1d2212543e4 (patch)
treecccb8c9a6080876bfed126604e1057e627368b1a
parent0b19487898b779b60de8f07ff1a52ef515b8d072 (diff)
downloadrockbox-4158ba1ff13d623ee32b91efedd4d1d2212543e4.tar.gz
rockbox-4158ba1ff13d623ee32b91efedd4d1d2212543e4.zip
Changed back the copyright's name in onplay.c (silly UTF-8, sorry Björn ! ), changed the internal multi-screen API a little bit, in a cleaner way
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7716 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/SOURCES1
-rw-r--r--apps/gui/list.c45
-rw-r--r--apps/gui/textarea.c65
-rw-r--r--apps/gui/textarea.h81
-rw-r--r--apps/onplay.c2
-rw-r--r--apps/screen_access.c34
-rw-r--r--apps/screen_access.h39
-rw-r--r--apps/tree.c10
8 files changed, 173 insertions, 104 deletions
diff --git a/apps/SOURCES b/apps/SOURCES
index 07c121f5a3..42633a2ffc 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -39,6 +39,7 @@ gui/list.c
39gui/scrollbar.c 39gui/scrollbar.c
40gui/splash.c 40gui/splash.c
41gui/statusbar.c 41gui/statusbar.c
42gui/textarea.c
42 43
43#ifdef HAVE_LCD_CHARCELLS 44#ifdef HAVE_LCD_CHARCELLS
44player/icons.c 45player/icons.c
diff --git a/apps/gui/list.c b/apps/gui/list.c
index 998e7b9522..d566dabfbb 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -29,6 +29,7 @@
29#include "list.h" 29#include "list.h"
30#include "scrollbar.h" 30#include "scrollbar.h"
31#include "statusbar.h" 31#include "statusbar.h"
32#include "textarea.h"
32 33
33#ifdef HAVE_LCD_CHARCELLS 34#ifdef HAVE_LCD_CHARCELLS
34#define SCROLL_LIMIT 1 35#define SCROLL_LIMIT 1
@@ -70,6 +71,7 @@ void gui_list_set_display(struct gui_list * gui_list, struct screen * display)
70void gui_list_put_selection_in_screen(struct gui_list * gui_list, 71void gui_list_put_selection_in_screen(struct gui_list * gui_list,
71 bool put_from_end) 72 bool put_from_end)
72{ 73{
74 gui_textarea_update_nblines(gui_list->display);
73 int nb_lines=gui_list->display->nb_lines; 75 int nb_lines=gui_list->display->nb_lines;
74 if(put_from_end) 76 if(put_from_end)
75 { 77 {
@@ -103,12 +105,9 @@ void gui_list_draw(struct gui_list * gui_list)
103 /* Adjust the position of icon, cursor, text */ 105 /* Adjust the position of icon, cursor, text */
104#ifdef HAVE_LCD_BITMAP 106#ifdef HAVE_LCD_BITMAP
105 display->setfont(FONT_UI); 107 display->setfont(FONT_UI);
106 screen_update_nblines(display); 108 gui_textarea_update_nblines(display);
107 bool draw_scrollbar = (global_settings.scrollbar && 109 bool draw_scrollbar = (global_settings.scrollbar &&
108 display->nb_lines < gui_list->nb_items); 110 display->nb_lines < gui_list->nb_items);
109 int list_y_start = screen_get_text_y_start(gui_list->display);
110 int list_y_end = screen_get_text_y_end(gui_list->display);
111
112 draw_cursor = !global_settings.invert_cursor; 111 draw_cursor = !global_settings.invert_cursor;
113 text_pos = 0; /* here it's in pixels */ 112 text_pos = 0; /* here it's in pixels */
114 if(draw_scrollbar) 113 if(draw_scrollbar)
@@ -133,18 +132,10 @@ void gui_list_draw(struct gui_list * gui_list)
133 else 132 else
134 text_pos = 1; 133 text_pos = 1;
135#endif 134#endif
136 /* The drawing part */ 135
136 gui_textarea_clear(display);
137#ifdef HAVE_LCD_BITMAP 137#ifdef HAVE_LCD_BITMAP
138 /* clear the drawing area */ 138 screen_set_xmargin(display, text_pos);
139 display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
140 display->fillrect(0, list_y_start,
141 display->width, list_y_end - list_y_start);
142 display->set_drawmode(DRMODE_SOLID);
143
144 display->stop_scroll();
145 display->setmargins(text_pos, list_y_start);
146#else
147 display->clear_display();
148#endif 139#endif
149 140
150 for(i = 0;i < display->nb_lines;i++) 141 for(i = 0;i < display->nb_lines;i++)
@@ -197,20 +188,16 @@ void gui_list_draw(struct gui_list * gui_list)
197 /* Draw the scrollbar if needed*/ 188 /* Draw the scrollbar if needed*/
198 if(draw_scrollbar) 189 if(draw_scrollbar)
199 { 190 {
191 int y_start = gui_textarea_get_ystart(display);
200 int scrollbar_y_end = display->char_height * 192 int scrollbar_y_end = display->char_height *
201 display->nb_lines + list_y_start; 193 display->nb_lines + y_start;
202 gui_scrollbar_draw(display, 0, list_y_start, SCROLLBAR_WIDTH-1, 194 gui_scrollbar_draw(display, 0, y_start, SCROLLBAR_WIDTH-1,
203 scrollbar_y_end - list_y_start, gui_list->nb_items, 195 scrollbar_y_end - y_start, gui_list->nb_items,
204 gui_list->start_item, 196 gui_list->start_item,
205 gui_list->start_item + display->nb_lines, VERTICAL); 197 gui_list->start_item + display->nb_lines, VERTICAL);
206 } 198 }
207 display->update_rect(0, list_y_start, display->width,
208 list_y_end - list_y_start);
209#else
210#ifdef SIMULATOR
211 display->update();
212#endif
213#endif 199#endif
200 gui_textarea_update(display);
214} 201}
215 202
216void gui_list_select_item(struct gui_list * gui_list, int item_number) 203void gui_list_select_item(struct gui_list * gui_list, int item_number)
@@ -251,11 +238,9 @@ void gui_list_select_next(struct gui_list * gui_list)
251 238
252void gui_list_select_previous(struct gui_list * gui_list) 239void gui_list_select_previous(struct gui_list * gui_list)
253{ 240{
254 int item_pos;
255 int nb_lines = gui_list->display->nb_lines;
256
257 if( gui_list->selected_item == 0 ) 241 if( gui_list->selected_item == 0 )
258 { 242 {
243 int nb_lines = gui_list->display->nb_lines;
259 if(gui_list->limit_scroll) 244 if(gui_list->limit_scroll)
260 return; 245 return;
261 gui_list->selected_item--; 246 gui_list->selected_item--;
@@ -270,6 +255,7 @@ void gui_list_select_previous(struct gui_list * gui_list)
270 } 255 }
271 else 256 else
272 { 257 {
258 int item_pos;
273 gui_list->selected_item--; 259 gui_list->selected_item--;
274 item_pos = gui_list->selected_item - gui_list->start_item; 260 item_pos = gui_list->selected_item - gui_list->start_item;
275 if( item_pos < SCROLL_LIMIT-1 && gui_list->start_item > 0 ) 261 if( item_pos < SCROLL_LIMIT-1 && gui_list->start_item > 0 )
@@ -321,10 +307,11 @@ void gui_list_add_item(struct gui_list * gui_list)
321 307
322void gui_list_del_item(struct gui_list * gui_list) 308void gui_list_del_item(struct gui_list * gui_list)
323{ 309{
324 int nb_lines = gui_list->display->nb_lines;
325
326 if(gui_list->nb_items > 0) 310 if(gui_list->nb_items > 0)
327 { 311 {
312 gui_textarea_update_nblines(gui_list->display);
313 int nb_lines = gui_list->display->nb_lines;
314
328 int dist_selected_from_end = gui_list->nb_items 315 int dist_selected_from_end = gui_list->nb_items
329 - gui_list->selected_item - 1; 316 - gui_list->selected_item - 1;
330 int dist_start_from_end = gui_list->nb_items 317 int dist_start_from_end = gui_list->nb_items
diff --git a/apps/gui/textarea.c b/apps/gui/textarea.c
new file mode 100644
index 0000000000..c49602611f
--- /dev/null
+++ b/apps/gui/textarea.c
@@ -0,0 +1,65 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Kevin Ferrare
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "textarea.h"
21
22void gui_textarea_clear(struct screen * display)
23{
24#ifdef HAVE_LCD_BITMAP
25 int y_start = gui_textarea_get_ystart(display);
26 int y_end = gui_textarea_get_yend(display);
27
28 display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
29 display->fillrect(0, y_start, display->width, y_end - y_start);
30 display->set_drawmode(DRMODE_SOLID);
31 display->stop_scroll();
32 screen_set_ymargin(display, y_start);
33#else
34 display->clear_display();
35#endif
36}
37
38#ifdef HAVE_LCD_BITMAP
39void gui_textarea_update(struct screen * display)
40{
41 int y_start = gui_textarea_get_ystart(display);
42 int y_end = gui_textarea_get_yend(display);
43 display->update_rect(0, y_start, display->width, y_end - y_start);
44}
45#endif
46
47void gui_textarea_update_nblines(struct screen * display)
48{
49#ifdef HAVE_LCD_BITMAP
50 int height=display->height;
51 if(global_settings.statusbar)
52 height -= STATUSBAR_HEIGHT;
53#ifdef HAS_BUTTONBAR
54 if(global_settings.buttonbar && display->has_buttonbar)
55 height -= BUTTONBAR_HEIGHT;
56#endif
57 display->getstringsize("A", &display->char_width, &display->char_height);
58 display->nb_lines = height / display->char_height;
59#else
60 display->char_width = 1;
61 display->char_height = 1;
62 /* default on char based player supported by rb */
63 display->nb_lines = MAX_LINES_ON_SCREEN;
64#endif
65}
diff --git a/apps/gui/textarea.h b/apps/gui/textarea.h
new file mode 100644
index 0000000000..5249aed7a5
--- /dev/null
+++ b/apps/gui/textarea.h
@@ -0,0 +1,81 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 by Kevin Ferrare
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef _GUI_TEXTAREA_H_
21#define _GUI_TEXTAREA_H_
22#include "screen_access.h"
23#include "settings.h"
24#include "statusbar.h"
25
26/*
27 * Clears the area in the screen in which text can be displayed
28 * and sets the y margin properly
29 * - display : the screen structure
30 */
31extern void gui_textarea_clear(struct screen * display);
32
33/*
34 * Updates the area in the screen in which text can be displayed
35 * - display : the screen structure
36 */
37#ifdef HAVE_LCD_BITMAP
38extern void gui_textarea_update(struct screen * display);
39#else
40#ifdef SIMULATOR
41#define gui_textarea_update(display) \
42 (display)->update();
43#else
44#define gui_textarea_update(display)
45#endif
46#endif
47
48/*
49 * Compute the number of text lines the display can draw with the current font
50 * Also updates the char height and width
51 * - display : the screen structure
52 */
53extern void gui_textarea_update_nblines(struct screen * display);
54
55#ifdef HAVE_LCD_BITMAP
56/*
57 * Compute the number of pixels from which text can be displayed
58 * - display : the screen structure
59 * Returns the number of pixels
60 */
61#define gui_textarea_get_ystart(display) \
62 ( (global_settings.statusbar)? STATUSBAR_HEIGHT : 0)
63
64/*
65 * Compute the number of pixels below which text can't be displayed
66 * - display : the screen structure
67 * Returns the number of pixels
68 */
69#ifdef HAS_BUTTONBAR
70#define gui_textarea_get_yend(display) \
71 ( (display)->height - ( (global_settings.buttonbar && \
72 (display)->has_buttonbar)? \
73 BUTTONBAR_HEIGHT : 0) )
74#else
75#define gui_textarea_get_yend(display) \
76 ( (display)->height )
77#endif /* HAS_BUTTONBAR */
78
79#endif /* HAVE_LCD_BITMAP */
80
81#endif /* _GUI_TEXTAREA_H_ */
diff --git a/apps/onplay.c b/apps/onplay.c
index df23c42443..fc59e94ff4 100644
--- a/apps/onplay.c
+++ b/apps/onplay.c
@@ -7,7 +7,7 @@
7 * \/ \/ \/ \/ \/ 7 * \/ \/ \/ \/ \/
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2002 Bjn Stenberg 10 * Copyright (C) 2002 Björn Stenberg
11 * 11 *
12 * All files in this archive are subject to the GNU General Public License. 12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement. 13 * See the file COPYING in the source tree root for full license agreement.
diff --git a/apps/screen_access.c b/apps/screen_access.c
index 064464d59c..343aeddec8 100644
--- a/apps/screen_access.c
+++ b/apps/screen_access.c
@@ -144,32 +144,7 @@ void screen_init(struct screen * screen, enum screen_type screen_type)
144#ifdef HAS_BUTTONBAR 144#ifdef HAS_BUTTONBAR
145 screen->has_buttonbar=false; 145 screen->has_buttonbar=false;
146#endif 146#endif
147 screen_update_nblines(screen); 147 gui_textarea_update_nblines(screen);
148}
149
150/*
151 * Returns the number of text lines that can be drawn on the given screen
152 * with it's current font
153 */
154void screen_update_nblines(struct screen * screen)
155{
156#ifdef HAVE_LCD_BITMAP
157 int height=screen->height;
158 if(global_settings.statusbar)
159 height -= STATUSBAR_HEIGHT;
160#ifdef HAS_BUTTONBAR
161 if(global_settings.buttonbar && screen->has_buttonbar)
162 height -= BUTTONBAR_HEIGHT;
163#endif
164 screen->getstringsize("A", &screen->char_width, &screen->char_height);
165 screen->nb_lines = height / screen->char_height;
166#else
167 screen->char_width=1;
168 screen->char_height=1;
169 /* default on char based player supported by rb */
170 screen->nb_lines = MAX_LINES_ON_SCREEN;
171#endif
172
173} 148}
174 149
175void screen_access_init(void) 150void screen_access_init(void)
@@ -179,10 +154,3 @@ void screen_access_init(void)
179 screen_init(&screens[1], SCREEN_REMOTE); 154 screen_init(&screens[1], SCREEN_REMOTE);
180#endif 155#endif
181} 156}
182
183void screen_access_update_nb_lines(void)
184{
185 int i;
186 for(i=0;i<NB_SCREENS;++i)
187 screen_update_nblines(&screens[i]);
188}
diff --git a/apps/screen_access.h b/apps/screen_access.h
index 0a5452c580..a91d2915fa 100644
--- a/apps/screen_access.h
+++ b/apps/screen_access.h
@@ -106,13 +106,6 @@ struct screen
106 */ 106 */
107extern void screen_init(struct screen * screen, enum screen_type screen_type); 107extern void screen_init(struct screen * screen, enum screen_type screen_type);
108 108
109/*
110 * Compute the number of text lines the display can draw with the current font
111 * - screen : the screen structure
112 * Returns the number of text lines
113 */
114extern void screen_update_nblines(struct screen * screen);
115
116#ifdef HAS_BUTTONBAR 109#ifdef HAS_BUTTONBAR
117/* 110/*
118 * Sets if the given screen has a buttonbar or not 111 * Sets if the given screen has a buttonbar or not
@@ -123,31 +116,21 @@ extern void screen_update_nblines(struct screen * screen);
123 (screen)->has_buttonbar=has_btnb; 116 (screen)->has_buttonbar=has_btnb;
124#endif 117#endif
125 118
126#ifdef HAVE_LCD_BITMAP
127/* 119/*
128 * Compute the number of pixels from which text can be displayed 120 * Sets the x margin in pixels for the given screen
129 * - screen : the screen structure 121 * - screen : the screen structure
130 * Returns the number of pixels 122 * - xmargin : the number of pixels to the left of the screen
131 */ 123 */
132#define screen_get_text_y_start(screen) \ 124#define screen_set_xmargin(screen, xmargin) \
133 ( (global_settings.statusbar)? STATUSBAR_HEIGHT : 0) 125 (screen)->setmargins(xmargin, (screen)->getymargin());
134 126
135/* 127/*
136 * Compute the number of pixels below which text can't be displayed 128 * Sets the y margin in pixels for the given screen
137 * - screen : the screen structure 129 * - screen : the screen structure
138 * Returns the number of pixels 130 * - xmargin : the number of pixels to the top of the screen
139 */ 131 */
140#ifdef HAS_BUTTONBAR 132#define screen_set_ymargin(screen, ymargin) \
141#define screen_get_text_y_end(screen) \ 133 (screen)->setmargins((screen)->getxmargin(), ymargin);
142 ( (screen)->height - ( (global_settings.buttonbar && \
143 (screen)->has_buttonbar)? \
144 BUTTONBAR_HEIGHT : 0) )
145#else
146#define screen_get_text_y_end(screen) \
147 ( (screen)->height )
148#endif /* HAS_BUTTONBAR */
149
150#endif /* HAVE_LCD_BITMAP */
151 134
152/* 135/*
153 * Initializes the whole screen_access api 136 * Initializes the whole screen_access api
@@ -155,12 +138,6 @@ extern void screen_update_nblines(struct screen * screen);
155extern void screen_access_init(void); 138extern void screen_access_init(void);
156 139
157/* 140/*
158 * Just recalculate the number of text lines that can be displayed
159 * on each screens in case of poilice change for example
160 */
161extern void screen_access_update_nb_lines(void);
162
163/*
164 * exported screens array that should be used 141 * exported screens array that should be used
165 * by each app that wants to write to access display 142 * by each app that wants to write to access display
166 */ 143 */
diff --git a/apps/tree.c b/apps/tree.c
index cd3d2717c7..d637e5c686 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -511,9 +511,6 @@ static bool dirbrowse(void)
511 curr_context=CONTEXT_ID3DB; 511 curr_context=CONTEXT_ID3DB;
512 else 512 else
513 curr_context=CONTEXT_TREE; 513 curr_context=CONTEXT_TREE;
514#ifdef HAVE_LCD_BITMAP
515 screen_access_update_nb_lines();
516#endif
517 tc.selected_item = 0; 514 tc.selected_item = 0;
518 tc.dirlevel=0; 515 tc.dirlevel=0;
519 tc.firstpos=0; 516 tc.firstpos=0;
@@ -756,7 +753,6 @@ static bool dirbrowse(void)
756 { 753 {
757 if (quick_screen(curr_context, BUTTON_F3)) 754 if (quick_screen(curr_context, BUTTON_F3))
758 reload_dir = true; 755 reload_dir = true;
759 screen_access_update_nb_lines();
760 restore = true; 756 restore = true;
761 } 757 }
762 break; 758 break;
@@ -889,9 +885,6 @@ static bool dirbrowse(void)
889 if (!id3db) /* Try reload to catch 'no longer valid' case. */ 885 if (!id3db) /* Try reload to catch 'no longer valid' case. */
890 reload_dir = true; 886 reload_dir = true;
891#endif 887#endif
892#ifdef HAVE_LCD_BITMAP
893 screen_access_update_nb_lines();
894#endif
895 id3db = check_changed_id3mode(id3db); 888 id3db = check_changed_id3mode(id3db);
896 restore = true; 889 restore = true;
897 start_wps=false; 890 start_wps=false;
@@ -931,9 +924,6 @@ static bool dirbrowse(void)
931 924
932 if (restore || reload_dir) { 925 if (restore || reload_dir) {
933 /* restore display */ 926 /* restore display */
934#ifdef HAVE_LCD_BITMAP
935 screen_access_update_nb_lines();
936#endif
937 numentries = update_dir(); 927 numentries = update_dir();
938 if (currdir[1] && (numentries < 0)) 928 if (currdir[1] && (numentries < 0))
939 { /* not in root and reload failed */ 929 { /* not in root and reload failed */