diff options
author | Matt Brejza <mbrejza@gmail.com> | 2016-06-25 16:23:59 +0100 |
---|---|---|
committer | Matt Brejza <mbrejza@gmail.com> | 2016-06-25 16:23:59 +0100 |
commit | 1cd01204800105e55e0b3ffe2ed4c06ea5036d75 (patch) | |
tree | e5e6a8a607827ec2d3ba4d7a61e2a9a4438aa708 /src/gwin/gwin_list.c | |
parent | bb7f100804f7f2f76fe7579dc952a6fe8fbd3d04 (diff) | |
download | uGFX-1cd01204800105e55e0b3ffe2ed4c06ea5036d75.tar.gz uGFX-1cd01204800105e55e0b3ffe2ed4c06ea5036d75.tar.bz2 uGFX-1cd01204800105e55e0b3ffe2ed4c06ea5036d75.zip |
Added ability for List to scroll when navigted via toggle
Diffstat (limited to 'src/gwin/gwin_list.c')
-rw-r--r-- | src/gwin/gwin_list.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gwin/gwin_list.c b/src/gwin/gwin_list.c index 494d2de9..e73faf15 100644 --- a/src/gwin/gwin_list.c +++ b/src/gwin/gwin_list.c @@ -183,6 +183,9 @@ static void sendListEvent(GWidgetObject *gw, int item) { const gfxQueueASyncItem * qi; const gfxQueueASyncItem * qix; int i; + + coord_t iheight; + iheight = gdispGetFontMetric(gw->g.font, fontHeight) + LST_VERT_PAD; switch (role) { // select down @@ -193,6 +196,12 @@ static void sendListEvent(GWidgetObject *gw, int item) { if (qix) { qi2li->flags &=~ GLIST_FLG_SELECTED; qix2li->flags |= GLIST_FLG_SELECTED; + + //if we need to scroll down + if (((i+2)*iheight - gw2obj->top) > gw->g.height){ + gw2obj->top += iheight; + } + _gwinUpdate(&gw->g); } break; @@ -210,6 +219,14 @@ static void sendListEvent(GWidgetObject *gw, int item) { if (qix) { qi2li->flags &=~ GLIST_FLG_SELECTED; qix2li->flags |= GLIST_FLG_SELECTED; + + //if we need to scroll up + if (((i-1)*iheight) < gw2obj->top){ + gw2obj->top -= iheight; + if (gw2obj->top < 0) + gw2obj->top = 0; + } + _gwinUpdate(&gw->g); } break; |