ecs #15
@ -52,6 +52,7 @@ func (ent *entity) unlink () {
|
|||||||
|
|
||||||
func (entity *entity) link (parent *entity) {
|
func (entity *entity) link (parent *entity) {
|
||||||
entity.parent = parent
|
entity.parent = parent
|
||||||
|
entity.clip(parent.clippedBounds)
|
||||||
if parent.window != nil {
|
if parent.window != nil {
|
||||||
entity.setWindow(parent.window)
|
entity.setWindow(parent.window)
|
||||||
}
|
}
|
||||||
@ -110,6 +111,13 @@ func (entity *entity) forMouseTargetContainers (callback func (tomo.MouseTargetC
|
|||||||
entity.parent.forMouseTargetContainers(callback)
|
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 ----------- //
|
// ----------- Entity ----------- //
|
||||||
|
|
||||||
func (entity *entity) Invalidate () {
|
func (entity *entity) Invalidate () {
|
||||||
@ -204,7 +212,7 @@ func (entity *entity) CountChildren () int {
|
|||||||
func (entity *entity) PlaceChild (index int, bounds image.Rectangle) {
|
func (entity *entity) PlaceChild (index int, bounds image.Rectangle) {
|
||||||
child := entity.children[index]
|
child := entity.children[index]
|
||||||
child.bounds = bounds
|
child.bounds = bounds
|
||||||
child.clippedBounds = entity.bounds.Intersect(bounds)
|
child.clip(entity.clippedBounds)
|
||||||
child.Invalidate()
|
child.Invalidate()
|
||||||
child.InvalidateLayout()
|
child.InvalidateLayout()
|
||||||
}
|
}
|
||||||
|
@ -170,6 +170,7 @@ func (system *system) draw () {
|
|||||||
defer func () { system.invalidateIgnore = false } ()
|
defer func () { system.invalidateIgnore = false } ()
|
||||||
|
|
||||||
for entity := range system.drawingInvalid {
|
for entity := range system.drawingInvalid {
|
||||||
|
if entity.clippedBounds.Empty() { continue }
|
||||||
entity.element.Draw (canvas.Cut (
|
entity.element.Draw (canvas.Cut (
|
||||||
system.canvas,
|
system.canvas,
|
||||||
entity.clippedBounds))
|
entity.clippedBounds))
|
||||||
|
Reference in New Issue
Block a user