mirror of
https://github.com/koreader/koreader.git
synced 2025-12-24 12:14:05 +01:00
Update UI layout code to use new SVG icons
- Add IconWidget, use it for icons instead of ImageWidget. Specify icons by name only, look for them (with either .svg or .png suffixes) in multiple directories (including koreader/settings/icons/ to allow customizing them). Don't crash when icon name not found, shown a black background warning icon instead. - Don't trust the icons' native sizes: replace scale_for_dpi=true with width/height=DGENERIC_ICON_SIZE, so all icons get the same (tunable) size - except in a few specific use cases. - Top and bottom menu bars: normalize, and have icons properly centered in them, extend vertical line separators up to the edges. - TOC: adjust expand/collapse icons size to items size
This commit is contained in:
@@ -561,22 +561,31 @@ function ReaderToc:onShowToc()
|
||||
end
|
||||
end
|
||||
|
||||
-- update collapsible state
|
||||
-- Estimate expand/collapse icon size
|
||||
local items_per_page = G_reader_settings:readSetting("items_per_page") or 14
|
||||
-- *2/5 to acount for Menu top title and bottom icons, and add some air between consecutive icons
|
||||
local icon_size = math.floor(Screen:getHeight() / items_per_page * 2/5)
|
||||
local button_width = icon_size * 2
|
||||
self.expand_button = Button:new{
|
||||
icon = "resources/icons/appbar.control.expand.png",
|
||||
icon = "control.expand",
|
||||
icon_rotation_angle = BD.mirroredUILayout() and 180 or 0,
|
||||
width = Screen:scaleBySize(30),
|
||||
width = button_width,
|
||||
icon_width = icon_size,
|
||||
icon_height = icon_size,
|
||||
bordersize = 0,
|
||||
show_parent = self,
|
||||
}
|
||||
|
||||
self.collapse_button = Button:new{
|
||||
icon = "resources/icons/appbar.control.collapse.png",
|
||||
width = Screen:scaleBySize(30),
|
||||
icon = "control.collapse",
|
||||
width = button_width,
|
||||
icon_width = icon_size,
|
||||
icon_height = icon_size,
|
||||
bordersize = 0,
|
||||
show_parent = self,
|
||||
}
|
||||
|
||||
-- update collapsible state
|
||||
if #self.toc > 0 and #self.collapsed_toc == 0 then
|
||||
local depth = 0
|
||||
for i = #self.toc, 1, -1 do
|
||||
@@ -608,7 +617,7 @@ function ReaderToc:onShowToc()
|
||||
cface = Font:getFace("x_smallinfofont"),
|
||||
single_line = true,
|
||||
align_baselines = true,
|
||||
perpage = G_reader_settings:readSetting("items_per_page") or 14,
|
||||
perpage = items_per_page,
|
||||
line_color = require("ffi/blitbuffer").COLOR_WHITE,
|
||||
on_close_ges = {
|
||||
GestureRange:new{
|
||||
|
||||
Reference in New Issue
Block a user