Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
wheel_menu.c File Reference

Data Structures

struct  wheelItemInfo_t
 
struct  wheelDrawInfo_t
 

Macros

#define wheelAspectRatio   ((ringItems >= 10) ? (TFT_WIDTH + 60) : TFT_WIDTH) / TFT_HEIGHT
 
#define PAD_FILL   5
 

Functions

wheelMenuRenderer_tinitWheelMenu (const font_t *font, uint16_t anchorAngle, const rectangle_t *textBox)
 Initializes and returns a new wheel menu with the default settings.
 
void deinitWheelMenu (wheelMenuRenderer_t *renderer)
 Deinitialize and free all memory associated with the wheel menu renderer.
 
void wheelMenuSetItemInfo (wheelMenuRenderer_t *renderer, const char *label, const wsg_t *icon, uint8_t position, wheelScrollDir_t scrollDir)
 Sets the icon and ring position for the item with the given label.
 
void wheelMenuSetItemColor (wheelMenuRenderer_t *renderer, const char *label, paletteColor_t selectedBg, paletteColor_t unselectedBg)
 Set both the selected and unselected background colors for the item with the given laebl.
 
void wheelMenuSetItemTextIcon (wheelMenuRenderer_t *renderer, const char *label, const char *textIcon)
 Set a short text string to use a very short text tring as an item's icon, instead of an image.
 
void wheelMenuSetItemSize (wheelMenuRenderer_t *renderer, const char *label, int16_t w, int16_t h, wheelMenuShapeFlags_t shapeFlags)
 Set specific dimensions for a menu item.
 
void drawWheelMenu (menu_t *menu, wheelMenuRenderer_t *renderer, int64_t elapsedUs)
 Draw the wheel menu onto the screen.
 
menu_twheelMenuTouch (menu_t *menu, wheelMenuRenderer_t *renderer, uint16_t angle, uint16_t radius)
 Register a touchpad touch event with the wheel menu.
 
menu_twheelMenuButton (menu_t *menu, wheelMenuRenderer_t *renderer, const buttonEvt_t *evt)
 Handle a button press, used for when a setting or option menu item can be scrolled.
 
menu_twheelMenuTouchRelease (menu_t *menu, wheelMenuRenderer_t *renderer)
 Inform the wheel menu that the touchpad has been released, selecting the current item.
 
bool wheelMenuActive (menu_t *menu, wheelMenuRenderer_t *renderer)
 Returns whether or not the wheel menu is active and should be drawn.
 

Data Structure Documentation

◆ wheelItemInfo_t

struct wheelItemInfo_t
Data Fields
const char * label
const wsg_t * icon
uint8_t position
wheelScrollDir_t scroll
paletteColor_t selectedBg
paletteColor_t unselectedBg
const char * textIcon
bool customSize
int16_t width
int16_t height
wheelMenuShapeFlags_t shapeFlags

◆ wheelDrawInfo_t

struct wheelDrawInfo_t
Data Fields
int8_t drawOrder
uint16_t x
uint16_t y
wheelMenuShapeFlags_t shape
int16_t w
int16_t h
int16_t r
bool selected
const wsg_t * wsg
paletteColor_t bgColor
const char * text

Macro Definition Documentation

◆ wheelAspectRatio

#define wheelAspectRatio   ((ringItems >= 10) ? (TFT_WIDTH + 60) : TFT_WIDTH) / TFT_HEIGHT

◆ PAD_FILL

#define PAD_FILL   5

Function Documentation

◆ initWheelMenu()

wheelMenuRenderer_t * initWheelMenu ( const font_t * font,
uint16_t anchorAngle,
const rectangle_t * textBox )

Initializes and returns a new wheel menu with the default settings.

Parameters
fontThe font to draw menu item labels with
anchorAngleThe angle where the center of the first item will be anchored
textBoxIf non-NULL, defines the bounding box where the current item label will be written
Returns
A newly allocated wheel menu renderer

◆ deinitWheelMenu()

void deinitWheelMenu ( wheelMenuRenderer_t * renderer)

Deinitialize and free all memory associated with the wheel menu renderer.

Parameters
rendererThe whele menu renderer to deinitialize

◆ wheelMenuSetItemInfo()

void wheelMenuSetItemInfo ( wheelMenuRenderer_t * renderer,
const char * label,
const wsg_t * icon,
uint8_t position,
wheelScrollDir_t scrollDir )

Sets the icon and ring position for the item with the given label.

Parameters
rendererThe wheel menu renderer
labelThe label of the item to set the icon and position for
iconThe icon to use when drawing the menu item
positionThe order of the item in the ring, centered around the anchor angle
scrollDirWhich axis this item should be scrollable in

◆ wheelMenuSetItemColor()

void wheelMenuSetItemColor ( wheelMenuRenderer_t * renderer,
const char * label,
paletteColor_t selectedBg,
paletteColor_t unselectedBg )

Set both the selected and unselected background colors for the item with the given laebl.

Parameters
rendererThe wheel menu renderer
labelThe label of the item to set the color of
selectedBgThe background color for the item when selected
unselectedBgThe background color for the item when not selected

◆ wheelMenuSetItemTextIcon()

void wheelMenuSetItemTextIcon ( wheelMenuRenderer_t * renderer,
const char * label,
const char * textIcon )

Set a short text string to use a very short text tring as an item's icon, instead of an image.

Parameters
rendererThe wheel menu renderer
labelThe label to set the icon for
textIconThe short text string to draw as the icon text

◆ wheelMenuSetItemSize()

void wheelMenuSetItemSize ( wheelMenuRenderer_t * renderer,
const char * label,
int16_t w,
int16_t h,
wheelMenuShapeFlags_t shapeFlags )

Set specific dimensions for a menu item.

Parameters
rendererThe whee lmenu renderer
labelThe label of the item to configure dimensions for
wThe width of the item, or a negative number for "fit to content"
hThe height of the item, or a negative number for "fit to content"
shapeFlagsExtra flags for configuring the shape of the item

◆ drawWheelMenu()

void drawWheelMenu ( menu_t * menu,
wheelMenuRenderer_t * renderer,
int64_t elapsedUs )

Draw the wheel menu onto the screen.

Parameters
menuThe current top-level menu to render
rendererThe wheel menu rendrer
elapsedUsThe number of microseconds elapsed since the last frame was drawn

◆ wheelMenuTouch()

menu_t * wheelMenuTouch ( menu_t * menu,
wheelMenuRenderer_t * renderer,
uint16_t angle,
uint16_t radius )

Register a touchpad touch event with the wheel menu.

Parameters
menuThe menu touched
rendererThe wheel menu renderer
angleThe touchpad touch angle
radiusThe touchpad touch radius
Returns
menu_t* The current top-level menu, menuButton() would return

◆ wheelMenuButton()

menu_t * wheelMenuButton ( menu_t * menu,
wheelMenuRenderer_t * renderer,
const buttonEvt_t * evt )

Handle a button press, used for when a setting or option menu item can be scrolled.

The direction of the scroll depends on the wheelScrollDir_t value passed to wheelMenuSetItemInfo()

Parameters
menuThe menu to accept the button
rendererThe wheel menu renderer
evtThe button event to be handled
Returns
menu_t* The new top-level menu after handling the button press

◆ wheelMenuTouchRelease()

menu_t * wheelMenuTouchRelease ( menu_t * menu,
wheelMenuRenderer_t * renderer )

Inform the wheel menu that the touchpad has been released, selecting the current item.

Parameters
menuThe menu released
rendererThe wheel menu renderer
Returns
menu_t* The current top-level menu, as returned by menuButton()

◆ wheelMenuActive()

bool wheelMenuActive ( menu_t * menu,
wheelMenuRenderer_t * renderer )

Returns whether or not the wheel menu is active and should be drawn.

Parameters
menuThe menu
rendererThe wheel menu renderer
Returns
true if the wheel menu is active
false if the wheel menu is not active