Moved Shadow and added Background control.

This commit is contained in:
Sander Schobers 2019-04-11 22:33:31 +02:00
parent 6bcab622ae
commit 8d78083583

View File

@ -1,9 +1,27 @@
package ui package ui
import "opslag.de/schobers/geom" import (
"image/color"
type shadow struct { "opslag.de/schobers/geom"
)
func Background(content Control, c color.Color) Control {
return &background{Proxy: Proxy{Content: content}, Background: c}
}
type background struct {
Proxy Proxy
Background color.Color
}
func (b *background) Render(ctx Context) {
bounds := b.Proxy.Bounds()
if b.Background != nil {
ctx.Renderer().FillRectangle(bounds, b.Background)
}
b.Proxy.Render(ctx)
} }
func Shadow(content Control) *shadow { func Shadow(content Control) *shadow {
@ -12,6 +30,10 @@ func Shadow(content Control) *shadow {
return s return s
} }
type shadow struct {
Proxy
}
func (s *shadow) Render(ctx Context) { func (s *shadow) Render(ctx Context) {
s.Proxy.Render(ctx) s.Proxy.Render(ctx)
b := s.Bounds() b := s.Bounds()