diff --git a/frontend/apps/reader/modules/readerdictionary.lua b/frontend/apps/reader/modules/readerdictionary.lua index 2c4bd6ac9..adc46f92b 100644 --- a/frontend/apps/reader/modules/readerdictionary.lua +++ b/frontend/apps/reader/modules/readerdictionary.lua @@ -106,7 +106,7 @@ function ReaderDictionary:showDict(word, results, box) -- differentiate between dict and wiki wiki = self.wiki, } - UIManager:show(self.dict_window) + UIManager:show(self.dict_window, nil, nil, "none") end end diff --git a/frontend/apps/reader/modules/readerfont.lua b/frontend/apps/reader/modules/readerfont.lua index ef8cfc362..d2bfaa2da 100644 --- a/frontend/apps/reader/modules/readerfont.lua +++ b/frontend/apps/reader/modules/readerfont.lua @@ -149,7 +149,7 @@ function ReaderFont:onSetFontSize(new_size) UIManager:show(Notification:new{ text = T( _("Font size set to %1."), self.font_size), timeout = 1, - }) + }, nil, nil, "none") self.ui.document:setFontSize(Screen:scaleBySize(new_size)) self.ui:handleEvent(Event:new("UpdatePos")) diff --git a/frontend/apps/reader/modules/readerfooter.lua b/frontend/apps/reader/modules/readerfooter.lua index 05b87ccb0..af57fa258 100644 --- a/frontend/apps/reader/modules/readerfooter.lua +++ b/frontend/apps/reader/modules/readerfooter.lua @@ -267,20 +267,13 @@ function ReaderFooter:onTapFooter(arg, ges) self.mode = 0 end self:applyFooterMode() + G_reader_settings:saveSetting("reader_footer_mode", self.mode) end if self.pageno then self:updateFooterPage() else self:updateFooterPos() end - local region = Geom:new{ - x = 0, - y = Screen:getHeight() - self.height, - w = Screen:getWidth(), - h = self.height - } - UIManager:setDirty(self.view.dialog, "partial", region) - G_reader_settings:saveSetting("reader_footer_mode", self.mode) return true end diff --git a/frontend/apps/reader/modules/readerhighlight.lua b/frontend/apps/reader/modules/readerhighlight.lua index b642808c5..628531087 100644 --- a/frontend/apps/reader/modules/readerhighlight.lua +++ b/frontend/apps/reader/modules/readerhighlight.lua @@ -368,7 +368,9 @@ function ReaderHighlight:onHoldRelease() }, tap_close_callback = function() self:handleEvent(Event:new("Tap")) end, } - UIManager:show(self.highlight_dialog) + UIManager:show(self.highlight_dialog, nil, nil, function() + return "partial", self.highlight_dialog.dimen + end) end return true end diff --git a/frontend/apps/reader/modules/readerpaging.lua b/frontend/apps/reader/modules/readerpaging.lua index e9381f7ed..24fd3e964 100644 --- a/frontend/apps/reader/modules/readerpaging.lua +++ b/frontend/apps/reader/modules/readerpaging.lua @@ -344,8 +344,8 @@ function ReaderPaging:onPanRelease(arg, ges) end else self.last_pan_relative_y = 0 - -- trigger full refresh - UIManager:setDirty(nil, "full") + -- trigger partial refresh + UIManager:setDirty(nil, "partial") end end diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index b327fc7e9..3f0fea5a2 100644 --- a/frontend/ui/uimanager.lua +++ b/frontend/ui/uimanager.lua @@ -83,7 +83,8 @@ end -- register & show a widget -- modal widget should be always on the top -function UIManager:show(widget, x, y) +-- for refreshtype & refreshregion see description of setDirty() +function UIManager:show(widget, x, y, refreshtype, refreshregion) DEBUG("show widget", widget.id) self._running = true local window = {x = x or 0, y = y or 0, widget = widget} @@ -97,7 +98,7 @@ function UIManager:show(widget, x, y) end end -- and schedule it to be painted - self:setDirty(widget, "partial") + self:setDirty(widget, refreshtype or "partial", refreshregion) -- tell the widget that it is shown now widget:handleEvent(Event:new("Show")) -- check if this widget disables double tap gesture @@ -107,7 +108,8 @@ function UIManager:show(widget, x, y) end -- unregister a widget -function UIManager:close(widget) +-- for refreshtype & refreshregion see description of setDirty() +function UIManager:close(widget, refreshtype, refreshregion) if not widget then DEBUG("widget not exist to be closed") return @@ -127,8 +129,9 @@ function UIManager:close(widget) if dirty then -- schedule remaining widgets to be painted for i = 1, #self._window_stack do - self:setDirty(self._window_stack[i].widget, "partial") + self:setDirty(self._window_stack[i].widget) end + self:_refresh(refreshtype, refreshregion) end end @@ -204,7 +207,7 @@ function UIManager:setDirty(widget, refreshtype, refreshregion) end end -- handle refresh information - if not refreshtype then return end + if not refreshtype or refreshtype == "none" then return end if type(refreshtype) == "function" then -- callback, will be issued after painting table.insert(self._refresh_func_stack, refreshtype) diff --git a/frontend/ui/widget/buttondialog.lua b/frontend/ui/widget/buttondialog.lua index 0383c3dbd..f5b6d7dd1 100644 --- a/frontend/ui/widget/buttondialog.lua +++ b/frontend/ui/widget/buttondialog.lua @@ -63,4 +63,9 @@ function ButtonDialog:onClose() return true end +function ButtonDialog:paintTo(...) + InputContainer.paintTo(self, ...) + self.dimen = self[1][1].dimen -- FrameContainer +end + return ButtonDialog diff --git a/frontend/ui/widget/dictquicklookup.lua b/frontend/ui/widget/dictquicklookup.lua index 5c11dd4ad..26c74b91c 100644 --- a/frontend/ui/widget/dictquicklookup.lua +++ b/frontend/ui/widget/dictquicklookup.lua @@ -88,6 +88,7 @@ function DictQuickLookup:init() end function DictQuickLookup:update() + local orig_dimen = self.dict_frame and self.dict_frame.dimen or Geom:new{} -- calculate window dimension and try to not hide highlighted word self.align = "center" self.region = Geom:new{ @@ -256,7 +257,12 @@ function DictQuickLookup:update() self.dict_frame, } } - UIManager:setDirty("all", "partial") + + UIManager:setDirty("all", function() + local update_region = self.dict_frame.dimen:combine(orig_dimen) + DEBUG("update dict region", update_region) + return "partial", update_region + end) end function DictQuickLookup:isPrevDictAvaiable() @@ -282,14 +288,7 @@ function DictQuickLookup:changeDictionary(index) self.lookupword = self.results[index].word self.definition = self.results[index].definition - local orig_dimen = self.dict_frame and self.dict_frame.dimen or Geom:new{} self:update() - - UIManager.update_regions_func = function() - local update_region = self.dict_frame.dimen:combine(orig_dimen) - DEBUG("update dict region", update_region) - return {update_region} - end end function DictQuickLookup:changeToDefaultDict() diff --git a/frontend/ui/widget/infomessage.lua b/frontend/ui/widget/infomessage.lua index f91807ff3..fe17f4cf2 100644 --- a/frontend/ui/widget/infomessage.lua +++ b/frontend/ui/widget/infomessage.lua @@ -25,6 +25,7 @@ local InfoMessage = InputContainer:new{ face = Font:getFace("infofont", 25), text = "", timeout = nil, -- in seconds + closed = false, } function InfoMessage:init() @@ -78,22 +79,30 @@ function InfoMessage:init() } end +function InfoMessage:close() + if not self.closed then + self.closed = true + UIManager:close(self, "partial", self[1][1].dimen) + end +end + function InfoMessage:onShow() -- triggered by the UIManager after we got successfully shown (not yet painted) if self.timeout then - UIManager:scheduleIn(self.timeout, function() UIManager:close(self) end) + UIManager:scheduleIn(self.timeout, function() self:close() end) end + self.closed = false return true end function InfoMessage:onAnyKeyPressed() -- triggered by our defined key events - UIManager:close(self) + self:close() return true end function InfoMessage:onTapClose() - UIManager:close(self) + self:close() return true end diff --git a/frontend/ui/widget/notification.lua b/frontend/ui/widget/notification.lua index 4df000238..9bd2916b6 100644 --- a/frontend/ui/widget/notification.lua +++ b/frontend/ui/widget/notification.lua @@ -20,6 +20,7 @@ local Notification = InputContainer:new{ timeout = nil, margin = 5, padding = 5, + closed = false, } function Notification:init() @@ -55,17 +56,25 @@ function Notification:init() } end +function Notification:close() + if not self.closed then + self.closed = true + UIManager:close(self, "partial", self[1][1].dimen) + end +end + function Notification:onShow() -- triggered by the UIManager after we got successfully shown (not yet painted) if self.timeout then - UIManager:scheduleIn(self.timeout, function() UIManager:close(self) end) + UIManager:scheduleIn(self.timeout, function() self:close() end) end + self.closed = false return true end function Notification:onAnyKeyPressed() -- triggered by our defined key events - UIManager:close(self) + self:close() return true end