Don't paint invisible background-colored rounded corners (#7046)

* Don't paint invisible background-colored rounded corners

Made obvious when testing #7042

* Only enforce a highlight radius on buttons that don't already set a
custom one ;).

(Mostly, square buttons with a 0 radius ^^).

ffi/blitbuffer already handles radius being nil, which suits us just fine
:)
reviewable/pr7048/r1
NiLuJe 3 years ago committed by GitHub
parent 7bc8ed87d0
commit 21af9144ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -44,7 +44,7 @@ local Button = InputContainer:new{
margin = 0,
bordersize = Size.border.button,
background = Blitbuffer.COLOR_WHITE,
radius = Size.radius.button,
radius = nil,
padding = Size.padding.button,
padding_h = nil,
padding_v = nil,
@ -233,6 +233,11 @@ function Button:onTapSelectButton()
-- c.f., #4554 & #4541
-- NOTE: self[1] -> self.frame, if you're confused about what this does vs. onFocus/onUnfocus ;).
if self.text then
-- We only want the button's *highlight* to have rounded corners (otherwise they're redundant, same color as the bg).
-- The nil check is to discriminate the default from callers that explicitly request a specific radius.
if self[1].radius == nil then
self[1].radius = Size.radius.button
end
UIManager:widgetRepaint(self[1], self[1].dimen.x, self[1].dimen.y)
end
UIManager:setDirty(nil, function()
@ -245,11 +250,13 @@ function Button:onTapSelectButton()
-- widget no more there (destroyed, re-init'ed by setText(), or not inverted: nothing to invert back
return
end
self[1].invert = false
UIManager:widgetRepaint(self[1], self[1].dimen.x, self[1].dimen.y)
if self.text then
UIManager:widgetRepaint(self[1], self[1].dimen.x, self[1].dimen.y)
-- Since we kill the corners, we only need a single repaint.
if self[1].radius == Size.radius.button then
self[1].radius = nil
end
UIManager:widgetRepaint(self[1], self[1].dimen.x, self[1].dimen.y)
UIManager:setDirty(nil, function()
return "fast", self[1].dimen
end)

@ -28,7 +28,7 @@ local FrameContainer = WidgetContainer:new{
background = nil,
color = Blitbuffer.COLOR_BLACK,
margin = 0,
radius = 0,
radius = nil,
inner_bordersize = 0,
bordersize = Size.border.window,
padding = Size.padding.default,

Loading…
Cancel
Save