2020-05-11 09:44:50 +00:00
|
|
|
package tins2020
|
|
|
|
|
|
|
|
import "github.com/veandco/go-sdl2/sdl"
|
|
|
|
|
|
|
|
var _ Control = &Proxy{}
|
|
|
|
|
|
|
|
type Proxy struct {
|
|
|
|
Proxied Control
|
2020-05-12 07:11:27 +00:00
|
|
|
|
|
|
|
bounds Rectangle
|
2020-05-11 09:44:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Proxy) Arrange(ctx *Context, bounds Rectangle) {
|
2020-05-12 07:11:27 +00:00
|
|
|
p.bounds = bounds
|
2020-05-11 09:44:50 +00:00
|
|
|
if p.Proxied == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
p.Proxied.Arrange(ctx, bounds)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Proxy) Handle(ctx *Context, event sdl.Event) bool {
|
|
|
|
if p.Proxied == nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return p.Proxied.Handle(ctx, event)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Proxy) Init(ctx *Context) error {
|
|
|
|
if p.Proxied == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return p.Proxied.Init(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Proxy) Render(ctx *Context) {
|
|
|
|
if p.Proxied == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
p.Proxied.Render(ctx)
|
|
|
|
}
|
2020-05-12 07:11:27 +00:00
|
|
|
|
|
|
|
func (p *Proxy) SetContent(ctx *Context, content Control) {
|
|
|
|
p.Proxied = content
|
|
|
|
if content == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
content.Arrange(ctx, p.bounds)
|
|
|
|
}
|