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

Detailed Description

The new and improved paint menu will work like this, thanks to the new touchpad:

  1. When the touchpad is pressed, the canvas is saved (if not already otherwise?)
  2. A ring selector is drawn over the center of the screen. It is divided into 4 sectors, with a dead-zone circle in the center. When the touchpad is moved towards a ring, it is highlighted.
  3. There are multiple types of entries in the ring. Some will move to another menu when selected by releasing the touchpad, and some will allow pressing up/down and/or left/right on the D-pad to change values. If a sub-menu is selected, it can be exited by pressing B, or maybe there will be an "exit" ring?
  4. Maybe there shuold be an option to have a "sticky" menu – instead of requiring you to hold the touchpad at the same time as going up/down, it would keep you in the menu until you hit B.
  5. "Tool Ring" Layout:
    • The top sector is the tool selector, with left/right.
    • The left sector is the color selector, with up/down. And, maybe A or Left edits the color?
    • The right sector is the tool size selector, with left/right.
    • The bottom sector is the "..." or "Settings" menu
  6. "Settings" layout:
    • Save
    • Load
    • New
    • Exit
    • ... edit palette?

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_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 drawWheelMenu (menu_t *menu, wheelMenuRenderer_t *renderer, int64_t elapsedUs)
 Draw the wheel menu onto the screen.
 
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.
 
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

◆ wheelMenuRenderer_t

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.

Enumeration Type Documentation

◆ wheelScrollDir_t

Wheel scroll directions.

Enumerator
NO_SCROLL 

Do not allow setting values to scroll with buttons.

SCROLL_VERT 

Allow scrolling setting value with Up/Down D-Pad buttons.

SCROLL_HORIZ 

Allow scrolling setting value with Let/Right D-Pad buttons.

SCROLL_REVERSE 

Flip the direction of scrolling.

SCROLL_VERT_R 

Allow scrolling setting value with Up/Down, reversed.

SCROLL_HORIZ_R 

Allow scrolling setting value with Up/Down, reversed.

ZOOM_SUBMENU 

When zoomed to a settings item, display it as a submenu.

ZOOM_GAUGE 

When zoomed to a settings item, display it as a gauge.

ZOOM_CONVEYOR 

When zoomed to a settings item, display it as a rotating conveyor belt.

MASK_ZOOM 

Mask for all zoom options.

◆ wheelMenuShapeFlags_t

Enumerator
WM_SHAPE_DEFAULT 
WM_SHAPE_ROUNDED_RECT 
WM_SHAPE_SQUARE 

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

◆ 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

◆ 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

◆ 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