Add Visible, SetVisible to Box

This commit is contained in:
Sasha Koshka 2024-05-26 15:14:40 -04:00
parent a5830c9823
commit 8b44526c94
1 changed files with 19 additions and 3 deletions

22
box.go
View File

@ -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()
}