mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge branch 'master' into new_ui_code
This commit is contained in:
7
Makefile
7
Makefile
@@ -71,8 +71,7 @@ DJVULIBS := $(DJVUDIR)/build/libdjvu/.libs/libdjvulibre.a
|
||||
CRENGINELIBS := $(CRENGINEDIR)/crengine/libcrengine.a \
|
||||
$(CRENGINEDIR)/thirdparty/chmlib/libchmlib.a \
|
||||
$(CRENGINEDIR)/thirdparty/libpng/libpng.a \
|
||||
# we don't support dictionary lookup corrently
|
||||
#$(CRENGINEDIR)/thirdparty/antiword/libantiword.a
|
||||
$(CRENGINEDIR)/thirdparty/antiword/libantiword.a
|
||||
THIRDPARTYLIBS := $(MUPDFLIBDIR)/libfreetype.a \
|
||||
$(MUPDFLIBDIR)/libopenjpeg.a \
|
||||
$(MUPDFLIBDIR)/libjbig2dec.a \
|
||||
@@ -138,6 +137,10 @@ fetchthirdparty:
|
||||
# CREngine patch: disable fontconfig
|
||||
grep USE_FONTCONFIG $(CRENGINEDIR)/crengine/include/crsetup.h && grep -v USE_FONTCONFIG $(CRENGINEDIR)/crengine/include/crsetup.h > /tmp/new && mv /tmp/new $(CRENGINEDIR)/crengine/include/crsetup.h || echo "USE_FONTCONFIG already disabled"
|
||||
test -f mupdf-thirdparty.zip || wget http://www.mupdf.com/download/mupdf-thirdparty.zip
|
||||
# CREngine patch: change child nodes' type face
|
||||
# @TODO replace this dirty hack 24.04 2012 (houqp)
|
||||
cd kpvcrlib/crengine/crengine/src && \
|
||||
patch -N -p0 < ../../../lvrend_node_type_face.patch || true
|
||||
unzip mupdf-thirdparty.zip -d mupdf
|
||||
# dirty patch in MuPDF's thirdparty liby for CREngine
|
||||
cd mupdf/thirdparty/jpeg-*/ && \
|
||||
|
||||
3
cre.cpp
3
cre.cpp
@@ -269,6 +269,7 @@ static int setFontFace(lua_State *L) {
|
||||
const char *face = luaL_checkstring(L, 2);
|
||||
|
||||
doc->text_view->setDefaultFontFace(lString8(face));
|
||||
//fontMan->SetFallbackFontFace(lString8(face));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -364,6 +365,7 @@ static int cursorRight(lua_State *L) {
|
||||
//LVDocView *tv = doc->text_view;
|
||||
|
||||
//ldomXPointer p = tv->getCurrentPageMiddleParagraph();
|
||||
//lString16 s = p.getText();
|
||||
//lString16 s = p.toString();
|
||||
//printf("~~~~~~~~~~%s\n", UnicodeToLocal(s).c_str());
|
||||
|
||||
@@ -378,7 +380,6 @@ static int cursorRight(lua_State *L) {
|
||||
//LVPageWordSelector sel(doc->text_view);
|
||||
//doc->text_view->doCommand(DCMD_SELECT_FIRST_SENTENCE);
|
||||
//sel.moveBy(DIR_RIGHT, 2);
|
||||
//sel.updateSelection();
|
||||
//printf("---------------- %s\n", UnicodeToLocal(sel.getSelectedWord()->getText()).c_str());
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -428,18 +428,15 @@ function CREReader:adjustCreReaderCommands()
|
||||
end
|
||||
end
|
||||
)
|
||||
self.commands:add(KEY_VPLUS, nil, "vol+",
|
||||
"increase gamma",
|
||||
function(self)
|
||||
cre.setGammaIndex(self.gamma_index + 1)
|
||||
self.gamma_index = cre.getGammaIndex()
|
||||
self:redrawCurrentPage()
|
||||
end
|
||||
)
|
||||
self.commands:add(KEY_VMINUS, nil, "vol-",
|
||||
"decrease gamma",
|
||||
function(self)
|
||||
cre.setGammaIndex(self.gamma_index - 1)
|
||||
self.commands:addGroup("vol-/+",
|
||||
{Keydef:new(KEY_VPLUS,nil), Keydef:new(KEY_VMINUS,nil)},
|
||||
"decrease/increase gamma",
|
||||
function(self, keydef)
|
||||
local delta = 1
|
||||
if keydef.keycode == KEY_VMINUS then
|
||||
delta = -1
|
||||
end
|
||||
cre.setGammaIndex(self.gamma_index+delta)
|
||||
self.gamma_index = cre.getGammaIndex()
|
||||
self:redrawCurrentPage()
|
||||
end
|
||||
|
||||
2
djvu.c
2
djvu.c
@@ -133,7 +133,7 @@ static int walkTableOfContent(lua_State *L, miniexp_t r, int *count, int depth)
|
||||
strcpy(page_number,miniexp_to_str(miniexp_car(miniexp_cdr(miniexp_nth(counter, lista)))));
|
||||
/* page numbers appear as #11, set # to 0 so strtol works */
|
||||
page_number[0]= '0';
|
||||
lua_pushnumber(L, strtol(page_number, NULL, 10)+1);
|
||||
lua_pushnumber(L, strtol(page_number, NULL, 10));
|
||||
lua_settable(L, -3);
|
||||
|
||||
lua_pushstring(L, "depth");
|
||||
|
||||
@@ -45,6 +45,18 @@ function DJVUReader:zoomedRectCoordTransform(x0, y0, x1, y1)
|
||||
(y1 - y0) * self.globalzoom
|
||||
end
|
||||
|
||||
-- make sure at least part of the box can be seen in next/previous view
|
||||
-- @FIXME only works in FIT_TO_CONTENT_WIDTH mode 21.04 2012 (houqp)
|
||||
-- @TODO use zoomedRectCoordTransform in unireader, no need to overwrite
|
||||
-- it in here.
|
||||
function DJVUReader:_isBoxInNextView(box)
|
||||
return self.cur_full_height - (box.y0 * self.globalzoom) > -self.offset_y + G_height
|
||||
end
|
||||
|
||||
function DJVUReader:_isBoxInPrevView(box)
|
||||
return self.cur_full_height - (box.y1 * self.globalzoom) < -self.offset_y
|
||||
end
|
||||
|
||||
-- y axel in djvulibre starts from bottom
|
||||
function DJVUReader:_isEntireWordInScreenHeightRange(w)
|
||||
return (w ~= nil) and
|
||||
|
||||
@@ -57,8 +57,9 @@ function FileChooser:readDir()
|
||||
if file_type == "djvu"
|
||||
or file_type == "pdf" or file_type == "xps" or file_type == "cbz"
|
||||
or file_type == "epub" or file_type == "txt" or file_type == "rtf"
|
||||
or file_type == "htm" or file_type == "html"
|
||||
or file_type == "fb2" or file_type == "chm" then
|
||||
or file_type == "htm" or file_type == "html" or file_type == "mobi"
|
||||
or file_type == "fb2" or file_type == "chm" or file_type == "doc"
|
||||
or file_type == "zip" then
|
||||
table.insert(self.files, f)
|
||||
end
|
||||
end
|
||||
@@ -197,6 +198,7 @@ function FileChooser:choose(ypos, height)
|
||||
settings menu in the future.
|
||||
--]]
|
||||
return nil, function()
|
||||
InfoMessage:show("Searching...",0)
|
||||
FileSearcher:init( self.path )
|
||||
FileSearcher:choose(keywords)
|
||||
end
|
||||
|
||||
@@ -38,8 +38,9 @@ function FileSearcher:readDir()
|
||||
or file_type == "xps" or file_type == "cbz"
|
||||
or file_type == "epub" or file_type == "txt"
|
||||
or file_type == "rtf" or file_type == "htm"
|
||||
or file_type == "html"
|
||||
or file_type == "fb2" or file_type == "chm" then
|
||||
or file_type == "html" or file_type == "mobi"
|
||||
or file_type == "fb2" or file_type == "chm"
|
||||
or file_type == "doc" or file_type == "zip" then
|
||||
file_entry = {dir=d, name=f,}
|
||||
table.insert(self.files, file_entry)
|
||||
--debug("file:"..d.."/"..f)
|
||||
|
||||
@@ -43,11 +43,10 @@ ADD_SUBDIRECTORY(${CR_3RDPARTY_DIR}/libpng)
|
||||
#message("Will build patched JPEGLIB library")
|
||||
#ADD_SUBDIRECTORY(${CR_3RDPARTY_DIR}/libjpeg)
|
||||
|
||||
message("Will not build patched ANTIWORD library, because we haven't supported dictionary lookup yet.")
|
||||
#message("Will build patched ANTIWORD library")
|
||||
ADD_DEFINITIONS(-DENABLE_ANTIWORD=0)
|
||||
#ADD_DEFINITIONS(-DCR3_ANTIWORD_PATCH=1)
|
||||
#ADD_SUBDIRECTORY(${CR_3RDPARTY_DIR}/antiword)
|
||||
message("Will build patched ANTIWORD library")
|
||||
ADD_DEFINITIONS(-DENABLE_ANTIWORD=1)
|
||||
ADD_DEFINITIONS(-DCR3_ANTIWORD_PATCH=1)
|
||||
ADD_SUBDIRECTORY(${CR_3RDPARTY_DIR}/antiword)
|
||||
|
||||
message("Will build crengine library")
|
||||
SET(GUI kpv)
|
||||
|
||||
Submodule kpvcrlib/crengine updated: 73805ee9b0...7a73d16665
12
kpvcrlib/lvrend_node_type_face.patch
Normal file
12
kpvcrlib/lvrend_node_type_face.patch
Normal file
@@ -0,0 +1,12 @@
|
||||
--- lvrend.cpp 2012-04-24 10:27:33.000000000 +0800
|
||||
+++ lvrend-patched.cpp 2012-04-24 10:27:28.000000000 +0800
|
||||
@@ -1902,7 +1902,8 @@
|
||||
UPDATE_STYLE_FIELD( font_style, css_fs_inherit );
|
||||
UPDATE_STYLE_FIELD( font_weight, css_fw_inherit );
|
||||
UPDATE_STYLE_FIELD( font_family, css_ff_inherit );
|
||||
- UPDATE_STYLE_FIELD( font_name, "" );
|
||||
+ //UPDATE_STYLE_FIELD( font_name, "" );
|
||||
+ pstyle->font_name = parent_font.get()->getTypeFace();
|
||||
UPDATE_LEN_FIELD( font_size );
|
||||
//UPDATE_LEN_FIELD( text_indent );
|
||||
spreadParent( pstyle->text_indent, parent_style->text_indent );
|
||||
@@ -44,7 +44,7 @@ function openFile(filename)
|
||||
reader = DJVUReader
|
||||
elseif file_type == "pdf" or file_type == "xps" or file_type == "cbz" then
|
||||
reader = PDFReader
|
||||
elseif file_type == "epub" or file_type == "txt" or file_type == "rtf" or file_type == "htm" or file_type == "html" or file_type == "fb2" or file_type == "chm" then
|
||||
elseif file_type == "epub" or file_type == "txt" or file_type == "rtf" or file_type == "htm" or file_type == "html" or file_type == "fb2" or file_type == "chm" or file_type == "mobi" or file_type == "doc" or file_type == "zip" then
|
||||
reader = CREReader
|
||||
end
|
||||
if reader then
|
||||
|
||||
@@ -134,13 +134,10 @@ function SelectMenu:addAllCommands()
|
||||
self.commands:add(KEY_FW_PRESS, nil, "",
|
||||
"select menu item",
|
||||
function(sm)
|
||||
if sm.last_shortcut < 30 then
|
||||
if sm.items == 0 then
|
||||
return "break"
|
||||
else
|
||||
self.selected_item = (sm.perpage * (sm.page - 1)
|
||||
+ sm.current)
|
||||
end
|
||||
if sm.items == 0 then
|
||||
return "break"
|
||||
else
|
||||
self.selected_item = (sm.perpage * (sm.page - 1) + sm.current)
|
||||
end
|
||||
end
|
||||
)
|
||||
@@ -282,9 +279,9 @@ function SelectMenu:choose(ypos, height)
|
||||
|
||||
renderUtf8Text(fb.bb, 50, y, cface,
|
||||
self.item_array[i], true)
|
||||
end -- EOF if i <= self.items
|
||||
end -- EOF for
|
||||
end -- EOF if
|
||||
end -- if i <= self.items
|
||||
end -- for c=1, self.perpage
|
||||
end -- if self.items == 0
|
||||
|
||||
-- draw footer
|
||||
y = ypos + self.title_H + (self.spacing * self.perpage)
|
||||
|
||||
131
unireader.lua
131
unireader.lua
@@ -27,7 +27,7 @@ UniReader = {
|
||||
-- zoom state:
|
||||
globalzoom = 1.0,
|
||||
globalzoom_orig = 1.0,
|
||||
globalzoommode = -1, -- ZOOM_FIT_TO_PAGE
|
||||
globalzoom_mode = -1, -- ZOOM_FIT_TO_PAGE
|
||||
|
||||
globalrotate = 0,
|
||||
|
||||
@@ -174,6 +174,16 @@ function UniReader:getRectInScreen(x0, y0, x1, y1)
|
||||
return x, y, w, h
|
||||
end
|
||||
|
||||
-- make sure at least part of the box can be seen in next/previous view
|
||||
-- @FIXME only works in FIT_TO_CONTENT_WIDTH mode 21.04 2012 (houqp)
|
||||
function UniReader:_isBoxInNextView(box)
|
||||
return box.y1 * self.globalzoom > -self.offset_y + G_height
|
||||
end
|
||||
|
||||
function UniReader:_isBoxInPrevView(box)
|
||||
return box.y0 * self.globalzoom < -self.offset_y
|
||||
end
|
||||
|
||||
-- make sure the whole word/line can be seen in screen
|
||||
-- @TODO when not in FIT_TO_CONTENT_WIDTH mode,
|
||||
-- self.offset_{x,y} might be negative. 12.04 2012 (houqp)
|
||||
@@ -218,6 +228,18 @@ function UniReader:_isWordInScreenRange(w)
|
||||
(not is_entire_word_out_of_screen_width)
|
||||
end
|
||||
|
||||
function UniReader:_isWordInNextView(w)
|
||||
return self:_isBoxInNextView(w)
|
||||
end
|
||||
|
||||
function UniReader:_isLineInNextView(l)
|
||||
return self:_isBoxInNextView(l)
|
||||
end
|
||||
|
||||
function UniReader:_isLineInPrevView(l)
|
||||
return self:_isBoxInPrevView(l)
|
||||
end
|
||||
|
||||
function UniReader:toggleTextHighLight(word_list)
|
||||
for _,text_item in ipairs(word_list) do
|
||||
for _,line_item in ipairs(text_item) do
|
||||
@@ -540,7 +562,7 @@ function UniReader:startHighLightMode()
|
||||
|
||||
self.cursor:clear()
|
||||
if w.new ~= 0
|
||||
and not self:_isEntireLineInScreenHeightRange(t[l.new])
|
||||
and self:_isLineInPrevView(t[l.new])
|
||||
and self:_isEntireWordInScreenWidthRange(t[l.new][w.new]) then
|
||||
-- word is in previous view
|
||||
local pageno = self:prevView()
|
||||
@@ -569,7 +591,7 @@ function UniReader:startHighLightMode()
|
||||
if tmp_w == 0 then
|
||||
tmp_w = 1
|
||||
end
|
||||
if not self:_isEntireLineInScreenHeightRange(t[l.new])
|
||||
if self:_isLineInNextView(t[l.new])
|
||||
and self:_isEntireWordInScreenWidthRange(t[l.new][tmp_w]) then
|
||||
local pageno = self:nextView()
|
||||
self:goto(pageno)
|
||||
@@ -595,7 +617,7 @@ function UniReader:startHighLightMode()
|
||||
if tmp_w == 0 then
|
||||
tmp_w = 1
|
||||
end
|
||||
if not self:_isEntireLineInScreenHeightRange(t[l.new])
|
||||
if self:_isLineInPrevView(t[l.new])
|
||||
and self:_isEntireWordInScreenWidthRange(t[l.new][tmp_w]) then
|
||||
-- goto next view of current page
|
||||
local pageno = self:prevView()
|
||||
@@ -621,7 +643,7 @@ function UniReader:startHighLightMode()
|
||||
if w.cur == 0 then
|
||||
tmp_w = 1
|
||||
end
|
||||
if not self:_isEntireLineInScreenHeightRange(t[l.new])
|
||||
if self:_isLineInNextView(t[l.new])
|
||||
and self:_isEntireWordInScreenWidthRange(t[l.new][tmp_w]) then
|
||||
-- goto next view of current page
|
||||
local pageno = self:nextView()
|
||||
@@ -638,6 +660,10 @@ function UniReader:startHighLightMode()
|
||||
end
|
||||
end
|
||||
elseif ev.code == KEY_DEL then
|
||||
-- handle left end of line as special case
|
||||
if w.cur == 0 then
|
||||
w.cur = 1
|
||||
end
|
||||
if self.highlight[self.pageno] then
|
||||
for k, text_item in ipairs(self.highlight[self.pageno]) do
|
||||
for _, line_item in ipairs(text_item) do
|
||||
@@ -646,14 +672,15 @@ function UniReader:startHighLightMode()
|
||||
and t[l.cur][w.cur].x0 >= line_item.x0
|
||||
and t[l.cur][w.cur].x1 <= line_item.x1 then
|
||||
self.highlight[self.pageno][k] = nil
|
||||
-- remove page entry if empty
|
||||
if #self.highlight[self.pageno] == 0 then
|
||||
self.highlight[self.pageno] = nil
|
||||
end
|
||||
return
|
||||
end
|
||||
end -- for line_item
|
||||
end -- for text_item
|
||||
end -- if not highlight table
|
||||
if #self.highlight[self.pageno] == 0 then
|
||||
self.highlight[self.pageno] = nil
|
||||
end
|
||||
return
|
||||
elseif ev.code == KEY_FW_PRESS then
|
||||
l.new, w.new = l.cur, w.cur
|
||||
l.start, w.start = l.cur, w.cur
|
||||
@@ -688,7 +715,7 @@ function UniReader:startHighLightMode()
|
||||
end
|
||||
|
||||
if w.new ~= 0 and
|
||||
not self:_isEntireLineInScreenHeightRange(t[l.new]) then
|
||||
self:_isLineInPrevView(t[l.new]) then
|
||||
-- word out of left and right sides of current view should
|
||||
-- not trigger pan by page
|
||||
if self:_isEntireWordInScreenWidthRange(t[l.new][w.new]) then
|
||||
@@ -725,7 +752,7 @@ function UniReader:startHighLightMode()
|
||||
is_meet_end = true
|
||||
end
|
||||
|
||||
if not self:_isEntireLineInScreenHeightRange(t[l.new]) then
|
||||
if self:_isLineInNextView(t[l.new]) then
|
||||
if self:_isEntireWordInScreenWidthRange(t[l.new][w.new]) then
|
||||
local pageno = self:nextView()
|
||||
self:goto(pageno)
|
||||
@@ -954,7 +981,7 @@ function UniReader:loadSettings(filename)
|
||||
self.bbox = bbox
|
||||
|
||||
self.globalzoom = self.settings:readSetting("globalzoom") or 1.0
|
||||
self.globalzoommode = self.settings:readSetting("globalzoommode") or -1
|
||||
self.globalzoom_mode = self.settings:readSetting("globalzoom_mode") or -1
|
||||
|
||||
self:loadSpecialSettings()
|
||||
return true
|
||||
@@ -1168,8 +1195,8 @@ function UniReader:setzoom(page, preCache)
|
||||
|
||||
debug("page::getUsedBBox", x0, y0, x1, y1 )
|
||||
|
||||
if self.globalzoommode == self.ZOOM_FIT_TO_PAGE
|
||||
or self.globalzoommode == self.ZOOM_FIT_TO_CONTENT then
|
||||
if self.globalzoom_mode == self.ZOOM_FIT_TO_PAGE
|
||||
or self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT then
|
||||
self.globalzoom = width / pwidth
|
||||
self.offset_x = 0
|
||||
self.offset_y = (height - (self.globalzoom * pheight)) / 2
|
||||
@@ -1179,21 +1206,21 @@ function UniReader:setzoom(page, preCache)
|
||||
self.offset_y = 0
|
||||
end
|
||||
self.pan_by_page = false
|
||||
elseif self.globalzoommode == self.ZOOM_FIT_TO_PAGE_WIDTH
|
||||
or self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_WIDTH then
|
||||
elseif self.globalzoom_mode == self.ZOOM_FIT_TO_PAGE_WIDTH
|
||||
or self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_WIDTH then
|
||||
self.globalzoom = width / pwidth
|
||||
self.offset_x = 0
|
||||
self.offset_y = (height - (self.globalzoom * pheight)) / 2
|
||||
self.pan_by_page = false
|
||||
elseif self.globalzoommode == self.ZOOM_FIT_TO_PAGE_HEIGHT
|
||||
or self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_HEIGHT then
|
||||
elseif self.globalzoom_mode == self.ZOOM_FIT_TO_PAGE_HEIGHT
|
||||
or self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_HEIGHT then
|
||||
self.globalzoom = height / pheight
|
||||
self.offset_x = (width - (self.globalzoom * pwidth)) / 2
|
||||
self.offset_y = 0
|
||||
self.pan_by_page = false
|
||||
end
|
||||
|
||||
if self.globalzoommode == self.ZOOM_FIT_TO_CONTENT then
|
||||
if self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT then
|
||||
if (x1 - x0) < pwidth then
|
||||
self.globalzoom = width / (x1 - x0)
|
||||
if height / (y1 - y0) < self.globalzoom then
|
||||
@@ -1202,7 +1229,7 @@ function UniReader:setzoom(page, preCache)
|
||||
end
|
||||
self.offset_x = -1 * x0 * self.globalzoom
|
||||
self.offset_y = -1 * y0 * self.globalzoom
|
||||
elseif self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_WIDTH then
|
||||
elseif self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_WIDTH then
|
||||
if (x1 - x0) < pwidth then
|
||||
self.globalzoom = width / (x1 - x0)
|
||||
end
|
||||
@@ -1210,8 +1237,8 @@ function UniReader:setzoom(page, preCache)
|
||||
self.offset_y = -1 * y0 * self.globalzoom
|
||||
self.content_top = self.offset_y
|
||||
-- enable pan mode in ZOOM_FIT_TO_CONTENT_WIDTH
|
||||
self.globalzoommode = self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN
|
||||
elseif self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then
|
||||
self.globalzoom_mode = self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN
|
||||
elseif self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then
|
||||
if self.content_top == -2012 then
|
||||
-- We must handle previous page turn as a special cases,
|
||||
-- because we want to arrive at the bottom of previous page.
|
||||
@@ -1223,16 +1250,16 @@ function UniReader:setzoom(page, preCache)
|
||||
self.content_top = -1 * y0 * self.globalzoom
|
||||
self.offset_y = fb.bb:getHeight() - self.fullheight
|
||||
end
|
||||
elseif self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_HEIGHT then
|
||||
elseif self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_HEIGHT then
|
||||
if (y1 - y0) < pheight then
|
||||
self.globalzoom = height / (y1 - y0)
|
||||
end
|
||||
self.offset_x = -1 * x0 * self.globalzoom
|
||||
self.offset_y = -1 * y0 * self.globalzoom
|
||||
elseif self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_HALF_WIDTH
|
||||
or self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_HALF_WIDTH_MARGIN then
|
||||
elseif self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_HALF_WIDTH
|
||||
or self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_HALF_WIDTH_MARGIN then
|
||||
local margin = self.pan_margin
|
||||
if self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_HALF_WIDTH then margin = 0 end
|
||||
if self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_HALF_WIDTH then margin = 0 end
|
||||
local pg_margin = 0 -- margin scaled to page size
|
||||
if margin > 0 then pg_margin = margin * 2 / self.globalzoom end
|
||||
self.globalzoom = width / (x1 - x0 + pg_margin)
|
||||
@@ -1241,7 +1268,7 @@ function UniReader:setzoom(page, preCache)
|
||||
self.offset_y = -1 * y0 * self.globalzoom * 2 + margin
|
||||
self.globalzoom = width / (x1 - x0 + pg_margin) * 2
|
||||
debug("column mode offset:", self.offset_x, self.offset_y, " zoom:", self.globalzoom);
|
||||
self.globalzoommode = self.ZOOM_BY_VALUE -- enable pan mode
|
||||
self.globalzoom_mode = self.ZOOM_BY_VALUE -- enable pan mode
|
||||
self.pan_x = self.offset_x
|
||||
self.pan_y = self.offset_y
|
||||
self.pan_by_page = true
|
||||
@@ -1292,11 +1319,11 @@ function UniReader:show(no)
|
||||
self.dest_x = (width - (bb:getWidth() - offset_x)) / 2
|
||||
end
|
||||
if bb:getHeight() - offset_y < height and
|
||||
self.globalzoommode ~= self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then
|
||||
self.globalzoom_mode ~= self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then
|
||||
-- we can't fill the whole output height and not in
|
||||
-- ZOOM_FIT_TO_CONTENT_WIDTH_PAN mode, center the content
|
||||
self.dest_y = (height - (bb:getHeight() - offset_y)) / 2
|
||||
elseif self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN and
|
||||
elseif self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN and
|
||||
self.offset_y > 0 then
|
||||
-- if we are in ZOOM_FIT_TO_CONTENT_WIDTH_PAN mode and turning to
|
||||
-- the top of the page, we might leave an empty space between the
|
||||
@@ -1442,10 +1469,10 @@ end
|
||||
function UniReader:nextView()
|
||||
local pageno = self.pageno
|
||||
|
||||
if self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then
|
||||
if self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then
|
||||
if self.offset_y <= self.min_offset_y then
|
||||
-- hit content bottom, turn to next page
|
||||
self.globalzoommode = self.ZOOM_FIT_TO_CONTENT_WIDTH
|
||||
self.globalzoom_mode = self.ZOOM_FIT_TO_CONTENT_WIDTH
|
||||
pageno = pageno + 1
|
||||
else
|
||||
-- goto next view of current page
|
||||
@@ -1469,7 +1496,7 @@ end
|
||||
function UniReader:prevView()
|
||||
local pageno = self.pageno
|
||||
|
||||
if self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then
|
||||
if self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then
|
||||
if self.offset_y >= self.content_top then
|
||||
-- hit content top, turn to previous page
|
||||
-- set self.content_top with magic num to signal self:setZoom
|
||||
@@ -1502,9 +1529,9 @@ function UniReader:modifyGamma(factor)
|
||||
end
|
||||
|
||||
-- adjust zoom state and trigger re-rendering
|
||||
function UniReader:setGlobalZoomMode(newzoommode)
|
||||
if self.globalzoommode ~= newzoommode then
|
||||
self.globalzoommode = newzoommode
|
||||
function UniReader:setglobalzoom_mode(newzoommode)
|
||||
if self.globalzoom_mode ~= newzoommode then
|
||||
self.globalzoom_mode = newzoommode
|
||||
self:redrawCurrentPage()
|
||||
end
|
||||
end
|
||||
@@ -1512,7 +1539,7 @@ end
|
||||
-- adjust zoom state and trigger re-rendering
|
||||
function UniReader:setGlobalZoom(zoom)
|
||||
if self.globalzoom ~= zoom then
|
||||
self.globalzoommode = self.ZOOM_BY_VALUE
|
||||
self.globalzoom_mode = self.ZOOM_BY_VALUE
|
||||
self.globalzoom = zoom
|
||||
self:redrawCurrentPage()
|
||||
end
|
||||
@@ -1791,7 +1818,7 @@ function UniReader:inputLoop()
|
||||
self.settings:saveSetting("bookmarks", self.bookmarks)
|
||||
self.settings:saveSetting("bbox", self.bbox)
|
||||
self.settings:saveSetting("globalzoom", self.globalzoom)
|
||||
self.settings:saveSetting("globalzoommode", self.globalzoommode)
|
||||
self.settings:saveSetting("globalzoom_mode", self.globalzoom_mode)
|
||||
self.settings:saveSetting("highlight", self.highlight)
|
||||
self:saveSpecialSettings()
|
||||
self.settings:close()
|
||||
@@ -1881,42 +1908,42 @@ function UniReader:addAllCommands()
|
||||
self.commands:add(KEY_A,nil,"A",
|
||||
"zoom to fit page",
|
||||
function(unireader)
|
||||
unireader:setGlobalZoomMode(unireader.ZOOM_FIT_TO_PAGE)
|
||||
unireader:setglobalzoom_mode(unireader.ZOOM_FIT_TO_PAGE)
|
||||
end)
|
||||
self.commands:add(KEY_A,MOD_SHIFT,"A",
|
||||
"zoom to fit content",
|
||||
function(unireader)
|
||||
unireader:setGlobalZoomMode(unireader.ZOOM_FIT_TO_CONTENT)
|
||||
unireader:setglobalzoom_mode(unireader.ZOOM_FIT_TO_CONTENT)
|
||||
end)
|
||||
self.commands:add(KEY_S,nil,"S",
|
||||
"zoom to fit page width",
|
||||
function(unireader)
|
||||
unireader:setGlobalZoomMode(unireader.ZOOM_FIT_TO_PAGE_WIDTH)
|
||||
unireader:setglobalzoom_mode(unireader.ZOOM_FIT_TO_PAGE_WIDTH)
|
||||
end)
|
||||
self.commands:add(KEY_S,MOD_SHIFT,"S",
|
||||
"zoom to fit content width",
|
||||
function(unireader)
|
||||
unireader:setGlobalZoomMode(unireader.ZOOM_FIT_TO_CONTENT_WIDTH)
|
||||
unireader:setglobalzoom_mode(unireader.ZOOM_FIT_TO_CONTENT_WIDTH)
|
||||
end)
|
||||
self.commands:add(KEY_D,nil,"D",
|
||||
"zoom to fit page height",
|
||||
function(unireader)
|
||||
unireader:setGlobalZoomMode(unireader.ZOOM_FIT_TO_PAGE_HEIGHT)
|
||||
unireader:setglobalzoom_mode(unireader.ZOOM_FIT_TO_PAGE_HEIGHT)
|
||||
end)
|
||||
self.commands:add(KEY_D,MOD_SHIFT,"D",
|
||||
"zoom to fit content height",
|
||||
function(unireader)
|
||||
unireader:setGlobalZoomMode(unireader.ZOOM_FIT_TO_CONTENT_HEIGHT)
|
||||
unireader:setglobalzoom_mode(unireader.ZOOM_FIT_TO_CONTENT_HEIGHT)
|
||||
end)
|
||||
self.commands:add(KEY_F,nil,"F",
|
||||
"zoom to fit margin 2-column mode",
|
||||
function(unireader)
|
||||
unireader:setGlobalZoomMode(unireader.ZOOM_FIT_TO_CONTENT_HALF_WIDTH_MARGIN)
|
||||
unireader:setglobalzoom_mode(unireader.ZOOM_FIT_TO_CONTENT_HALF_WIDTH_MARGIN)
|
||||
end)
|
||||
self.commands:add(KEY_F,MOD_SHIFT,"F",
|
||||
"zoom to fit content 2-column mode",
|
||||
function(unireader)
|
||||
unireader:setGlobalZoomMode(unireader.ZOOM_FIT_TO_CONTENT_HALF_WIDTH)
|
||||
unireader:setglobalzoom_mode(unireader.ZOOM_FIT_TO_CONTENT_HALF_WIDTH)
|
||||
end)
|
||||
self.commands:add(KEY_G,nil,"G",
|
||||
"open 'go to page' input box",
|
||||
@@ -1973,8 +2000,8 @@ function UniReader:addAllCommands()
|
||||
"rotate screen 90° clockwise",
|
||||
function(unireader)
|
||||
unireader:screenRotate("clockwise")
|
||||
if self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then
|
||||
self:setGlobalZoomMode(self.ZOOM_FIT_TO_CONTENT_WIDTH)
|
||||
if self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then
|
||||
self:setglobalzoom_mode(self.ZOOM_FIT_TO_CONTENT_WIDTH)
|
||||
else
|
||||
self:redrawCurrentPage()
|
||||
end
|
||||
@@ -1988,8 +2015,8 @@ function UniReader:addAllCommands()
|
||||
"rotate screen 90° counterclockwise",
|
||||
function(unireader)
|
||||
unireader:screenRotate("anticlockwise")
|
||||
if self.globalzoommode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then
|
||||
self:setGlobalZoomMode(self.ZOOM_FIT_TO_CONTENT_WIDTH)
|
||||
if self.globalzoom_mode == self.ZOOM_FIT_TO_CONTENT_WIDTH_PAN then
|
||||
self:setglobalzoom_mode(self.ZOOM_FIT_TO_CONTENT_WIDTH)
|
||||
else
|
||||
self:redrawCurrentPage()
|
||||
end
|
||||
@@ -2019,7 +2046,7 @@ function UniReader:addAllCommands()
|
||||
unireader.bbox[unireader:oddEven(unireader.pageno)] = bbox
|
||||
unireader.bbox.enabled = true
|
||||
debug("bbox", unireader.pageno, unireader.bbox)
|
||||
unireader.globalzoommode = unireader.ZOOM_FIT_TO_CONTENT -- use bbox
|
||||
unireader.globalzoom_mode = unireader.ZOOM_FIT_TO_CONTENT -- use bbox
|
||||
showInfoMsgWithDelay("Manual crop setting saved.", 2000, 1)
|
||||
end)
|
||||
self.commands:add(KEY_Z,MOD_SHIFT,"Z",
|
||||
@@ -2052,9 +2079,9 @@ function UniReader:addAllCommands()
|
||||
"pan the active view; use Shift or Alt for smaller steps",
|
||||
function(unireader,keydef)
|
||||
if keydef.keycode ~= KEY_FW_PRESS then
|
||||
unireader.globalzoommode = unireader.ZOOM_BY_VALUE
|
||||
unireader.globalzoom_mode = unireader.ZOOM_BY_VALUE
|
||||
end
|
||||
if unireader.globalzoommode == unireader.ZOOM_BY_VALUE then
|
||||
if unireader.globalzoom_mode == unireader.ZOOM_BY_VALUE then
|
||||
local x
|
||||
local y
|
||||
if keydef.modifier==MOD_SHIFT then -- shift always moves in small steps
|
||||
|
||||
Reference in New Issue
Block a user