From 0a6054baa63e63ac9cfdf32194c01c07eb47be81 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sun, 26 Dec 2021 20:52:13 -0800 Subject: [PATCH] TabFrame: SetTabsHidden Option SetTabsHidden(bool) can hide the tab row on a TabFrame, leaving only the content frames behind. This way the caller can provide the transition changes via SetTab and use the TabFrame only for its management features. --- tabframe.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tabframe.go b/tabframe.go index 6d3ee68..beb3f6f 100644 --- a/tabframe.go +++ b/tabframe.go @@ -108,6 +108,17 @@ func (w *TabFrame) AddTab(key string, child Widget) *Frame { return frame } +// SetTabsHidden can hide the tab buttons and reveal only their frames. +// It would be up to the caller to SetTab between the frames, using the +// TabFrame only for placement and tab handling. +func (w *TabFrame) SetTabsHidden(hidden bool) { + if hidden { + w.header.Hide() + } else { + w.header.Show() + } +} + // set the tab style between active and inactive func (w *TabFrame) setButtonStyle(button *Button, active bool) { var style = button.GetStyle() @@ -218,7 +229,7 @@ The tabs are simple Button widgets but drawn with no borders. Instead, borders are painted on post-hoc in the Present function. */ func (w *TabFrame) presentBorders(e render.Engine, P render.Point) { - if len(w.tabButtons) == 0 { + if len(w.tabButtons) == 0 || w.header.Hidden() { return }