From 745e3837e00106df5045f1779a2ba91d9292e486 Mon Sep 17 00:00:00 2001 From: Hans-Werner Hilse Date: Sun, 30 Nov 2014 17:28:18 +0000 Subject: [PATCH 1/9] updating the screen in tap handler of readerfooter is not needed Was a hack anyway, c.f. https://github.com/koreader/koreader/pull/1306#discussion_r21057461 Seems to be not needed anymore. If some areas are now not refreshed anymore, that ought to be fixed in another place. This also gets rid of redundant screen flashes. --- frontend/apps/reader/modules/readerfooter.lua | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) 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 From c4a990316272dc7ab5aa4a718af33170ed9fb55a Mon Sep 17 00:00:00 2001 From: Hans-Werner Hilse Date: Sun, 30 Nov 2014 17:30:37 +0000 Subject: [PATCH 2/9] on finish of pan gesture when scrolling, do partial refresh it was set to a full refresh. However, we want to behave as if in non-scrolling mode and issue a partial refresh. That might get updated to a full refresh if the full-refresh counter has reached the limit - which is configurable. --- frontend/apps/reader/modules/readerpaging.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 3f9dc4631582fbe1ce9eb2edf8ed8c2b4c50f9f8 Mon Sep 17 00:00:00 2001 From: Hans-Werner Hilse Date: Sun, 30 Nov 2014 17:57:41 +0000 Subject: [PATCH 3/9] fix dict window refresh was still using old API also, move this to another place. --- frontend/ui/widget/dictquicklookup.lua | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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() From afb59667c0e7c60640357b470fba1190df30e2f0 Mon Sep 17 00:00:00 2001 From: Hans-Werner Hilse Date: Sun, 30 Nov 2014 18:07:35 +0000 Subject: [PATCH 4/9] allow for more control on refreshes when show()ing widgets for now, we have show() automatically call setDirty() for the new widget, as before. However, now show() takes two arguments for refresh configuration that will get passed on to setDirty(). For compatibility, the default is here in show() to do a partial refresh. So if you want no refresh triggered (via this show() call), add a function that doesn't return anything. --- frontend/ui/uimanager.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index b327fc7e9..185395343 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 & refresharea see description of setDirty() +function UIManager:show(widget, x, y, refreshtype, refresharea) 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", refresharea) -- tell the widget that it is shown now widget:handleEvent(Event:new("Show")) -- check if this widget disables double tap gesture @@ -204,7 +205,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) From 8376e2f8210bdaca97332b63d26430bf13849a09 Mon Sep 17 00:00:00 2001 From: Hans-Werner Hilse Date: Sun, 30 Nov 2014 18:11:02 +0000 Subject: [PATCH 5/9] dictionary window triggers refresh itself, not via show() --- frontend/apps/reader/modules/readerdictionary.lua | 2 +- frontend/apps/reader/modules/readerfont.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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")) From 143c56c48cd1de59d8d5eb2de0b8cb183e564116 Mon Sep 17 00:00:00 2001 From: Hans-Werner Hilse Date: Sun, 30 Nov 2014 18:26:29 +0000 Subject: [PATCH 6/9] record ButtonDialog.dimen --- frontend/ui/widget/buttondialog.lua | 5 +++++ 1 file changed, 5 insertions(+) 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 From e7f7417cd3b7e324e69a96af3b71d58fd607c104 Mon Sep 17 00:00:00 2001 From: Hans-Werner Hilse Date: Sun, 30 Nov 2014 18:27:27 +0000 Subject: [PATCH 7/9] refresh only dialog part of the screen for multi-word selection window --- frontend/apps/reader/modules/readerhighlight.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 From 1091a8a3b975da996f0bd1ea5ce343b5778a4f58 Mon Sep 17 00:00:00 2001 From: Hans-Werner Hilse Date: Sun, 30 Nov 2014 22:01:13 +0000 Subject: [PATCH 8/9] add refresh control to UIManager:close() --- frontend/ui/uimanager.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frontend/ui/uimanager.lua b/frontend/ui/uimanager.lua index 185395343..3f0fea5a2 100644 --- a/frontend/ui/uimanager.lua +++ b/frontend/ui/uimanager.lua @@ -83,8 +83,8 @@ end -- register & show a widget -- modal widget should be always on the top --- for refreshtype & refresharea see description of setDirty() -function UIManager:show(widget, x, y, refreshtype, refresharea) +-- 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} @@ -98,7 +98,7 @@ function UIManager:show(widget, x, y, refreshtype, refresharea) end end -- and schedule it to be painted - self:setDirty(widget, refreshtype or "partial", refresharea) + 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 @@ -108,7 +108,8 @@ function UIManager:show(widget, x, y, refreshtype, refresharea) 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 @@ -128,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 From e8642fbad7761bceba65bf079d5cbd82f2f0da65 Mon Sep 17 00:00:00 2001 From: Hans-Werner Hilse Date: Sun, 30 Nov 2014 22:25:23 +0000 Subject: [PATCH 9/9] use API for refresh when closing widgets in message popups --- frontend/ui/widget/infomessage.lua | 15 ++++++++++++--- frontend/ui/widget/notification.lua | 13 +++++++++++-- 2 files changed, 23 insertions(+), 5 deletions(-) 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