list update

ugfx_release_2.6
Joel Bodenmann 2013-07-28 23:18:59 +02:00
parent 632566e243
commit 31f3554602
2 changed files with 22 additions and 5 deletions

View File

@ -45,6 +45,12 @@ typedef struct GEventGWinList {
// A list window // A list window
typedef struct GListObject { typedef struct GListObject {
GWidgetObject w; 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) int cnt; // Number of items currently in the list (quicker than counting each time)
gfxQueueASync list_head; // The list of items gfxQueueASync list_head; // The list of items
} GListObject; } GListObject;

View File

@ -201,19 +201,30 @@ static void gwinListDefaultDraw(GWidgetObject* gw, void* param) {
#define gcw ((GListObject *)gw) #define gcw ((GListObject *)gw)
switch (role) { switch (role) {
// select up // select down
case 0: case 0:
_selectUp(gw); _selectDown(gw);
break; break;
// select down // select up
case 1: case 1:
_selectDown(gw); _selectUp(gw);
break; break;
} }
#undef gcw #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 #endif
static void _destroy(GHandle gh) { static void _destroy(GHandle gh) {
@ -244,7 +255,7 @@ static const gwidgetVMT listVMT = {
#if GINPUT_NEED_TOGGLE #if GINPUT_NEED_TOGGLE
{ {
2, // two toggle roles 2, // two toggle roles
ToggleAssin, // Assign toggles ToggleAssign, // Assign toggles
ToggleGet, // get toggles ToggleGet, // get toggles
0, 0,
ToggleOn, // process toggle on event ToggleOn, // process toggle on event