From 4158ba1ff13d623ee32b91efedd4d1d2212543e4 Mon Sep 17 00:00:00 2001 From: Kevin Ferrare Date: Tue, 1 Nov 2005 23:56:03 +0000 Subject: [PATCH] =?UTF-8?q?Changed=20back=20the=20copyright's=20name=20in?= =?UTF-8?q?=20onplay.c=20(silly=20UTF-8,=20sorry=20Bj=C3=83=C2=B6rn=20!=20?= =?UTF-8?q?),=20changed=20the=20internal=20multi-screen=20API=20a=20little?= =?UTF-8?q?=20bit,=20in=20a=20cleaner=20way?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7716 a1c6a512-1295-4272-9138-f99709370657 --- apps/SOURCES | 1 + apps/gui/list.c | 45 +++++++++--------------- apps/gui/textarea.c | 65 +++++++++++++++++++++++++++++++++++ apps/gui/textarea.h | 81 ++++++++++++++++++++++++++++++++++++++++++++ apps/onplay.c | 2 +- apps/screen_access.c | 34 +------------------ apps/screen_access.h | 39 +++++---------------- apps/tree.c | 10 ------ 8 files changed, 173 insertions(+), 104 deletions(-) create mode 100644 apps/gui/textarea.c create mode 100644 apps/gui/textarea.h 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 gui/scrollbar.c gui/splash.c gui/statusbar.c +gui/textarea.c #ifdef HAVE_LCD_CHARCELLS player/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 @@ #include "list.h" #include "scrollbar.h" #include "statusbar.h" +#include "textarea.h" #ifdef HAVE_LCD_CHARCELLS #define SCROLL_LIMIT 1 @@ -70,6 +71,7 @@ void gui_list_set_display(struct gui_list * gui_list, struct screen * display) void gui_list_put_selection_in_screen(struct gui_list * gui_list, bool put_from_end) { + gui_textarea_update_nblines(gui_list->display); int nb_lines=gui_list->display->nb_lines; if(put_from_end) { @@ -103,12 +105,9 @@ void gui_list_draw(struct gui_list * gui_list) /* Adjust the position of icon, cursor, text */ #ifdef HAVE_LCD_BITMAP display->setfont(FONT_UI); - screen_update_nblines(display); + gui_textarea_update_nblines(display); bool draw_scrollbar = (global_settings.scrollbar && display->nb_lines < gui_list->nb_items); - int list_y_start = screen_get_text_y_start(gui_list->display); - int list_y_end = screen_get_text_y_end(gui_list->display); - draw_cursor = !global_settings.invert_cursor; text_pos = 0; /* here it's in pixels */ if(draw_scrollbar) @@ -133,18 +132,10 @@ void gui_list_draw(struct gui_list * gui_list) else text_pos = 1; #endif - /* The drawing part */ -#ifdef HAVE_LCD_BITMAP - /* clear the drawing area */ - display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); - display->fillrect(0, list_y_start, - display->width, list_y_end - list_y_start); - display->set_drawmode(DRMODE_SOLID); - display->stop_scroll(); - display->setmargins(text_pos, list_y_start); -#else - display->clear_display(); + gui_textarea_clear(display); +#ifdef HAVE_LCD_BITMAP + screen_set_xmargin(display, text_pos); #endif for(i = 0;i < display->nb_lines;i++) @@ -197,20 +188,16 @@ void gui_list_draw(struct gui_list * gui_list) /* Draw the scrollbar if needed*/ if(draw_scrollbar) { + int y_start = gui_textarea_get_ystart(display); int scrollbar_y_end = display->char_height * - display->nb_lines + list_y_start; - gui_scrollbar_draw(display, 0, list_y_start, SCROLLBAR_WIDTH-1, - scrollbar_y_end - list_y_start, gui_list->nb_items, + display->nb_lines + y_start; + gui_scrollbar_draw(display, 0, y_start, SCROLLBAR_WIDTH-1, + scrollbar_y_end - y_start, gui_list->nb_items, gui_list->start_item, gui_list->start_item + display->nb_lines, VERTICAL); } - display->update_rect(0, list_y_start, display->width, - list_y_end - list_y_start); -#else -#ifdef SIMULATOR - display->update(); -#endif #endif + gui_textarea_update(display); } void 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) void gui_list_select_previous(struct gui_list * gui_list) { - int item_pos; - int nb_lines = gui_list->display->nb_lines; - if( gui_list->selected_item == 0 ) { + int nb_lines = gui_list->display->nb_lines; if(gui_list->limit_scroll) return; gui_list->selected_item--; @@ -270,6 +255,7 @@ void gui_list_select_previous(struct gui_list * gui_list) } else { + int item_pos; gui_list->selected_item--; item_pos = gui_list->selected_item - gui_list->start_item; 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) void gui_list_del_item(struct gui_list * gui_list) { - int nb_lines = gui_list->display->nb_lines; - if(gui_list->nb_items > 0) { + gui_textarea_update_nblines(gui_list->display); + int nb_lines = gui_list->display->nb_lines; + int dist_selected_from_end = gui_list->nb_items - gui_list->selected_item - 1; 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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 by Kevin Ferrare + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "textarea.h" + +void gui_textarea_clear(struct screen * display) +{ +#ifdef HAVE_LCD_BITMAP + int y_start = gui_textarea_get_ystart(display); + int y_end = gui_textarea_get_yend(display); + + display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); + display->fillrect(0, y_start, display->width, y_end - y_start); + display->set_drawmode(DRMODE_SOLID); + display->stop_scroll(); + screen_set_ymargin(display, y_start); +#else + display->clear_display(); +#endif +} + +#ifdef HAVE_LCD_BITMAP +void gui_textarea_update(struct screen * display) +{ + int y_start = gui_textarea_get_ystart(display); + int y_end = gui_textarea_get_yend(display); + display->update_rect(0, y_start, display->width, y_end - y_start); +} +#endif + +void gui_textarea_update_nblines(struct screen * display) +{ +#ifdef HAVE_LCD_BITMAP + int height=display->height; + if(global_settings.statusbar) + height -= STATUSBAR_HEIGHT; +#ifdef HAS_BUTTONBAR + if(global_settings.buttonbar && display->has_buttonbar) + height -= BUTTONBAR_HEIGHT; +#endif + display->getstringsize("A", &display->char_width, &display->char_height); + display->nb_lines = height / display->char_height; +#else + display->char_width = 1; + display->char_height = 1; + /* default on char based player supported by rb */ + display->nb_lines = MAX_LINES_ON_SCREEN; +#endif +} 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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2005 by Kevin Ferrare + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef _GUI_TEXTAREA_H_ +#define _GUI_TEXTAREA_H_ +#include "screen_access.h" +#include "settings.h" +#include "statusbar.h" + +/* + * Clears the area in the screen in which text can be displayed + * and sets the y margin properly + * - display : the screen structure + */ +extern void gui_textarea_clear(struct screen * display); + +/* + * Updates the area in the screen in which text can be displayed + * - display : the screen structure + */ +#ifdef HAVE_LCD_BITMAP +extern void gui_textarea_update(struct screen * display); +#else +#ifdef SIMULATOR +#define gui_textarea_update(display) \ + (display)->update(); +#else +#define gui_textarea_update(display) +#endif +#endif + +/* + * Compute the number of text lines the display can draw with the current font + * Also updates the char height and width + * - display : the screen structure + */ +extern void gui_textarea_update_nblines(struct screen * display); + +#ifdef HAVE_LCD_BITMAP +/* + * Compute the number of pixels from which text can be displayed + * - display : the screen structure + * Returns the number of pixels + */ +#define gui_textarea_get_ystart(display) \ + ( (global_settings.statusbar)? STATUSBAR_HEIGHT : 0) + +/* + * Compute the number of pixels below which text can't be displayed + * - display : the screen structure + * Returns the number of pixels + */ +#ifdef HAS_BUTTONBAR +#define gui_textarea_get_yend(display) \ + ( (display)->height - ( (global_settings.buttonbar && \ + (display)->has_buttonbar)? \ + BUTTONBAR_HEIGHT : 0) ) +#else +#define gui_textarea_get_yend(display) \ + ( (display)->height ) +#endif /* HAS_BUTTONBAR */ + +#endif /* HAVE_LCD_BITMAP */ + +#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 @@ * \/ \/ \/ \/ \/ * $Id$ * - * Copyright (C) 2002 Bj�n Stenberg + * Copyright (C) 2002 Björn Stenberg * * All files in this archive are subject to the GNU General Public License. * 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) #ifdef HAS_BUTTONBAR screen->has_buttonbar=false; #endif - screen_update_nblines(screen); -} - -/* - * Returns the number of text lines that can be drawn on the given screen - * with it's current font - */ -void screen_update_nblines(struct screen * screen) -{ -#ifdef HAVE_LCD_BITMAP - int height=screen->height; - if(global_settings.statusbar) - height -= STATUSBAR_HEIGHT; -#ifdef HAS_BUTTONBAR - if(global_settings.buttonbar && screen->has_buttonbar) - height -= BUTTONBAR_HEIGHT; -#endif - screen->getstringsize("A", &screen->char_width, &screen->char_height); - screen->nb_lines = height / screen->char_height; -#else - screen->char_width=1; - screen->char_height=1; - /* default on char based player supported by rb */ - screen->nb_lines = MAX_LINES_ON_SCREEN; -#endif - + gui_textarea_update_nblines(screen); } void screen_access_init(void) @@ -179,10 +154,3 @@ void screen_access_init(void) screen_init(&screens[1], SCREEN_REMOTE); #endif } - -void screen_access_update_nb_lines(void) -{ - int i; - for(i=0;ihas_buttonbar=has_btnb; #endif -#ifdef HAVE_LCD_BITMAP /* - * Compute the number of pixels from which text can be displayed + * Sets the x margin in pixels for the given screen * - screen : the screen structure - * Returns the number of pixels + * - xmargin : the number of pixels to the left of the screen */ -#define screen_get_text_y_start(screen) \ - ( (global_settings.statusbar)? STATUSBAR_HEIGHT : 0) +#define screen_set_xmargin(screen, xmargin) \ + (screen)->setmargins(xmargin, (screen)->getymargin()); /* - * Compute the number of pixels below which text can't be displayed + * Sets the y margin in pixels for the given screen * - screen : the screen structure - * Returns the number of pixels + * - xmargin : the number of pixels to the top of the screen */ -#ifdef HAS_BUTTONBAR -#define screen_get_text_y_end(screen) \ - ( (screen)->height - ( (global_settings.buttonbar && \ - (screen)->has_buttonbar)? \ - BUTTONBAR_HEIGHT : 0) ) -#else -#define screen_get_text_y_end(screen) \ - ( (screen)->height ) -#endif /* HAS_BUTTONBAR */ - -#endif /* HAVE_LCD_BITMAP */ +#define screen_set_ymargin(screen, ymargin) \ + (screen)->setmargins((screen)->getxmargin(), ymargin); /* * Initializes the whole screen_access api */ extern void screen_access_init(void); -/* - * Just recalculate the number of text lines that can be displayed - * on each screens in case of poilice change for example - */ -extern void screen_access_update_nb_lines(void); - /* * exported screens array that should be used * by each app that wants to write to access display 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) curr_context=CONTEXT_ID3DB; else curr_context=CONTEXT_TREE; -#ifdef HAVE_LCD_BITMAP - screen_access_update_nb_lines(); -#endif tc.selected_item = 0; tc.dirlevel=0; tc.firstpos=0; @@ -756,7 +753,6 @@ static bool dirbrowse(void) { if (quick_screen(curr_context, BUTTON_F3)) reload_dir = true; - screen_access_update_nb_lines(); restore = true; } break; @@ -888,9 +884,6 @@ static bool dirbrowse(void) else if (!id3db) /* Try reload to catch 'no longer valid' case. */ reload_dir = true; -#endif -#ifdef HAVE_LCD_BITMAP - screen_access_update_nb_lines(); #endif id3db = check_changed_id3mode(id3db); restore = true; @@ -931,9 +924,6 @@ static bool dirbrowse(void) if (restore || reload_dir) { /* restore display */ -#ifdef HAVE_LCD_BITMAP - screen_access_update_nb_lines(); -#endif numentries = update_dir(); if (currdir[1] && (numentries < 0)) { /* not in root and reload failed */