From 398a6c2f773ae39d830456a92b25d79797181c06 Mon Sep 17 00:00:00 2001 From: Oliver <480930+rivo@users.noreply.github.com> Date: Thu, 7 Jun 2018 14:19:25 +0200 Subject: [PATCH] Added a function to resize a Flex item. Resolves #125 --- flex.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/flex.go b/flex.go index 5238f5b..e5bf5e0 100644 --- a/flex.go +++ b/flex.go @@ -101,6 +101,19 @@ func (f *Flex) RemoveItem(p Primitive) *Flex { return f } +// ResizeItem sets a new size for the item(s) with the given primitive. If there +// are multiple Flex items with the same primitive, they will all receive the +// same size. For details regarding the size parameters, see AddItem(). +func (f *Flex) ResizeItem(p Primitive, fixedSize, proportion int) *Flex { + for _, item := range f.items { + if item.Item == p { + item.FixedSize = fixedSize + item.Proportion = proportion + } + } + return f +} + // Draw draws this primitive onto the screen. func (f *Flex) Draw(screen tcell.Screen) { f.Box.Draw(screen)