From 207dd250415a41c3d27ea57674bba14d4a479b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gergely=20B=C3=B3di?= Date: Sat, 28 Jan 2023 19:55:04 +0100 Subject: [PATCH] add flex.ResizeItemAt --- flex.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/flex.go b/flex.go index 469a0e3..37077f9 100644 --- a/flex.go +++ b/flex.go @@ -49,7 +49,7 @@ type Flex struct { // background before any items are drawn, set it to a box with the desired // color: // -// flex.Box = NewBox() +// flex.Box = NewBox() func NewFlex() *Flex { f := &Flex{ direction: FlexColumn, @@ -137,6 +137,15 @@ func (f *Flex) ResizeItem(p Primitive, fixedSize, proportion int) *Flex { return f } +// ResizeItemAt sets a new size for the item ath the given index. +// For details regarding the size parameters, see AddItem(). +func (f *Flex) ResizeItemAt(index int, fixedSize, proportion int) *Flex { + item := f.items[index] + item.FixedSize = fixedSize + item.Proportion = proportion + return f +} + // Draw draws this primitive onto the screen. func (f *Flex) Draw(screen tcell.Screen) { f.Box.DrawForSubclass(screen, f)