(function(options) { /* options = { h = height c = # of items draw = function(idx, rect, selected) select = function(idx) }*/ if (!options) return Bangle.setUI(); var w = Bangle.appRect.w; var h = Bangle.appRect.h; var X = Bangle.appRect.x; var Y = Bangle.appRect.y; var s = { scroll : 0|options.scroll, draw : function(idx) { g.reset(); // prefer drawing the list so that the selected item is in the middle of the screen var ty=((h-options.h)/2)-s.scroll*options.h; var y=ty; var by=y+options.c*options.h; if (by<=h) y += (h-by); if (y>0) y = 0; // draw for (var i=0;i-options.h+1)&&(yh) { g.setColor(g.theme.fg) .fillPoly(pb) .setColor(g.theme.bg) .drawPoly(pb,true); } }, drawItem : idx => draw(idx) }; g.reset().clearRect(X,Y,X+w-1,Y+h-1); s.draw(); Bangle.setUI("updown",dir=>{ if (dir) { s.scroll += dir; if (s.scroll<0) s.scroll = options.c-1; if (s.scroll>=options.c) s.scroll = 0; s.draw(); } else { options.select(s.scroll); } }); return s; })