diff --git a/frontend/ui/bbox.lua b/frontend/ui/bbox.lua index 26e745108..35b67559a 100644 --- a/frontend/ui/bbox.lua +++ b/frontend/ui/bbox.lua @@ -147,14 +147,10 @@ function BBoxWidget:onConfirmCrop() self.ui:handleEvent(Event:new("BBoxUpdate"), self.page_bbox) self.document.bbox[self.pageno] = self.page_bbox self.document.bbox[self:oddEven(self.pageno)] = self.page_bbox - self.ui:handleEvent(Event:new("SetZoomMode", self.orig_zoom_mode)) - self.document.configurable.text_wrap = self.orig_reflow_mode - UIManager.repaint_all = true + self.ui:handleEvent(Event:new("ExitPageCrop")) end function BBoxWidget:onCancelCrop() UIManager:close(self) - self.ui:handleEvent(Event:new("SetZoomMode", self.orig_zoom_mode)) - self.document.configurable.text_wrap = self.orig_reflow_mode - UIManager.repaint_all = true + self.ui:handleEvent(Event:new("ExitPageCrop")) end diff --git a/frontend/ui/reader/readercropping.lua b/frontend/ui/reader/readercropping.lua index 57d50f9e3..3a74cdecf 100644 --- a/frontend/ui/reader/readercropping.lua +++ b/frontend/ui/reader/readercropping.lua @@ -4,12 +4,18 @@ ReaderCropping = InputContainer:new{} function ReaderCropping:onPageCrop(mode) if mode == "auto" then return end - local orig_reflow_mode = self.document.configurable.text_wrap - self.document.configurable.text_wrap = 0 + self.orig_reflow_mode = self.document.configurable.text_wrap self.ui:handleEvent(Event:new("CloseConfig")) self.cropping_zoommode = true self.cropping_offset = true - self.ui:handleEvent(Event:new("SetZoomMode", "page")) + if self.orig_reflow_mode == 1 then + self.document.configurable.text_wrap = 0 + -- if we are in reflow mode, then we are already in page + -- mode, just force readerview to recalculate visible_area + self.view:recalculate() + else + self.ui:handleEvent(Event:new("SetZoomMode", "page")) + end self.cropping_zoommode = false local ubbox = self.document:getPageBBox(self.current_page) --DEBUG("used page bbox", ubbox) @@ -19,13 +25,25 @@ function ReaderCropping:onPageCrop(mode) crop = self, document = self.document, pageno = self.current_page, - orig_zoom_mode = self.orig_zoom_mode, - orig_reflow_mode = orig_reflow_mode, } UIManager:show(self.crop_bbox) return true end +function ReaderCropping:onExitPageCrop() + self.document.configurable.text_wrap = self.orig_reflow_mode + self.view:recalculate() + -- Exiting should have the same look and feel with entering. + if self.orig_reflow_mode == 1 then + self.document.configurable.text_wrap = 1 + self.view:recalculate() + else + self.ui:handleEvent(Event:new("SetZoomMode", self.orig_zoom_mode)) + end + UIManager.repaint_all = true + return true +end + function ReaderCropping:onPageUpdate(page_no) --DEBUG("page updated to", page_no) self.current_page = page_no @@ -38,7 +56,7 @@ end function ReaderCropping:onScreenOffsetUpdate(screen_offset) if self.cropping_offset then - DEBUG("offset updated to", screen_offset) + --DEBUG("offset updated to", screen_offset) self.screen_offset = screen_offset self.cropping_offset = false end