From 24ca5854c5cba91329c0c581a8202fa94f587685 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Tue, 6 Mar 2012 23:18:52 +0100 Subject: [PATCH] override getUsedBBox for cropping #35 --- unireader.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/unireader.lua b/unireader.lua index acd8cd733..bd050d118 100644 --- a/unireader.lua +++ b/unireader.lua @@ -66,6 +66,8 @@ UniReader = { cache = {}, jump_stack = {}, toc = nil, + + bbox = nil, -- override getUsedBBox } function UniReader:new(o) @@ -193,6 +195,14 @@ function UniReader:setzoom(page) if y0 < 0 then y0 = 0 end if y1 > pheight then y1 = pheight end + if self.bbox then + print("# ORIGINAL page::getUsedBBox "..x0.."*"..y0.." "..x1.."*"..y1); + x0 = self.bbox["x0"] + y0 = self.bbox["y0"] + x1 = self.bbox["x1"] + y1 = self.bbox["y1"] + end + print("# page::getUsedBBox "..x0.."*"..y0.." "..x1.."*"..y1); if self.globalzoommode == self.ZOOM_FIT_TO_PAGE @@ -573,6 +583,14 @@ function UniReader:inputloop() keep_running = false end break + elseif ev.code == KEY_Z then + local bbox = {} + bbox["x0"] = - self.offset_x / self.globalzoom + bbox["y0"] = - self.offset_y / self.globalzoom + bbox["x1"] = bbox["x0"] + width / self.globalzoom + bbox["y1"] = bbox["y0"] + height / self.globalzoom + self.bbox = bbox + print("# bbox " .. dump(self.bbox)) end -- switch to ZOOM_BY_VALUE to enable panning on fiveway move