Allow any multiswipe to close some fullscreen widgets

For consistency with BookMap and PageBrowser widgets
where swipe south (the usual gesture to quick close)
can't be used for closing and we had to use any
multiswipe instead, allow any multiswipe to close
these other fullscreen widgets too:
Menu (ToC, Bookmarks), KeyValuePage, ImageViewer,
BookStatusWidget, ReaderProgress, CalendarView.
reviewable/pr8733/r1
poire-z 2 years ago
parent 3af268dd7a
commit 95b35ec669

@ -114,6 +114,12 @@ function BookStatusWidget:init()
range = function() return self.dimen end,
}
}
self.ges_events.MultiSwipe = {
GestureRange:new{
ges = "multiswipe",
range = function() return self.dimen end,
}
}
end
local screen_size = Screen:getSize()
@ -602,6 +608,14 @@ function BookStatusWidget:onSwipe(arg, ges_ev)
end
end
function BookStatusWidget:onMultiSwipe(arg, ges_ev)
-- For consistency with other fullscreen widgets where swipe south can't be
-- used to close and where we then allow any multiswipe to close, allow any
-- multiswipe to close this widget too.
self:onClose()
return true
end
function BookStatusWidget:onClose()
self:saveSummary()
-- NOTE: Flash on close to avoid ghosting, since we show an image.

@ -115,6 +115,8 @@ function ImageViewer:init()
scale = {diagonal - Screen:scaleBySize(200), diagonal}, rate = 1.0,
}
},
-- Allow closing with any multiswipe
MultiSwipe = { GestureRange:new{ ges = "multiswipe", range = range } },
}
end
if self.fullscreen then
@ -549,6 +551,13 @@ function ImageViewer:onSwipe(_, ges)
return true
end
function ImageViewer:onMultiSwipe(_, ges)
-- As swipe south to close is only enabled when scaled to fit, but not
-- when we are zoomed in/out, allow any multiswipe to close.
self:onClose()
return true
end
function ImageViewer:onHold(_, ges)
-- Start of pan
self._panning = true

@ -295,6 +295,12 @@ function KeyValuePage:init()
range = self.dimen,
}
}
self.ges_events.MultiSwipe = {
GestureRange:new{
ges = "multiswipe",
range = self.dimen,
}
}
end
-- return button
@ -634,6 +640,14 @@ function KeyValuePage:onSwipe(arg, ges_ev)
end
end
function KeyValuePage:onMultiSwipe(arg, ges_ev)
-- For consistency with other fullscreen widgets where swipe south can't be
-- used to close and where we then allow any multiswipe to close, allow any
-- multiswipe to close this widget too.
self:onClose()
return true
end
function KeyValuePage:onClose()
UIManager:close(self)
return true

@ -914,6 +914,12 @@ function Menu:init()
range = self.dimen,
}
}
self.ges_events.MultiSwipe = {
GestureRange:new{
ges = "multiswipe",
range = self.dimen,
}
}
end
self.ges_events.Close = self.on_close_ges
end
@ -1348,7 +1354,7 @@ function Menu:onSwipe(arg, ges_ev)
elseif direction == "south" then
if self.has_close_button and not self.no_title then
-- If there is a close button displayed (so, this Menu can be
-- closed), allow easier closing with swipe up/down
-- closed), allow easier closing with swipe south.
self:onClose()
end
-- If there is no close button, it's a top level Menu and swipe
@ -1362,6 +1368,18 @@ function Menu:onSwipe(arg, ges_ev)
end
end
function Menu:onMultiSwipe(arg, ges_ev)
-- For consistency with other fullscreen widgets where swipe south can't be
-- used to close and where we then allow any multiswipe to close, allow any
-- multiswipe to close this widget too.
if self.has_close_button and not self.no_title then
-- If there is a close button displayed (so, this Menu can be
-- closed), allow easier closing with swipe south.
self:onClose()
end
return true
end
function Menu:setTitleBarLeftIcon(icon)
self.title_bar:setLeftIcon(icon)
end

@ -442,6 +442,12 @@ function CalendarView:init()
range = self.dimen,
}
}
self.ges_events.MultiSwipe = {
GestureRange:new{
ges = "multiswipe",
range = self.dimen,
}
}
end
self.outer_padding = Size.padding.large
@ -830,6 +836,14 @@ function CalendarView:onSwipe(arg, ges_ev)
end
end
function CalendarView:onMultiSwipe(arg, ges_ev)
-- For consistency with other fullscreen widgets where swipe south can't be
-- used to close and where we then allow any multiswipe to close, allow any
-- multiswipe to close this widget too.
self:onClose()
return true
end
function CalendarView:onClose()
UIManager:close(self)
return true

@ -71,6 +71,12 @@ function ReaderProgress:init()
range = function() return self.dimen end,
}
}
self.ges_events.MultiSwipe = {
GestureRange:new{
ges = "multiswipe",
range = function() return self.dimen end,
}
}
end
self.covers_fullscreen = true -- hint for UIManager:_repaint()
self[1] = FrameContainer:new{
@ -519,6 +525,14 @@ function ReaderProgress:onSwipe(arg, ges_ev)
end
end
function ReaderProgress:onMultiSwipe(arg, ges_ev)
-- For consistency with other fullscreen widgets where swipe south can't be
-- used to close and where we then allow any multiswipe to close, allow any
-- multiswipe to close this widget too.
self:onClose()
return true
end
function ReaderProgress:onClose()
UIManager:close(self)
return true

Loading…
Cancel
Save