diff options
author | Michael Brown <mcb30@ipxe.org> | 2024-06-20 12:21:57 -0700 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2024-06-20 13:14:35 -0700 |
commit | 122777f789a68512593e4aa6da3ace3d0d8664ec (patch) | |
tree | 25e8fc721b355c45e6e10d53f9866e32369f05b2 /src/include | |
parent | 76e0933d781474acf52000cba0afaebe32361667 (diff) | |
download | ipxe-122777f789a68512593e4aa6da3ace3d0d8664ec.tar.gz |
[hci] Allow tab key to be used to cycle through UI elements
Add support for wraparound scrolling and allow the tab key to be used
to move forward through a list of elements, wrapping back around to
the beginning of the list on overflow.
This is mildly useful for a menu, and likely to be a strong user
expectation for an interactive form.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/ipxe/jumpscroll.h | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/src/include/ipxe/jumpscroll.h b/src/include/ipxe/jumpscroll.h index 7a5b111c1..470f08e71 100644 --- a/src/include/ipxe/jumpscroll.h +++ b/src/include/ipxe/jumpscroll.h @@ -9,6 +9,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); +#include <stdint.h> + /** A jump scroller */ struct jump_scroller { /** Maximum number of visible rows */ @@ -22,6 +24,35 @@ struct jump_scroller { }; /** + * Construct scroll movement + * + * @v delta Change in scroller position + * @ret move Scroll movement + */ +#define SCROLL( delta ) ( ( unsigned int ) ( uint16_t ) ( int16_t ) (delta) ) + +/** + * Extract change in scroller position + * + * @v move Scroll movement + * @ret delta Change in scroller position + */ +#define SCROLL_DELTA( scroll ) ( ( int16_t ) ( (scroll) & 0x0000ffffUL ) ) + +/** Scroll movement flags */ +#define SCROLL_FLAGS 0xffff0000UL +#define SCROLL_WRAP 0x80000000UL /**< Wrap around scrolling */ + +/** Do not scroll */ +#define SCROLL_NONE SCROLL ( 0 ) + +/** Scroll up by one line */ +#define SCROLL_UP SCROLL ( -1 ) + +/** Scroll down by one line */ +#define SCROLL_DOWN SCROLL ( +1 ) + +/** * Check if jump scroller is currently on first page * * @v scroll Jump scroller @@ -43,8 +74,9 @@ 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 unsigned int jump_scroll_key ( struct jump_scroller *scroll, int key ); +extern unsigned int jump_scroll_move ( struct jump_scroller *scroll, + unsigned int move ); extern int jump_scroll ( struct jump_scroller *scroll ); #endif /* _IPXE_JUMPSCROLL_H */ |