From 310bf60ed76bd7e36380ca6725a12c4ad6dc2efd Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Fri, 29 Oct 2021 18:45:30 +0200 Subject: [PATCH] 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");