2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00

Allow for disabling flashing of menu, icons and buttons (#3339)

This commit is contained in:
poire-z 2017-10-10 23:50:45 +02:00 committed by Frans de Jonge
parent 430b61ba76
commit f90973f73a
8 changed files with 128 additions and 80 deletions

View File

@ -111,6 +111,7 @@ common_settings.screen = {
require("ui/elements/screen_eink_opt_menu_table"),
require("ui/elements/menu_activate"),
require("ui/elements/screen_disable_double_tap_table"),
require("ui/elements/flash_ui"),
require("ui/elements/flash_keyboard"),
},
}

View File

@ -0,0 +1,11 @@
local _ = require("gettext")
return {
text = _("Flash buttons and menu items"),
checked_func = function()
return G_reader_settings:nilOrTrue("flash_ui")
end,
callback = function()
G_reader_settings:flipNilOrTrue("flash_ui")
end,
}

View File

@ -188,19 +188,23 @@ end
function Button:onTapSelectButton()
if self.enabled and self.callback then
UIManager:scheduleIn(0.0, function()
self[1].invert = true
UIManager:setDirty(self.show_parent, function()
return "ui", self[1].dimen
end)
end)
UIManager:scheduleIn(0.1, function()
if G_reader_settings:isFalse("flash_ui") then
self.callback()
self[1].invert = false
UIManager:setDirty(self.show_parent, function()
return "ui", self[1].dimen
else
UIManager:scheduleIn(0.0, function()
self[1].invert = true
UIManager:setDirty(self.show_parent, function()
return "ui", self[1].dimen
end)
end)
end)
UIManager:scheduleIn(0.1, function()
self.callback()
self[1].invert = false
UIManager:setDirty(self.show_parent, function()
return "ui", self[1].dimen
end)
end)
end
elseif self.tap_input then
self:onInput(self.tap_input)
elseif type(self.tap_input_func) == "function" then

View File

@ -88,19 +88,23 @@ end
function CheckButton:onTapCheckButton()
if self.enabled and self.callback then
UIManager:scheduleIn(0.0, function()
self.invert = true
UIManager:setDirty(self.show_parent, function()
return "ui", self.dimen
end)
end)
UIManager:scheduleIn(0.1, function()
if G_reader_settings:isFalse("flash_ui") then
self.callback()
self.invert = false
UIManager:setDirty(self.show_parent, function()
return "ui", self.dimen
else
UIManager:scheduleIn(0.0, function()
self.invert = true
UIManager:setDirty(self.show_parent, function()
return "ui", self.dimen
end)
end)
end)
UIManager:scheduleIn(0.1, function()
self.callback()
self.invert = false
UIManager:setDirty(self.show_parent, function()
return "ui", self.dimen
end)
end)
end
elseif self.tap_input then
self:onInput(self.tap_input)
elseif type(self.tap_input_func) == "function" then

View File

@ -92,20 +92,24 @@ function IconButton:initGesListener()
end
function IconButton:onTapIconButton()
UIManager:scheduleIn(0.0, function()
self.image.invert = true
UIManager:setDirty(self.show_parent, function()
return "ui", self[1].dimen
end)
end)
-- make sure button reacts before doing callback
UIManager:scheduleIn(0.1, function()
if G_reader_settings:isFalse("flash_ui") then
self.callback()
self.image.invert = false
UIManager:setDirty(self.show_parent, function()
return "ui", self[1].dimen
else
UIManager:scheduleIn(0.0, function()
self.image.invert = true
UIManager:setDirty(self.show_parent, function()
return "ui", self[1].dimen
end)
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, function()
return "ui", self[1].dimen
end)
end)
end
return true
end

View File

@ -211,17 +211,21 @@ end
function KeyValueItem:onTap()
if self.callback then
self[1].invert = true
UIManager:setDirty(self.show_parent, function()
return "ui", self[1].dimen
end)
UIManager:scheduleIn(0.1, function()
if G_reader_settings:isFalse("flash_ui") then
self.callback()
self[1].invert = false
else
self[1].invert = true
UIManager:setDirty(self.show_parent, function()
return "ui", self[1].dimen
end)
end)
UIManager:scheduleIn(0.1, function()
self.callback()
self[1].invert = false
UIManager:setDirty(self.show_parent, function()
return "ui", self[1].dimen
end)
end)
end
end
return true
end

View File

@ -295,35 +295,47 @@ end
function MenuItem:onTapSelect(arg, ges)
local pos = self:getGesPosition(ges)
self[1].invert = true
local refreshfunc = function()
return "ui", self[1].dimen
end
UIManager:setDirty(self.show_parent, refreshfunc)
UIManager:scheduleIn(0.1, function()
self[1].invert = false
UIManager:setDirty(self.show_parent, refreshfunc)
if G_reader_settings:isFalse("flash_ui") then
logger.dbg("creating coroutine for menu select")
local co = coroutine.create(function()
self.menu:onMenuSelect(self.table, pos)
end)
coroutine.resume(co)
end)
else
self[1].invert = true
local refreshfunc = function()
return "ui", self[1].dimen
end
UIManager:setDirty(self.show_parent, refreshfunc)
UIManager:scheduleIn(0.1, function()
self[1].invert = false
UIManager:setDirty(self.show_parent, refreshfunc)
logger.dbg("creating coroutine for menu select")
local co = coroutine.create(function()
self.menu:onMenuSelect(self.table, pos)
end)
coroutine.resume(co)
end)
end
return true
end
function MenuItem:onHoldSelect(arg, ges)
local pos = self:getGesPosition(ges)
self[1].invert = true
local refreshfunc = function()
return "ui", self[1].dimen
end
UIManager:setDirty(self.show_parent, refreshfunc)
UIManager:scheduleIn(0.1, function()
self[1].invert = false
UIManager:setDirty(self.show_parent, refreshfunc)
if G_reader_settings:isFalse("flash_ui") then
self.menu:onMenuHold(self.table, pos)
end)
else
self[1].invert = true
local refreshfunc = function()
return "ui", self[1].dimen
end
UIManager:setDirty(self.show_parent, refreshfunc)
UIManager:scheduleIn(0.1, function()
self[1].invert = false
UIManager:setDirty(self.show_parent, refreshfunc)
self.menu:onMenuHold(self.table, pos)
end)
end
return true
end

View File

@ -107,18 +107,22 @@ function TouchMenuItem:onTapSelect(arg, ges)
end
if enabled == false then return end
self.item_frame.invert = true
UIManager:setDirty(self.show_parent, function()
return "ui", self.dimen
end)
-- yield to main UI loop to invert item
UIManager:scheduleIn(0.1, function()
if G_reader_settings:isFalse("flash_ui") then
self.menu:onMenuSelect(self.item)
self.item_frame.invert = false
else
self.item_frame.invert = true
UIManager:setDirty(self.show_parent, function()
return "ui", self.dimen
end)
end)
-- yield to main UI loop to invert item
UIManager:scheduleIn(0.1, function()
self.menu:onMenuSelect(self.item)
self.item_frame.invert = false
UIManager:setDirty(self.show_parent, function()
return "ui", self.dimen
end)
end)
end
return true
end
@ -129,21 +133,25 @@ function TouchMenuItem:onHoldSelect(arg, ges)
end
if enabled == false then return end
UIManager:scheduleIn(0.0, function()
self.item_frame.invert = true
UIManager:setDirty(self.show_parent, function()
return "ui", self.dimen
end)
end)
UIManager:scheduleIn(0.1, function()
if G_reader_settings:isFalse("flash_ui") then
self.menu:onMenuHold(self.item)
end)
UIManager:scheduleIn(0.5, function()
self.item_frame.invert = false
UIManager:setDirty(self.show_parent, function()
return "ui", self.dimen
else
UIManager:scheduleIn(0.0, function()
self.item_frame.invert = true
UIManager:setDirty(self.show_parent, function()
return "ui", self.dimen
end)
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, function()
return "ui", self.dimen
end)
end)
end
return true
end