diff --git a/apps/promenu/ChangeLog b/apps/promenu/ChangeLog index 4a0f538fb..e04c93bbd 100644 --- a/apps/promenu/ChangeLog +++ b/apps/promenu/ChangeLog @@ -14,3 +14,4 @@ 0.10: Trigger `remove` callbacks when ending the menu 0.11: Add options for natural scroll and disabling wrap-around 0.12: Fix bug where settings would behave as if all were set to false +0.13: Fix bug in handling changes to `Bangle.appRect` diff --git a/apps/promenu/bootb2.js b/apps/promenu/bootb2.js index d11beb48c..fceb0906e 100644 --- a/apps/promenu/bootb2.js +++ b/apps/promenu/bootb2.js @@ -20,14 +20,7 @@ E.showMenu = function (items) { var menuItems = Object.keys(items).filter(function (x) { return x.length; }); var fontHeight = options.fontHeight || 25; var selected = options.scroll || options.selected || 0; - var ar = Bangle.appRect; - g.reset().clearRect(ar); - var x = ar.x; - var x2 = ar.x2; - var y = ar.y; - var y2 = ar.y2 - 12; - if (options.title) - y += 22; + g.reset().clearRect(Bangle.appRect); var lastIdx = 0; var selectEdit = undefined; var scroller = { @@ -36,6 +29,7 @@ E.showMenu = function (items) { var nameScroller = null; var drawLine = function (name, v, item, idx, x, y, nameScroll) { if (nameScroll === void 0) { nameScroll = 0; } + var x2 = Bangle.appRect.x2; var hl = (idx === selected && !selectEdit); if (g.theme.dark) { fillRectRnd(x, y, x2, y + fontHeight - 3, 7, hl ? g.theme.bgH : g.theme.bg + 40); @@ -74,6 +68,12 @@ E.showMenu = function (items) { }; var l = { draw: function (rowmin, rowmax) { + var _a = Bangle.appRect, x = _a.x, x2 = _a.x2, y = _a.y, y2 = _a.y2; + if (y === 0) + y = 24; + if (options.title) + y += 22; + y2 -= 12; if (nameScroller) clearInterval(nameScroller), nameScroller = null; var rows = 0 | Math.min((y2 - y) / fontHeight, menuItems.length); diff --git a/apps/promenu/bootb2.ts b/apps/promenu/bootb2.ts index e128151e3..2719f92f8 100644 --- a/apps/promenu/bootb2.ts +++ b/apps/promenu/bootb2.ts @@ -34,15 +34,7 @@ E.showMenu = (items?: Menu): MenuInstance => { let selected = options.scroll || options.selected || 0; - const ar = Bangle.appRect; - g.reset().clearRect(ar); - - const x = ar.x; - const x2 = ar.x2; - let y = ar.y; - const y2 = ar.y2 - 12; // padding at end for arrow - if (options.title) - y += 22; + g.reset().clearRect(Bangle.appRect); let lastIdx = 0; let selectEdit: undefined | ActualMenuItem = undefined; @@ -61,6 +53,7 @@ E.showMenu = (items?: Menu): MenuInstance => { y: number, nameScroll: number = 0, ) => { + const { x2 } = Bangle.appRect; const hl = (idx === selected && !selectEdit); if(g.theme.dark){ fillRectRnd(x, y, x2, y + fontHeight - 3, 7, hl ? g.theme.bgH : g.theme.bg + 40); @@ -114,6 +107,13 @@ E.showMenu = (items?: Menu): MenuInstance => { const l = { draw: (rowmin?: number, rowmax?: number) => { + // always refresh appRect, a back button may have appeared + let { x, x2, y, y2 } = Bangle.appRect; + if(y === 0) y = 24; // always bump down for widgets/back button + + if (options.title) y += 22; + y2 -= 12; // padding at end for arrow + if (nameScroller) clearInterval(nameScroller), nameScroller = null; let rows = 0|Math.min((y2 - y) / fontHeight, menuItems.length); let idx = E.clip(selected - (rows>>1), 0, menuItems.length - rows); diff --git a/apps/promenu/metadata.json b/apps/promenu/metadata.json index 05583e1fd..9b0ba2121 100644 --- a/apps/promenu/metadata.json +++ b/apps/promenu/metadata.json @@ -1,7 +1,7 @@ { "id": "promenu", "name": "Pro Menu", - "version": "0.12", + "version": "0.13", "description": "Replace the built in menu function. Supports Bangle.js 1 and Bangle.js 2.", "icon": "icon.png", "type": "bootloader",