[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" },
}
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)
end

@ -171,6 +171,9 @@ function ReaderGesture:init()
multiswipe_northwest_southwest_northwest = Device:hasWifiToggle() and "toggle_wifi" or "nothing",
multiswipe_southeast_southwest_northwest = Device:hasWifiToggle() and "wifi_off" 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)
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"),
sub_item_table = self:buildMenu("tap_right_bottom_corner", self.default_gesture["tap_right_bottom_corner"]),
separator = true,
},
{
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
function ReaderGesture:buildMenu(ges, default)
@ -519,12 +538,15 @@ function ReaderGesture:setupGesture(ges, action)
local zone
local overrides
local direction, distance
local zone_fullscreen = {
ratio_x = 0.0, ratio_y = 0,
ratio_w = 1, ratio_h = 1,
}
if ges == "multiswipe" then
ges_type = "multiswipe"
zone = {
ratio_x = 0.0, ratio_y = 0,
ratio_w = 1, ratio_h = 1,
}
zone = zone_fullscreen
direction = {
northeast = true, northwest = true,
southeast = true, southwest = true,
@ -553,6 +575,14 @@ function ReaderGesture:setupGesture(ges, action)
else
overrides = { 'readerfooter_tap', 'filemanager_tap' }
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
ges_type = "swipe"
zone = {

@ -31,21 +31,6 @@ function ReaderToc:init()
doc = "show Table of Content menu" },
}
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.ui.menu:registerToMainMenu(self)
end

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

@ -100,6 +100,11 @@ function Device:init()
error("screen/framebuffer must be implemented")
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.isColorEnabled = function()
if G_reader_settings:has("color_rendering") then

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

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

Loading…
Cancel
Save