aboutsummaryrefslogtreecommitdiffstats
path: root/gui/layout
diff options
context:
space:
mode:
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
+}