Changed some fn names, also corrected a bug with fonts and made the filetree work like the original one (stop on reaching list limits when pressing button)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7679 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Kevin Ferrare 2005-10-28 23:52:49 +00:00
parent 6ff8463216
commit d452d26885
14 changed files with 106 additions and 67 deletions

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) Linus Nielsen Feltzing (2002), Kévin FERRARE (2005)
* Copyright (C) Linus Nielsen Feltzing (2002), Kevin FERRARE (2005)
*
* 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.
@ -91,7 +91,7 @@ void gui_buttonbar_set(struct gui_buttonbar * buttonbar,
void gui_buttonbar_unset(struct gui_buttonbar * buttonbar)
{
int i;
for(i = 0;i < BUTTONBAR_MAX_BUTTONS;++i)
for(i = 0;i < BUTTONBAR_MAX_BUTTONS;i++)
buttonbar->caption[i][0] = 0;
}
@ -105,7 +105,7 @@ void gui_buttonbar_draw(struct gui_buttonbar * buttonbar)
display->width, BUTTONBAR_HEIGHT);
display->set_drawmode(DRMODE_SOLID);
for(i = 0;i < BUTTONBAR_MAX_BUTTONS;++i)
for(i = 0;i < BUTTONBAR_MAX_BUTTONS;i++)
gui_buttonbar_draw_button(buttonbar, i);
display->update_rect(0, display->height - BUTTONBAR_HEIGHT,
display->width, BUTTONBAR_HEIGHT);
@ -117,7 +117,7 @@ bool gui_buttonbar_isset(struct gui_buttonbar * buttonbar)
if(!global_settings.buttonbar)
return(false);
int i;
for(i = 0;i < BUTTONBAR_MAX_BUTTONS;++i)
for(i = 0;i < BUTTONBAR_MAX_BUTTONS;i++)
if(buttonbar->caption[i] != 0)
return true;
return false;

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2005 by Kévin FERRARE
* 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.

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) Robert E. Hak(2002), Kévin FERRARE (2005)
* Copyright (C) Robert E. Hak(2002), Kevin FERRARE (2005)
*
* 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.

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2005 by Kévin FERRARE
* 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.

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2005 by Kévin FERRARE
* 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.
@ -48,9 +48,10 @@ void gui_list_init(struct gui_list * gui_list,
gui_list_set_nb_items(gui_list, 0);
gui_list->selected_item = 0;
gui_list->start_item = 0;
gui_list->limit_scroll=false;
}
void gui_list_set_nb_items(struct gui_list * gui_list, int nb_items)
inline void gui_list_set_nb_items(struct gui_list * gui_list, int nb_items)
{
gui_list->nb_items = nb_items;
}
@ -88,12 +89,7 @@ void gui_list_put_selection_in_screen(struct gui_list * gui_list,
gui_list->start_item = 0;
}
void gui_list_get_selected_item_name(struct gui_list * gui_list, char *buffer)
{
gui_list->callback_get_item_name(gui_list->selected_item, buffer);
}
int gui_list_get_selected_item_position(struct gui_list * gui_list)
inline int gui_list_get_sel_pos(struct gui_list * gui_list)
{
return gui_list->selected_item;
}
@ -149,8 +145,7 @@ void gui_list_draw(struct gui_list * gui_list)
display->width, list_y_end - list_y_start);
display->set_drawmode(DRMODE_SOLID);
/* FIXME: should not be handled here, but rather in the
* code that changes fonts */
display->setfont(FONT_UI);
screen_update_nblines(display);
display->stop_scroll();
@ -159,7 +154,7 @@ void gui_list_draw(struct gui_list * gui_list)
display->clear_display();
#endif
for(i = 0;i < display->nb_lines;++i)
for(i = 0;i < display->nb_lines;i++)
{
char entry_buffer[MAX_PATH];
char * entry_name;
@ -234,18 +229,20 @@ void gui_list_select_next(struct gui_list * gui_list)
{
int item_pos;
int end_item;
int nb_lines = gui_list->display->nb_lines;
++gui_list->selected_item;
if( gui_list->selected_item >= gui_list->nb_items )
if( gui_list->selected_item == gui_list->nb_items-1 )
{
if(gui_list->limit_scroll)
return;
++gui_list->selected_item;
/* we have already reached the bottom of the list */
gui_list->selected_item = 0;
gui_list->start_item = 0;
}
else
{
int nb_lines = gui_list->display->nb_lines;
++gui_list->selected_item;
item_pos = gui_list->selected_item - gui_list->start_item;
end_item = gui_list->start_item + nb_lines;
/* we start scrolling vertically when reaching the line
@ -261,9 +258,11 @@ void gui_list_select_previous(struct gui_list * gui_list)
int item_pos;
int nb_lines = gui_list->display->nb_lines;
--gui_list->selected_item;
if( gui_list->selected_item < 0 )
if( gui_list->selected_item == 0 )
{
if(gui_list->limit_scroll)
return;
--gui_list->selected_item;
/* we have aleady reached the top of the list */
int start;
gui_list->selected_item = gui_list->nb_items-1;
@ -275,6 +274,7 @@ void gui_list_select_previous(struct gui_list * gui_list)
}
else
{
--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 )
--gui_list->start_item;
@ -284,7 +284,11 @@ void gui_list_select_previous(struct gui_list * gui_list)
void gui_list_select_next_page(struct gui_list * gui_list, int nb_lines)
{
if(gui_list->selected_item == gui_list->nb_items-1)
{
if(gui_list->limit_scroll)
return;
gui_list->selected_item = 0;
}
else
{
gui_list->selected_item += nb_lines;
@ -297,7 +301,11 @@ void gui_list_select_next_page(struct gui_list * gui_list, int nb_lines)
void gui_list_select_previous_page(struct gui_list * gui_list, int nb_lines)
{
if(gui_list->selected_item == 0)
{
if(gui_list->limit_scroll)
return;
gui_list->selected_item = gui_list->nb_items - 1;
}
else
{
gui_list->selected_item -= nb_lines;
@ -339,6 +347,10 @@ void gui_list_del_item(struct gui_list * gui_list)
}
}
inline void gui_list_limit_scroll(struct gui_list * gui_list, bool scroll)
{
gui_list->limit_scroll=scroll;
}
/*
* Synchronized lists stuffs
*/
@ -366,15 +378,9 @@ void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items)
}
}
void gui_synclist_get_selected_item_name(struct gui_synclist * lists,
char *buffer)
int gui_synclist_get_sel_pos(struct gui_synclist * lists)
{
gui_list_get_selected_item_name(&(lists->gui_list[0]), buffer);
}
int gui_synclist_get_selected_item_position(struct gui_synclist * lists)
{
return gui_list_get_selected_item_position(&(lists->gui_list[0]));
return gui_list_get_sel_pos(&(lists->gui_list[0]));
}
void gui_synclist_draw(struct gui_synclist * lists)
@ -437,14 +443,26 @@ void gui_synclist_del_item(struct gui_synclist * lists)
gui_list_del_item(&(lists->gui_list[i]));
}
void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll)
{
int i;
for(i = 0;i < NB_SCREENS;i++)
gui_list_limit_scroll(&(lists->gui_list[i]), scroll);
}
bool gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
{
gui_synclist_limit_scroll(lists, true);
switch(button)
{
case LIST_PREV:
case LIST_PREV | BUTTON_REPEAT:
#ifdef LIST_RC_PREV
case LIST_RC_PREV:
#endif
gui_synclist_limit_scroll(lists, false);
case LIST_PREV | BUTTON_REPEAT:
#ifdef LIST_RC_PREV
case LIST_RC_PREV | BUTTON_REPEAT:
#endif
gui_synclist_select_previous(lists);
@ -452,9 +470,14 @@ bool gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
return true;
case LIST_NEXT:
case LIST_NEXT | BUTTON_REPEAT:
#ifdef LIST_RC_NEXT
case LIST_RC_NEXT:
#endif
gui_synclist_limit_scroll(lists, false);
case LIST_NEXT | BUTTON_REPEAT:
#ifdef LIST_RC_NEXT
case LIST_RC_NEXT | BUTTON_REPEAT:
#endif
gui_synclist_select_next(lists);
@ -465,6 +488,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
* have the same number of lines*/
#ifdef LIST_PGUP
case LIST_PGUP:
gui_synclist_limit_scroll(lists, false);
case LIST_PGUP | BUTTON_REPEAT:
gui_synclist_select_previous_page(lists, SCREEN_MAIN);
gui_synclist_draw(lists);
@ -473,6 +497,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
#ifdef LIST_RC_PGUP
case LIST_RC_PGUP:
gui_synclist_limit_scroll(lists, false);
case LIST_RC_PGUP | BUTTON_REPEAT:
gui_synclist_select_previous_page(lists, SCREEN_REMOTE);
gui_synclist_draw(lists);
@ -481,6 +506,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
#ifdef LIST_PGDN
case LIST_PGDN:
gui_synclist_limit_scroll(lists, false);
case LIST_PGDN | BUTTON_REPEAT:
gui_synclist_select_next_page(lists, SCREEN_MAIN);
gui_synclist_draw(lists);
@ -489,6 +515,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, unsigned button)
#ifdef LIST_RC_PGDN
case LIST_RC_PGDN:
gui_synclist_limit_scroll(lists, false);
case LIST_RC_PGDN | BUTTON_REPEAT:
gui_synclist_select_next_page(lists, SCREEN_REMOTE);
gui_synclist_draw(lists);

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2005 by Kévin FERRARE
* 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.
@ -75,6 +75,9 @@ struct gui_list
struct screen * display;
int line_scroll_limit;
/* defines wether the list should stop when reaching the top/bottom
* or should continue (by going to bottom/top) */
bool limit_scroll;
};
/*
@ -91,12 +94,12 @@ extern void gui_list_init(struct gui_list * gui_list,
);
/*
* Sets the numburs of items the list can currently display
* Sets the numbers of items the list can currently display
* note that the list's context like the currently pointed item is resetted
* - gui_list : the list structure to initialize
* - nb_items : the numbers of items you want
*/
extern void gui_list_set_nb_items(struct gui_list * gui_list, int nb_items);
extern inline void gui_list_set_nb_items(struct gui_list * gui_list, int nb_items);
/*
* Puts the selection in the screen
@ -117,20 +120,12 @@ extern void gui_list_put_selection_in_screen(struct gui_list * gui_list,
extern void gui_list_set_display(struct gui_list * gui_list,
struct screen * display);
/*
* Gives the name of the selected object
* - gui_list : the list structure
* - buffer : a buffer which is filled with the name
*/
extern void gui_list_get_selected_item_name(struct gui_list * gui_list,
char *buffer);
/*
* Gives the position of the selected item
* - gui_list : the list structure
* Returns the position
*/
extern int gui_list_get_selected_item_position(struct gui_list * gui_list);
extern inline int gui_list_get_sel_pos(struct gui_list * gui_list);
/*
* Selects an item in the list
@ -187,6 +182,15 @@ extern void gui_list_add_item(struct gui_list * gui_list);
*/
extern void gui_list_del_item(struct gui_list * gui_list);
/*
* Tells the list wether it should stop when reaching the top/bottom
* or should continue (by going to bottom/top)
* - gui_list : the list structure
* - scroll :
* - true : stops when reaching top/bottom
* - false : continues to go to bottom/top when reaching top/bottom
*/
extern inline void gui_list_limit_scroll(struct gui_list * gui_list, bool scroll);
/*
* This part handles as many lists as there are connected screens
@ -207,9 +211,8 @@ extern void gui_synclist_init(struct gui_synclist * lists,
char * (*callback_get_item_name)(int selected_item, char *buffer)
);
extern void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items);
extern void gui_synclist_get_selected_item_name(struct gui_synclist * lists,
char *buffer);
extern int gui_synclist_get_selected_item_position(struct gui_synclist * lists);
extern int gui_synclist_get_sel_pos(struct gui_synclist * lists);
extern void gui_synclist_draw(struct gui_synclist * lists);
extern void gui_synclist_select_item(struct gui_synclist * lists,
int item_number);
@ -221,6 +224,8 @@ extern void gui_synclist_select_previous_page(struct gui_synclist * lists,
enum screen_type screen);
extern void gui_synclist_add_item(struct gui_synclist * lists);
extern void gui_synclist_del_item(struct gui_synclist * lists);
extern void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll);
/*
* Do the action implied by the given button,
* returns true if something has been done, false otherwise

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) Markus Braun (2002), Kévin FERRARE (2005)
* Copyright (C) Markus Braun (2002), Kevin FERRARE (2005)
*
* 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.

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2005 Kévin FERRARE
* Copyright (C) 2005 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.

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) Daniel Stenberg (2002), Kévin FERRARE (2005)
* Copyright (C) Daniel Stenberg (2002), Kevin FERRARE (2005)
*
* 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.
@ -207,7 +207,7 @@ void gui_syncsplash(int ticks, bool center, const char *fmt, ...)
va_list ap;
int i;
va_start( ap, fmt );
for(i=0;i<NB_SCREENS;++i)
for(i=0;i<NB_SCREENS;i++)
internal_splash(&(screens[i]), center, fmt, ap);
va_end( ap );

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2005 by Kévin FERRARE
* 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.

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) Robert E. Hak (2002), Linus Nielsen Feltzing (2002), Kévin FERRARE (2005)
* Copyright (C) Robert E. Hak (2002), Linus Nielsen Feltzing (2002), Kevin FERRARE (2005)
*
* 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.
@ -111,9 +111,11 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
struct screen * display = bar->display;
#ifdef HAVE_LCD_BITMAP
#ifdef HAVE_RTC
struct tm* tm; /* For Time */
#else
#endif
#ifndef HAVE_LCD_BITMAP
(void)force_redraw; /* players always "redraw" */
#endif
@ -123,9 +125,12 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
bar->info.battery_safe = battery_level_safe();
#ifdef HAVE_LCD_BITMAP
#ifdef HAVE_RTC
tm = get_time();
bar->info.hour = tm->tm_hour;
bar->info.minute = tm->tm_min;
#endif
bar->info.shuffle = global_settings.playlist_shuffle;
#if CONFIG_KEYPAD == IRIVER_H100_PAD
bar->info.keylock = button_hold();
@ -495,7 +500,7 @@ void gui_statusbar_time(struct screen * display, int hour, int minute)
void gui_syncstatusbar_init(struct gui_syncstatusbar * bars)
{
int i;
for(i = 0;i < NB_SCREENS;++i) {
for(i = 0;i < NB_SCREENS;i++) {
gui_statusbar_init( &(bars->statusbars[i]) );
gui_statusbar_set_screen( &(bars->statusbars[i]), &(screens[i]) );
}
@ -505,7 +510,7 @@ void gui_syncstatusbar_draw(struct gui_syncstatusbar * bars,
bool force_redraw)
{
int i;
for(i = 0;i < NB_SCREENS;++i) {
for(i = 0;i < NB_SCREENS;i++) {
gui_statusbar_draw( &(bars->statusbars[i]), force_redraw );
}
}

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2005 by Kévin FERRARE
* 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.
@ -26,8 +26,10 @@
struct status_info {
int battlevel;
int volume;
#ifdef HAVE_RTC
int hour;
int minute;
#endif
int playmode;
int repeat;
bool inserted;

View file

@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2005 by Kévin FERRARE
* 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.

View file

@ -939,7 +939,7 @@ static bool dirbrowse(void)
reload_dir = false;
}
if(need_update) {
tc.selected_item = gui_synclist_get_selected_item_position(&tree_lists);
tc.selected_item = gui_synclist_get_sel_pos(&tree_lists);
need_update=false;
if ( numentries > 0 ) {
/* Voice the file if changed */