Child draw bounds are properly clipped
This commit is contained in:
parent
0bf5c3b86c
commit
785cc2d908
@ -52,6 +52,7 @@ func (ent *entity) unlink () {
|
||||
|
||||
func (entity *entity) link (parent *entity) {
|
||||
entity.parent = parent
|
||||
entity.clip(parent.clippedBounds)
|
||||
if parent.window != nil {
|
||||
entity.setWindow(parent.window)
|
||||
}
|
||||
@ -110,6 +111,13 @@ func (entity *entity) forMouseTargetContainers (callback func (tomo.MouseTargetC
|
||||
entity.parent.forMouseTargetContainers(callback)
|
||||
}
|
||||
|
||||
func (entity *entity) clip (bounds image.Rectangle) {
|
||||
entity.clippedBounds = entity.bounds.Intersect(bounds)
|
||||
for _, child := range entity.children {
|
||||
child.clip(entity.clippedBounds)
|
||||
}
|
||||
}
|
||||
|
||||
// ----------- Entity ----------- //
|
||||
|
||||
func (entity *entity) Invalidate () {
|
||||
@ -204,7 +212,7 @@ func (entity *entity) CountChildren () int {
|
||||
func (entity *entity) PlaceChild (index int, bounds image.Rectangle) {
|
||||
child := entity.children[index]
|
||||
child.bounds = bounds
|
||||
child.clippedBounds = entity.bounds.Intersect(bounds)
|
||||
child.clip(entity.clippedBounds)
|
||||
child.Invalidate()
|
||||
child.InvalidateLayout()
|
||||
}
|
||||
|
@ -170,6 +170,7 @@ func (system *system) draw () {
|
||||
defer func () { system.invalidateIgnore = false } ()
|
||||
|
||||
for entity := range system.drawingInvalid {
|
||||
if entity.clippedBounds.Empty() { continue }
|
||||
entity.element.Draw (canvas.Cut (
|
||||
system.canvas,
|
||||
entity.clippedBounds))
|
||||
|
Reference in New Issue
Block a user