aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Hannam <andrewh@inmarket.com.au>2016-07-09 17:27:44 +1000
committerAndrew Hannam <andrewh@inmarket.com.au>2016-07-09 17:27:44 +1000
commited9b268d5bce5fe6d703bc785034191312782db0 (patch)
tree26e87d228db977ea39af36b93e45f38f6ccf51a4 /src
parente1c7003fa32c8700b155538f51276d9da3a82ae9 (diff)
parent1cd01204800105e55e0b3ffe2ed4c06ea5036d75 (diff)
downloaduGFX-ed9b268d5bce5fe6d703bc785034191312782db0.tar.gz
uGFX-ed9b268d5bce5fe6d703bc785034191312782db0.tar.bz2
uGFX-ed9b268d5bce5fe6d703bc785034191312782db0.zip
Merged in mattbrejza/ugfx/list_toggle_scroll (pull request #23)
Added ability for List to scroll when navigted via toggle
Diffstat (limited to 'src')
-rw-r--r--src/gwin/gwin_list.c17
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;