aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-01-19 22:43:07 -0500
committerSam Anthony <sam@samanthony.xyz>2024-01-19 22:43:07 -0500
commit95944c92c6d9171e3a8a2619e62bbfa29d48bfef (patch)
treee48c3bf421d69ef48ea9dade43f86ff9dc30e05b /main.go
parent5d107e1443baa6762bbb30b62de68a25c011cf79 (diff)
downloadvolute-95944c92c6d9171e3a8a2619e62bbfa29d48bfef.zip
refine widget screen space allocation
Diffstat (limited to 'main.go')
-rw-r--r--main.go27
1 files changed, 25 insertions, 2 deletions
diff --git a/main.go b/main.go
index f1bf3b4..9c16af1 100644
--- a/main.go
+++ b/main.go
@@ -38,8 +38,8 @@ func run() {
Rows: []int{2, 8, 8},
Background: color.Gray{255},
Gap: 1,
- Split: layout.EvenSplit,
- SplitRows: layout.EvenSplit,
+ Split: split,
+ SplitRows: splitRows,
Margin: 0,
Border: 0,
BorderColor: color.Gray{16},
@@ -97,6 +97,29 @@ Loop:
}
}
+func split(elements int, space int) []int {
+ bounds := make([]int, elements)
+ widths := []int{
+ widget.TextSize("displacement (cc)").X,
+ widget.TextSize("123456").X,
+ }
+ for i := 0; i < elements && space > 0; i++ {
+ bounds[i] = min(widths[min(i, len(widths)-1)], space)
+ space -= bounds[i]
+ }
+ return bounds
+}
+
+func splitRows(elements int, space int) []int {
+ bounds := make([]int, elements)
+ height := widget.TextSize("1").Y
+ for i := 0; i < elements && space > 0; i++ {
+ bounds[i] = min(height, space)
+ space -= bounds[i]
+ }
+ return bounds
+}
+
func main() {
mainthread.Run(run)
}