From 8b44526c940b458c041f0c8ef4791e61aca9d9ad Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sun, 26 May 2024 15:14:40 -0400 Subject: [PATCH] Add Visible, SetVisible to Box --- box.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/box.go b/box.go index f96daca..e2f9d56 100644 --- a/box.go +++ b/box.go @@ -19,6 +19,7 @@ type box struct { parent parent outer anyBox + visible bool bounds image.Rectangle minSize image.Point userMinSize image.Point @@ -174,6 +175,16 @@ func (this *box) SetPadding (padding tomo.Inset) { this.invalidateMinimum() } +func (this *box) SetVisible (visible bool) { + if this.visible == visible { return } + this.visible = visible + this.invalidateMinimum() +} + +func (this *box) Visible () bool { + return this.visible +} + func (this *box) SetDNDData (dat data.Data) { this.dndData = dat } @@ -460,12 +471,12 @@ func (this *box) recursiveRedo () { func (this *box) invalidateLayout () { if this.parent == nil || this.parent.window() == nil { return } - this.parent.window().invalidateLayout(this.outer) + this.window().invalidateLayout(this.outer) } func (this *box) invalidateDraw () { if this.parent == nil || this.parent.window() == nil { return } - this.parent.window().invalidateDraw(this.outer) + this.window().invalidateDraw(this.outer) } func (this *box) invalidateMinimum () { @@ -473,7 +484,7 @@ func (this *box) invalidateMinimum () { this.minSizeQueued = true return } - this.parent.window().invalidateMinimum(this.outer) + this.window().invalidateMinimum(this.outer) } func (this *box) canBeFocused () bool { @@ -500,3 +511,8 @@ func (this *box) transparent () bool { return transparent(this.color) && (this.texture == nil || !this.texture.Opaque()) } + +func (this *box) window () *window { + if this.parent == nil { return nil } + return this.parent.window() +}