From 8d780835834a81bf51334728cec8e0fe60a9c25a Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Thu, 11 Apr 2019 22:33:31 +0200 Subject: [PATCH] Moved Shadow and added Background control. --- ui/{shadow.go => visual.go} | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) rename ui/{shadow.go => visual.go} (55%) diff --git a/ui/shadow.go b/ui/visual.go similarity index 55% rename from ui/shadow.go rename to ui/visual.go index 6f0a1b6..afe3b87 100644 --- a/ui/shadow.go +++ b/ui/visual.go @@ -1,9 +1,27 @@ 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 + + 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 { @@ -12,6 +30,10 @@ func Shadow(content Control) *shadow { return s } +type shadow struct { + Proxy +} + func (s *shadow) Render(ctx Context) { s.Proxy.Render(ctx) b := s.Bounds()