Propagate keyboard color changes properly

This commit is contained in:
Gabriel Tofvesson 2025-05-25 17:05:31 +02:00
parent 3282023edd
commit 4ba1932138
2 changed files with 20 additions and 2 deletions

View File

@ -12,6 +12,9 @@ local DEFAULT_PADDING_H = 1
local DEFAULT_PADDING_V = 1
local HANDLER_IGNORE_CLICK = function() return true end
local ID_KEY_LIST = "$Keyboard$List"
local ID_PADDED_KEY = "$Keyboard$List$Padding"
local Keyboard = Padding:new{
bgColor = DEFAULT_COLOR_BG,
keyColor = DEFAULT_COLOR_KEY,
@ -122,6 +125,7 @@ function Keyboard:setLayout(layout)
})
end
return List:new{
id = ID_KEY_LIST,
bgColor = this.colorBg,
[Orientation:getId()] = Orientation.HORIZONTAL,
[Children:getId()] = keysEntries
@ -135,7 +139,7 @@ function Keyboard:setLayout(layout)
end
self.element[Children:getId()] = keyboardLines
self.setDirty()
self:setDirty()
end
function Keyboard:setKeyColor(color)
@ -145,6 +149,19 @@ function Keyboard:setKeyColor(color)
end
end
function Keyboard:setDirty(fullInvalidate)
local keyList = self:findById(ID_KEY_LIST)
for _,key in pairs(keyList[Children:getId()]) do
if key:getId() == ID_PADDED_KEY then
key:setBgColor(self.bgColor)
key.element:setBgColor(self.keyColor)
else
key:setBgColor(self.keyColor)
end
end
Padding.setDirty(self, fullInvalidate)
end
local function layoutNumbers(layout)
table.insert(layout, 1, { "1234567890" })
return layout

View File

@ -7,6 +7,7 @@ end
function TextProgress:setProgress(progress)
self.progress = progress
self:setDirty()
end
function TextProgress:draw()