2019-12-06 21:55:39 +00:00
|
|
|
local BD = require("ui/bidi")
|
2017-04-29 08:38:09 +00:00
|
|
|
local Blitbuffer = require("ffi/blitbuffer")
|
|
|
|
local Button = require("ui/widget/button")
|
2016-12-29 07:27:48 +00:00
|
|
|
local CenterContainer = require("ui/widget/container/centercontainer")
|
|
|
|
local CloseButton = require("ui/widget/closebutton")
|
|
|
|
local Device = require("device")
|
2017-04-29 08:38:09 +00:00
|
|
|
local Event = require("ui/event")
|
2016-12-29 07:27:48 +00:00
|
|
|
local Font = require("ui/font")
|
2017-04-29 08:38:09 +00:00
|
|
|
local FrameContainer = require("ui/widget/container/framecontainer")
|
|
|
|
local Geom = require("ui/geometry")
|
|
|
|
local GestureRange = require("ui/gesturerange")
|
2016-12-29 07:27:48 +00:00
|
|
|
local HorizontalGroup = require("ui/widget/horizontalgroup")
|
2017-10-22 11:09:49 +00:00
|
|
|
local HorizontalSpan = require("ui/widget/horizontalspan")
|
2017-04-29 08:38:09 +00:00
|
|
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
|
|
|
local LineWidget = require("ui/widget/linewidget")
|
2018-01-29 20:27:24 +00:00
|
|
|
local Math = require("optmath")
|
|
|
|
local MovableContainer = require("ui/widget/container/movablecontainer")
|
2017-04-29 08:38:09 +00:00
|
|
|
local OverlapGroup = require("ui/widget/overlapgroup")
|
2016-12-29 07:27:48 +00:00
|
|
|
local ProgressWidget = require("ui/widget/progresswidget")
|
2017-09-13 14:56:20 +00:00
|
|
|
local Size = require("ui/size")
|
2017-04-29 08:38:09 +00:00
|
|
|
local TextWidget = require("ui/widget/textwidget")
|
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
local VerticalGroup = require("ui/widget/verticalgroup")
|
2016-12-29 07:27:48 +00:00
|
|
|
local VerticalSpan = require("ui/widget/verticalspan")
|
2017-04-29 08:38:09 +00:00
|
|
|
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
|
|
|
local _ = require("gettext")
|
|
|
|
local Screen = Device.screen
|
2016-12-29 07:27:48 +00:00
|
|
|
|
|
|
|
local SkimToWidget = InputContainer:new{
|
2017-04-29 08:38:09 +00:00
|
|
|
title_face = Font:getFace("x_smalltfont"),
|
2016-12-29 07:27:48 +00:00
|
|
|
width = nil,
|
|
|
|
height = nil,
|
|
|
|
}
|
|
|
|
|
|
|
|
function SkimToWidget:init()
|
2017-04-29 08:38:09 +00:00
|
|
|
self.medium_font_face = Font:getFace("ffont")
|
2017-09-13 14:56:20 +00:00
|
|
|
self.screen_width = Screen:getWidth()
|
|
|
|
self.screen_height = Screen:getHeight()
|
2016-12-29 07:27:48 +00:00
|
|
|
self.span = math.ceil(self.screen_height * 0.01)
|
2020-06-12 23:56:36 +00:00
|
|
|
self.width = math.floor(self.screen_width * 0.95)
|
2017-09-13 14:56:20 +00:00
|
|
|
self.button_bordersize = Size.border.button
|
|
|
|
-- the buttons need some kind of separation but maybe I should just implement
|
|
|
|
-- margin_left and margin_right…
|
2017-09-11 08:32:39 +00:00
|
|
|
self.button_margin = self.button_bordersize
|
2020-06-12 23:56:36 +00:00
|
|
|
self.button_width = math.floor(self.screen_width * 0.16) - (2*self.button_margin)
|
2016-12-29 07:27:48 +00:00
|
|
|
if Device:hasKeys() then
|
|
|
|
self.key_events = {
|
|
|
|
Close = { {"Back"}, doc = "close skimto page" }
|
|
|
|
}
|
|
|
|
end
|
|
|
|
if Device:isTouchDevice() then
|
|
|
|
self.ges_events = {
|
|
|
|
TapProgress = {
|
|
|
|
GestureRange:new{
|
|
|
|
ges = "tap",
|
|
|
|
range = Geom:new{
|
|
|
|
x = 0, y = 0,
|
|
|
|
w = self.screen_width,
|
|
|
|
h = self.screen_height,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
end
|
2018-09-18 19:37:13 +00:00
|
|
|
local dialog_title = _("Skim")
|
2020-03-16 15:52:09 +00:00
|
|
|
self.curr_page = self.ui:getCurrentPage()
|
2016-12-29 07:27:48 +00:00
|
|
|
self.page_count = self.document:getPageCount()
|
|
|
|
|
2020-03-26 13:04:59 +00:00
|
|
|
local curr_page_display = tostring(self.curr_page)
|
|
|
|
if self.ui.pagemap and self.ui.pagemap:wantsPageLabels() then
|
|
|
|
curr_page_display = self.ui.pagemap:getCurrentPageLabel(true)
|
|
|
|
end
|
|
|
|
|
2020-09-27 20:25:16 +00:00
|
|
|
self.ticks_flattened = self.ui.toc:getTocTicksFlattened()
|
2017-10-22 11:09:49 +00:00
|
|
|
|
|
|
|
local skimto_title = FrameContainer:new{
|
2017-09-13 14:56:20 +00:00
|
|
|
padding = Size.padding.default,
|
2017-10-16 15:51:56 +00:00
|
|
|
margin = Size.margin.title,
|
2016-12-29 07:27:48 +00:00
|
|
|
bordersize = 0,
|
|
|
|
TextWidget:new{
|
2017-10-22 11:09:49 +00:00
|
|
|
text = dialog_title,
|
2016-12-29 07:27:48 +00:00
|
|
|
face = self.title_face,
|
|
|
|
bold = true,
|
2020-06-12 23:56:36 +00:00
|
|
|
max_width = math.floor(self.screen_width * 0.95),
|
2016-12-29 07:27:48 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-10-22 11:09:49 +00:00
|
|
|
self.progress_bar = ProgressWidget:new{
|
2020-06-12 23:56:36 +00:00
|
|
|
width = math.floor(self.screen_width * 0.9),
|
2019-09-26 22:38:44 +00:00
|
|
|
height = Size.item.height_big,
|
2016-12-29 07:27:48 +00:00
|
|
|
percentage = self.curr_page / self.page_count,
|
2020-09-27 20:25:16 +00:00
|
|
|
ticks = self.ticks_flattened,
|
2017-10-22 11:09:49 +00:00
|
|
|
tick_width = Size.line.medium,
|
|
|
|
last = self.page_count,
|
2016-12-29 07:27:48 +00:00
|
|
|
}
|
|
|
|
self.skimto_progress = FrameContainer:new{
|
2017-09-13 14:56:20 +00:00
|
|
|
padding = Size.padding.button,
|
|
|
|
margin = Size.margin.small,
|
2016-12-29 07:27:48 +00:00
|
|
|
bordersize = 0,
|
2017-10-22 11:09:49 +00:00
|
|
|
self.progress_bar,
|
2016-12-29 07:27:48 +00:00
|
|
|
}
|
|
|
|
|
2017-10-22 11:09:49 +00:00
|
|
|
local skimto_line = LineWidget:new{
|
2016-12-29 07:27:48 +00:00
|
|
|
dimen = Geom:new{
|
|
|
|
w = self.width,
|
2017-09-13 14:56:20 +00:00
|
|
|
h = Size.line.thick,
|
2016-12-29 07:27:48 +00:00
|
|
|
}
|
|
|
|
}
|
2017-10-22 11:09:49 +00:00
|
|
|
local skimto_bar = OverlapGroup:new{
|
2016-12-29 07:27:48 +00:00
|
|
|
dimen = {
|
|
|
|
w = self.width,
|
2017-10-22 11:09:49 +00:00
|
|
|
h = skimto_title:getSize().h
|
2016-12-29 07:27:48 +00:00
|
|
|
},
|
2017-10-22 11:09:49 +00:00
|
|
|
skimto_title,
|
2017-10-16 15:51:56 +00:00
|
|
|
CloseButton:new{ window = self, padding_top = Size.margin.title, },
|
2016-12-29 07:27:48 +00:00
|
|
|
}
|
2017-10-22 11:09:49 +00:00
|
|
|
local button_minus = Button:new{
|
2016-12-29 07:27:48 +00:00
|
|
|
text = "-1",
|
2017-09-11 08:32:39 +00:00
|
|
|
bordersize = self.button_bordersize,
|
|
|
|
margin = self.button_margin,
|
2016-12-29 07:27:48 +00:00
|
|
|
radius = 0,
|
|
|
|
enabled = true,
|
2017-09-11 08:32:39 +00:00
|
|
|
width = self.button_width,
|
2016-12-29 07:27:48 +00:00
|
|
|
show_parent = self,
|
|
|
|
callback = function()
|
2020-02-09 12:00:57 +00:00
|
|
|
self:goToPage(self.curr_page - 1)
|
2016-12-29 07:27:48 +00:00
|
|
|
end,
|
|
|
|
}
|
2017-10-22 11:09:49 +00:00
|
|
|
local button_minus_ten = Button:new{
|
2016-12-29 07:27:48 +00:00
|
|
|
text = "-10",
|
2017-09-11 08:32:39 +00:00
|
|
|
bordersize = self.button_bordersize,
|
|
|
|
margin = self.button_margin,
|
2016-12-29 07:27:48 +00:00
|
|
|
radius = 0,
|
|
|
|
enabled = true,
|
2017-09-11 08:32:39 +00:00
|
|
|
width = self.button_width,
|
2016-12-29 07:27:48 +00:00
|
|
|
show_parent = self,
|
|
|
|
callback = function()
|
2020-02-09 12:00:57 +00:00
|
|
|
self:goToPage(self.curr_page - 10)
|
2016-12-29 07:27:48 +00:00
|
|
|
end,
|
|
|
|
}
|
2017-10-22 11:09:49 +00:00
|
|
|
local button_plus = Button:new{
|
2016-12-29 07:27:48 +00:00
|
|
|
text = "+1",
|
2017-09-11 08:32:39 +00:00
|
|
|
bordersize = self.button_bordersize,
|
|
|
|
margin = self.button_margin,
|
2016-12-29 07:27:48 +00:00
|
|
|
radius = 0,
|
|
|
|
enabled = true,
|
2017-09-11 08:32:39 +00:00
|
|
|
width = self.button_width,
|
2016-12-29 07:27:48 +00:00
|
|
|
show_parent = self,
|
|
|
|
callback = function()
|
2020-02-09 12:00:57 +00:00
|
|
|
self:goToPage(self.curr_page + 1)
|
2016-12-29 07:27:48 +00:00
|
|
|
end,
|
|
|
|
}
|
2017-10-22 11:09:49 +00:00
|
|
|
local button_plus_ten = Button:new{
|
2016-12-29 07:27:48 +00:00
|
|
|
text = "+10",
|
2017-09-11 08:32:39 +00:00
|
|
|
bordersize = self.button_bordersize,
|
|
|
|
margin = self.button_margin,
|
2016-12-29 07:27:48 +00:00
|
|
|
radius = 0,
|
|
|
|
enabled = true,
|
2017-09-11 08:32:39 +00:00
|
|
|
width = self.button_width,
|
2016-12-29 07:27:48 +00:00
|
|
|
show_parent = self,
|
|
|
|
callback = function()
|
2020-02-09 12:00:57 +00:00
|
|
|
self:goToPage(self.curr_page + 10)
|
2016-12-29 07:27:48 +00:00
|
|
|
end,
|
|
|
|
}
|
2017-10-22 11:09:49 +00:00
|
|
|
self.current_page_text = Button:new{
|
2020-03-26 13:04:59 +00:00
|
|
|
text = curr_page_display,
|
2016-12-29 07:27:48 +00:00
|
|
|
bordersize = 0,
|
2017-09-11 08:32:39 +00:00
|
|
|
margin = self.button_margin,
|
2016-12-29 07:27:48 +00:00
|
|
|
radius = 0,
|
2017-10-22 11:09:49 +00:00
|
|
|
padding = 0,
|
2016-12-29 07:27:48 +00:00
|
|
|
enabled = true,
|
2020-06-12 23:56:36 +00:00
|
|
|
width = math.floor(self.screen_width * 0.2) - (2*self.button_margin),
|
2016-12-29 07:27:48 +00:00
|
|
|
show_parent = self,
|
|
|
|
callback = function()
|
|
|
|
self.callback_switch_to_goto()
|
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
2019-12-06 21:55:39 +00:00
|
|
|
local chapter_next_text = "▷│"
|
|
|
|
local chapter_prev_text = "│◁"
|
|
|
|
local bookmark_next_text = "☆▷"
|
|
|
|
local bookmark_prev_text = "◁☆"
|
|
|
|
if BD.mirroredUILayout() then
|
|
|
|
chapter_next_text, chapter_prev_text = chapter_prev_text, chapter_next_text
|
|
|
|
bookmark_next_text, bookmark_prev_text = bookmark_prev_text, bookmark_next_text
|
|
|
|
end
|
2017-10-22 11:09:49 +00:00
|
|
|
local button_chapter_next = Button:new{
|
2019-12-06 21:55:39 +00:00
|
|
|
text = chapter_next_text,
|
2017-10-22 11:09:49 +00:00
|
|
|
bordersize = self.button_bordersize,
|
|
|
|
margin = self.button_margin,
|
|
|
|
radius = 0,
|
|
|
|
enabled = true,
|
|
|
|
width = self.button_width,
|
|
|
|
show_parent = self,
|
|
|
|
callback = function()
|
2020-09-27 20:25:16 +00:00
|
|
|
local page = self.ui.toc:getNextChapter(self.curr_page)
|
2017-10-22 11:09:49 +00:00
|
|
|
if page and page >=1 and page <= self.page_count then
|
2020-02-09 12:00:57 +00:00
|
|
|
self:goToPage(page)
|
2017-10-22 11:09:49 +00:00
|
|
|
end
|
|
|
|
end,
|
2020-02-09 12:00:57 +00:00
|
|
|
hold_callback = function()
|
|
|
|
self:goToPage(self.page_count)
|
|
|
|
end,
|
2016-12-29 07:27:48 +00:00
|
|
|
}
|
|
|
|
|
2017-10-22 11:09:49 +00:00
|
|
|
local button_chapter_prev = Button:new{
|
2019-12-06 21:55:39 +00:00
|
|
|
text = chapter_prev_text,
|
2017-10-22 11:09:49 +00:00
|
|
|
bordersize = self.button_bordersize,
|
|
|
|
margin = self.button_margin,
|
|
|
|
radius = 0,
|
|
|
|
enabled = true,
|
|
|
|
width = self.button_width,
|
|
|
|
show_parent = self,
|
|
|
|
callback = function()
|
2020-09-27 20:25:16 +00:00
|
|
|
local page = self.ui.toc:getPreviousChapter(self.curr_page)
|
2017-10-22 11:09:49 +00:00
|
|
|
if page and page >=1 and page <= self.page_count then
|
2020-02-09 12:00:57 +00:00
|
|
|
self:goToPage(page)
|
2017-10-22 11:09:49 +00:00
|
|
|
end
|
|
|
|
end,
|
2020-02-09 12:00:57 +00:00
|
|
|
hold_callback = function()
|
|
|
|
self:goToPage(1)
|
|
|
|
end,
|
2016-12-29 07:27:48 +00:00
|
|
|
}
|
|
|
|
|
2017-10-22 11:09:49 +00:00
|
|
|
local button_bookmark_next = Button:new{
|
2019-12-06 21:55:39 +00:00
|
|
|
text = bookmark_next_text,
|
2017-10-22 11:09:49 +00:00
|
|
|
bordersize = self.button_bordersize,
|
|
|
|
margin = self.button_margin,
|
|
|
|
radius = 0,
|
|
|
|
enabled = true,
|
|
|
|
width = self.button_width,
|
|
|
|
show_parent = self,
|
|
|
|
callback = function()
|
2020-06-01 05:13:58 +00:00
|
|
|
self:goToByEvent("GotoNextBookmarkFromPage")
|
2020-02-09 12:00:57 +00:00
|
|
|
end,
|
|
|
|
hold_callback = function()
|
2020-03-16 15:52:09 +00:00
|
|
|
local page = self.ui.bookmark:getLastBookmarkedPageFromPage(self.ui:getCurrentPage())
|
2020-02-09 12:00:57 +00:00
|
|
|
self:goToBookmark(page)
|
2017-10-22 11:09:49 +00:00
|
|
|
end,
|
2016-12-29 07:27:48 +00:00
|
|
|
}
|
|
|
|
|
2017-10-22 11:09:49 +00:00
|
|
|
local button_bookmark_prev = Button:new{
|
2019-12-06 21:55:39 +00:00
|
|
|
text = bookmark_prev_text,
|
2017-10-22 11:09:49 +00:00
|
|
|
bordersize = self.button_bordersize,
|
2017-09-11 08:32:39 +00:00
|
|
|
margin = self.button_margin,
|
2016-12-29 07:27:48 +00:00
|
|
|
radius = 0,
|
|
|
|
enabled = true,
|
2017-10-22 11:09:49 +00:00
|
|
|
width = self.button_width,
|
2016-12-29 07:27:48 +00:00
|
|
|
show_parent = self,
|
|
|
|
callback = function()
|
2020-06-01 05:13:58 +00:00
|
|
|
self:goToByEvent("GotoPreviousBookmarkFromPage")
|
2020-02-09 12:00:57 +00:00
|
|
|
end,
|
|
|
|
hold_callback = function()
|
2020-03-16 15:52:09 +00:00
|
|
|
local page = self.ui.bookmark:getFirstBookmarkedPageFromPage(self.ui:getCurrentPage())
|
2020-02-09 12:00:57 +00:00
|
|
|
self:goToBookmark(page)
|
2016-12-29 07:27:48 +00:00
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
2020-06-12 23:56:36 +00:00
|
|
|
local horizontal_span_up = HorizontalSpan:new{ width = math.floor(self.screen_width * 0.2) }
|
2017-10-22 11:09:49 +00:00
|
|
|
local button_table_up = HorizontalGroup:new{
|
|
|
|
align = "center",
|
|
|
|
button_chapter_prev,
|
|
|
|
button_bookmark_prev,
|
|
|
|
horizontal_span_up,
|
|
|
|
button_bookmark_next,
|
|
|
|
button_chapter_next,
|
|
|
|
}
|
|
|
|
|
|
|
|
local vertical_group_up = VerticalGroup:new{ align = "center" }
|
|
|
|
local padding_span_up = VerticalSpan:new{ width = math.ceil(self.screen_height * 0.015) }
|
|
|
|
table.insert(vertical_group_up, padding_span_up)
|
|
|
|
table.insert(vertical_group_up, button_table_up)
|
|
|
|
table.insert(vertical_group_up, padding_span_up)
|
|
|
|
|
|
|
|
local button_table_down = HorizontalGroup:new{
|
2016-12-29 07:27:48 +00:00
|
|
|
align = "center",
|
2017-10-22 11:09:49 +00:00
|
|
|
button_minus,
|
|
|
|
button_minus_ten,
|
|
|
|
self.current_page_text,
|
|
|
|
button_plus_ten,
|
|
|
|
button_plus,
|
2016-12-29 07:27:48 +00:00
|
|
|
}
|
2017-10-22 11:09:49 +00:00
|
|
|
local vertical_group_down = VerticalGroup:new{ align = "center" }
|
|
|
|
local padding_span = VerticalSpan:new{ width = math.ceil(self.screen_height * 0.015) }
|
|
|
|
table.insert(vertical_group_down, padding_span)
|
|
|
|
table.insert(vertical_group_down, button_table_down)
|
|
|
|
table.insert(vertical_group_down, padding_span)
|
2016-12-29 07:27:48 +00:00
|
|
|
|
|
|
|
self.skimto_frame = FrameContainer:new{
|
2017-09-13 14:56:20 +00:00
|
|
|
radius = Size.radius.window,
|
|
|
|
bordersize = Size.border.window,
|
2016-12-29 07:27:48 +00:00
|
|
|
padding = 0,
|
|
|
|
margin = 0,
|
|
|
|
background = Blitbuffer.COLOR_WHITE,
|
|
|
|
VerticalGroup:new{
|
|
|
|
align = "center",
|
2017-10-22 11:09:49 +00:00
|
|
|
skimto_bar,
|
|
|
|
skimto_line,
|
|
|
|
vertical_group_up,
|
2016-12-29 07:27:48 +00:00
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{
|
2017-10-22 11:09:49 +00:00
|
|
|
w = skimto_line:getSize().w,
|
2016-12-29 07:27:48 +00:00
|
|
|
h = self.skimto_progress:getSize().h,
|
|
|
|
},
|
|
|
|
self.skimto_progress,
|
|
|
|
},
|
2017-10-22 11:09:49 +00:00
|
|
|
vertical_group_down,
|
2016-12-29 07:27:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
self[1] = WidgetContainer:new{
|
|
|
|
align = "center",
|
|
|
|
dimen =Geom:new{
|
|
|
|
x = 0, y = 0,
|
|
|
|
w = self.screen_width,
|
|
|
|
h = self.screen_height,
|
|
|
|
},
|
2018-01-29 20:27:24 +00:00
|
|
|
MovableContainer:new{
|
|
|
|
-- alpha = 0.8,
|
2016-12-29 07:27:48 +00:00
|
|
|
self.skimto_frame,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2017-10-22 11:09:49 +00:00
|
|
|
function SkimToWidget:update()
|
|
|
|
if self.curr_page <= 0 then
|
|
|
|
self.curr_page = 1
|
|
|
|
end
|
|
|
|
if self.curr_page > self.page_count then
|
|
|
|
self.curr_page = self.page_count
|
|
|
|
end
|
|
|
|
self.progress_bar.percentage = self.curr_page / self.page_count
|
2020-03-26 13:04:59 +00:00
|
|
|
local curr_page_display = tostring(self.curr_page)
|
|
|
|
if self.ui.pagemap and self.ui.pagemap:wantsPageLabels() then
|
|
|
|
curr_page_display = self.ui.pagemap:getCurrentPageLabel(true)
|
|
|
|
end
|
|
|
|
self.current_page_text:setText(curr_page_display, self.current_page_text.width)
|
2017-10-22 11:09:49 +00:00
|
|
|
end
|
|
|
|
|
2018-08-15 13:22:55 +00:00
|
|
|
function SkimToWidget:addOriginToLocationStack(add_current)
|
|
|
|
-- Only add the page from which we launched the SkimToWidget
|
|
|
|
-- to the location stack, unless add_current = true
|
|
|
|
if not self.orig_page_added_to_stack or add_current then
|
|
|
|
self.ui.link:addCurrentLocationToStack()
|
|
|
|
self.orig_page_added_to_stack = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-12-29 07:27:48 +00:00
|
|
|
function SkimToWidget:onCloseWidget()
|
|
|
|
UIManager:setDirty(nil, function()
|
2017-10-22 11:09:49 +00:00
|
|
|
return "ui", self.skimto_frame.dimen
|
2016-12-29 07:27:48 +00:00
|
|
|
end)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
function SkimToWidget:onShow()
|
|
|
|
UIManager:setDirty(self, function()
|
|
|
|
return "ui", self.skimto_frame.dimen
|
|
|
|
end)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2020-02-09 12:00:57 +00:00
|
|
|
function SkimToWidget:goToPage(page)
|
|
|
|
self.curr_page = page
|
|
|
|
self:addOriginToLocationStack()
|
|
|
|
self.ui:handleEvent(Event:new("GotoPage", self.curr_page))
|
|
|
|
self:update()
|
|
|
|
end
|
|
|
|
|
|
|
|
function SkimToWidget:goToBookmark(page)
|
|
|
|
if page then
|
|
|
|
self:addOriginToLocationStack()
|
|
|
|
self.ui.bookmark:gotoBookmark(page)
|
2020-03-16 15:52:09 +00:00
|
|
|
self.curr_page = self.ui:getCurrentPage()
|
2020-02-09 12:00:57 +00:00
|
|
|
self:update()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-06-01 05:13:58 +00:00
|
|
|
function SkimToWidget:goToByEvent(event_name)
|
|
|
|
if event_name then
|
|
|
|
self:addOriginToLocationStack()
|
2020-06-25 19:19:50 +00:00
|
|
|
self.ui:handleEvent(Event:new(event_name, false))
|
|
|
|
-- add_current_location_to_stack=false, as we handled it here
|
2020-06-01 05:13:58 +00:00
|
|
|
self.curr_page = self.ui:getCurrentPage()
|
|
|
|
self:update()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-12-29 07:27:48 +00:00
|
|
|
function SkimToWidget:onAnyKeyPressed()
|
|
|
|
UIManager:close(self)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
function SkimToWidget:onTapProgress(arg, ges_ev)
|
2018-01-29 20:27:24 +00:00
|
|
|
if ges_ev.pos:intersectWith(self.progress_bar.dimen) then
|
2019-12-06 21:55:39 +00:00
|
|
|
local perc = self.progress_bar:getPercentageFromPosition(ges_ev.pos)
|
|
|
|
if not perc then
|
|
|
|
return true
|
|
|
|
end
|
2018-01-29 20:27:24 +00:00
|
|
|
local page = Math.round(perc * self.page_count)
|
2018-08-15 13:22:55 +00:00
|
|
|
self:addOriginToLocationStack()
|
2016-12-29 07:27:48 +00:00
|
|
|
self.ui:handleEvent(Event:new("GotoPage", page ))
|
|
|
|
self.curr_page = page
|
|
|
|
self:update()
|
2018-01-29 20:27:24 +00:00
|
|
|
elseif not ges_ev.pos:intersectWith(self.skimto_frame.dimen) then
|
|
|
|
-- close if tap outside
|
2016-12-29 07:27:48 +00:00
|
|
|
self:onClose()
|
|
|
|
end
|
2018-01-29 20:27:24 +00:00
|
|
|
-- otherwise, do nothing (it's easy missing taping a button)
|
2016-12-29 07:27:48 +00:00
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
function SkimToWidget:onClose()
|
|
|
|
UIManager:close(self)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
return SkimToWidget
|