From d463bb90ad629dfc8f1cd4f4b6b9590b0008832d Mon Sep 17 00:00:00 2001 From: Sam Anthony Date: Thu, 9 May 2024 17:32:54 -0400 Subject: tree widget --- gui/layout/split.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'gui/layout/split.go') 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 +} -- cgit v1.2.3