zntg/ui/visual.go
Sander Schobers 3591e22c97 Added Fonts() to context similarly as Textures().
- Fonts are now managed by context instead of the implementation specific renderers.
2020-05-15 15:42:24 +02:00

46 lines
973 B
Go

package ui
import (
"image/color"
"opslag.de/schobers/geom"
"opslag.de/schobers/zntg"
)
func Background(content Control, c color.Color) Control {
return &background{Proxy: Proxy{Content: content}, Background: c}
}
type background struct {
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 {
s := &shadow{}
s.Content = content
return s
}
type shadow struct {
Proxy
}
func (s *shadow) Render(ctx Context) {
s.Proxy.Render(ctx)
b := s.Bounds()
shadow := zntg.RGBA(0xBD, 0xBD, 0xBD, 0x2F)
ctx.Renderer().FillRectangle(geom.RectF32(b.Min.X, b.Min.Y, b.Max.X, b.Min.Y+3), shadow)
ctx.Renderer().FillRectangle(geom.RectF32(b.Min.X, b.Min.Y, b.Max.X, b.Min.Y+2), shadow)
ctx.Renderer().FillRectangle(geom.RectF32(b.Min.X, b.Min.Y, b.Max.X, b.Min.Y+1), shadow)
}