Fixed transparent boxes not redrawing sometimes

This commit is contained in:
Sasha Koshka 2023-09-07 18:22:04 -04:00
parent 0c0b8ae475
commit db2ed06daf
2 changed files with 36 additions and 13 deletions

View File

@ -1,6 +1,7 @@
package x
import "image"
import "image/color"
import "git.tebibyte.media/tomo/tomo"
import "git.tebibyte.media/tomo/tomo/event"
import "git.tebibyte.media/tomo/tomo/canvas"
@ -29,6 +30,16 @@ func (backend *Backend) NewContainerBox() tomo.ContainerBox {
return this
}
func (this *containerBox) SetColor (c color.Color) {
this.box.SetColor(c)
this.invalidateTransparentChildren()
}
func (this *containerBox) SetTexture (texture canvas.Texture) {
this.box.SetTexture(texture)
this.invalidateTransparentChildren()
}
func (this *containerBox) SetOverflow (horizontal, vertical bool) {
if this.hOverflow == horizontal && this.vOverflow == vertical { return }
this.hOverflow = horizontal
@ -162,6 +173,17 @@ func (this *containerBox) drawBackgroundPart (can canvas.Canvas) {
pen.Rectangle(this.innerClippingBounds)
}
func (this *containerBox) invalidateTransparentChildren () {
window := this.window()
if this.window == nil { return }
for _, box := range this.children {
box := assertAnyBox(box)
if box.transparent() {
window.invalidateDraw(box)
}
}
}
func (this *containerBox) flushActionQueue () {
for _, box := range this.children {
box.(anyBox).flushActionQueue()

View File

@ -52,6 +52,7 @@ type anyBox interface {
recursiveRedo ()
canBeFocused () bool
boxUnder (image.Point) anyBox
transparent () bool
propagate (func (anyBox) bool) bool
propagateAlt (func (anyBox) bool) bool