Swadge ESP32-S2
APIs to develop for the Magfest Swadge
Toggle main menu visibility
Loading...
Searching...
No Matches
wheel_menu.h
Go to the documentation of this file.
1
26
#ifndef _WHEEL_MENU_H_
27
#define _WHEEL_MENU_H_
28
29
#include "
menu.h
"
30
#include "
menu_utils.h
"
31
#include "
wsg.h
"
32
#include "
geometry.h
"
33
#include "
palette.h
"
34
38
typedef
enum
39
{
40
NO_SCROLL
= 0,
41
SCROLL_VERT
= 1,
42
SCROLL_HORIZ
= 2,
43
SCROLL_REVERSE
= 4,
44
SCROLL_VERT_R
=
SCROLL_VERT
|
SCROLL_REVERSE
,
45
SCROLL_HORIZ_R
=
SCROLL_HORIZ
|
SCROLL_REVERSE
,
46
ZOOM_SUBMENU
= 8,
47
ZOOM_GAUGE
= 16,
48
ZOOM_CONVEYOR
= 32,
49
MASK_ZOOM
= 56,
50
}
wheelScrollDir_t
;
51
52
typedef
enum
53
{
54
WM_SHAPE_DEFAULT
= 0,
55
WM_SHAPE_ROUNDED_RECT
= 1,
56
WM_SHAPE_SQUARE
= 2,
57
}
wheelMenuShapeFlags_t
;
58
62
typedef
struct
63
{
64
const
font_t
*
font
;
65
const
rectangle_t
*
textBox
;
66
list_t
itemInfos
;
67
uint16_t
anchorAngle
;
68
uint16_t
x
;
69
uint16_t
y
;
70
uint16_t
spokeR
;
71
uint16_t
unselR
;
72
uint16_t
selR
;
73
paletteColor_t
textColor
;
74
paletteColor_t
unselBgColor
;
75
paletteColor_t
selBgColor
;
76
paletteColor_t
borderColor
;
77
bool
customBack
;
78
bool
touched
;
79
bool
active
;
80
bool
zoomed
;
81
bool
zoomBackSelected
;
82
uint8_t
zoomValue
;
83
int32_t
timer
;
84
}
wheelMenuRenderer_t
;
85
86
wheelMenuRenderer_t
*
initWheelMenu
(
const
font_t
* font, uint16_t anchorAngle,
const
rectangle_t
* textBox);
87
void
deinitWheelMenu
(
wheelMenuRenderer_t
* renderer);
88
void
drawWheelMenu
(
menu_t
* menu,
wheelMenuRenderer_t
* renderer, int64_t elapsedUs);
89
90
void
wheelMenuSetColor
(
wheelMenuRenderer_t
* renderer,
paletteColor_t
textColor);
91
void
wheelMenuSetItemInfo
(
wheelMenuRenderer_t
* renderer,
const
char
* label,
const
wsg_t
* icon, uint8_t position,
92
wheelScrollDir_t
scrollDir);
93
void
wheelMenuSetItemIcon
(
wheelMenuRenderer_t
* renderer,
const
char
* label,
const
wsg_t
* icon);
94
void
wheelMenuSetItemColor
(
wheelMenuRenderer_t
* renderer,
const
char
* label,
paletteColor_t
selectedBg,
95
paletteColor_t
unselectedBg);
96
void
wheelMenuSetItemTextIcon
(
wheelMenuRenderer_t
* renderer,
const
char
* label,
const
char
* textIcon);
97
void
wheelMenuSetItemSize
(
wheelMenuRenderer_t
* renderer,
const
char
* label, int16_t w, int16_t h,
98
wheelMenuShapeFlags_t
shapeFlags);
99
menu_t
*
wheelMenuTouch
(
menu_t
* menu,
wheelMenuRenderer_t
* renderer, uint16_t angle, uint16_t radius);
100
menu_t
*
wheelMenuButton
(
menu_t
* menu,
wheelMenuRenderer_t
* renderer,
const
buttonEvt_t
* evt);
101
menu_t
*
wheelMenuTouchRelease
(
menu_t
* menu,
wheelMenuRenderer_t
* renderer);
102
bool
wheelMenuActive
(
menu_t
* menu,
wheelMenuRenderer_t
* renderer);
103
104
#endif
font_t
A font is a collection of font_ch_t for all ASCII characters. Each character has the same height and ...
Definition
font.h:66
geometry.h
rectangle_t
Signed integer representation of a rectangle.
Definition
geometry.h:59
buttonEvt_t
A button event containing the button that triggered the event, whether it was pressed or released,...
Definition
hdw-btn.h:83
list_t
A doubly linked list with pointers to the first and last nodes.
Definition
linked_list.h:87
menu.h
menu_t
struct _menu_t menu_t
The underlying data for a menu. This fundamentally is a list of menuItem_t.
Definition
menu.h:153
menu_utils.h
palette.h
paletteColor_t
paletteColor_t
All 216 possible colors, named like cRGB.
Definition
palette.h:23
wheelMenuRenderer_t::active
bool active
Whether the menu should be shown, regardless of touch.
Definition
wheel_menu.h:79
wheelMenuRenderer_t::itemInfos
list_t itemInfos
The list holding each item's information.
Definition
wheel_menu.h:66
wheelMenuRenderer_t::unselBgColor
paletteColor_t unselBgColor
Default background color of unselected items.
Definition
wheel_menu.h:74
wheelMenuRenderer_t::textColor
paletteColor_t textColor
Color of the selected menu item text label.
Definition
wheel_menu.h:73
wheelMenuRenderer_t::anchorAngle
uint16_t anchorAngle
The angle around which the 0th menu item will be centered.
Definition
wheel_menu.h:67
wheelMenuRenderer_t::zoomed
bool zoomed
Whether or not a settings item is selected.
Definition
wheel_menu.h:80
wheelMenuRenderer_t::font
const font_t * font
The font to draw the menu labels with.
Definition
wheel_menu.h:64
wheelMenuRenderer_t::timer
int32_t timer
The timer for animations.
Definition
wheel_menu.h:83
wheelMenuRenderer_t::x
uint16_t x
The X position of the center of the menu.
Definition
wheel_menu.h:68
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.
Definition
wheel_menu.c:137
wheelMenuRenderer_t::borderColor
paletteColor_t borderColor
Color of the circle borders.
Definition
wheel_menu.h:76
wheelMenuRenderer_t::customBack
bool customBack
Whether the center "back" circle has been customized.
Definition
wheel_menu.h:77
wheelMenuRenderer_t::touched
bool touched
Whether the touchpad is currently touched.
Definition
wheel_menu.h:78
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.
Definition
wheel_menu.c:204
wheelMenuRenderer_t::unselR
uint16_t unselR
The radius of unselected items' sectors.
Definition
wheel_menu.h:71
wheelMenuTouchRelease
menu_t * wheelMenuTouchRelease(menu_t *menu, wheelMenuRenderer_t *renderer)
Inform the wheel menu that the touchpad has been released, selecting the current item.
Definition
wheel_menu.c:942
wheelMenuRenderer_t::zoomBackSelected
bool zoomBackSelected
Whether or not the center is selected while zoomed.
Definition
wheel_menu.h:81
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.
Definition
wheel_menu.c:76
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.
Definition
wheel_menu.c:861
wheelMenuRenderer_t::y
uint16_t y
The Y position of the center of the menu.
Definition
wheel_menu.h:69
wheelMenuSetItemIcon
void wheelMenuSetItemIcon(wheelMenuRenderer_t *renderer, const char *label, const wsg_t *icon)
Set the icon for an item with the given label.
Definition
wheel_menu.c:159
wheelMenuRenderer_t::selR
uint16_t selR
The radius of the selected sector.
Definition
wheel_menu.h:72
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.
Definition
wheel_menu.c:685
wheelMenuShapeFlags_t
wheelMenuShapeFlags_t
Definition
wheel_menu.h:53
WM_SHAPE_ROUNDED_RECT
@ WM_SHAPE_ROUNDED_RECT
Definition
wheel_menu.h:55
WM_SHAPE_SQUARE
@ WM_SHAPE_SQUARE
Definition
wheel_menu.h:56
WM_SHAPE_DEFAULT
@ WM_SHAPE_DEFAULT
Definition
wheel_menu.h:54
wheelMenuRenderer_t::spokeR
uint16_t spokeR
The radial offset of the ring items.
Definition
wheel_menu.h:70
wheelMenuRenderer_t::selBgColor
paletteColor_t selBgColor
Default background color of selected items.
Definition
wheel_menu.h:75
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.
Definition
wheel_menu.c:172
wheelMenuSetColor
void wheelMenuSetColor(wheelMenuRenderer_t *renderer, paletteColor_t textColor)
Set the text color for the selected item.
Definition
wheel_menu.c:123
drawWheelMenu
void drawWheelMenu(menu_t *menu, wheelMenuRenderer_t *renderer, int64_t elapsedUs)
Draw the wheel menu onto the screen.
Definition
wheel_menu.c:221
wheelMenuActive
bool wheelMenuActive(menu_t *menu, wheelMenuRenderer_t *renderer)
Returns whether or not the wheel menu is active and should be drawn.
Definition
wheel_menu.c:1036
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.
Definition
wheel_menu.c:188
wheelMenuRenderer_t::zoomValue
uint8_t zoomValue
The current selected option/value if zoomed.
Definition
wheel_menu.h:82
wheelMenuRenderer_t::textBox
const rectangle_t * textBox
A pointer to the text box to draw the selected item's label inside.
Definition
wheel_menu.h:65
wheelScrollDir_t
wheelScrollDir_t
Wheel scroll directions.
Definition
wheel_menu.h:39
SCROLL_HORIZ
@ SCROLL_HORIZ
Allow scrolling setting value with Let/Right D-Pad buttons.
Definition
wheel_menu.h:42
ZOOM_GAUGE
@ ZOOM_GAUGE
When zoomed to a settings item, display it as a gauge.
Definition
wheel_menu.h:47
ZOOM_CONVEYOR
@ ZOOM_CONVEYOR
When zoomed to a settings item, display it as a rotating conveyor belt.
Definition
wheel_menu.h:48
ZOOM_SUBMENU
@ ZOOM_SUBMENU
When zoomed to a settings item, display it as a submenu.
Definition
wheel_menu.h:46
NO_SCROLL
@ NO_SCROLL
Do not allow setting values to scroll with buttons.
Definition
wheel_menu.h:40
MASK_ZOOM
@ MASK_ZOOM
Mask for all zoom options.
Definition
wheel_menu.h:49
SCROLL_VERT
@ SCROLL_VERT
Allow scrolling setting value with Up/Down D-Pad buttons.
Definition
wheel_menu.h:41
SCROLL_REVERSE
@ SCROLL_REVERSE
Flip the direction of scrolling.
Definition
wheel_menu.h:43
SCROLL_HORIZ_R
@ SCROLL_HORIZ_R
Allow scrolling setting value with Up/Down, reversed.
Definition
wheel_menu.h:45
SCROLL_VERT_R
@ SCROLL_VERT_R
Allow scrolling setting value with Up/Down, reversed.
Definition
wheel_menu.h:44
deinitWheelMenu
void deinitWheelMenu(wheelMenuRenderer_t *renderer)
Deinitialize and free all memory associated with the wheel menu renderer.
Definition
wheel_menu.c:106
wheelMenuRenderer_t
Renderer for a menu wheel.
Definition
wheel_menu.h:63
wsg.h
wsg_t
A sprite using paletteColor_t colors that can be drawn to the display.
Definition
wsg.h:57
main
utils
input
wheel_menu.h
Generated by
1.17.0