aboutsummaryrefslogtreecommitdiffstats
path: root/gui/layout
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-05-09 17:32:54 -0400
committerSam Anthony <sam@samanthony.xyz>2024-05-09 17:32:54 -0400
commitd463bb90ad629dfc8f1cd4f4b6b9590b0008832d (patch)
treebf8763649c6a2f1af1fe46821216e327c094dcfa /gui/layout
parent76980fe3014b5c133c4e30590e92bd922aa9b9c1 (diff)
downloadvolute-d463bb90ad629dfc8f1cd4f4b6b9590b0008832d.zip
tree widget
Diffstat (limited to 'gui/layout')
-rw-r--r--gui/layout/split.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/gui/layout/split.go b/gui/layout/split.go
index db04225..455d74b 100644
--- a/gui/layout/split.go
+++ b/gui/layout/split.go
@@ -1,6 +1,10 @@
package layout
-import "fmt"
+import (
+ "fmt"
+
+ "volute/gui/text"
+)
// SplitFunc represents a way to split a space among a number of elements.
// The length of the returned slice must be equal to the number of elements.
@@ -24,3 +28,13 @@ func EvenSplit(elements int, width int) []int {
}
return ret
}
+
+func TextRowSplit(elements int, space int) []int {
+ bounds := make([]int, elements)
+ height := text.Size("1").Y
+ for i := 0; i < elements && space > 0; i++ {
+ bounds[i] = min(height, space)
+ space -= bounds[i]
+ }
+ return bounds
+}