2013-10-18 20:38:07 +00:00
|
|
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
2014-10-30 18:42:18 +00:00
|
|
|
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
|
|
|
|
},
|
2012-05-18 22:50:26 +00:00
|
|
|
}
|
|
|
|
|
2012-12-31 03:57:23 +00:00
|
|
|
function ReaderPanning:init()
|
2016-02-14 21:47:36 +00:00
|
|
|
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 = {
|
2014-06-05 06:58:53 +00:00
|
|
|
{ "Up" }, doc = "move visible area up",
|
2014-03-13 13:52:43 +00:00
|
|
|
event = "Panning", args = {0, -1} },
|
|
|
|
MoveDown = {
|
2014-06-05 06:58:53 +00:00
|
|
|
{ "Down" }, doc = "move visible area down",
|
2014-03-13 13:52:43 +00:00
|
|
|
event = "Panning", args = {0, 1} },
|
|
|
|
MoveLeft = {
|
2014-06-05 06:58:53 +00:00
|
|
|
{ "Left" }, doc = "move visible area left",
|
2014-03-13 13:52:43 +00:00
|
|
|
event = "Panning", args = {-1, 0} },
|
|
|
|
MoveRight = {
|
2014-06-05 06:58:53 +00:00
|
|
|
{ "Right" }, doc = "move visible area right",
|
2014-03-13 13:52:43 +00:00
|
|
|
event = "Panning", args = {1, 0} },
|
|
|
|
}
|
|
|
|
end
|
2012-12-31 03:57:23 +00:00
|
|
|
end
|
|
|
|
|
2012-05-18 22:50:26 +00:00
|
|
|
function ReaderPanning:onSetDimensions(dimensions)
|
2014-03-13 13:52:43 +00:00
|
|
|
self.dimen = dimensions
|
2012-05-18 22:50:26 +00:00
|
|
|
end
|
|
|
|
|
2016-12-29 08:10:38 +00:00
|
|
|
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
|
2012-05-18 22:50:26 +00:00
|
|
|
end
|
2013-10-18 20:38:07 +00:00
|
|
|
|
|
|
|
return ReaderPanning
|