From 3ac00b90d613c3a4aa453b1ba8d7a3211668ea76 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Tue, 5 Jun 2012 19:03:06 +0800 Subject: [PATCH] add y direction panning for readerrolling.lua --- frontend/ui/reader/readerrolling.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/frontend/ui/reader/readerrolling.lua b/frontend/ui/reader/readerrolling.lua index 8c96b2ba4..33025df7d 100644 --- a/frontend/ui/reader/readerrolling.lua +++ b/frontend/ui/reader/readerrolling.lua @@ -1,8 +1,13 @@ +require "ui/reader/readerpanning" + ReaderRolling = InputContainer:new{ key_events = { GotoNextView = { {Input.group.PgFwd}, doc = "go to next view", event = "GotoViewRel", args = 1 }, GotoPrevView = { {Input.group.PgBack}, doc = "go to previous view", event = "GotoViewRel", args = -1 }, + MoveUp = { {"Up"}, doc = "move view up", event = "Panning", args = {0, -1} }, + MoveDown = { {"Down"}, doc = "move view down", event = "Panning", args = {0, 1} }, + GotoFirst = { {"1"}, doc = "go to start", event = "GotoPercent", args = 0}, Goto11 = { {"2"}, doc = "go to 11%", event = "GotoPercent", args = 11}, Goto22 = { {"3"}, doc = "go to 22%", event = "GotoPercent", args = 22}, @@ -14,8 +19,10 @@ ReaderRolling = InputContainer:new{ Goto88 = { {"9"}, doc = "go to 88%", event = "GotoPercent", args = 88}, GotoLast = { {"0"}, doc = "go to end", event = "GotoPercent", args = 100}, }, + current_pos = 0, length = nil, + panning_steps = ReaderPanning.panning_steps, } function ReaderRolling:init() @@ -45,6 +52,13 @@ function ReaderRolling:onGotoViewRel(diff) return true end +function ReaderRolling:onPanning(args, key) + local _, dy = unpack(args) + DEBUG("key =", key) + self:gotoPos(self.current_pos + dy * self.panning_steps.normal) + return true +end + function ReaderRolling:onZoom() --@TODO re-read length info after font or lineheight changes 05.06 2012 (houqp) end