koreader/frontend/apps/reader/modules/readerflipping.lua

60 lines
1.9 KiB
Lua
Raw Normal View History

local InputContainer = require("ui/widget/container/inputcontainer")
2013-10-18 22:38:07 +02:00
local LeftContainer = require("ui/widget/container/leftcontainer")
local ImageWidget = require("ui/widget/imagewidget")
local GestureRange = require("ui/gesturerange")
local Device = require("device")
2013-10-18 22:38:07 +02:00
local Geom = require("ui/geometry")
local Screen = require("device").screen
local Event = require("ui/event")
local ReaderFlipping = InputContainer:new{
2014-03-13 21:52:43 +08:00
orig_reflow_mode = 0,
2013-03-31 21:37:57 +08:00
}
function ReaderFlipping:init()
2014-03-13 21:52:43 +08:00
local widget = ImageWidget:new{
file = "resources/icons/appbar.book.open.png",
}
self[1] = LeftContainer:new{
dimen = Geom:new{w = Screen:getWidth(), h = widget:getSize().h},
widget,
}
self:resetLayout()
end
function ReaderFlipping:resetLayout()
local new_screen_width = Screen:getWidth()
if new_screen_width == self._last_screen_width then return end
local new_screen_height = Screen:getHeight()
self._last_screen_width = new_screen_width
self[1].dimen.w = new_screen_width
2014-03-13 21:52:43 +08:00
if Device:isTouchDevice() then
self.ges_events = {
Tap = {
GestureRange:new{
ges = "tap",
range = Geom:new{
x = new_screen_width*DTAP_ZONE_FLIPPING.x,
y = new_screen_height*DTAP_ZONE_FLIPPING.y,
w = new_screen_width*DTAP_ZONE_FLIPPING.w,
h = new_screen_height*DTAP_ZONE_FLIPPING.h
2014-03-13 21:52:43 +08:00
}
}
}
}
end
end
function ReaderFlipping:onTap()
if not self.ui.document.info.has_pages then
-- ReaderRolling has no support (yet) for onTogglePageFlipping,
-- so don't make that top left tap area unusable (and allow
-- taping on links there)
return false
end
2014-03-13 21:52:43 +08:00
self.ui:handleEvent(Event:new("TogglePageFlipping"))
return true
end
2013-10-18 22:38:07 +02:00
return ReaderFlipping