highlight current toc entry

pull/547/head
chrox 10 years ago
parent 9ee1352a76
commit ac396e3aa9

@ -53,6 +53,10 @@ function ReaderToc:onUpdateToc()
return true
end
function ReaderToc:onPageUpdate(pageno)
self.pageno = pageno
end
function ReaderToc:fillToc()
self.toc = self.ui.document:getToc()
end
@ -103,6 +107,16 @@ function ReaderToc:onShowToc()
v.mandatory = v.page
end
end
-- update current entry
if #self.toc > 0 then
for i=1, #self.toc do
v = self.toc[i]
if v.page > self.pageno then
self.toc.current = i > 1 and i - 1 or 1
break
end
end
end
local menu_container = CenterContainer:new{
dimen = Screen:getSize(),

@ -180,6 +180,7 @@ function MenuItem:init()
TextWidget:new{
text = self.text,
face = self.face,
bold = self.bold,
}
}
@ -188,6 +189,7 @@ function MenuItem:init()
TextWidget:new{
text = mandatory,
face = self.info_face,
bold = self.bold,
}
}
@ -462,6 +464,7 @@ function Menu:init()
if #self.item_table > 0 then
-- if the table is not yet initialized, this call
-- must be done manually:
self.page = math.ceil((self.item_table.current or 1) / self.perpage)
self:updateItems(1)
end
end
@ -500,6 +503,7 @@ function Menu:updateItems(select_number)
show_parent = self.show_parent,
text = self.item_table[i].text,
mandatory = self.item_table[i].mandatory,
bold = self.item_table.current == i,
face = self.cface,
dimen = self.item_dimen:new(),
shortcut = item_shortcut,

Loading…
Cancel
Save