1
0
Fork 0
forked from len0rd/rockbox

Make private functions static. Remove some functions from the plugin api as they weren't used in any plugins and could then be declared static.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12462 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nils Wallménius 2007-02-23 21:52:45 +00:00
parent a2ef94ed87
commit 7fdee10a70
4 changed files with 105 additions and 167 deletions

View file

@ -48,7 +48,20 @@ static bool offset_out_of_view = false;
#define SHOW_LIST_TITLE ((gui_list->title != NULL) && \ #define SHOW_LIST_TITLE ((gui_list->title != NULL) && \
(gui_list->display->nb_lines > 1)) (gui_list->display->nb_lines > 1))
void gui_list_init(struct gui_list * gui_list, static void gui_list_put_selection_in_screen(struct gui_list * gui_list,
bool put_from_end);
/*
* Initializes a scrolling list
* - gui_list : the list structure to initialize
* - callback_get_item_icon : pointer to a function that associates an icon
* to a given item number
* - callback_get_item_name : pointer to a function that associates a label
* to a given item number
* - data : extra data passed to the list callback
*/
static void gui_list_init(struct gui_list * gui_list,
list_get_name callback_get_item_name, list_get_name callback_get_item_name,
void * data, void * data,
bool scroll_all, bool scroll_all,
@ -74,7 +87,13 @@ void gui_list_init(struct gui_list * gui_list,
gui_list->title_icon = NOICON; gui_list->title_icon = NOICON;
} }
void gui_list_set_display(struct gui_list * gui_list, struct screen * display) /*
* Attach the scrolling list to a screen
* (The previous screen attachement is lost)
* - gui_list : the list structure
* - display : the screen to attach
*/
static void gui_list_set_display(struct gui_list * gui_list, struct screen * display)
{ {
if(gui_list->display != 0) /* we switched from a previous display */ if(gui_list->display != 0) /* we switched from a previous display */
gui_list->display->stop_scroll(); gui_list->display->stop_scroll();
@ -85,7 +104,12 @@ void gui_list_set_display(struct gui_list * gui_list, struct screen * display)
gui_list_put_selection_in_screen(gui_list, false); gui_list_put_selection_in_screen(gui_list, false);
} }
void gui_list_flash(struct gui_list * gui_list) /*
* One call on 2, the selected lune will either blink the cursor or
* invert/display normal the selected line
* - gui_list : the list structure
*/
static void gui_list_flash(struct gui_list * gui_list)
{ {
struct screen * display=gui_list->display; struct screen * display=gui_list->display;
gui_list->cursor_flash_state=!gui_list->cursor_flash_state; gui_list->cursor_flash_state=!gui_list->cursor_flash_state;
@ -117,7 +141,14 @@ void gui_list_flash(struct gui_list * gui_list)
#endif #endif
} }
void gui_list_put_selection_in_screen(struct gui_list * gui_list, /*
* Puts the selection in the screen
* - gui_list : the list structure
* - put_from_end : if true, selection will be put as close from
* the end of the list as possible, else, it's
* from the beginning
*/
static void gui_list_put_selection_in_screen(struct gui_list * gui_list,
bool put_from_end) bool put_from_end)
{ {
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
@ -181,7 +212,11 @@ static int gui_list_get_item_offset(struct gui_list * gui_list, int item_width,
} }
#endif #endif
void gui_list_draw(struct gui_list * gui_list) /*
* Draws the list on the attached screen
* - gui_list : the list structure
*/
static void gui_list_draw(struct gui_list * gui_list)
{ {
struct screen * display=gui_list->display; struct screen * display=gui_list->display;
int cursor_pos = 0; int cursor_pos = 0;
@ -371,7 +406,12 @@ void gui_list_draw(struct gui_list * gui_list)
gui_textarea_update(display); gui_textarea_update(display);
} }
void gui_list_select_item(struct gui_list * gui_list, int item_number) /*
* Selects an item in the list
* - gui_list : the list structure
* - item_number : the number of the item which will be selected
*/
static void gui_list_select_item(struct gui_list * gui_list, int item_number)
{ {
if( item_number > gui_list->nb_items-1 || item_number < 0 ) if( item_number > gui_list->nb_items-1 || item_number < 0 )
return; return;
@ -379,7 +419,12 @@ void gui_list_select_item(struct gui_list * gui_list, int item_number)
gui_list_put_selection_in_screen(gui_list, false); gui_list_put_selection_in_screen(gui_list, false);
} }
void gui_list_select_next(struct gui_list * gui_list) /*
* Selects the next item in the list
* (Item 0 gets selected if the end of the list is reached)
* - gui_list : the list structure
*/
static void gui_list_select_next(struct gui_list * gui_list)
{ {
if( gui_list->selected_item+gui_list->selected_size >= gui_list->nb_items ) if( gui_list->selected_item+gui_list->selected_size >= gui_list->nb_items )
{ {
@ -422,7 +467,12 @@ void gui_list_select_next(struct gui_list * gui_list)
} }
} }
void gui_list_select_previous(struct gui_list * gui_list) /*
* Selects the previous item in the list
* (Last item in the list gets selected if the list beginning is reached)
* - gui_list : the list structure
*/
static void gui_list_select_previous(struct gui_list * gui_list)
{ {
int nb_lines = gui_list->display->nb_lines; int nb_lines = gui_list->display->nb_lines;
if (SHOW_LIST_TITLE) if (SHOW_LIST_TITLE)
@ -466,7 +516,12 @@ void gui_list_select_previous(struct gui_list * gui_list)
} }
} }
void gui_list_select_next_page(struct gui_list * gui_list, int nb_lines) /*
* Go to next page if any, else selects the last item in the list
* - gui_list : the list structure
* - nb_lines : the number of lines to try to move the cursor
*/
static void gui_list_select_next_page(struct gui_list * gui_list, int nb_lines)
{ {
if(gui_list->selected_item == gui_list->nb_items-gui_list->selected_size) if(gui_list->selected_item == gui_list->nb_items-gui_list->selected_size)
{ {
@ -486,7 +541,12 @@ void gui_list_select_next_page(struct gui_list * gui_list, int nb_lines)
gui_list_put_selection_in_screen(gui_list, true); gui_list_put_selection_in_screen(gui_list, true);
} }
void gui_list_select_previous_page(struct gui_list * gui_list, int nb_lines) /*
* Go to previous page if any, else selects the first item in the list
* - gui_list : the list structure
* - nb_lines : the number of lines to try to move the cursor
*/
static void gui_list_select_previous_page(struct gui_list * gui_list, int nb_lines)
{ {
if(gui_list->selected_item == 0) if(gui_list->selected_item == 0)
{ {
@ -506,7 +566,11 @@ void gui_list_select_previous_page(struct gui_list * gui_list, int nb_lines)
gui_list_put_selection_in_screen(gui_list, false); gui_list_put_selection_in_screen(gui_list, false);
} }
void gui_list_add_item(struct gui_list * gui_list) /*
* Adds an item to the list (the callback will be asked for one more item)
* - gui_list : the list structure
*/
static void gui_list_add_item(struct gui_list * gui_list)
{ {
gui_list->nb_items++; gui_list->nb_items++;
/* if only one item in the list, select it */ /* if only one item in the list, select it */
@ -514,7 +578,11 @@ void gui_list_add_item(struct gui_list * gui_list)
gui_list->selected_item = 0; gui_list->selected_item = 0;
} }
void gui_list_del_item(struct gui_list * gui_list) /*
* Removes an item to the list (the callback will be asked for one less item)
* - gui_list : the list structure
*/
static void gui_list_del_item(struct gui_list * gui_list)
{ {
if(gui_list->nb_items > 0) if(gui_list->nb_items > 0)
{ {
@ -540,7 +608,13 @@ void gui_list_del_item(struct gui_list * gui_list)
} }
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
void gui_list_scroll_right(struct gui_list * gui_list)
/*
* Makes all the item in the list scroll by one step to the right.
* Should stop increasing the value when reaching the widest item value
* in the list.
*/
static void gui_list_scroll_right(struct gui_list * gui_list)
{ {
/* FIXME: This is a fake right boundry limiter. there should be some /* FIXME: This is a fake right boundry limiter. there should be some
* callback function to find the longest item on the list in pixels, * callback function to find the longest item on the list in pixels,
@ -550,7 +624,11 @@ void gui_list_scroll_right(struct gui_list * gui_list)
gui_list->offset_position = 1000; gui_list->offset_position = 1000;
} }
void gui_list_scroll_left(struct gui_list * gui_list) /*
* Makes all the item in the list scroll by one step to the left.
* stops at starting position.
*/
static void gui_list_scroll_left(struct gui_list * gui_list)
{ {
gui_list->offset_position-=offset_step; gui_list->offset_position-=offset_step;
if (gui_list->offset_position < 0) if (gui_list->offset_position < 0)
@ -570,7 +648,11 @@ void gui_list_screen_scroll_out_of_view(bool enable)
} }
#endif /* HAVE_LCD_BITMAP */ #endif /* HAVE_LCD_BITMAP */
void gui_list_set_title(struct gui_list * gui_list, char * title, ICON icon) /*
* Set the title and title icon of the list. Setting title to NULL disables
* both the title and icon. Use NOICON if there is no icon.
*/
static void gui_list_set_title(struct gui_list * gui_list, char * title, ICON icon)
{ {
gui_list->title = title; gui_list->title = title;
gui_list->title_icon = icon; gui_list->title_icon = icon;
@ -649,21 +731,21 @@ void gui_synclist_select_item(struct gui_synclist * lists, int item_number)
gui_list_select_item(&(lists->gui_list[i]), item_number); gui_list_select_item(&(lists->gui_list[i]), item_number);
} }
void gui_synclist_select_next(struct gui_synclist * lists) static void gui_synclist_select_next(struct gui_synclist * lists)
{ {
int i; int i;
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
gui_list_select_next(&(lists->gui_list[i])); gui_list_select_next(&(lists->gui_list[i]));
} }
void gui_synclist_select_previous(struct gui_synclist * lists) static void gui_synclist_select_previous(struct gui_synclist * lists)
{ {
int i; int i;
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
gui_list_select_previous(&(lists->gui_list[i])); gui_list_select_previous(&(lists->gui_list[i]));
} }
void gui_synclist_select_next_page(struct gui_synclist * lists, static void gui_synclist_select_next_page(struct gui_synclist * lists,
enum screen_type screen) enum screen_type screen)
{ {
int i; int i;
@ -672,7 +754,7 @@ void gui_synclist_select_next_page(struct gui_synclist * lists,
screens[screen].nb_lines); screens[screen].nb_lines);
} }
void gui_synclist_select_previous_page(struct gui_synclist * lists, static void gui_synclist_select_previous_page(struct gui_synclist * lists,
enum screen_type screen) enum screen_type screen)
{ {
int i; int i;
@ -718,14 +800,14 @@ void gui_synclist_flash(struct gui_synclist * lists)
} }
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
void gui_synclist_scroll_right(struct gui_synclist * lists) static void gui_synclist_scroll_right(struct gui_synclist * lists)
{ {
int i; int i;
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
gui_list_scroll_right(&(lists->gui_list[i])); gui_list_scroll_right(&(lists->gui_list[i]));
} }
void gui_synclist_scroll_left(struct gui_synclist * lists) static void gui_synclist_scroll_left(struct gui_synclist * lists)
{ {
int i; int i;
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)

View file

@ -99,22 +99,6 @@ struct gui_list
ICON title_icon; ICON title_icon;
}; };
/*
* Initializes a scrolling list
* - gui_list : the list structure to initialize
* - callback_get_item_icon : pointer to a function that associates an icon
* to a given item number
* - callback_get_item_name : pointer to a function that associates a label
* to a given item number
* - data : extra data passed to the list callback
*/
extern void gui_list_init(struct gui_list * gui_list,
list_get_name callback_get_item_name,
void * data,
bool scroll_all,
int selected_size
);
/* /*
* Sets the numbers 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 * note that the list's context like the currently pointed item is resetted
@ -131,16 +115,6 @@ extern void gui_list_init(struct gui_list * gui_list,
#define gui_list_get_nb_items(gui_list) \ #define gui_list_get_nb_items(gui_list) \
(gui_list)->nb_items (gui_list)->nb_items
/*
* Puts the selection in the screen
* - gui_list : the list structure
* - put_from_end : if true, selection will be put as close from
* the end of the list as possible, else, it's
* from the beginning
*/
extern void gui_list_put_selection_in_screen(struct gui_list * gui_list,
bool put_from_end);
/* /*
* Sets the icon callback function * Sets the icon callback function
* - gui_list : the list structure * - gui_list : the list structure
@ -149,15 +123,6 @@ extern void gui_list_put_selection_in_screen(struct gui_list * gui_list,
#define gui_list_set_icon_callback(gui_list, _callback) \ #define gui_list_set_icon_callback(gui_list, _callback) \
(gui_list)->callback_get_item_icon=_callback (gui_list)->callback_get_item_icon=_callback
/*
* Attach the scrolling list to a screen
* (The previous screen attachement is lost)
* - gui_list : the list structure
* - display : the screen to attach
*/
extern void gui_list_set_display(struct gui_list * gui_list,
struct screen * display);
/* /*
* Gives the position of the selected item * Gives the position of the selected item
* - gui_list : the list structure * - gui_list : the list structure
@ -167,82 +132,13 @@ extern void gui_list_set_display(struct gui_list * gui_list,
(gui_list)->selected_item (gui_list)->selected_item
/*
* Selects an item in the list
* - gui_list : the list structure
* - item_number : the number of the item which will be selected
*/
extern void gui_list_select_item(struct gui_list * gui_list, int item_number);
/*
* Draws the list on the attached screen
* - gui_list : the list structure
*/
extern void gui_list_draw(struct gui_list * gui_list);
/*
* Selects the next item in the list
* (Item 0 gets selected if the end of the list is reached)
* - gui_list : the list structure
*/
extern void gui_list_select_next(struct gui_list * gui_list);
/*
* Selects the previous item in the list
* (Last item in the list gets selected if the list beginning is reached)
* - gui_list : the list structure
*/
extern void gui_list_select_previous(struct gui_list * gui_list);
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
/*
* Makes all the item in the list scroll by one step to the right.
* Should stop increasing the value when reaching the widest item value
* in the list.
*/
void gui_list_scroll_right(struct gui_list * gui_list);
/*
* Makes all the item in the list scroll by one step to the left.
* stops at starting position.
*/
void gui_list_scroll_left(struct gui_list * gui_list);
/* parse global setting to static int */ /* parse global setting to static int */
extern void gui_list_screen_scroll_step(int ofs); extern void gui_list_screen_scroll_step(int ofs);
/* parse global setting to static bool */ /* parse global setting to static bool */
extern void gui_list_screen_scroll_out_of_view(bool enable); extern void gui_list_screen_scroll_out_of_view(bool enable);
#endif /* HAVE_LCD_BITMAP */ #endif /* HAVE_LCD_BITMAP */
/*
* Go to next page if any, else selects the last item in the list
* - gui_list : the list structure
* - nb_lines : the number of lines to try to move the cursor
*/
extern void gui_list_select_next_page(struct gui_list * gui_list,
int nb_lines);
/*
* Go to previous page if any, else selects the first item in the list
* - gui_list : the list structure
* - nb_lines : the number of lines to try to move the cursor
*/
extern void gui_list_select_previous_page(struct gui_list * gui_list,
int nb_lines);
/*
* Adds an item to the list (the callback will be asked for one more item)
* - gui_list : the list structure
*/
extern void gui_list_add_item(struct gui_list * gui_list);
/*
* Removes an item to the list (the callback will be asked for one less item)
* - gui_list : the list structure
*/
extern void gui_list_del_item(struct gui_list * gui_list);
/* /*
* Tells the list wether it should stop when reaching the top/bottom * Tells the list wether it should stop when reaching the top/bottom
* or should continue (by going to bottom/top) * or should continue (by going to bottom/top)
@ -254,20 +150,6 @@ extern void gui_list_del_item(struct gui_list * gui_list);
#define gui_list_limit_scroll(gui_list, scroll) \ #define gui_list_limit_scroll(gui_list, scroll) \
(gui_list)->limit_scroll=scroll (gui_list)->limit_scroll=scroll
/*
* One call on 2, the selected lune will either blink the cursor or
* invert/display normal the selected line
* - gui_list : the list structure
*/
extern void gui_list_flash(struct gui_list * gui_list);
/*
* Set the title and title icon of the list. Setting title to NULL disables
* both the title and icon. Use NOICON if there is no icon.
*/
extern void gui_list_set_title(struct gui_list *gui_list, char* title,
ICON icon);
/* /*
* This part handles as many lists as there are connected screens * This part handles as many lists as there are connected screens
* (the api is similar to the ones above) * (the api is similar to the ones above)
@ -298,20 +180,12 @@ extern int gui_synclist_get_sel_pos(struct gui_synclist * lists);
extern void gui_synclist_draw(struct gui_synclist * lists); extern void gui_synclist_draw(struct gui_synclist * lists);
extern void gui_synclist_select_item(struct gui_synclist * lists, extern void gui_synclist_select_item(struct gui_synclist * lists,
int item_number); int item_number);
extern void gui_synclist_select_next(struct gui_synclist * lists);
extern void gui_synclist_select_previous(struct gui_synclist * lists);
extern void gui_synclist_select_next_page(struct gui_synclist * lists,
enum screen_type screen);
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_add_item(struct gui_synclist * lists);
extern void gui_synclist_del_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); extern void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll);
extern void gui_synclist_flash(struct gui_synclist * lists); extern void gui_synclist_flash(struct gui_synclist * lists);
extern void gui_synclist_set_title(struct gui_synclist * lists, char * title, extern void gui_synclist_set_title(struct gui_synclist * lists, char * title,
ICON icon); ICON icon);
void gui_synclist_scroll_right(struct gui_synclist * lists);
void gui_synclist_scroll_left(struct gui_synclist * lists);
/* /*
* Do the action implied by the given button, * Do the action implied by the given button,

View file

@ -179,18 +179,10 @@ static const struct plugin_api rockbox_api = {
gui_synclist_get_sel_pos, gui_synclist_get_sel_pos,
gui_synclist_draw, gui_synclist_draw,
gui_synclist_select_item, gui_synclist_select_item,
gui_synclist_select_next,
gui_synclist_select_previous,
gui_synclist_select_next_page,
gui_synclist_select_previous_page,
gui_synclist_add_item, gui_synclist_add_item,
gui_synclist_del_item, gui_synclist_del_item,
gui_synclist_limit_scroll, gui_synclist_limit_scroll,
gui_synclist_flash, gui_synclist_flash,
#ifdef HAVE_LCD_BITMAP
gui_synclist_scroll_right,
gui_synclist_scroll_left,
#endif
gui_synclist_do_button, gui_synclist_do_button,
gui_synclist_set_title, gui_synclist_set_title,

View file

@ -110,12 +110,12 @@
#define PLUGIN_MAGIC 0x526F634B /* RocK */ #define PLUGIN_MAGIC 0x526F634B /* RocK */
/* increase this every time the api struct changes */ /* increase this every time the api struct changes */
#define PLUGIN_API_VERSION 44 #define PLUGIN_API_VERSION 45
/* update this to latest version if a change to the api struct breaks /* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any backwards compatibility (and please take the opportunity to sort in any
new function which are "waiting" at the end of the function table) */ new function which are "waiting" at the end of the function table) */
#define PLUGIN_MIN_API_VERSION 44 #define PLUGIN_MIN_API_VERSION 45
/* plugin return codes */ /* plugin return codes */
enum plugin_status { enum plugin_status {
@ -268,20 +268,10 @@ struct plugin_api {
void (*gui_synclist_draw)(struct gui_synclist * lists); void (*gui_synclist_draw)(struct gui_synclist * lists);
void (*gui_synclist_select_item)(struct gui_synclist * lists, void (*gui_synclist_select_item)(struct gui_synclist * lists,
int item_number); int item_number);
void (*gui_synclist_select_next)(struct gui_synclist * lists);
void (*gui_synclist_select_previous)(struct gui_synclist * lists);
void (*gui_synclist_select_next_page)(struct gui_synclist * lists,
enum screen_type screen);
void (*gui_synclist_select_previous_page)(struct gui_synclist * lists,
enum screen_type screen);
void (*gui_synclist_add_item)(struct gui_synclist * lists); void (*gui_synclist_add_item)(struct gui_synclist * lists);
void (*gui_synclist_del_item)(struct gui_synclist * lists); void (*gui_synclist_del_item)(struct gui_synclist * lists);
void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll); void (*gui_synclist_limit_scroll)(struct gui_synclist * lists, bool scroll);
void (*gui_synclist_flash)(struct gui_synclist * lists); void (*gui_synclist_flash)(struct gui_synclist * lists);
#ifdef HAVE_LCD_BITMAP
void (*gui_synclist_scroll_right)(struct gui_synclist * lists);
void (*gui_synclist_scroll_left)(struct gui_synclist * lists);
#endif
unsigned (*gui_synclist_do_button)(struct gui_synclist * lists, unsigned (*gui_synclist_do_button)(struct gui_synclist * lists,
unsigned button,enum list_wrap wrap); unsigned button,enum list_wrap wrap);
void (*gui_synclist_set_title)(struct gui_synclist *lists, char* title, ICON icon); void (*gui_synclist_set_title)(struct gui_synclist *lists, char* title, ICON icon);