BookMap/PageBrowser: allow mousewheel scrolling

Also fix SDL to use sendEvent() instead of broadcastEvent(),
so such BookMap scrolling doesn't also scroll pages in the
book below.
reviewable/pr10990/r1
poire-z 7 months ago
parent 35f16f87a4
commit bbf923c7a8

@ -230,12 +230,12 @@ function Device:init()
local fake_release_ev = Event:new("Gesture", fake_ges_release)
if scrolled_y == down then
fake_ges.direction = "north"
UIManager:broadcastEvent(fake_pan_ev)
UIManager:broadcastEvent(fake_release_ev)
UIManager:sendEvent(fake_pan_ev)
UIManager:sendEvent(fake_release_ev)
elseif scrolled_y == up then
fake_ges.direction = "south"
UIManager:broadcastEvent(fake_pan_ev)
UIManager:broadcastEvent(fake_release_ev)
UIManager:sendEvent(fake_pan_ev)
UIManager:sendEvent(fake_release_ev)
end
elseif ev.code == SDL_MULTIGESTURE then
-- no-op for now

@ -639,6 +639,12 @@ function BookMapWidget:init()
range = self.dimen,
}
},
Pan = { -- (for mousewheel scrolling support)
GestureRange:new{
ges = "pan",
range = self.dimen,
}
},
Tap = {
GestureRange:new{
ges = "tap",
@ -1608,6 +1614,16 @@ function BookMapWidget:onSwipe(arg, ges)
end
end
function BookMapWidget:onPan(arg, ges)
if ges.mousewheel_direction then
if ges.direction == "north" then
return self:onScrollRowDown()
elseif ges.direction == "south" then
return self:onScrollRowUp()
end
end
end
function BookMapWidget:onPinch(arg, ges)
if self.overview_mode then
return true

@ -76,6 +76,12 @@ function PageBrowserWidget:init()
range = self.dimen,
}
},
Pan = { -- (for mousewheel scrolling support)
GestureRange:new{
ges = "pan",
range = self.dimen,
}
},
Tap = {
GestureRange:new{
ges = "tap",
@ -1176,6 +1182,17 @@ function PageBrowserWidget:onSwipe(arg, ges)
end
end
function PageBrowserWidget:onPan(arg, ges)
if ges.mousewheel_direction then
if ges.direction == "north" then
self:onScrollRowDown()
elseif ges.direction == "south" then
self:onScrollRowUp()
end
end
return true
end
function PageBrowserWidget:onPinch(arg, ges)
if ges.direction == "horizontal" then
if self:updateNbCols(1, true) then

Loading…
Cancel
Save