From d912afbb9776d91736ab6f4caca5f91228593d1f Mon Sep 17 00:00:00 2001 From: thyttan <6uuxstm66@mozmail.comā©> Date: Sun, 18 Jun 2023 23:06:56 +0200 Subject: [PATCH] swscroll: pull in changes from showScroller_Q3 --- apps/swscroll/ChangeLog | 1 + apps/swscroll/boot.js | 38 +++++++++++++++++++++---------------- apps/swscroll/metadata.json | 2 +- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/apps/swscroll/ChangeLog b/apps/swscroll/ChangeLog index b35c27001..1adab01bb 100644 --- a/apps/swscroll/ChangeLog +++ b/apps/swscroll/ChangeLog @@ -1,4 +1,5 @@ 0.01: Inital release. 0.02: Rebasing on latest changes to showScroller_Q3 (https://github.com/espruino/Espruino/commit/2d3c34ef7c2b9fe2118e816aacd2e096adb99596). 0.03: Rebasing on latest changes to showScroller_Q3 (https://github.com/espruino/Espruino/commit/b6f8105b6348bb6f7cd03ac11efc1f3585c6ad79). Ensure that changing a menu item when half-scrolled off screen doesn't overwrite widgets. +0.04: Rebasing on latest changes to showScroller_Q3 (https://github.com/espruino/Espruino/commit/a0e2d9231df709849f81abf572a742b0fceab85b). Fixes missing `isActive` function that caused an error. diff --git a/apps/swscroll/boot.js b/apps/swscroll/boot.js index 57a5d8fb3..3c4b55817 100644 --- a/apps/swscroll/boot.js +++ b/apps/swscroll/boot.js @@ -10,12 +10,25 @@ E.showScroller = (function(options) { } returns { - draw = draw all - drawItem(idx) = draw specific item + scroll: int // current scroll amount + draw: function() // draw all + drawItem : function(idx) // draw specific item + isActive : function() // is this scroller still active? } + */ if (!options) return Bangle.setUI(); // remove existing handlers +var touchHandler = (_,e)=>{ + if (e.y=0) && i{ - if (e.y=0) && i { g.reset().clearRect(R.x,R.y,R.x2,R.y2); @@ -98,7 +103,8 @@ var s = { g.reset().setClipRect(R.x,Math.max(y,R.y),R.x2,Math.min(y+options.h,R.y2)); options.draw(i, {x:R.x,y:y,w:R.w,h:options.h}); g.setClipRect(0,0,g.getWidth()-1,g.getHeight()-1); -}}; + }, isActive : () => Bangle.touchHandler == touchHandler + }; var rScroll = s.scroll&~1; // rendered menu scroll (we only shift by 2 because of dither) s.draw(); // draw the full scroller g.flip(); // force an update now to make this snappier diff --git a/apps/swscroll/metadata.json b/apps/swscroll/metadata.json index eff55e4bd..3258b9b21 100644 --- a/apps/swscroll/metadata.json +++ b/apps/swscroll/metadata.json @@ -1,7 +1,7 @@ { "id": "swscroll", "name": "Swipe menus", - "version": "0.03", + "version": "0.04", "description": "Replace built in E.showScroller to act on swipe instead of drag. Navigate menus in discrete steps instead of a continuous motion.", "readme": "README.md", "icon": "app.png",