From f2f500e474109e91b8f83d5d2e76ee79bb09c194 Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Fri, 29 Oct 2021 18:35:55 +0200 Subject: [PATCH 1/2] menusmall: add `wrap` option --- apps.json | 2 +- apps/menusmall/ChangeLog | 1 + apps/menusmall/boot.js | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps.json b/apps.json index edc70c8ee..ab56b2429 100644 --- a/apps.json +++ b/apps.json @@ -4059,7 +4059,7 @@ { "id": "menusmall", "name": "Small Menus", - "version": "0.01", + "version": "0.02", "description": "Replace Bangle.js 2's menus with a version that contains smaller text", "icon": "app.png", "type": "boot", diff --git a/apps/menusmall/ChangeLog b/apps/menusmall/ChangeLog index 5560f00bc..2f2e25462 100644 --- a/apps/menusmall/ChangeLog +++ b/apps/menusmall/ChangeLog @@ -1 +1,2 @@ 0.01: New App! +0.02: add `wrap` option \ No newline at end of file diff --git a/apps/menusmall/boot.js b/apps/menusmall/boot.js index 59e47b178..7ee3dfda1 100644 --- a/apps/menusmall/boot.js +++ b/apps/menusmall/boot.js @@ -100,8 +100,10 @@ E.showMenu = function(items) { if (l.selectEdit) { var item = l.selectEdit; item.value -= (dir||1)*(item.step||1); - if (item.min!==undefined && item.valueitem.max) item.value = item.max; + if (item.min!==undefined && item.valueitem.max) + item.value = (item.wrap && item.min!==undefined) ? item.min : item.max; if (item.onchange) item.onchange(item.value); l.draw(options.selected,options.selected); } else { From 310bf60ed76bd7e36380ca6725a12c4ad6dc2efd Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Fri, 29 Oct 2021 18:45:30 +0200 Subject: [PATCH 2/2] menusmall: use Bangle.appRect --- apps/menusmall/ChangeLog | 2 +- apps/menusmall/boot.js | 21 ++++++++------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/apps/menusmall/ChangeLog b/apps/menusmall/ChangeLog index 2f2e25462..6de3d41f4 100644 --- a/apps/menusmall/ChangeLog +++ b/apps/menusmall/ChangeLog @@ -1,2 +1,2 @@ 0.01: New App! -0.02: add `wrap` option \ No newline at end of file +0.02: add `wrap` option, use Bangle.appRect \ No newline at end of file diff --git a/apps/menusmall/boot.js b/apps/menusmall/boot.js index 7ee3dfda1..805413e2b 100644 --- a/apps/menusmall/boot.js +++ b/apps/menusmall/boot.js @@ -1,28 +1,23 @@ "";//not entirely sure why we need this - related to how bootupdate adds these to .boot0 E.showMenu = function(items) { - g.clear(1).flip(); // clear screen if no menu supplied - Bangle.drawWidgets(); + g.clearRect(Bangle.appRect); // clear screen if no menu supplied if (!items) { Bangle.setUI(); return; } - var w = g.getWidth(); - var h = g.getHeight(); + var menuItems = Object.keys(items); var options = items[""]; if (options) menuItems.splice(menuItems.indexOf(""),1); if (!(options instanceof Object)) options = {}; - options.fontHeight=14; - options.x=0; - options.x2=w-1; - options.y=24; - options.y2=h-12; + options.fontHeight = options.fontHeight|14; if (options.selected === undefined) options.selected = 0; - var x = 0|options.x; - var x2 = options.x2||(g.getWidth()-1); - var y = 0|options.y; - var y2 = options.y2||(g.getHeight()-1); + var ar = Bangle.appRect; + var x = ar.x; + var x2 = ar.x2; + var y = ar.y; + var y2 = ar.y2 - 11; // padding at end for arrow if (options.title) y += 15; var loc = require("locale");