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.
This commit is contained in:
poire-z
2023-10-08 17:51:43 +02:00
parent 35f16f87a4
commit bbf923c7a8
3 changed files with 37 additions and 4 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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