Files
koreader/frontend/apps/reader/modules/readerpanning.lua
NiLuJe b523c2e8b9 InputContainer: Fall cleanup ;).
Get rid of the doc & seqtext fields, as they are not actually used (nor
are they particularly useful, the event handler's name should be pretty
self-explanatory).

Also, tweak the key_events documentation to highlight the quirks of the
API, especially as far as array nesting is involved...

Random drive-by cleanup of the declarations of key_events & ges_events
to re-use the existing instance object (now that we know they're sane
;p) for tables with a single member (less GC pressure).
2022-10-29 22:55:20 +02:00

57 lines
1.4 KiB
Lua

local InputContainer = require("ui/widget/container/inputcontainer")
local Device = require("device")
local _ = require("gettext")
local ReaderPanning = InputContainer:extend{
-- defaults
panning_steps = {
normal = 50,
alt = 25,
shift = 10,
altshift = 5
},
}
function ReaderPanning:init()
if Device:hasKeyboard() then
self.key_events = {
-- these will all generate the same event, just with different arguments
MoveUp = {
{ "Up" },
event = "Panning",
args = {0, -1}
},
MoveDown = {
{ "Down" },
event = "Panning",
args = {0, 1}
},
MoveLeft = {
{ "Left" },
event = "Panning",
args = {-1, 0}
},
MoveRight = {
{ "Right" },
event = "Panning",
args = {1, 0}
},
}
end
end
function ReaderPanning:onSetDimensions(dimensions)
self.dimen = dimensions
end
function ReaderPanning:onPanning(args, _)
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 * (1/100),
dy * self.panning_steps.normal * self.dimen.h * (1/100))
return true
end
return ReaderPanning