From 1cd92ed32e5c1bb0b7bd1f4217cb1428bacd218b Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sun, 14 Aug 2022 16:11:44 +0200 Subject: [PATCH] Add background_color attribute to exec display elements Signed-off-by: Knut Ahlers --- cmd/streamdeck/display_exec.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/streamdeck/display_exec.go b/cmd/streamdeck/display_exec.go index 21440e1..dc8cc44 100644 --- a/cmd/streamdeck/display_exec.go +++ b/cmd/streamdeck/display_exec.go @@ -62,6 +62,19 @@ func (d displayElementExec) Display(ctx context.Context, idx int, attributes att } // Initialize background + if attributes.BackgroundColor != nil { + if len(attributes.BackgroundColor) != 4 { + return errors.New("Background color definition needs 4 hex values") + } + + if err := ctx.Err(); err != nil { + // Page context was cancelled, do not draw + return err + } + + imgRenderer.DrawBackgroundColor(attributes.BackgroundToColor()) + } + if attributes.Image != "" { if err = imgRenderer.DrawBackgroundFromFile(attributes.Image); err != nil { return errors.Wrap(err, "Unable to draw background from disk")