From d452d26885e67aa7d95f50afcbed14c1b837200d Mon Sep 17 00:00:00 2001 From: Kevin Ferrare Date: Fri, 28 Oct 2005 23:52:49 +0000 Subject: 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 --- apps/gui/buttonbar.c | 8 ++--- apps/gui/buttonbar.h | 2 +- apps/gui/icon.c | 2 +- apps/gui/icon.h | 2 +- apps/gui/list.c | 91 ++++++++++++++++++++++++++++++++++------------------ apps/gui/list.h | 35 +++++++++++--------- apps/gui/scrollbar.c | 2 +- apps/gui/scrollbar.h | 2 +- apps/gui/splash.c | 4 +-- apps/gui/splash.h | 2 +- apps/gui/statusbar.c | 15 ++++++--- apps/gui/statusbar.h | 4 ++- apps/screen_access.c | 2 +- apps/tree.c | 2 +- 14 files changed, 106 insertions(+), 67 deletions(-) diff --git a/apps/gui/buttonbar.c b/apps/gui/buttonbar.c index be87b1b81f..45dc056232 100644 --- a/apps/gui/buttonbar.c +++ b/apps/gui/buttonbar.c @@ -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; diff --git a/apps/gui/buttonbar.h b/apps/gui/buttonbar.h index ee7b8d02c4..9a3f9f4d01 100644 --- a/apps/gui/buttonbar.h +++ b/apps/gui/buttonbar.h @@ -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. diff --git a/apps/gui/icon.c b/apps/gui/icon.c index 4d174d3427..073cabc532 100644 --- a/apps/gui/icon.c +++ b/apps/gui/icon.c @@ -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. diff --git a/apps/gui/icon.h b/apps/gui/icon.h index 46faf0972f..119ee3cc47 100644 --- a/apps/gui/icon.h +++ b/apps/gui/icon.h @@ -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. diff --git a/apps/gui/list.c b/apps/gui/list.c index bb3eb7caaa..1a83a65e64 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -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; } @@ -108,7 +104,7 @@ void gui_list_draw(struct gui_list * gui_list) global_settings.show_icons) ; bool draw_cursor; int i; - + /* Adjust the position of icon, cursor, text */ #ifdef HAVE_LCD_BITMAP bool draw_scrollbar = (global_settings.scrollbar && @@ -116,7 +112,7 @@ void gui_list_draw(struct gui_list * gui_list) 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) @@ -131,7 +127,7 @@ void gui_list_draw(struct gui_list * gui_list) } else text_pos += CURSOR_WIDTH; - + if(draw_icons) text_pos += 8; #else @@ -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,12 +154,12 @@ 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; int current_item = gui_list->start_item + i; - + /* When there are less items to display than the * current available space on the screen, we stop*/ if(current_item >= gui_list->nb_items) @@ -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; @@ -332,13 +340,17 @@ void gui_list_del_item(struct gui_list * gui_list) --gui_list->selected_item; } --gui_list->nb_items; - + /* scroll the list if needed */ if( (dist_start_from_end < nb_lines) && (gui_list->start_item != 0) ) --gui_list->start_item; } } +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) -{ - gui_list_get_selected_item_name(&(lists->gui_list[0]), buffer); -} - -int gui_synclist_get_selected_item_position(struct gui_synclist * lists) +int gui_synclist_get_sel_pos(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); diff --git a/apps/gui/list.h b/apps/gui/list.h index fd553f381c..e47f260a1b 100644 --- a/apps/gui/list.h +++ b/apps/gui/list.h @@ -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 diff --git a/apps/gui/scrollbar.c b/apps/gui/scrollbar.c index 9d5717f1a7..da6e18ca91 100644 --- a/apps/gui/scrollbar.c +++ b/apps/gui/scrollbar.c @@ -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. diff --git a/apps/gui/scrollbar.h b/apps/gui/scrollbar.h index 51c08352ba..c8ce694caa 100644 --- a/apps/gui/scrollbar.h +++ b/apps/gui/scrollbar.h @@ -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. diff --git a/apps/gui/splash.c b/apps/gui/splash.c index a3cbb198df..9d1cf75732 100644 --- a/apps/gui/splash.c +++ b/apps/gui/splash.c @@ -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;idisplay; -#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 ); } } diff --git a/apps/gui/statusbar.h b/apps/gui/statusbar.h index 483652d67d..d3acbec8e5 100644 --- a/apps/gui/statusbar.h +++ b/apps/gui/statusbar.h @@ -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; diff --git a/apps/screen_access.c b/apps/screen_access.c index a4f87de80e..e56a75dcce 100644 --- a/apps/screen_access.c +++ b/apps/screen_access.c @@ -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. diff --git a/apps/tree.c b/apps/tree.c index b26221a0fe..33fb92259c 100644 --- a/apps/tree.c +++ b/apps/tree.c @@ -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 */ -- cgit v1.2.3