2
0
mirror of https://github.com/koreader/koreader synced 2024-11-13 19:11:25 +00:00

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) local fake_release_ev = Event:new("Gesture", fake_ges_release)
if scrolled_y == down then if scrolled_y == down then
fake_ges.direction = "north" fake_ges.direction = "north"
UIManager:broadcastEvent(fake_pan_ev) UIManager:sendEvent(fake_pan_ev)
UIManager:broadcastEvent(fake_release_ev) UIManager:sendEvent(fake_release_ev)
elseif scrolled_y == up then elseif scrolled_y == up then
fake_ges.direction = "south" fake_ges.direction = "south"
UIManager:broadcastEvent(fake_pan_ev) UIManager:sendEvent(fake_pan_ev)
UIManager:broadcastEvent(fake_release_ev) UIManager:sendEvent(fake_release_ev)
end end
elseif ev.code == SDL_MULTIGESTURE then elseif ev.code == SDL_MULTIGESTURE then
-- no-op for now -- no-op for now

View File

@ -639,6 +639,12 @@ function BookMapWidget:init()
range = self.dimen, range = self.dimen,
} }
}, },
Pan = { -- (for mousewheel scrolling support)
GestureRange:new{
ges = "pan",
range = self.dimen,
}
},
Tap = { Tap = {
GestureRange:new{ GestureRange:new{
ges = "tap", ges = "tap",
@ -1608,6 +1614,16 @@ function BookMapWidget:onSwipe(arg, ges)
end end
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) function BookMapWidget:onPinch(arg, ges)
if self.overview_mode then if self.overview_mode then
return true return true

View File

@ -76,6 +76,12 @@ function PageBrowserWidget:init()
range = self.dimen, range = self.dimen,
} }
}, },
Pan = { -- (for mousewheel scrolling support)
GestureRange:new{
ges = "pan",
range = self.dimen,
}
},
Tap = { Tap = {
GestureRange:new{ GestureRange:new{
ges = "tap", ges = "tap",
@ -1176,6 +1182,17 @@ function PageBrowserWidget:onSwipe(arg, ges)
end end
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) function PageBrowserWidget:onPinch(arg, ges)
if ges.direction == "horizontal" then if ges.direction == "horizontal" then
if self:updateNbCols(1, true) then if self:updateNbCols(1, true) then