[UX] Gesture manager: add two-finger swipe left and right (#4815)

Also add Device:hasMultitouch() to control whether the configuration menu is shown.

Cf. #4727.
pull/4822/head
Frans de Jonge 5 years ago committed by GitHub
parent 523be5e7d9
commit 728bb187fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -29,21 +29,6 @@ function ReaderBookmark:init()
doc = "show bookmarks" }, doc = "show bookmarks" },
} }
end end
if Device:isTouchDevice() then
self.ges_events = {
ShowBookmark = {
GestureRange:new{
ges = "two_finger_swipe",
range = Geom:new{
x = 0, y = 0,
w = Screen:getWidth(),
h = Screen:getHeight(),
},
direction = "west"
}
},
}
end
self.ui.menu:registerToMainMenu(self) self.ui.menu:registerToMainMenu(self)
end end

@ -171,6 +171,9 @@ function ReaderGesture:init()
multiswipe_northwest_southwest_northwest = Device:hasWifiToggle() and "toggle_wifi" or "nothing", multiswipe_northwest_southwest_northwest = Device:hasWifiToggle() and "toggle_wifi" or "nothing",
multiswipe_southeast_southwest_northwest = Device:hasWifiToggle() and "wifi_off" or "nothing", multiswipe_southeast_southwest_northwest = Device:hasWifiToggle() and "wifi_off" or "nothing",
multiswipe_southeast_northeast_northwest = Device:hasWifiToggle() and "wifi_on" or "nothing", multiswipe_southeast_northeast_northwest = Device:hasWifiToggle() and "wifi_on" or "nothing",
two_finger_swipe_west = self.ges_mode == "gesture_reader" and "bookmarks" or "folder_shortcuts",
two_finger_swipe_east = self.ges_mode == "gesture_reader" and "toc" or "nothing",
} }
local gm = G_reader_settings:readSetting(self.ges_mode) local gm = G_reader_settings:readSetting(self.ges_mode)
if gm == nil then G_reader_settings:saveSetting(self.ges_mode, {}) end if gm == nil then G_reader_settings:saveSetting(self.ges_mode, {}) end
@ -290,6 +293,7 @@ function ReaderGesture:addToMainMenu(menu_items)
{ {
text = _("Tap bottom right corner"), text = _("Tap bottom right corner"),
sub_item_table = self:buildMenu("tap_right_bottom_corner", self.default_gesture["tap_right_bottom_corner"]), sub_item_table = self:buildMenu("tap_right_bottom_corner", self.default_gesture["tap_right_bottom_corner"]),
separator = true,
}, },
{ {
text = _("Short diagonal swipe"), text = _("Short diagonal swipe"),
@ -297,6 +301,21 @@ function ReaderGesture:addToMainMenu(menu_items)
}, },
}, },
} }
if Device:hasMultitouch() then
table.insert(menu_items.gesture_manager.sub_item_table, {
text = _("Two-finger swipes"),
sub_item_table = {
{
text = _("Two-finger swipe left"),
sub_item_table = self:buildMenu("two_finger_swipe_west", self.default_gesture["two_finger_swipe_west"]),
},
{
text = _("Two-finger swipe right"),
sub_item_table = self:buildMenu("two_finger_swipe_east", self.default_gesture["two_finger_swipe_east"]),
},
},
})
end
end end
function ReaderGesture:buildMenu(ges, default) function ReaderGesture:buildMenu(ges, default)
@ -519,12 +538,15 @@ function ReaderGesture:setupGesture(ges, action)
local zone local zone
local overrides local overrides
local direction, distance local direction, distance
local zone_fullscreen = {
ratio_x = 0.0, ratio_y = 0,
ratio_w = 1, ratio_h = 1,
}
if ges == "multiswipe" then if ges == "multiswipe" then
ges_type = "multiswipe" ges_type = "multiswipe"
zone = { zone = zone_fullscreen
ratio_x = 0.0, ratio_y = 0,
ratio_w = 1, ratio_h = 1,
}
direction = { direction = {
northeast = true, northwest = true, northeast = true, northwest = true,
southeast = true, southwest = true, southeast = true, southwest = true,
@ -553,6 +575,14 @@ function ReaderGesture:setupGesture(ges, action)
else else
overrides = { 'readerfooter_tap', 'filemanager_tap' } overrides = { 'readerfooter_tap', 'filemanager_tap' }
end end
elseif ges == "two_finger_swipe_west" then
ges_type = "two_finger_swipe"
zone = zone_fullscreen
direction = {west = true}
elseif ges == "two_finger_swipe_east" then
ges_type = "two_finger_swipe"
zone = zone_fullscreen
direction = {east = true}
elseif ges == "short_diagonal_swipe" then elseif ges == "short_diagonal_swipe" then
ges_type = "swipe" ges_type = "swipe"
zone = { zone = {

@ -31,21 +31,6 @@ function ReaderToc:init()
doc = "show Table of Content menu" }, doc = "show Table of Content menu" },
} }
end end
if Device:isTouchDevice() then
self.ges_events = {
ShowToc = {
GestureRange:new{
ges = "two_finger_swipe",
range = Geom:new{
x = 0, y = 0,
w = Screen:getWidth(),
h = Screen:getHeight(),
},
direction = "east"
}
},
}
end
self:resetToc() self:resetToc()
self.ui.menu:registerToMainMenu(self) self.ui.menu:registerToMainMenu(self)
end end

@ -56,21 +56,25 @@ local CervantesTouch = Cervantes:new{
model = "CervantesTouch", model = "CervantesTouch",
display_dpi = 167, display_dpi = 167,
hasFrontlight = no, hasFrontlight = no,
hasMultitouch = no,
} }
-- Cervantes TouchLight / Fnac Touch Plus -- Cervantes TouchLight / Fnac Touch Plus
local CervantesTouchLight = Cervantes:new{ local CervantesTouchLight = Cervantes:new{
model = "CervantesTouchLight", model = "CervantesTouchLight",
display_dpi = 167, display_dpi = 167,
hasMultitouch = no,
} }
-- Cervantes 2013 / Fnac Touch Light -- Cervantes 2013 / Fnac Touch Light
local Cervantes2013 = Cervantes:new{ local Cervantes2013 = Cervantes:new{
model = "Cervantes2013", model = "Cervantes2013",
display_dpi = 212, display_dpi = 212,
hasMultitouch = no,
} }
-- Cervantes 3 / Fnac Touch Light 2 -- Cervantes 3 / Fnac Touch Light 2
local Cervantes3 = Cervantes:new{ local Cervantes3 = Cervantes:new{
model = "Cervantes3", model = "Cervantes3",
display_dpi = 300, display_dpi = 300,
hasMultitouch = no,
} }
-- Cervantes 4 -- Cervantes 4
local Cervantes4 = Cervantes:new{ local Cervantes4 = Cervantes:new{

@ -100,6 +100,11 @@ function Device:init()
error("screen/framebuffer must be implemented") error("screen/framebuffer must be implemented")
end end
if self.hasMultitouch == nil then
-- default to assuming multitouch when dealing with a touch device
self.hasMultitouch = self.isTouchDevice
end
self.screen.isColorScreen = self.hasColorScreen self.screen.isColorScreen = self.hasColorScreen
self.screen.isColorEnabled = function() self.screen.isColorEnabled = function()
if G_reader_settings:has("color_rendering") then if G_reader_settings:has("color_rendering") then

@ -52,12 +52,14 @@ local KoboTrilogy = Kobo:new{
-- hook accordingly -- hook accordingly
touch_probe_ev_epoch_time = true, touch_probe_ev_epoch_time = true,
hasKeys = yes, hasKeys = yes,
hasMultitouch = no,
} }
-- Kobo Mini: -- Kobo Mini:
local KoboPixie = Kobo:new{ local KoboPixie = Kobo:new{
model = "Kobo_pixie", model = "Kobo_pixie",
display_dpi = 200, display_dpi = 200,
hasMultitouch = no,
-- bezel: -- bezel:
viewport = Geom:new{x=0, y=2, w=596, h=794}, viewport = Geom:new{x=0, y=2, w=596, h=794},
} }
@ -81,6 +83,7 @@ local KoboDaylight = Kobo:new{
local KoboDahlia = Kobo:new{ local KoboDahlia = Kobo:new{
model = "Kobo_dahlia", model = "Kobo_dahlia",
hasFrontlight = yes, hasFrontlight = yes,
hasMultitouch = no,
touch_phoenix_protocol = true, touch_phoenix_protocol = true,
display_dpi = 265, display_dpi = 265,
-- the bezel covers the top 11 pixels: -- the bezel covers the top 11 pixels:
@ -91,6 +94,7 @@ local KoboDahlia = Kobo:new{
local KoboDragon = Kobo:new{ local KoboDragon = Kobo:new{
model = "Kobo_dragon", model = "Kobo_dragon",
hasFrontlight = yes, hasFrontlight = yes,
hasMultitouch = no,
display_dpi = 265, display_dpi = 265,
} }
@ -98,6 +102,7 @@ local KoboDragon = Kobo:new{
local KoboKraken = Kobo:new{ local KoboKraken = Kobo:new{
model = "Kobo_kraken", model = "Kobo_kraken",
hasFrontlight = yes, hasFrontlight = yes,
hasMultitouch = no,
display_dpi = 212, display_dpi = 212,
} }

@ -21,6 +21,7 @@ local Device = Generic:new{
local AppImage = Device:new{ local AppImage = Device:new{
model = "AppImage", model = "AppImage",
hasMultitouch = no,
hasOTAUpdates = yes, hasOTAUpdates = yes,
} }

Loading…
Cancel
Save