2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00
koreader/frontend/apps/reader/modules/readerpanning.lua

49 lines
1.4 KiB
Lua
Raw Normal View History

2013-10-18 20:38:07 +00:00
local InputContainer = require("ui/widget/container/inputcontainer")
local Device = require("device")
2013-10-18 20:38:07 +00:00
local _ = require("gettext")
local ReaderPanning = InputContainer:new{
2014-03-13 13:52:43 +00:00
-- defaults
panning_steps = {
normal = 50,
alt = 25,
shift = 10,
altshift = 5
},
}
function ReaderPanning:init()
if Device:hasKeyboard() then
2014-03-13 13:52:43 +00:00
self.key_events = {
-- these will all generate the same event, just with different arguments
MoveUp = {
{ "Up" }, doc = "move visible area up",
2014-03-13 13:52:43 +00:00
event = "Panning", args = {0, -1} },
MoveDown = {
{ "Down" }, doc = "move visible area down",
2014-03-13 13:52:43 +00:00
event = "Panning", args = {0, 1} },
MoveLeft = {
{ "Left" }, doc = "move visible area left",
2014-03-13 13:52:43 +00:00
event = "Panning", args = {-1, 0} },
MoveRight = {
{ "Right" }, doc = "move visible area right",
2014-03-13 13:52:43 +00:00
event = "Panning", args = {1, 0} },
}
end
end
function ReaderPanning:onSetDimensions(dimensions)
2014-03-13 13:52:43 +00:00
self.dimen = dimensions
end
function ReaderPanning:onPanning(args, _)
2014-03-13 13:52:43 +00:00
local dx, dy = unpack(args)
-- for now, bounds checking/calculation is done in the view
self.view:PanningUpdate(
dx * self.panning_steps.normal * self.dimen.w / 100,
dy * self.panning_steps.normal * self.dimen.h / 100)
return true
end
2013-10-18 20:38:07 +00:00
return ReaderPanning