mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
3 lines
1.2 KiB
JavaScript
3 lines
1.2 KiB
JavaScript
(function(d){function m(b){return b*d.h+a.y-h}function k(b){return Math.floor((b+h-a.y)/d.h)}if(!d)return Bangle.setUI();var a=Bangle.appRect,f=0|d.scrollMin,l=d.h*d.c-a.h;l<f&&(l=f);var e={scroll:E.clip(0|d.scroll,f,l),draw:()=>{g.reset().clearRect(a.x,a.y,a.x2,a.y2);g.setClipRect(a.x,a.y,a.x2,a.y2);for(var b=k(a.y),c=Math.min(k(a.y2),d.c-1);b<=c;b++)d.draw(b,{x:a.x,y:m(b),w:a.w,h:d.h});g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1)},drawItem:b=>{var c=m(b);g.reset().setClipRect(a.x,
|
|
c,a.x2,c+d.h);d.draw(b,{x:a.x,y:c,w:a.w,h:d.h});g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1)}},h=e.scroll&-2;e.draw();g.flip();Bangle.setUI({mode:"custom",back:d.back,drag:b=>{var c=b.dy;e.scroll-c>l&&(c=e.scroll-l);e.scroll-c<f&&(c=e.scroll-f);e.scroll-=c;c=h;h=e.scroll&-2;if(c-=h){g.reset().setClipRect(a.x,a.y,a.x2,a.y2);g.scroll(0,c);b=b.dy;if(0>b)for(g.setClipRect(a.x,a.y2-(1-b),a.x2,a.y2),b=k(a.y2-(1-b)),c=m(b);c<a.y2;)d.draw(b,{x:a.x,y:c,w:a.w,h:d.h}),b++,c+=d.h;else for(g.setClipRect(a.x,
|
|
a.y,a.x2,a.y+b),b=k(a.y+b),c=m(b);c>a.y-d.h;)d.draw(b,{x:a.x,y:c,w:a.w,h:d.h}),c-=d.h,b--;g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1)}},touch:(b,c)=>{c.y<a.y-4||(b=k(c.y),(0>f||0<=b)&&b<d.c&&d.select(b))}});return e}) |