aboutsummaryrefslogtreecommitdiffstats
path: root/src/gwin/list.c
diff options
context:
space:
mode:
authorJoel Bodenmann <joel@unormal.org>2013-07-28 15:26:59 +0200
committerJoel Bodenmann <joel@unormal.org>2013-07-28 15:26:59 +0200
commit632566e243e1fa914dfee6ec87913d940856963c (patch)
treea8434024a8b9f55790ee801003dbe8b42cad59e8 /src/gwin/list.c
parent30df14b595c0a795943a9593ea32d23cf53d148f (diff)
downloaduGFX-632566e243e1fa914dfee6ec87913d940856963c.tar.gz
uGFX-632566e243e1fa914dfee6ec87913d940856963c.tar.bz2
uGFX-632566e243e1fa914dfee6ec87913d940856963c.zip
list fix
Diffstat (limited to 'src/gwin/list.c')
-rw-r--r--src/gwin/list.c55
1 files changed, 45 insertions, 10 deletions
diff --git a/src/gwin/list.c b/src/gwin/list.c
index f495ada4..54bac334 100644
--- a/src/gwin/list.c
+++ b/src/gwin/list.c
@@ -44,7 +44,8 @@ typedef struct ListItem {
#endif
} ListItem;
-void _selectUp(GWidgetObject *gw) {
+// select the next item in the list
+static int _selectDown(GWidgetObject *gw) {
#define gcw ((GListObject *)gw)
gfxQueueASyncItem *qi;
@@ -55,19 +56,44 @@ void _selectUp(GWidgetObject *gw) {
((ListItem*)qi)->flags &=~ GLIST_FLG_SELECTED;
qi = gfxQueueASyncNext(qi);
((ListItem*)qi)->flags |= GLIST_FLG_SELECTED;
+
+ break;
}
}
_gwidgetRedraw((GHandle)gw);
+ return ++i;
+
#undef gcw
}
-static void _selectDown(GWidgetObject *gw) {
+// select the previous item in the list
+static int _selectUp(GWidgetObject *gw) {
#define gcw ((GListObject *)gw)
+ gfxQueueASyncItem *qi;
+ gfxQueueASyncItem *qi2;
+ uint16_t i;
+
+ qi = gfxQueueASyncPeek(&gcw->list_head);
+ qi2 = qi;
+
+ for (i = 0; qi2; qi2 = gfxQueueASyncNext(qi), i++) {
+ if (((ListItem*)qi2)->flags & GLIST_FLG_SELECTED) {
+ ((ListItem*)qi2)->flags &=~ GLIST_FLG_SELECTED;
+ ((ListItem*)qi)->flags |= GLIST_FLG_SELECTED;
+
+ break;
+ }
+
+ qi = qi2;
+ }
+
_gwidgetRedraw((GHandle)gw);
+ return --i;
+
#undef gcw
}
@@ -137,14 +163,23 @@ static void gwinListDefaultDraw(GWidgetObject* gw, void* param) {
uint16_t i, item_id, item_height;
const gfxQueueASyncItem* qi;
- item_height = gdispGetFontMetric(gwinGetDefaultFont(), fontHeight) + 2*BORDER;
- item_id = (y - gw->g.y) / item_height;
-
- for(qi = gfxQueueASyncPeek(&gcw->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) {
- if (item_id == i)
- li->flags |= GLIST_FLG_SELECTED;
- else
- li->flags &=~ GLIST_FLG_SELECTED;
+ item_id = -1;
+
+ if (x > gw->g.width - BORDER_SCROLL) {
+ if (y < BORDER_SCROLL)
+ item_id = _selectUp(gw);
+ else if (y > gw->g.height - BORDER_SCROLL)
+ item_id = _selectDown(gw);
+ } else if (x < gw->g.width - BORDER_SCROLL - BORDER) {
+ item_height = gdispGetFontMetric(gwinGetDefaultFont(), fontHeight) + 2*BORDER;
+ item_id = (y) / item_height;
+
+ for(qi = gfxQueueASyncPeek(&gcw->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) {
+ if (item_id == i)
+ li->flags |= GLIST_FLG_SELECTED;
+ else
+ li->flags &=~ GLIST_FLG_SELECTED;
+ }
}
_gwidgetRedraw((GHandle)gw);