diff options
| author | Michael Brown | 2015-03-03 03:47:37 +0100 |
|---|---|---|
| committer | Michael Brown | 2015-03-03 03:47:37 +0100 |
| commit | 58752cc10d3a9eb47ffd360259c80cefa132ffd6 (patch) | |
| tree | 36c7ac4941159fd5b06c8054ed9ea71a9d3ec342 /src/include/ipxe | |
| parent | [settings] Rewrite unrelicensable portions of settings.c (diff) | |
| download | ipxe-58752cc10d3a9eb47ffd360259c80cefa132ffd6.tar.gz ipxe-58752cc10d3a9eb47ffd360259c80cefa132ffd6.tar.xz ipxe-58752cc10d3a9eb47ffd360259c80cefa132ffd6.zip | |
[menu] Abstract out the generic concept of a jump scroller
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe')
| -rw-r--r-- | src/include/ipxe/jumpscroll.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/include/ipxe/jumpscroll.h b/src/include/ipxe/jumpscroll.h new file mode 100644 index 000000000..7a5b111c1 --- /dev/null +++ b/src/include/ipxe/jumpscroll.h @@ -0,0 +1,50 @@ +#ifndef _IPXE_JUMPSCROLL_H +#define _IPXE_JUMPSCROLL_H + +/** @file + * + * Jump scrolling + * + */ + +FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); + +/** A jump scroller */ +struct jump_scroller { + /** Maximum number of visible rows */ + unsigned int rows; + /** Total number of items */ + unsigned int count; + /** Currently selected item */ + unsigned int current; + /** First visible item */ + unsigned int first; +}; + +/** + * Check if jump scroller is currently on first page + * + * @v scroll Jump scroller + * @ret is_first Scroller is currently on first page + */ +static inline int jump_scroll_is_first ( struct jump_scroller *scroll ) { + + return ( scroll->first == 0 ); +} + +/** + * Check if jump scroller is currently on last page + * + * @v scroll Jump scroller + * @ret is_last Scroller is currently on last page + */ +static inline int jump_scroll_is_last ( struct jump_scroller *scroll ) { + + return ( ( scroll->first + scroll->rows ) >= scroll->count ); +} + +extern int jump_scroll_key ( struct jump_scroller *scroll, int key ); +extern int jump_scroll_move ( struct jump_scroller *scroll, int move ); +extern int jump_scroll ( struct jump_scroller *scroll ); + +#endif /* _IPXE_JUMPSCROLL_H */ |
