From 0a863f07c70696e7e722e2e00c3d625c4239a091 Mon Sep 17 00:00:00 2001 From: chrox Date: Mon, 20 Oct 2014 22:17:53 +0800 Subject: [PATCH 1/2] show 50 ticks on the mini progress bar at most --- frontend/apps/reader/modules/readerfooter.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/apps/reader/modules/readerfooter.lua b/frontend/apps/reader/modules/readerfooter.lua index ebb296609..3a57acd8a 100644 --- a/frontend/apps/reader/modules/readerfooter.lua +++ b/frontend/apps/reader/modules/readerfooter.lua @@ -21,6 +21,7 @@ local ReaderFooter = InputContainer:new{ pageno = nil, pages = nil, toc_level = 0, + max_ticks = 50, progress_percentage = 0.0, progress_text = nil, text_font_face = "ffont", @@ -63,8 +64,14 @@ function ReaderFooter:init() face = Font:getFace(self.text_font_face, self.text_font_size), } local text_width = self.progress_text:getSize().w - local ticks = (self.ui.toc and DMINIBAR_PROGRESS_MARKER) - and self.ui.toc:getTocTicks(self.toc_level) or {} + local ticks = {} + if self.ui.toc and DMINIBAR_PROGRESS_MARKER then + local max_level = self.ui.toc:getMaxDepth() + for i = self.toc_level, -max_level, -1 do + ticks = self.ui.toc:getTocTicks(i) + if #ticks < self.max_ticks then break end + end + end self.progress_bar = ProgressWidget:new{ width = math.floor(Screen:getWidth() - text_width - self.padding), height = self.bar_height, From 2ad63fc1a3da0574d11062ea96dddd973f8125c0 Mon Sep 17 00:00:00 2001 From: chrox Date: Mon, 20 Oct 2014 22:19:31 +0800 Subject: [PATCH 2/2] expand/collapse TOC only by tap on the icon --- frontend/apps/reader/modules/readertoc.lua | 2 ++ frontend/ui/widget/button.lua | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/apps/reader/modules/readertoc.lua b/frontend/apps/reader/modules/readertoc.lua index 5d01201dc..7053f3cc3 100644 --- a/frontend/apps/reader/modules/readertoc.lua +++ b/frontend/apps/reader/modules/readertoc.lua @@ -244,12 +244,14 @@ function ReaderToc:onShowToc() -- update collapsible state self.expand_button = Button:new{ icon = "resources/icons/appbar.control.expand.png", + width = Screen:scaleByDPI(30), bordersize = 0, show_parent = self, } self.collapse_button = Button:new{ icon = "resources/icons/appbar.control.collapse.png", + width = Screen:scaleByDPI(30), bordersize = 0, show_parent = self, } diff --git a/frontend/ui/widget/button.lua b/frontend/ui/widget/button.lua index bafeb87d2..bd6f837b9 100644 --- a/frontend/ui/widget/button.lua +++ b/frontend/ui/widget/button.lua @@ -72,14 +72,14 @@ function Button:init() self[1] = self.frame if Device:isTouchDevice() then self.ges_events = { - TapSelect = { + TapSelectButton = { GestureRange:new{ ges = "tap", range = self.dimen, }, doc = "Tap Button", }, - HoldSelect = { + HoldSelectButton = { GestureRange:new{ ges = "hold", range = self.dimen, @@ -149,7 +149,7 @@ function Button:showHide(show) end end -function Button:onTapSelect() +function Button:onTapSelectButton() if self.enabled and self.callback then self[1].invert = true UIManager:setDirty(self.show_parent, "partial") @@ -162,7 +162,7 @@ function Button:onTapSelect() return true end -function Button:onHoldSelect() +function Button:onHoldSelectButton() if self.enabled and self.hold_callback then self.hold_callback() end