Skip to content

Commit

Permalink
Merge pull request #11498 from zwim/optimize_rounded
Browse files Browse the repository at this point in the history
UI: optimize and anti-alias rounded rectangles
  • Loading branch information
zwim committed Mar 8, 2024
2 parents dd8560c + 58b3367 commit c8f39c3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion base
Submodule base updated 3 files
+421 −40 blitbuffer.c
+1 −1 blitbuffer.h
+6 −5 ffi/blitbuffer.lua
9 changes: 9 additions & 0 deletions frontend/apps/filemanager/filemanagermenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,15 @@ To:
end,
})
end
table.insert(self.menu_items.developer_options.sub_item_table, {
text = _("Anti-alias rounded corners"),
checked_func = function()
return G_reader_settings:nilOrTrue("anti_alias_ui")
end,
callback = function()
G_reader_settings:flipNilOrTrue("anti_alias_ui")
end,
})
--- @note: Currently, only Kobo implements this quirk
if Device:hasEinkScreen() and Device:isKobo() then
table.insert(self.menu_items.developer_options.sub_item_table, {
Expand Down
18 changes: 12 additions & 6 deletions frontend/ui/widget/container/framecontainer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function FrameContainer:paintTo(bb, x, y)
if not self.dimen then
self.dimen = Geom:new{
x = x, y = y,
w = my_size.w, h = my_size.h
w = my_size.w, h = my_size.h,
}
else
self.dimen.x = x
Expand All @@ -110,11 +110,16 @@ function FrameContainer:paintTo(bb, x, y)
shift_x = container_width - my_size.w
end

--- @todo get rid of margin here? 13.03 2013 (houqp)
if self.background then
bb:paintRoundedRect(x, y,
container_width, container_height,
self.background, self.radius)
if not self.radius or not self.bordersize then
bb:paintRoundedRect(x, y,
container_width, container_height,
self.background, self.radius)
else
bb:paintRoundedRect(x, y,
container_width, container_height,
self.background, self.radius + self.bordersize)
end
end
if self.stripe_width and self.stripe_color and not self.stripe_over then
-- (No support for radius when hatched/stripe)
Expand All @@ -130,10 +135,11 @@ function FrameContainer:paintTo(bb, x, y)
self.inner_bordersize, self.color, self.radius)
end
if self.bordersize > 0 then
local anti_alias = G_reader_settings:nilOrTrue("anti_alias_ui")
bb:paintBorder(x + self.margin, y + self.margin,
container_width - self.margin * 2,
container_height - self.margin * 2,
self.bordersize, self.color, self.radius)
self.bordersize, self.color, self.radius, anti_alias)
end
if self[1] then
self[1]:paintTo(bb,
Expand Down
2 changes: 1 addition & 1 deletion frontend/ui/widget/container/inputcontainer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function InputContainer:paintTo(bb, x, y)
local content_size = self[1]:getSize()
self.dimen = Geom:new{
x = x, y = y,
w = content_size.w, h = content_size.h
w = content_size.w, h = content_size.h,
}
else
self.dimen.x = x
Expand Down

0 comments on commit c8f39c3

Please sign in to comment.