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
This commit is contained in:
parent
0b19487898
commit
4158ba1ff1
8 changed files with 173 additions and 104 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
65
apps/gui/textarea.c
Normal file
65
apps/gui/textarea.c
Normal file
|
@ -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
|
||||
}
|
81
apps/gui/textarea.h
Normal file
81
apps/gui/textarea.h
Normal file
|
@ -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_ */
|
|
@ -7,7 +7,7 @@
|
|||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2002 Bj<EFBFBD>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.
|
||||
|
|
|
@ -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;i<NB_SCREENS;++i)
|
||||
screen_update_nblines(&screens[i]);
|
||||
}
|
||||
|
|
|
@ -106,13 +106,6 @@ struct screen
|
|||
*/
|
||||
extern void screen_init(struct screen * screen, enum screen_type screen_type);
|
||||
|
||||
/*
|
||||
* Compute the number of text lines the display can draw with the current font
|
||||
* - screen : the screen structure
|
||||
* Returns the number of text lines
|
||||
*/
|
||||
extern void screen_update_nblines(struct screen * screen);
|
||||
|
||||
#ifdef HAS_BUTTONBAR
|
||||
/*
|
||||
* Sets if the given screen has a buttonbar or not
|
||||
|
@ -123,43 +116,27 @@ extern void screen_update_nblines(struct screen * screen);
|
|||
(screen)->has_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
|
||||
|
|
10
apps/tree.c
10
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 */
|
||||
|
|
Loading…
Reference in a new issue