From 70d9e23b0c4b4d7fdb6432634adef78cfe8bb8fd Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Thu, 11 Apr 2019 20:03:36 +0200 Subject: [PATCH] Added shadow control. --- ui/shadow.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 ui/shadow.go diff --git a/ui/shadow.go b/ui/shadow.go new file mode 100644 index 0000000..6f0a1b6 --- /dev/null +++ b/ui/shadow.go @@ -0,0 +1,22 @@ +package ui + +import "opslag.de/schobers/geom" + +type shadow struct { + Proxy +} + +func Shadow(content Control) *shadow { + s := &shadow{} + s.Content = content + return s +} + +func (s *shadow) Render(ctx Context) { + s.Proxy.Render(ctx) + b := s.Bounds() + shadow := 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) +}