Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
|
The new and improved paint menu will work like this, thanks to the new touchpad:
Go to the source code of this file.
Data Structures | |
struct | wheelMenuRenderer_t |
Renderer for a menu wheel. More... | |
Enumerations | |
enum | wheelScrollDir_t { NO_SCROLL = 0 , SCROLL_VERT = 1 , SCROLL_HORIZ = 2 , SCROLL_REVERSE = 4 , SCROLL_VERT_R = SCROLL_VERT | SCROLL_REVERSE , SCROLL_HORIZ_R = SCROLL_HORIZ | SCROLL_REVERSE , ZOOM_SUBMENU = 8 , ZOOM_GAUGE = 16 , ZOOM_CONVEYOR = 32 , MASK_ZOOM = 56 } |
Wheel scroll directions. More... | |
enum | wheelMenuShapeFlags_t { WM_SHAPE_DEFAULT = 0 , WM_SHAPE_ROUNDED_RECT = 1 , WM_SHAPE_SQUARE = 2 } |
Functions | |
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. | |
void | deinitWheelMenu (wheelMenuRenderer_t *renderer) |
Deinitialize and free all memory associated with the wheel menu renderer. | |
void | drawWheelMenu (menu_t *menu, wheelMenuRenderer_t *renderer, int64_t elapsedUs) |
Draw the wheel menu onto the screen. | |
void | wheelMenuSetColor (wheelMenuRenderer_t *renderer, paletteColor_t textColor) |
Set the text color for the selected item. | |
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 | wheelMenuSetItemIcon (wheelMenuRenderer_t *renderer, const char *label, const wsg_t *icon) |
Set the icon for an 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. | |
menu_t * | wheelMenuTouch (menu_t *menu, wheelMenuRenderer_t *renderer, uint16_t angle, uint16_t radius) |
Register a touchpad touch event with the wheel menu. | |
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. | |
menu_t * | wheelMenuTouchRelease (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. | |
struct wheelMenuRenderer_t |
Data Fields | ||
---|---|---|
const font_t * | font | The font to draw the menu labels with. |
const rectangle_t * | textBox | A pointer to the text box to draw the selected item's label inside. |
list_t | itemInfos | The list holding each item's information. |
uint16_t | anchorAngle | The angle around which the 0th menu item will be centered. |
uint16_t | x | The X position of the center of the menu. |
uint16_t | y | The Y position of the center of the menu. |
uint16_t | spokeR | The radial offset of the ring items. |
uint16_t | unselR | The radius of unselected items' sectors. |
uint16_t | selR | The radius of the selected sector. |
paletteColor_t | textColor | Color of the selected menu item text label. |
paletteColor_t | unselBgColor | Default background color of unselected items. |
paletteColor_t | selBgColor | Default background color of selected items. |
paletteColor_t | borderColor | Color of the circle borders. |
bool | customBack | Whether the center "back" circle has been customized. |
bool | touched | Whether the touchpad is currently touched. |
bool | active | Whether the menu should be shown, regardless of touch. |
bool | zoomed | Whether or not a settings item is selected. |
bool | zoomBackSelected | Whether or not the center is selected while zoomed. |
uint8_t | zoomValue | The current selected option/value if zoomed. |
int32_t | timer | The timer for animations. |
enum wheelScrollDir_t |
Wheel scroll directions.
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.
font | The font to draw menu item labels with |
anchorAngle | The angle where the center of the first item will be anchored |
textBox | If non-NULL, defines the bounding box where the current item label will be written |
void deinitWheelMenu | ( | wheelMenuRenderer_t * | renderer | ) |
Deinitialize and free all memory associated with the wheel menu renderer.
renderer | The whele menu renderer to deinitialize |
void drawWheelMenu | ( | menu_t * | menu, |
wheelMenuRenderer_t * | renderer, | ||
int64_t | elapsedUs ) |
Draw the wheel menu onto the screen.
menu | The current top-level menu to render |
renderer | The wheel menu rendrer |
elapsedUs | The number of microseconds elapsed since the last frame was drawn |
void wheelMenuSetColor | ( | wheelMenuRenderer_t * | renderer, |
paletteColor_t | textColor ) |
Set the text color for the selected item.
renderer | The wheel menu renderer |
textColor | The text color for the selected item |
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.
renderer | The wheel menu renderer |
label | The label of the item to set the icon and position for |
icon | The icon to use when drawing the menu item |
position | The order of the item in the ring, centered around the anchor angle |
scrollDir | Which axis this item should be scrollable in |
void wheelMenuSetItemIcon | ( | wheelMenuRenderer_t * | renderer, |
const char * | label, | ||
const wsg_t * | icon ) |
Set the icon for an item with the given label.
renderer | The wheel menu renderer |
label | The label of the item to set the icon and position for |
icon | The icon to use when drawing the menu item |
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.
renderer | The wheel menu renderer |
label | The label of the item to set the color of |
selectedBg | The background color for the item when selected |
unselectedBg | The background color for the item when not selected |
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.
renderer | The wheel menu renderer |
label | The label to set the icon for |
textIcon | The short text string to draw as the icon text |
void wheelMenuSetItemSize | ( | wheelMenuRenderer_t * | renderer, |
const char * | label, | ||
int16_t | w, | ||
int16_t | h, | ||
wheelMenuShapeFlags_t | shapeFlags ) |
Set specific dimensions for a menu item.
renderer | The whee lmenu renderer |
label | The label of the item to configure dimensions for |
w | The width of the item, or a negative number for "fit to content" |
h | The height of the item, or a negative number for "fit to content" |
shapeFlags | Extra flags for configuring the shape of the item |
menu_t * wheelMenuTouch | ( | menu_t * | menu, |
wheelMenuRenderer_t * | renderer, | ||
uint16_t | angle, | ||
uint16_t | radius ) |
Register a touchpad touch event with the wheel menu.
menu | The menu touched |
renderer | The wheel menu renderer |
angle | The touchpad touch angle |
radius | The touchpad touch radius |
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()
menu | The menu to accept the button |
renderer | The wheel menu renderer |
evt | The button event to be handled |
menu_t * wheelMenuTouchRelease | ( | menu_t * | menu, |
wheelMenuRenderer_t * | renderer ) |
Inform the wheel menu that the touchpad has been released, selecting the current item.
menu | The menu released |
renderer | The wheel menu renderer |
bool wheelMenuActive | ( | menu_t * | menu, |
wheelMenuRenderer_t * | renderer ) |
Returns whether or not the wheel menu is active and should be drawn.
menu | The menu |
renderer | The wheel menu renderer |