diff --git a/size.go b/size.go index 15b0c75..ef69fa7 100644 --- a/size.go +++ b/size.go @@ -12,11 +12,17 @@ func (tk *guiWidget) Size() (int, int) { return 0, 0 } + // don't count hidden widgets in size calculations + if tk.hidden { + return 0, 0 + } + switch tk.WidgetType { case widget.Window: var maxH int = 0 var maxW int = 0 for _, child := range tk.children { + if tk.hidden { continue } sizeW, sizeH := child.Size() maxW += sizeW if sizeH > maxH { @@ -35,6 +41,7 @@ func (tk *guiWidget) Size() (int, int) { maxH := tk.gocuiSize.Height() for _, child := range tk.children { + if tk.hidden { continue } sizeW, sizeH := child.Size() // increment straight down @@ -52,9 +59,11 @@ func (tk *guiWidget) Size() (int, int) { } func (w *guiWidget) sizeGrid() (int, int) { + if w.hidden { return 0, 0 } // first compute the max sizes of the rows and columns for _, child := range w.children { + if w.hidden { continue } sizeW, sizeH := child.Size() // set the child's realWidth, and grid offset @@ -78,14 +87,16 @@ func (w *guiWidget) sizeGrid() (int, int) { return totalW + me.GridPadW, totalH } -func (tk *guiWidget) sizeBox() (int, int) { - if tk.WidgetType != widget.Box { +func (w *guiWidget) sizeBox() (int, int) { + if w.WidgetType != widget.Box { return 0, 0 } + if w.hidden { return 0, 0 } var maxW int = 0 var maxH int = 0 - for _, child := range tk.children { + for _, child := range w.children { + if w.hidden {continue} sizeW, sizeH := child.Size() if child.direction == widget.Horizontal { maxW += sizeW