From e8de7aa662fe94b5f94ffca61d81c4e784adf30c Mon Sep 17 00:00:00 2001 From: Richard de Boer Date: Mon, 17 Jan 2022 21:39:04 +0100 Subject: [PATCH] wid_edit: "highlight" hidden widgets when editing --- apps/wid_edit/settings.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/apps/wid_edit/settings.js b/apps/wid_edit/settings.js index 395eea100..0969ed533 100644 --- a/apps/wid_edit/settings.js +++ b/apps/wid_edit/settings.js @@ -65,10 +65,27 @@ * Draw highlighted widget */ function highlight() { - if (WIDGET.width) { + if (WIDGET.width > 0) { + // draw widget, then draw a highlighted border on top WIDGET.draw(); g.setColor(g.theme.fgH) .drawRect(WIDGET.x, WIDGET.y, WIDGET.x+WIDGET.width-1, WIDGET.y+23); + } else { + // hidden widget: fake a width and provide our own draw() + const draw = WIDGET.draw, width = WIDGET.width; + WIDGET.width = 24; + WIDGET.draw = function() { + g.setColor(g.theme.bgH).setColor(g.theme.fgH) + .clearRect(this.x, this.y, this.x+23, this.y+23) + .drawRect(this.x, this.y, this.x+23, this.y+23) + .drawLine(this.x, this.y, this.x+23, this.y+23) + .drawLine(this.x, this.y+23, this.x+23, this.y); + }; + // re-layout+draw all widgets with our placeholder in between + redrawWidgets(); + // and restore original values + WIDGET.draw = draw; + WIDGET.width = width; } } highlight(); @@ -108,12 +125,9 @@ const menu = { "": {"title": name(id)}, /*LANG*/"< Back": () => { - if (WIDGET.width) { - g.reset().clearRect(WIDGET.x, WIDGET.y, WIDGET.x+WIDGET.width-1, WIDGET.y+23); - WIDGET.draw(); - } + redrawWidgets(); mainMenu(); - }, + }, /*LANG*/"Side": { value: (area === 'tl'), format: tl => tl ? /*LANG*/"Left" : /*LANG*/"Right",