From 7b8ee449c0f0b753cb45e4df33a963b9f6fd0fbf Mon Sep 17 00:00:00 2001 From: AR2000AR Date: Fri, 11 Aug 2023 23:10:00 +0200 Subject: [PATCH] [yawl] made color selection code more readable --- yawl/lib/yawl/widget/Button.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/yawl/lib/yawl/widget/Button.lua b/yawl/lib/yawl/widget/Button.lua index dc17528..69000bd 100644 --- a/yawl/lib/yawl/widget/Button.lua +++ b/yawl/lib/yawl/widget/Button.lua @@ -16,7 +16,11 @@ function Button:draw() if self:resetTime() > 0 and self:state() and (computer.uptime() - self._pressed) > self:resetTime() then self:state(false) end - local newBG = self:state() and (self:foregroundColor() or 0xffffff - self:backgroundColor()) or self:backgroundColor() + local newBG = self:backgroundColor() + if (not self:state()) then + --set to the foreground color. if there is none, invert the current color + newBG = self:foregroundColor() or (0xffffff - self:backgroundColor()) + end local oldBG = gpu.setBackground(newBG) gpu.fill(self:absX(), self:absY(), self:width(), self:height(), " ") gpu.setBackground(oldBG)