diff options
| author | Jeff Carr <[email protected]> | 2024-01-30 02:54:37 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-30 02:54:37 -0600 |
| commit | ab1c90e93e05c07641696e1cce93943f8e3a57f9 (patch) | |
| tree | b2da1f89cef0670220a4ce99c5875cd36f13803c | |
| parent | 4f19c8b64df77d204dfd0fab462f99f4ef5009b7 (diff) | |
sizes shouldn't include hidden widgets
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | size.go | 17 |
1 files changed, 14 insertions, 3 deletions
@@ -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 |
