Skip to content

Commit 016d7fa

Browse files
committed
Bangle.js2: showPrompt better alignment of text if no title, and add buttonHeight option
1 parent d0316c6 commit 016d7fa

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

ChangeLog

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
Storage: Ensure compaction removes any files with invalid file types
3636
Puck.js: v2.2 compatibility
3737
Graphics: stringMetrics (and so findFont) now doesn't set unrenderableChars for strings with a '\n' character
38+
Bangle.js2: showPrompt better alignment of text if no title, and add buttonHeight option
3839

3940
2v25 : ESP32C3: Get analogRead working correctly
4041
Graphics: Adjust image alignment when rotating images to avoid cropping (fix #2535)

libs/banglejs/jswrap_bangle.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -6071,7 +6071,7 @@ E.showMessage("Lots of text will wrap automatically",{
60716071
"return" : ["JsVar","A promise that is resolved when 'Ok' is pressed"],
60726072
"ifdef" : "BANGLEJS",
60736073
"typescript" : [
6074-
"showPrompt<T = boolean>(message: string, options?: { title?: string, buttons?: { [key: string]: T }, image?: string, remove?: () => void }): Promise<T>;",
6074+
"showPrompt<T = boolean>(message: string, options?: { title?: string, buttons?: { [key: string]: T }, buttonHeight?: number, image?: string, remove?: () => void }): Promise<T>;",
60756075
"showPrompt(): void;"
60766076
]
60776077
}
@@ -6112,7 +6112,8 @@ The second `options` argument can contain:
61126112
title: "Hello", // optional Title
61136113
buttons : {"Ok":true,"Cancel":false}, // optional list of button text & return value
61146114
img: "image_string" // optional image string to draw
6115-
remove: function() { } // Bangle.js: optional function to be called when the prompt is removed
6115+
remove: function() { } // Bangle.js: optional function to be called when the prompt is removed#
6116+
buttonHeight : 30, // Bangle.js2: optional height to force the buttons to be
61166117
}
61176118
```
61186119
*/

libs/js/banglejs/E_showPrompt_Q3.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
g.reset().setFontAlign(0,0);
1010
var R = Bangle.appRect, Y = R.y, W = R.w;
1111
var title = g.findFont(options.title||"", {w:W-2,wrap:1,max:24});
12-
if (title.text)
12+
if (title.text) {
1313
g.setColor(g.theme.fgH).setBgColor(g.theme.bgH).
1414
clearRect(0,Y,W-1,Y+4+title.h).
1515
drawString(title.text,W/2,Y+4+title.h/2);
16-
Y += title.h+4;
16+
Y += title.h+4;
17+
} else Y+=4;
1718
var BX = 0|"0123233"[btns.length],
1819
BY = Math.ceil(btns.length / BX),
19-
BW = (W-1)/BX, BH = (BY>1 || options.img)?40:50;
20+
BW = (W-1)/BX, BH = options.buttonHeight || ((BY>1 || options.img)?40:50);
2021
var H = R.y2-(Y + BY*BH);
2122
if (options.img) {
2223
var im = g.imageMetrics(options.img);

libs/js/banglejs/E_showPrompt_Q3.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)