Merge pull request #513 from chrox/master

fix semi-auto cropping for djvu files
pull/514/head
Qingping Hou 10 years ago
commit 52ac2dc041

@ -53,6 +53,9 @@ DSHOWFILESIZE = false
-- default to true, set to false for counterclockwise rotation -- default to true, set to false for counterclockwise rotation
DLANDSCAPE_CLOCKWISE_ROTATION = true DLANDSCAPE_CLOCKWISE_ROTATION = true
-- page overlap pixels
DOVERLAPPIXELS = 30
-- customizable tap zones(rectangles) -- customizable tap zones(rectangles)
-- x: x coordinate of top left corner in proportion of screen width -- x: x coordinate of top left corner in proportion of screen width
-- y: y coordinate of top left corner in proportion of screen height -- y: y coordinate of top left corner in proportion of screen height

@ -150,9 +150,13 @@ This method returns pagesize if bbox is corrupted
--]] --]]
function Document:getUsedBBoxDimensions(pageno, zoom, rotation) function Document:getUsedBBoxDimensions(pageno, zoom, rotation)
local bbox = self:getPageBBox(pageno) local bbox = self:getPageBBox(pageno)
-- clipping page bbox
if bbox.x0 < 0 then bbox.x0 = 0 end
if bbox.y0 < 0 then bbox.y0 = 0 end
if bbox.x1 < 0 then bbox.x1 = 0 end
if bbox.y1 < 0 then bbox.y1 = 0 end
local ubbox_dimen = nil local ubbox_dimen = nil
if (bbox.x0 < 0) or (bbox.y0 < 0) or (bbox.x1 < 0) or (bbox.y1 < 0) if (bbox.x0 > bbox.x1) or (bbox.y0 > bbox.y1) then
or (bbox.x0 == bbox.x1) or (bbox.y0 == bbox.y1) then
-- if document's bbox info is corrupted, we use the page size -- if document's bbox info is corrupted, we use the page size
ubbox_dimen = self:getPageDimensions(pageno, zoom, rotation) ubbox_dimen = self:getPageDimensions(pageno, zoom, rotation)
else else

@ -17,7 +17,7 @@ local ReaderPaging = InputContainer:new{
visible_area = nil, visible_area = nil,
page_area = nil, page_area = nil,
show_overlap_enable = nil, show_overlap_enable = nil,
overlap = Screen:scaleByDPI(30), overlap = Screen:scaleByDPI(DOVERLAPPIXELS),
page_flipping_mode = false, page_flipping_mode = false,
bookmark_flipping_mode = false, bookmark_flipping_mode = false,
@ -400,8 +400,9 @@ function ReaderPaging:getTopPage()
end end
function ReaderPaging:onInitScrollPageStates(orig) function ReaderPaging:onInitScrollPageStates(orig)
--DEBUG.traceback()
DEBUG("init scroll page states", orig) DEBUG("init scroll page states", orig)
if self.view.page_scroll then if self.view.page_scroll and self.view.state.page then
self.orig_page = self.current_page self.orig_page = self.current_page
self.view.page_states = {} self.view.page_states = {}
local blank_area = Geom:new{} local blank_area = Geom:new{}
@ -734,6 +735,7 @@ end
-- wrapper for bounds checking -- wrapper for bounds checking
function ReaderPaging:gotoPage(number, orig) function ReaderPaging:gotoPage(number, orig)
--DEBUG.traceback()
if number == self.current_page or not number then if number == self.current_page or not number then
return true return true
end end

@ -176,36 +176,36 @@ function ReaderUI:init()
end end
-- for page specific controller -- for page specific controller
if self.document.info.has_pages then if self.document.info.has_pages then
-- if needed, insert a paging container -- cropping controller
table.insert(self, ReaderPaging:new{ table.insert(self, ReaderCropping:new{
dialog = self.dialog, dialog = self.dialog,
view = self[1], view = self[1],
ui = self ui = self,
document = self.document,
}) })
-- zooming controller -- zooming controller
self.zoom = ReaderZooming:new{ local zoom = ReaderZooming:new{
dialog = self.dialog, dialog = self.dialog,
view = self[1], view = self[1],
ui = self ui = self
} }
table.insert(self, self.zoom) -- hold reference to zoom controller table.insert(self, zoom)
-- panning controller -- paging controller
table.insert(self, ReaderPanning:new{ table.insert(self, ReaderPaging:new{
dialog = self.dialog, dialog = self.dialog,
view = self[1], view = self[1],
ui = self ui = self
}) })
-- cropping controller -- panning controller
table.insert(self, ReaderCropping:new{ table.insert(self, ReaderPanning:new{
dialog = self.dialog, dialog = self.dialog,
view = self[1], view = self[1],
ui = self, ui = self
document = self.document,
}) })
-- hinting controller -- hinting controller
table.insert(self, ReaderHinting:new{ table.insert(self, ReaderHinting:new{
dialog = self.dialog, dialog = self.dialog,
zoom = self.zoom, zoom = zoom,
view = self[1], view = self[1],
ui = self, ui = self,
document = self.document, document = self.document,

@ -1 +1 @@
Subproject commit cf62f21087d511c2e9e4e852c2b4402a99bbdcfb Subproject commit 1ef0dee5c0dbbbe812b8b5292c5a053f5d88fdcf
Loading…
Cancel
Save