add modal widget type that will stay on the top of window stack

ConfirmBox and InfoMessage are default to be modal.
Now returning to filamanager after highlighting a PDF page
the confirmbox asking users to save the document will not be hidden by
the filamanager window.
And it's tested on Kindle that #791 is already been solved probably by
out refacorting of MuPDF backend.
pull/1071/head
chrox 10 years ago
parent dfcd67c5bf
commit 84029e9694

@ -132,10 +132,20 @@ function UIManager:init()
end
-- register & show a widget
-- modal widget should be always on the top
function UIManager:show(widget, x, y)
DEBUG("show widget", widget.id)
self._running = true
-- put widget on top of stack
table.insert(self._window_stack, {x = x or 0, y = y or 0, widget = widget})
local window = {x = x or 0, y = y or 0, widget = widget}
-- put this window on top of the toppest non-modal window
for i = #self._window_stack, 0, -1 do
local top_window = self._window_stack[i]
-- skip modal window
if not top_window or not top_window.widget.modal then
table.insert(self._window_stack, i + 1, window)
break
end
end
-- and schedule it to be painted
self:setDirty(widget)
-- tell the widget that it is shown now
@ -148,6 +158,7 @@ end
-- unregister a widget
function UIManager:close(widget)
DEBUG("close widget", widget.id)
Input.disable_double_tap = DGESDETECT_DISABLE_DOUBLE_TAP
local dirty = false
for i = #self._window_stack, 1, -1 do
@ -226,6 +237,7 @@ end
-- signal to quit
function UIManager:quit()
DEBUG("quit uimanager")
self._running = false
for i = #self._window_stack, 1, -1 do
table.remove(self._window_stack, i)

@ -24,6 +24,7 @@ local Blitbuffer = require("ffi/blitbuffer")
Widget that shows a message and OK/Cancel buttons
]]
local ConfirmBox = InputContainer:new{
modal = true,
text = _("no text"),
face = Font:getFace("infofont", 25),
ok_text = _("OK"),

@ -21,6 +21,7 @@ Widget that displays an informational message
it vanishes on key press or after a given timeout
]]
local InfoMessage = InputContainer:new{
modal = true,
face = Font:getFace("infofont", 25),
text = "",
timeout = nil, -- in seconds

Loading…
Cancel
Save