[fix] PDF footer margins (#5620)

closes #5612 

the change in `ReaderView:recalculate()` causes the viewable page size to be calculated by not including the footer, causing the text not to get cut off.

since the page area was not drawing under the footer `ReaderView:drawPageSurround()` had to be fixed to draw the margin under the footer so when tapping the footer off the area should be dran the background color.
reviewable/pr5623/r1
yparitcher 5 years ago committed by Frans de Jonge
parent 03fda96041
commit 6d3e7fcef6

@ -766,11 +766,6 @@ function ReaderPaging:onScrollPanRel(diff)
return true
end
function ReaderPaging:calculateOverlap()
local footer_height = (self.view.footer_visible and 1 or 0) * self.view.footer.height
return self.overlap + footer_height
end
function ReaderPaging:onScrollPageRel(page_diff)
if page_diff == 0 then return true end
if page_diff > 0 then
@ -786,7 +781,7 @@ function ReaderPaging:onScrollPageRel(page_diff)
local blank_area = Geom:new{}
blank_area:setSizeTo(self.view.dimen)
local overlap = self:calculateOverlap()
local overlap = self.overlap
local offset = Geom:new{
x = 0,
y = last_visible_area.h - overlap
@ -796,7 +791,7 @@ function ReaderPaging:onScrollPageRel(page_diff)
-- page up, first page should be moved to bottom
local blank_area = Geom:new{}
blank_area:setSizeTo(self.view.dimen)
local overlap = self:calculateOverlap()
local overlap = self.overlap
local first_page_state = table.remove(self.view.page_states, 1)
local offset = Geom:new{
x = 0,
@ -912,7 +907,7 @@ function ReaderPaging:onGotoPageRel(diff)
else
-- not end of page yet, goto next view
-- adjust panning step according to overlap
local overlap = self:calculateOverlap()
local overlap = self.overlap
if x_pan_off > overlap then
-- moving to next view, move view
x_pan_off = x_pan_off - overlap

@ -304,8 +304,9 @@ end
function ReaderView:drawPageSurround(bb, x, y)
if self.dimen.h > self.visible_area.h then
bb:paintRect(x, y, self.dimen.w, self.state.offset.y, self.outer_page_color)
bb:paintRect(x, y + self.dimen.h - self.state.offset.y - 1,
self.dimen.w, self.state.offset.y + 1, self.outer_page_color)
local bottom_margin = y + self.visible_area.h + self.state.offset.y
bb:paintRect(x, bottom_margin, self.dimen.w, self.state.offset.y +
self.ui.view.footer:getHeight(), self.outer_page_color)
end
if self.dimen.w > self.visible_area.w then
bb:paintRect(x, y, self.state.offset.x, self.dimen.h, self.outer_page_color)
@ -573,6 +574,9 @@ function ReaderView:recalculate()
self.state.rotation)
-- reset our size
self.visible_area:setSizeTo(self.dimen)
if self.ui.view.footer_visible then
self.visible_area.h = self.visible_area.h - self.ui.view.footer:getHeight()
end
if self.ui.document.configurable.writing_direction == 0 then
-- starts from left top of page_area
self.visible_area.x = self.page_area.x
@ -594,7 +598,11 @@ function ReaderView:recalculate()
end
self.state.offset = Geom:new{x = 0, y = 0}
if self.dimen.h > self.visible_area.h then
self.state.offset.y = (self.dimen.h - self.visible_area.h) / 2
if self.ui.view.footer_visible then
self.state.offset.y = (self.dimen.h - (self.visible_area.h + self.ui.view.footer:getHeight())) / 2
else
self.state.offset.y = (self.dimen.h - self.visible_area.h) / 2
end
end
if self.dimen.w > self.visible_area.w then
self.state.offset.x = (self.dimen.w - self.visible_area.w) / 2

@ -30,7 +30,7 @@ describe("ReaderLink module", function()
readerui:handleEvent(Event:new("SetScrollMode", false))
readerui:handleEvent(Event:new("SetZoomMode", "page"))
readerui.paging:onGotoPage(1)
readerui.link:onTap(nil, {pos = {x = 363, y = 585}})
readerui.link:onTap(nil, {pos = {x = 363, y = 565}})
UIManager:run()
assert.is.same(22, readerui.paging.current_page)
end)
@ -71,7 +71,7 @@ describe("ReaderLink module", function()
readerui:handleEvent(Event:new("SetScrollMode", false))
readerui:handleEvent(Event:new("SetZoomMode", "page"))
readerui.paging:onGotoPage(1)
readerui.link:onTap(nil, {pos = {x = 363, y = 585}})
readerui.link:onTap(nil, {pos = {x = 363, y = 565}})
UIManager:run()
assert.is.same(22, readerui.paging.current_page)
readerui.link:onGoBackLink()

Loading…
Cancel
Save