From 37289fb18d1ceb895f248f58d29d8c151494a197 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 26 Apr 2012 22:16:36 +0200 Subject: [PATCH 1/2] invert page bbox on X #35 --- unireader.lua | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/unireader.lua b/unireader.lua index 80f2d25eb..b0356f865 100644 --- a/unireader.lua +++ b/unireader.lua @@ -40,6 +40,7 @@ UniReader = { -- size of current page for current zoom level in pixels cur_full_width = 0, cur_full_height = 0, + cur_bbox = {}, -- current page bbox offset_x = 0, offset_y = 0, dest_x = 0, -- real offset_x when it's smaller than screen, so it's centered @@ -1280,6 +1281,15 @@ function UniReader:setzoom(page, preCache) if not preCache then -- save current page fullsize self.cur_full_width = self.fullwidth self.cur_full_height = self.fullheight + + self.cur_bbox = { + ["x0"] = x0, + ["y0"] = y0, + ["x1"] = x1, + ["y1"] = y1, + } + debug("cur_bbox", self.cur_bbox) + end self.min_offset_x = fb.bb:getWidth() - self.fullwidth self.min_offset_y = fb.bb:getHeight() - self.fullheight @@ -2065,6 +2075,29 @@ function UniReader:addAllCommands() end debug("bbox override", unireader.bbox.enabled); end) + self.commands:add(KEY_X,nil,"X", + "invert page bbox", + function(unireader) + local bbox = unireader.cur_bbox + debug("bbox", bbox) + local x,y = unireader:screenOffset() + x = x + bbox["x0"] * self.globalzoom + y = y + bbox["y0"] * self.globalzoom + local w = ( bbox["x1"] - bbox["x0"] ) * self.globalzoom + local h = ( bbox["y1"] - bbox["y0"] ) * self.globalzoom + debug("inxertRect",x,y,w,h) + if x < 0 then + w = w + x -- x is negative! + x = 0 + end + if y < 0 then + h = h + y + y = 0 + end + debug("inxertRect",x,y,w,h) + fb.bb:invertRect( x,y, w,h ) + fb:refresh(0) + end) self.commands:add(KEY_MENU,nil,"Menu", "toggle info box", function(unireader) From 44be8231156593712c547d048c3aea9e5e732f84 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Thu, 26 Apr 2012 22:27:00 +0200 Subject: [PATCH 2/2] use getRectInScreen --- unireader.lua | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/unireader.lua b/unireader.lua index b0356f865..8b6b4bfb8 100644 --- a/unireader.lua +++ b/unireader.lua @@ -2080,20 +2080,7 @@ function UniReader:addAllCommands() function(unireader) local bbox = unireader.cur_bbox debug("bbox", bbox) - local x,y = unireader:screenOffset() - x = x + bbox["x0"] * self.globalzoom - y = y + bbox["y0"] * self.globalzoom - local w = ( bbox["x1"] - bbox["x0"] ) * self.globalzoom - local h = ( bbox["y1"] - bbox["y0"] ) * self.globalzoom - debug("inxertRect",x,y,w,h) - if x < 0 then - w = w + x -- x is negative! - x = 0 - end - if y < 0 then - h = h + y - y = 0 - end + x,y,w,h = unireader:getRectInScreen( bbox["x0"], bbox["y0"], bbox["x1"], bbox["y1"] ) debug("inxertRect",x,y,w,h) fb.bb:invertRect( x,y, w,h ) fb:refresh(0)