mirror of
https://github.com/koreader/koreader.git
synced 2025-12-13 20:36:53 +01:00
adapt widgets to new refresh/repaint API
This commit is contained in:
@@ -148,7 +148,6 @@ function ReaderCropping:exitPageCrop(confirmed)
|
||||
else
|
||||
self:setCropZoomMode(confirmed)
|
||||
end
|
||||
UIManager.repaint_all = true
|
||||
end
|
||||
|
||||
function ReaderCropping:setCropZoomMode(confirmed)
|
||||
|
||||
@@ -267,22 +267,19 @@ function ReaderFooter:onTapFooter(arg, ges)
|
||||
self.mode = 0
|
||||
end
|
||||
self:applyFooterMode()
|
||||
local region = Geom:new{
|
||||
x = 0,
|
||||
y = Screen:getHeight() - self.height,
|
||||
w = Screen:getWidth(),
|
||||
h = self.height
|
||||
}
|
||||
UIManager.update_regions_func = function()
|
||||
return {region}
|
||||
end
|
||||
end
|
||||
if self.pageno then
|
||||
self:updateFooterPage()
|
||||
else
|
||||
self:updateFooterPos()
|
||||
end
|
||||
UIManager:setDirty(self.view.dialog, "partial")
|
||||
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
|
||||
|
||||
@@ -120,7 +120,6 @@ function ReaderHighlight:clear()
|
||||
else
|
||||
self.ui.document:clearSelection()
|
||||
end
|
||||
UIManager:setDirty(self.dialog, "full")
|
||||
if self.hold_pos then
|
||||
self.hold_pos = nil
|
||||
self.selected_text = nil
|
||||
@@ -240,13 +239,9 @@ function ReaderHighlight:onHold(arg, ges)
|
||||
table.insert(boxes, self.selected_word.sbox)
|
||||
self.view.highlight.temp[self.hold_pos.page] = boxes
|
||||
end
|
||||
--[[
|
||||
UIManager.update_regions_func = function()
|
||||
DEBUG("update ReaderHighlight onHold region", self.selected_word.sbox)
|
||||
return {self.selected_word.sbox}
|
||||
end
|
||||
--]]
|
||||
UIManager:setDirty(self.dialog, "partial")
|
||||
-- TODO: only mark word?
|
||||
-- UIManager:setDirty(self.dialog, "partial", self.selected_word.sbox)
|
||||
end
|
||||
return true
|
||||
end
|
||||
@@ -265,7 +260,12 @@ function ReaderHighlight:onHoldPan(arg, ges)
|
||||
|
||||
self.holdpan_pos = self.view:screenToPageTransform(ges.pos)
|
||||
DEBUG("holdpan position in page", self.holdpan_pos)
|
||||
local old_text = self.selected_text and self.selected_text.text
|
||||
self.selected_text = self.ui.document:getTextFromPositions(self.hold_pos, self.holdpan_pos)
|
||||
if self.selected_text and old_text and old_text == self.selected_text.text then
|
||||
-- no modification
|
||||
return
|
||||
end
|
||||
DEBUG("selected text:", self.selected_text)
|
||||
if self.selected_text then
|
||||
self.view.highlight.temp[self.hold_pos.page] = self.selected_text.sboxes
|
||||
|
||||
@@ -314,7 +314,8 @@ function ReaderPaging:onSwipe(arg, ges)
|
||||
self:onPagingRel(-1)
|
||||
end
|
||||
else
|
||||
UIManager.full_refresh = true
|
||||
-- trigger full refresh
|
||||
UIManager:setDirty(nil, "full")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -343,7 +344,8 @@ function ReaderPaging:onPanRelease(arg, ges)
|
||||
end
|
||||
else
|
||||
self.last_pan_relative_y = 0
|
||||
UIManager.full_refresh = true
|
||||
-- trigger full refresh
|
||||
UIManager:setDirty(nil, "full")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -649,7 +651,7 @@ function ReaderPaging:onScrollPageRel(diff)
|
||||
end
|
||||
-- update current pageno to the very last part in current view
|
||||
self:gotoPage(self.view.page_states[#self.view.page_states].page, "scrolling")
|
||||
UIManager:setDirty(self.view.dialog)
|
||||
UIManager:setDirty(self.view.dialog, "partial")
|
||||
end
|
||||
|
||||
function ReaderPaging:onGotoPageRel(diff)
|
||||
|
||||
@@ -389,7 +389,7 @@ function ReaderRolling:updatePos()
|
||||
self.old_page = new_page
|
||||
self.ui:handleEvent(Event:new("UpdateToc"))
|
||||
end
|
||||
UIManager.repaint_all = true
|
||||
UIManager:setDirty(self.view.dialog, "partial")
|
||||
end
|
||||
|
||||
--[[
|
||||
|
||||
@@ -42,7 +42,8 @@ function ReaderScreenshot:onScreenshot(filename)
|
||||
timeout = 2,
|
||||
})
|
||||
Screen:shot(screenshot_name)
|
||||
UIManager.full_refresh = true
|
||||
-- trigger full refresh
|
||||
UIManager:setDirty(nil, "full")
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ function ReaderSearch:onShowSearchDialog(text)
|
||||
}
|
||||
local res = do_search(self.searchFromCurrent, text, 0)()
|
||||
UIManager:show(self.search_dialog)
|
||||
-- TODO: regional
|
||||
UIManager:setDirty(self.dialog, "partial")
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -508,7 +508,7 @@ function ReaderView:recalculate()
|
||||
self.state.offset.x = (self.dimen.w - self.visible_area.w) / 2
|
||||
end
|
||||
-- flag a repaint so self:paintTo will be called
|
||||
UIManager:setDirty(self.dialog)
|
||||
UIManager:setDirty(self.dialog, "partial")
|
||||
end
|
||||
|
||||
function ReaderView:PanningUpdate(dx, dy)
|
||||
@@ -517,7 +517,7 @@ function ReaderView:PanningUpdate(dx, dy)
|
||||
self.visible_area:offsetWithin(self.page_area, dx, dy)
|
||||
if self.visible_area ~= old then
|
||||
-- flag a repaint
|
||||
UIManager:setDirty(self.dialog)
|
||||
UIManager:setDirty(self.dialog, "partial")
|
||||
DEBUG("on pan: page_area", self.page_area)
|
||||
DEBUG("on pan: visible_area", self.visible_area)
|
||||
self.ui:handleEvent(
|
||||
@@ -534,7 +534,7 @@ function ReaderView:PanningStart(x, y)
|
||||
self.visible_area = self.panning_visible_area:copy()
|
||||
self.visible_area:offsetWithin(self.page_area, x, y)
|
||||
self.ui:handleEvent(Event:new("ViewRecalculate", self.visible_area, self.page_area))
|
||||
UIManager:setDirty(self.dialog)
|
||||
UIManager:setDirty(self.dialog, "partial")
|
||||
end
|
||||
|
||||
function ReaderView:PanningStop()
|
||||
@@ -546,7 +546,7 @@ function ReaderView:SetZoomCenter(x, y)
|
||||
self.visible_area:centerWithin(self.page_area, x, y)
|
||||
if self.visible_area ~= old then
|
||||
self.ui:handleEvent(Event:new("ViewRecalculate", self.visible_area, self.page_area))
|
||||
UIManager:setDirty(self.dialog)
|
||||
UIManager:setDirty(self.dialog, "partial")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ function BBoxWidget:adjustScreenBBox(ges, relative)
|
||||
y1 = Math.round(bottom_right.y)
|
||||
}
|
||||
|
||||
UIManager.repaint_all = true
|
||||
UIManager:setDirty("all")
|
||||
end
|
||||
|
||||
function BBoxWidget:getModifiedPageBBox()
|
||||
|
||||
@@ -154,16 +154,16 @@ function Button:onTapSelectButton()
|
||||
if self.enabled and self.callback then
|
||||
UIManager:scheduleIn(0.0, function()
|
||||
self[1].invert = true
|
||||
UIManager.update_regions_func = function()
|
||||
return {self[1].dimen}
|
||||
end
|
||||
UIManager.repaint_all = true -- FIXME: Why?
|
||||
UIManager:setDirty(self.show_parent, "partial")
|
||||
UIManager:setDirty(self.show_parent, function()
|
||||
return "partial", self[1].dimen
|
||||
end)
|
||||
end)
|
||||
UIManager:scheduleIn(0.1, function()
|
||||
self.callback()
|
||||
self[1].invert = false
|
||||
UIManager:setDirty(self.show_parent, "partial")
|
||||
UIManager:setDirty(self.show_parent, function()
|
||||
return "partial", self[1].dimen
|
||||
end)
|
||||
end)
|
||||
end
|
||||
return true
|
||||
|
||||
@@ -70,10 +70,9 @@ function OptionTextItem:onTapSelect()
|
||||
self.config:onConfigChoose(self.values, self.name,
|
||||
self.event, self.args,
|
||||
self.events, self.current_item)
|
||||
UIManager.update_regions_func = function()
|
||||
return {self[1].dimen}
|
||||
end
|
||||
UIManager:setDirty(self.config, "partial")
|
||||
UIManager:setDirty(self.config, function()
|
||||
return "partial", self[1].dimen
|
||||
end)
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -125,10 +124,9 @@ function OptionIconItem:onTapSelect()
|
||||
self.config:onConfigChoose(self.values, self.name,
|
||||
self.event, self.args,
|
||||
self.events, self.current_item)
|
||||
UIManager.update_regions_func = function()
|
||||
return {self[1].dimen}
|
||||
end
|
||||
UIManager:setDirty(self.config, "partial")
|
||||
UIManager:setDirty(self.config, function()
|
||||
return "partial", self[1].dimen
|
||||
end)
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -525,7 +523,7 @@ end
|
||||
function ConfigDialog:onShowConfigPanel(index)
|
||||
self.panel_index = index
|
||||
self:update()
|
||||
UIManager.repaint_all = true
|
||||
UIManager:setDirty("all")
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -563,7 +561,7 @@ function ConfigDialog:onConfigChoose(values, name, event, args, events, position
|
||||
if events then
|
||||
self:onConfigEvents(events, position)
|
||||
end
|
||||
UIManager.repaint_all = true
|
||||
UIManager:setDirty("all")
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
@@ -256,8 +256,7 @@ function DictQuickLookup:update()
|
||||
self.dict_frame,
|
||||
}
|
||||
}
|
||||
UIManager.repaint_all = true
|
||||
UIManager.partial_refresh = true
|
||||
UIManager:setDirty("all", "partial")
|
||||
end
|
||||
|
||||
function DictQuickLookup:isPrevDictAvaiable()
|
||||
|
||||
@@ -80,6 +80,7 @@ function FocusManager:onFocusMove(args)
|
||||
current_item:handleEvent(Event:new("Unfocus"))
|
||||
self.layout[self.selected.y][self.selected.x]:handleEvent(Event:new("Focus"))
|
||||
-- trigger a repaint (we need to be the registered widget!)
|
||||
-- TODO: is this really needed?
|
||||
UIManager:setDirty(self.show_parent or self, "partial")
|
||||
break
|
||||
end
|
||||
|
||||
@@ -43,16 +43,17 @@ end
|
||||
function IconButton:onTapClickButton()
|
||||
UIManager:scheduleIn(0.0, function()
|
||||
self.image.invert = true
|
||||
UIManager.update_regions_func = function()
|
||||
return {self[1].dimen}
|
||||
end
|
||||
UIManager:setDirty(self.show_parent, "partial")
|
||||
UIManager:setDirty(self.show_parent, function()
|
||||
return "partial", self[1].dimen
|
||||
end)
|
||||
end)
|
||||
-- make sure button reacts before doing callback
|
||||
UIManager:scheduleIn(0.1, function()
|
||||
self.callback()
|
||||
self.image.invert = false
|
||||
UIManager:setDirty(self.show_parent, "partial")
|
||||
UIManager:setDirty(self.show_parent, function()
|
||||
return "partial", self[1].dimen
|
||||
end)
|
||||
end)
|
||||
return true
|
||||
end
|
||||
|
||||
@@ -116,8 +116,8 @@ function InputDialog:init()
|
||||
},
|
||||
self.dialog_frame,
|
||||
}
|
||||
UIManager.repaint_all = true
|
||||
UIManager.full_refresh = true
|
||||
-- do a full refresh - is this really needed?
|
||||
UIManager:setDirty("all", "full")
|
||||
end
|
||||
|
||||
function InputDialog:onShowKeyboard()
|
||||
|
||||
@@ -154,7 +154,9 @@ function InputText:addChar(char)
|
||||
table.insert(self.charlist, self.charpos, char)
|
||||
self.charpos = self.charpos + 1
|
||||
self:initTextBox(table.concat(self.charlist))
|
||||
UIManager:setDirty(self.parent, "partial")
|
||||
UIManager:setDirty(self.parent, function()
|
||||
return "ui", self.dimen
|
||||
end)
|
||||
end
|
||||
|
||||
function InputText:delChar()
|
||||
@@ -162,12 +164,14 @@ function InputText:delChar()
|
||||
self.charpos = self.charpos - 1
|
||||
table.remove(self.charlist, self.charpos)
|
||||
self:initTextBox(table.concat(self.charlist))
|
||||
UIManager:setDirty(self.parent, "partial")
|
||||
UIManager:setDirty(self.parent, "ui")
|
||||
end
|
||||
|
||||
function InputText:clear()
|
||||
self:initTextBox("")
|
||||
UIManager:setDirty(self.parent, "partial")
|
||||
UIManager:setDirty(self.parent, function()
|
||||
return "ui", self.dimen
|
||||
end)
|
||||
end
|
||||
|
||||
function InputText:getText()
|
||||
@@ -176,7 +180,9 @@ end
|
||||
|
||||
function InputText:setText(text)
|
||||
self:initTextBox(text)
|
||||
UIManager:setDirty(self.parent, "partial")
|
||||
UIManager:setDirty(self.parent, function()
|
||||
return "partial", self.dimen
|
||||
end)
|
||||
end
|
||||
|
||||
return InputText
|
||||
|
||||
@@ -87,8 +87,7 @@ function LoginDialog:init()
|
||||
},
|
||||
self.dialog_frame,
|
||||
}
|
||||
UIManager.repaint_all = true
|
||||
UIManager.full_refresh = true
|
||||
UIManager:setDirty("all", "full")
|
||||
end
|
||||
|
||||
function LoginDialog:getCredential()
|
||||
|
||||
@@ -283,6 +283,7 @@ end
|
||||
function MenuItem:onTapSelect(arg, ges)
|
||||
local pos = self:getGesPosition(ges)
|
||||
self[1].invert = true
|
||||
-- TODO: regional refresh
|
||||
UIManager:setDirty(self.show_parent, "partial")
|
||||
UIManager:scheduleIn(0.1, function()
|
||||
self[1].invert = false
|
||||
@@ -295,6 +296,7 @@ end
|
||||
function MenuItem:onHoldSelect(arg, ges)
|
||||
local pos = self:getGesPosition(ges)
|
||||
self[1].invert = true
|
||||
-- TODO: regional refresh
|
||||
UIManager:setDirty(self.show_parent, "partial")
|
||||
UIManager:scheduleIn(0.1, function()
|
||||
self[1].invert = false
|
||||
@@ -650,7 +652,9 @@ function Menu:updateItems(select_number)
|
||||
|
||||
-- nicolua
|
||||
-- FIXME: dirty hack to clear previous menus
|
||||
UIManager:setDirty(self.show_parent or self)
|
||||
-- TODO: regional refresh
|
||||
UIManager:setDirty("all", "partial")
|
||||
--UIManager:setDirty(self.show_parent or self, "partial")
|
||||
end
|
||||
|
||||
--[[
|
||||
|
||||
@@ -79,8 +79,7 @@ function MultiInputDialog:init()
|
||||
},
|
||||
self.dialog_frame,
|
||||
}
|
||||
UIManager.repaint_all = true
|
||||
UIManager.full_refresh = true
|
||||
UIManager:setDirty("all", "full")
|
||||
end
|
||||
|
||||
function MultiInputDialog:getFields()
|
||||
|
||||
@@ -77,10 +77,9 @@ function ScrollTextWidget:onScrollText(arg, ges)
|
||||
self.text_widget:scrollUp()
|
||||
self:updateScrollBar(self.text_widget)
|
||||
end
|
||||
UIManager.update_regions_func = function()
|
||||
return {self.dimen}
|
||||
end
|
||||
UIManager:setDirty(self.dialog, "partial")
|
||||
UIManager:setDirty(self.dialog, function()
|
||||
return "partial", self.dimen
|
||||
end)
|
||||
end
|
||||
|
||||
return ScrollTextWidget
|
||||
|
||||
@@ -144,10 +144,9 @@ function ToggleSwitch:onTapSelect(arg, gev)
|
||||
--]]
|
||||
self.config:onConfigChoose(self.values, self.name,
|
||||
self.event, self.args, self.events, self.position)
|
||||
UIManager.update_regions_func = function()
|
||||
return {self.dimen}
|
||||
end
|
||||
UIManager:setDirty(self.config, "partial")
|
||||
UIManager:setDirty(self.config, function()
|
||||
return "partial", self.dimen
|
||||
end)
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
@@ -98,17 +98,18 @@ function TouchMenuItem:onTapSelect(arg, ges)
|
||||
|
||||
UIManager:scheduleIn(0.0, function()
|
||||
self.item_frame.invert = true
|
||||
UIManager.update_regions_func = function()
|
||||
return {self.dimen}
|
||||
end
|
||||
UIManager:setDirty(self.show_parent, "partial")
|
||||
UIManager:setDirty(self.show_parent, function()
|
||||
return "partial", self.dimen
|
||||
end)
|
||||
end)
|
||||
UIManager:scheduleIn(0.1, function()
|
||||
self.menu:onMenuSelect(self.item)
|
||||
end)
|
||||
UIManager:scheduleIn(0.5, function()
|
||||
self.item_frame.invert = false
|
||||
UIManager:setDirty(self.show_parent, "partial")
|
||||
UIManager:setDirty(self.show_parent, function()
|
||||
return "partial", self.dimen
|
||||
end)
|
||||
end)
|
||||
return true
|
||||
end
|
||||
@@ -122,17 +123,18 @@ function TouchMenuItem:onHoldSelect(arg, ges)
|
||||
|
||||
UIManager:scheduleIn(0.0, function()
|
||||
self.item_frame.invert = true
|
||||
UIManager.update_regions_func = function()
|
||||
return {self.dimen}
|
||||
end
|
||||
UIManager:setDirty(self.show_parent, "partial")
|
||||
UIManager:setDirty(self.show_parent, function()
|
||||
return "partial", self.dimen
|
||||
end)
|
||||
end)
|
||||
UIManager:scheduleIn(0.1, function()
|
||||
self.menu:onMenuHold(self.item)
|
||||
end)
|
||||
UIManager:scheduleIn(0.5, function()
|
||||
self.item_frame.invert = false
|
||||
UIManager:setDirty(self.show_parent, "partial")
|
||||
UIManager:setDirty(self.show_parent, function()
|
||||
return "partial", self.dimen
|
||||
end)
|
||||
end)
|
||||
return true
|
||||
end
|
||||
@@ -460,7 +462,9 @@ function TouchMenu:updateItems()
|
||||
self.time_info.text = os.date("%H:%M").." @ "..Device:getPowerDevice():getCapacity().."%"
|
||||
-- FIXME: this is a dirty hack to clear previous menus
|
||||
-- refer to issue #664 (in kindlepdfviewer)
|
||||
UIManager.repaint_all = true
|
||||
-- TODO: regional refresh
|
||||
UIManager:setDirty("all", "partial")
|
||||
--UIManager:setDirty(self.show_parent or self, "partial")
|
||||
end
|
||||
|
||||
function TouchMenu:switchMenuTab(tab_num)
|
||||
|
||||
@@ -96,21 +96,22 @@ function VirtualKey:init()
|
||||
end
|
||||
|
||||
function VirtualKey:update_keyboard()
|
||||
UIManager.update_regions_func = function()
|
||||
UIManager:setDirty(self.keyboard, function()
|
||||
DEBUG("update key region", self[1].dimen)
|
||||
return {self[1].dimen}
|
||||
end
|
||||
UIManager:setDirty(self.keyboard, "partial")
|
||||
return "ui", self[1].dimen
|
||||
end)
|
||||
end
|
||||
|
||||
function VirtualKey:update_keyboard_inputbox()
|
||||
local inputbox = self.keyboard.inputbox
|
||||
UIManager.update_regions_func = function()
|
||||
DEBUG("update keyboard and inputbox", self[1].dimen, inputbox.dimen)
|
||||
return {self[1].dimen, inputbox.dimen}
|
||||
end
|
||||
UIManager:setDirty(inputbox, "partial")
|
||||
UIManager:setDirty(self.keyboard, "partial")
|
||||
UIManager:setDirty(self.keyboard, function()
|
||||
DEBUG("update inputbox", inputbox.dimen)
|
||||
return "ui", inputbox.dimen
|
||||
end)
|
||||
UIManager:setDirty(self.keyboard, function()
|
||||
DEBUG("update keyboard", self[1].dimen)
|
||||
return "ui", self[1].dimen
|
||||
end)
|
||||
end
|
||||
|
||||
function VirtualKey:onTapSelect()
|
||||
@@ -318,8 +319,13 @@ function VirtualKeyboard:setLayout(key)
|
||||
if self.utf8mode then self.umlautmode = false end
|
||||
end
|
||||
self:initLayout()
|
||||
UIManager.update_regions_func = nil
|
||||
UIManager:setDirty(self, "partial")
|
||||
UIManager:setDirty(self, function()
|
||||
-- correct coordinates of keyboard
|
||||
local dimen = self.dimen:copy()
|
||||
dimen.y = Screen:getHeight() - dimen.h
|
||||
DEBUG("update keyboard layout", dimen)
|
||||
return "partial", dimen
|
||||
end)
|
||||
end
|
||||
|
||||
function VirtualKeyboard:addChar(key)
|
||||
|
||||
19
frontend/up_reg.list
Normal file
19
frontend/up_reg.list
Normal file
@@ -0,0 +1,19 @@
|
||||
./apps/reader/modules/readerfooter.lua: UIManager.update_regions_func = function()
|
||||
./apps/reader/modules/readerhighlight.lua: UIManager.update_regions_func = function()
|
||||
./ui/widget/button.lua: UIManager.update_regions_func = function()
|
||||
./ui/widget/iconbutton.lua: UIManager.update_regions_func = function()
|
||||
./ui/widget/dictquicklookup.lua: UIManager.update_regions_func = function()
|
||||
./ui/widget/scrolltextwidget.lua: UIManager.update_regions_func = function()
|
||||
./ui/widget/touchmenu.lua: UIManager.update_regions_func = function()
|
||||
./ui/widget/touchmenu.lua: UIManager.update_regions_func = function()
|
||||
./ui/widget/virtualkeyboard.lua: UIManager.update_regions_func = function()
|
||||
./ui/widget/virtualkeyboard.lua: UIManager.update_regions_func = function()
|
||||
./ui/widget/virtualkeyboard.lua: UIManager.update_regions_func = nil
|
||||
./ui/widget/toggleswitch.lua: UIManager.update_regions_func = function()
|
||||
./ui/widget/configdialog.lua: UIManager.update_regions_func = function()
|
||||
./ui/widget/configdialog.lua: UIManager.update_regions_func = function()
|
||||
./ui/uimanager.lua: update_regions_func = nil,
|
||||
./ui/uimanager.lua: if self.update_regions_func then
|
||||
./ui/uimanager.lua: local update_regions = self.update_regions_func()
|
||||
./ui/uimanager.lua: for _, update_region in ipairs(update_regions) do
|
||||
./ui/uimanager.lua: self.update_regions_func = nil
|
||||
Reference in New Issue
Block a user