Fix setting contrast on non-touch devices (#4219)

pull/4232/head
Robert 6 years ago committed by poire-z
parent a706fde2d7
commit eed3a4b5a2

@ -83,7 +83,7 @@ function Button:init()
} }
} }
if self.preselect then if self.preselect then
self:onFocus() self.frame.invert = true
end end
self.dimen = self.frame:getSize() self.dimen = self.frame:getSize()
self[1] = self.frame self[1] = self.frame
@ -120,11 +120,13 @@ function Button:setIcon(icon)
end end
function Button:onFocus() function Button:onFocus()
if self.no_focus then return end
self.frame.invert = true self.frame.invert = true
return true return true
end end
function Button:onUnfocus() function Button:onUnfocus()
if self.no_focus then return end
self.frame.invert = false self.frame.invert = false
return true return true
end end

@ -28,8 +28,6 @@ function ButtonProgressWidget:init()
bordersize = 0, bordersize = 0,
padding = Size.padding.small, padding = Size.padding.small,
dim = not self.enabled, dim = not self.enabled,
width = self.width,
height = self.height,
} }
self.buttonprogress_content = HorizontalGroup:new{} self.buttonprogress_content = HorizontalGroup:new{}
@ -68,6 +66,7 @@ function ButtonProgressWidget:update()
self.position = i self.position = i
self:update() self:update()
end, end,
no_focus = true,
hold_callback = function() hold_callback = function()
self.hold_callback(i) self.hold_callback(i)
end, end,
@ -85,4 +84,31 @@ function ButtonProgressWidget:setPosition(position)
self:update() self:update()
end end
function ButtonProgressWidget:onFocus()
self.buttonprogress_frame.background = Blitbuffer.COLOR_BLACK
return true
end
function ButtonProgressWidget:onUnfocus()
self.buttonprogress_frame.background = Blitbuffer.COLOR_WHITE
return true
end
function ButtonProgressWidget:onTapSelect(arg, gev)
if gev == nil then
self:circlePosition()
end
end
function ButtonProgressWidget:circlePosition()
if self.position then
self.position = self.position+1
if self.position > self.num_buttons then
self.position = 1
end
self.callback(self.position)
self:update()
end
end
return ButtonProgressWidget return ButtonProgressWidget

Loading…
Cancel
Save