Fixed transparent boxes not redrawing sometimes
This commit is contained in:
		
							parent
							
								
									0c0b8ae475
								
							
						
					
					
						commit
						db2ed06daf
					
				| @ -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() | ||||
|  | ||||
		Reference in New Issue
	
	Block a user