aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/gwin/list.h6
-rw-r--r--src/gwin/list.c21
2 files changed, 22 insertions, 5 deletions
diff --git a/include/gwin/list.h b/include/gwin/list.h
index ba83f24b..d28206d9 100644
--- a/include/gwin/list.h
+++ b/include/gwin/list.h
@@ -45,6 +45,12 @@ typedef struct GEventGWinList {
// A list window
typedef struct GListObject {
GWidgetObject w;
+
+ #if GINPUT_NEED_TOGGLE
+ uint16_t t_up;
+ uint16_t t_dn;
+ #endif
+
int cnt; // Number of items currently in the list (quicker than counting each time)
gfxQueueASync list_head; // The list of items
} GListObject;
diff --git a/src/gwin/list.c b/src/gwin/list.c
index 54bac334..2509260c 100644
--- a/src/gwin/list.c
+++ b/src/gwin/list.c
@@ -201,19 +201,30 @@ static void gwinListDefaultDraw(GWidgetObject* gw, void* param) {
#define gcw ((GListObject *)gw)
switch (role) {
- // select up
+ // select down
case 0:
- _selectUp(gw);
+ _selectDown(gw);
break;
- // select down
+ // select up
case 1:
- _selectDown(gw);
+ _selectUp(gw);
break;
}
#undef gcw
}
+
+ static void ToggleAssign(GWidgetObject *gw, uint16_t role, uint16_t instance) {
+ if (role)
+ ((GListObject *)gw)->t_up = instance;
+ else
+ ((GListObject *)gw)->t_dn = instance;
+ }
+
+ static uint16_t ToggleGet(GWidgetObject *gw, uint16_t role) {
+ return role ? ((GListObject *)gw)->t_up : ((GListObject *)gw)->t_dn;
+ }
#endif
static void _destroy(GHandle gh) {
@@ -244,7 +255,7 @@ static const gwidgetVMT listVMT = {
#if GINPUT_NEED_TOGGLE
{
2, // two toggle roles
- ToggleAssin, // Assign toggles
+ ToggleAssign, // Assign toggles
ToggleGet, // get toggles
0,
ToggleOn, // process toggle on event