2
0
mirror of https://github.com/koreader/koreader synced 2024-11-13 19:11:25 +00:00

Merge pull request #513 from chrox/master

fix semi-auto cropping for djvu files
This commit is contained in:
Qingping Hou 2014-02-16 11:47:07 -05:00
commit 52ac2dc041
5 changed files with 34 additions and 25 deletions

View File

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

View File

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

View File

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

View File

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

@ -1 +1 @@
Subproject commit cf62f21087d511c2e9e4e852c2b4402a99bbdcfb
Subproject commit 1ef0dee5c0dbbbe812b8b5292c5a053f5d88fdcf