From a2f7f62a3d838cd0f048b541054e9eb8e10cc3d9 Mon Sep 17 00:00:00 2001 From: NuPogodi Date: Sat, 1 Sep 2012 13:01:17 +0300 Subject: [PATCH 1/3] crereader: remove not crengine-related 'M'-hotkey Since I've added new unireader-hotkey that calls menu with zoom-modes, one has to remove it from crereader.lua. Done... --- crereader.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crereader.lua b/crereader.lua index ad6cbcb51..b542334dd 100644 --- a/crereader.lua +++ b/crereader.lua @@ -324,7 +324,7 @@ function CREReader:getTocTitleOfCurrentPage() return self:getTocTitleByPage(self.doc:getXPointer()) end ---[[ NuPogodi, 16.08.12 --> to scroll chapters without calling TOC-menu +--[[ function to scroll chapters without calling TOC-menu, direction is either +1 (next chapter) or -1 (previous one). Jump over several chapters is principally possible when direction > 1 ]] @@ -345,8 +345,7 @@ function CREReader:gotoPrevNextTocEntry(direction) break end end - -- NuPogodi, 31.08.12: minor correction for the case - -- when current page is not the page opening current chapter + -- minor correction when current page is not the page opening current chapter if self.pageno > self.toc[item_no].page and direction < 0 then direction = direction + 1 end @@ -418,6 +417,10 @@ function CREReader:adjustCreReaderCommands() self.commands:del(KEY_N, MOD_SHIFT, "N") self.commands:del(KEY_X, MOD_SHIFT, "X") -- remove manual cropping + -- NuPogodi, 01.09.12: remove new hotkey in unireader.lua + -- that calls 'zoom-mode' menu + self.commands:del(KEY_M, nil, "M") + -- CCW-rotation self.commands:add(KEY_K, nil, "K", "rotate screen counterclockwise", From c9e20704a4d613f3f54e762072d8bbc088f3bbee Mon Sep 17 00:00:00 2001 From: NuPogodi Date: Sat, 1 Sep 2012 13:12:32 +0300 Subject: [PATCH 2/3] djvureader: moved render-mode functions Since parameter 'render_mode' is related to djvu-documents only, the hotkey 'R' and the respective function to toggle 'render_mode' are moved from unireader to djvureader. --- djvureader.lua | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/djvureader.lua b/djvureader.lua index 034b58c3d..129a4e2ba 100644 --- a/djvureader.lua +++ b/djvureader.lua @@ -21,8 +21,25 @@ end function DJVUReader:adjustDjvuReaderCommand() self.commands:del(KEY_J, MOD_SHIFT, "J") self.commands:del(KEY_K, MOD_SHIFT, "K") + self.commands:add(KEY_R, nil, "R", + "toggle rendering mode: b&w/colour", + function(DJVUReader) + DJVUReader:toggle_render_mode() + end) end +------------------------------------------------------- +-- toggle rendering mode between colour (0) and b&w (1) +------------------------------------------------------- + +function DJVUReader:toggle_render_mode() + InfoMessage:show("New render_mode = "..self.render_mode, 1) + Debug("toggle_render_mode, render_mode=", self.render_mode) + self.render_mode = 1 - self.render_mode + self:clearCache() + self.doc:cleanCache() + self:redrawCurrentPage() +end ---------------------------------------------------- -- highlight support @@ -41,4 +58,3 @@ function DJVUReader:invertTextYAxel(pageno, text_table) end return text_table end - From 4bb8ef7f452ff50d0ad6d9b19ca87dfc27128790 Mon Sep 17 00:00:00 2001 From: NuPogodi Date: Sat, 1 Sep 2012 13:39:14 +0300 Subject: [PATCH 3/3] unireader: refresh frequency; zoommode-menu, etc. 1. Restored default value rcountmax=5; the function to make manual full screen refresh is no more silent; at first, it asks user to set a number of partial refreshes (rcountmax) and then performs full refresh. TODO: saving parameter 'rcountmax' in the global reader settings (or separately, for each document). 2. The hotkey 'R' and the respective function toggle_render_mode() for djvu-documents are moved to djvureader. 3. Added hotkey 'M' and the respective function that calls menu with zoom-modes. Probably, one needs to remove unappropriate items, like "Fit zoom to page" and, less probably, the hotkeys (A, S, D, F and ^A, ^S, ^D, ^F) to set zoom-mode directly. --- unireader.lua | 66 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 18 deletions(-) diff --git a/unireader.lua b/unireader.lua index 808c00636..500edf75d 100644 --- a/unireader.lua +++ b/unireader.lua @@ -22,7 +22,7 @@ UniReader = { -- framebuffer update policy state: rcount = 5, - rcountmax = 0, + rcountmax = 5, -- zoom state: globalzoom = 1.0, @@ -1576,16 +1576,6 @@ function UniReader:modifyGamma(factor) self:redrawCurrentPage() end --- toggle rendering mode between colour (0) and b&w (1) -function UniReader:toggle_render_mode() - Debug("toggle_render_mode, render_mode=", self.render_mode) - self.render_mode = 1 - self.render_mode - self:clearCache() - self.doc:cleanCache() - showInfoMsgWithDelay("New render_mode = "..self.render_mode, 1000, 1) - self:redrawCurrentPage() -end - -- adjust zoom state and trigger re-rendering function UniReader:setglobalzoom_mode(newzoommode) if self.globalzoom_mode ~= newzoommode then @@ -2107,6 +2097,38 @@ function UniReader:addAllCommands() unireader:goto(math.max(math.floor(unireader.doc:getPages()*(keydef.keycode-KEY_1)/9),1)) end) -- end numeric keys + + -- function calls menu to visualize and/or to switch zoom mode + self.commands:add(KEY_M, nil, "M", + "select zoom mode", + function(unireader) + local mode_list = { + "Zoom by value", -- ZOOM_BY_VALUE = 0, remove? + "Fit zoom to page", -- A ZOOM_FIT_TO_PAGE = -1, + "Fit zoom to page width", -- S ZOOM_FIT_TO_PAGE_WIDTH = -2, + "Fit zoom to page height", -- D ZOOM_FIT_TO_PAGE_HEIGHT = -3, + "Fit zoom to content", -- ^A ZOOM_FIT_TO_CONTENT = -4, + "Fit zoom to content width", -- ^S ZOOM_FIT_TO_CONTENT_WIDTH = -5, + "Fit zoom to content height", -- ^D ZOOM_FIT_TO_CONTENT_HEIGHT = -6, + "Fit zoom to content width with panoraming", -- ZOOM_FIT_TO_CONTENT_WIDTH_PAN = -7, remove? + "Fit zoom to content height with panoraming", -- ZOOM_FIT_TO_CONTENT_HEIGHT_PAN = -8, remove? + "Fit zoom to content half-width with margin", -- F ZOOM_FIT_TO_CONTENT_HALF_WIDTH_MARGIN = -9, + "Fit zoom to content half-width" -- ^F ZOOM_FIT_TO_CONTENT_HALF_WIDTH = -10, + } + local zoom_menu = SelectMenu:new{ + menu_title = "Select mode to zoom pages", + item_array = mode_list, + current_entry = - unireader.globalzoom_mode + } + local re = zoom_menu:choose(0, G_height) + if not re or re==1 or re==8 or re==9 then -- if not proper zoom-mode + unireader:redrawCurrentPage() + else + unireader:setglobalzoom_mode(1-re) + end + end) + -- to leave or to erase 8 hotkeys switching zoom-mode directly? + self.commands:add(KEY_A,nil,"A", "zoom to fit page", function(unireader) @@ -2223,22 +2245,30 @@ function UniReader:addAllCommands() self:redrawCurrentPage() end end) - self.commands:add(KEY_R, nil, "R", - "toggle rendering mode: b&w/colour", - function(unireader) - unireader:toggle_render_mode() - end) + self.commands:add(KEY_R, MOD_SHIFT, "R", "manual full screen refresh", function(unireader) - -- eink will not refresh if nothing is changeed on the screen + local count = NumInputBox:input(G_height-100, 100, + "Full refresh after:", self.rcountmax, true) + -- convert string to number + if pcall(function () count = count + 0 end) then + -- restrict self.rcountmax in reasonable range + self.rcountmax = math.max(count, 0) + self.rcountmax = math.min(count, 10) + end + -- now, perform full screen refresh + self.rcount = self.rcountmax + self:redrawCurrentPage() + --[[ eink will not refresh if nothing is changeed on the screen -- so we fake a change here. fb.bb:invertRect(0, 0, 1, 1) fb:refresh(1) fb.bb:invertRect(0, 0, 1, 1) fb:refresh(0) - unireader.rcount = 0 + unireader.rcount = 0 ]] end) + self.commands:add(KEY_Z,nil,"Z", "set crop mode", function(unireader)