Skip to content

Commit c1f78e9

Browse files
committed
Fixed title spacing, added btns.length check, removed unused offset
1 parent 20b5cce commit c1f78e9

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

guiComponents.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,23 +1239,21 @@ namespace microgui {
12391239
this.title = (opts.title != null) ? opts.title : "";
12401240
this.btns = (opts.btns != null) ? opts.btns : [];
12411241

1242-
const titleYOffset = (this.title != "") ? 13 : 0;
1243-
12441242
const btnXOffset = (this.btns.length > 0) ? (this.bounds.width / (this.btns.length + 1)) : 0;
12451243

1246-
const xBorder = this.bounds.width * 0.08;
1244+
const xBorder = this.bounds.width * 0.15;
12471245
const yBorder = this.bounds.height * 0.05;
12481246
const ySpacing = (this.bounds.height - yBorder) / (this.btns.length + 1);
12491247

12501248
for (let i = 0; i < this.btns.length; i++) {
12511249
this.btns[i].setPosition(
12521250
xBorder + this.bounds.left + this.bounds.width,
1253-
titleYOffset + ((i + 1) * ySpacing)
1251+
(i + 1) * ySpacing
12541252
);
12551253
this.btns[i].setSelected(false)
12561254
}
12571255

1258-
if (this.btns) {
1256+
if (this.btns.length > 0) {
12591257
this.selectedTextBtnIndex = 0
12601258
this.btns[this.selectedTextBtnIndex].setSelected(true)
12611259
}

0 commit comments

Comments
 (0)