mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[UX] Add horizontal edge gestures (#5179)
This commit is contained in:
@@ -64,6 +64,21 @@ local FileManager = InputContainer:extend{
|
||||
}
|
||||
|
||||
function FileManager:init()
|
||||
if Device:isTouchDevice() then
|
||||
self:registerTouchZones({
|
||||
{
|
||||
id = "filemanager_swipe",
|
||||
ges = "swipe",
|
||||
screen_zone = {
|
||||
ratio_x = 0, ratio_y = 0,
|
||||
ratio_w = Screen:getWidth(), ratio_h = Screen:getHeight(),
|
||||
},
|
||||
handler = function(ges)
|
||||
self:onSwipeFM(ges)
|
||||
end,
|
||||
},
|
||||
})
|
||||
end
|
||||
self.show_parent = self.show_parent or self
|
||||
local icon_size = Screen:scaleBySize(35)
|
||||
local home_button = IconButton:new{
|
||||
@@ -411,6 +426,15 @@ function FileManager:onShowPlusMenu()
|
||||
return true
|
||||
end
|
||||
|
||||
function FileManager:onSwipeFM(ges)
|
||||
if ges.direction == "west" then
|
||||
self.file_chooser:onNextPage()
|
||||
elseif ges.direction == "east" then
|
||||
self.file_chooser:onPrevPage()
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function FileManager:tapPlus()
|
||||
local buttons = {
|
||||
{
|
||||
|
||||
@@ -166,6 +166,10 @@ function ReaderGesture:init()
|
||||
one_finger_swipe_left_edge_up = Device:hasFrontlight() and "increase_frontlight" or "ignore",
|
||||
one_finger_swipe_right_edge_down = Device:hasNaturalLight() and "decrease_frontlight_warmth" or "ignore",
|
||||
one_finger_swipe_right_edge_up = Device:hasNaturalLight() and "increase_frontlight_warmth" or "ignore",
|
||||
one_finger_swipe_top_edge_right = "ignore",
|
||||
one_finger_swipe_top_edge_left = "ignore",
|
||||
one_finger_swipe_bottom_edge_right = "ignore",
|
||||
one_finger_swipe_bottom_edge_left = "ignore",
|
||||
two_finger_tap_top_left_corner = "ignore",
|
||||
two_finger_tap_top_right_corner = "ignore",
|
||||
two_finger_tap_bottom_left_corner = "ignore",
|
||||
@@ -385,9 +389,24 @@ function ReaderGesture:addToMainMenu(menu_items)
|
||||
text_func = function() return actionTextFunc("one_finger_swipe_right_edge_up", _("Right edge up")) end,
|
||||
sub_item_table = self:buildMenu("one_finger_swipe_right_edge_up", self.default_gesture["one_finger_swipe_right_edge_up"]),
|
||||
},
|
||||
{
|
||||
text_func = function() return actionTextFunc("one_finger_swipe_top_edge_right", _("Top edge right")) end,
|
||||
sub_item_table = self:buildMenu("one_finger_swipe_top_edge_right", self.default_gesture["one_finger_swipe_top_edge_right"]),
|
||||
},
|
||||
{
|
||||
text_func = function() return actionTextFunc("one_finger_swipe_top_edge_left", _("Top edge left")) end,
|
||||
sub_item_table = self:buildMenu("one_finger_swipe_top_edge_left", self.default_gesture["one_finger_swipe_top_edge_left"]),
|
||||
},
|
||||
{
|
||||
text_func = function() return actionTextFunc("one_finger_swipe_bottom_edge_right", _("Bottom edge right")) end,
|
||||
sub_item_table = self:buildMenu("one_finger_swipe_bottom_edge_right", self.default_gesture["one_finger_swipe_bottom_edge_right"]),
|
||||
},
|
||||
{
|
||||
text_func = function() return actionTextFunc("one_finger_swipe_bottom_edge_left", _("Bottom edge left")) end,
|
||||
sub_item_table = self:buildMenu("one_finger_swipe_bottom_edge_left", self.default_gesture["one_finger_swipe_bottom_edge_left"]),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
},
|
||||
}
|
||||
menu_items.gesture_intervals = {
|
||||
@@ -838,6 +857,14 @@ function ReaderGesture:setupGesture(ges, action)
|
||||
ratio_x = 7/8, ratio_y = 1/8,
|
||||
ratio_w = 1/8, ratio_h = 7/8,
|
||||
}
|
||||
local zone_top_edge = {
|
||||
ratio_x = 1/8, ratio_y = 0,
|
||||
ratio_w = 7/8, ratio_h = 1/8,
|
||||
}
|
||||
local zone_bottom_edge = {
|
||||
ratio_x = 1/8, ratio_y = 7/8,
|
||||
ratio_w = 7/8, ratio_h = 1/8,
|
||||
}
|
||||
|
||||
-- legacy global variable DTAP_ZONE_FLIPPING may still be defined in default.persistent.lua
|
||||
local dtap_zone_top_left = DTAP_ZONE_FLIPPING and DTAP_ZONE_FLIPPING or DTAP_ZONE_TOP_LEFT
|
||||
@@ -870,13 +897,16 @@ function ReaderGesture:setupGesture(ges, action)
|
||||
|
||||
local overrides_tap_corner
|
||||
local overrides_hold_corner
|
||||
local overrides_vertical_edge
|
||||
local overrides_vertical_edge, overrides_horizontal_edge
|
||||
local overrides_pan, overrides_pan_release
|
||||
local overrides_swipe_pan, overrides_swipe_pan_release
|
||||
if self.is_docless then
|
||||
overrides_tap_corner = {
|
||||
"filemanager_tap",
|
||||
}
|
||||
overrides_horizontal_edge = {
|
||||
"filemanager_swipe",
|
||||
}
|
||||
else
|
||||
overrides_tap_corner = {
|
||||
"tap_backward",
|
||||
@@ -970,6 +1000,34 @@ function ReaderGesture:setupGesture(ges, action)
|
||||
overrides = overrides_vertical_edge
|
||||
overrides_swipe_pan = overrides_pan
|
||||
overrides_swipe_pan_release = overrides_pan_release
|
||||
elseif ges == "one_finger_swipe_top_edge_right" then
|
||||
ges_type = "swipe"
|
||||
zone = zone_top_edge
|
||||
direction = {east = true}
|
||||
overrides = overrides_horizontal_edge
|
||||
overrides_swipe_pan = overrides_pan
|
||||
overrides_swipe_pan_release = overrides_pan_release
|
||||
elseif ges == "one_finger_swipe_top_edge_left" then
|
||||
ges_type = "swipe"
|
||||
zone = zone_top_edge
|
||||
direction = {west = true}
|
||||
overrides = overrides_horizontal_edge
|
||||
overrides_swipe_pan = overrides_pan
|
||||
overrides_swipe_pan_release = overrides_pan_release
|
||||
elseif ges == "one_finger_swipe_bottom_edge_right" then
|
||||
ges_type = "swipe"
|
||||
zone = zone_bottom_edge
|
||||
direction = {east = true}
|
||||
overrides = overrides_horizontal_edge
|
||||
overrides_swipe_pan = overrides_pan
|
||||
overrides_swipe_pan_release = overrides_pan_release
|
||||
elseif ges == "one_finger_swipe_bottom_edge_left" then
|
||||
ges_type = "swipe"
|
||||
zone = zone_bottom_edge
|
||||
direction = {west = true}
|
||||
overrides = overrides_horizontal_edge
|
||||
overrides_swipe_pan = overrides_pan
|
||||
overrides_swipe_pan_release = overrides_pan_release
|
||||
elseif ges == "two_finger_tap_top_left_corner" then
|
||||
ges_type = "two_finger_tap"
|
||||
zone = zone_top_left_corner
|
||||
@@ -1017,6 +1075,7 @@ function ReaderGesture:setupGesture(ges, action)
|
||||
if self.is_docless then
|
||||
overrides = {
|
||||
"filemanager_tap",
|
||||
"filemanager_swipe"
|
||||
}
|
||||
else
|
||||
overrides = {
|
||||
|
||||
@@ -810,12 +810,15 @@ function Menu:init()
|
||||
}
|
||||
}
|
||||
end
|
||||
self.ges_events.Swipe = {
|
||||
GestureRange:new{
|
||||
ges = "swipe",
|
||||
range = self.dimen,
|
||||
-- delegate swipe gesture to GestureManager in filemanager
|
||||
if self.is_file_manager ~= true then
|
||||
self.ges_events.Swipe = {
|
||||
GestureRange:new{
|
||||
ges = "swipe",
|
||||
range = self.dimen,
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
self.ges_events.Close = self.on_close_ges
|
||||
end
|
||||
|
||||
@@ -1225,14 +1228,8 @@ function Menu:onSwipe(arg, ges_ev)
|
||||
-- no use for now
|
||||
do end -- luacheck: ignore 541
|
||||
else -- diagonal swipe
|
||||
if self.is_file_manager and G_reader_settings:readSetting("gesture_fm") and
|
||||
G_reader_settings:readSetting("gesture_fm")["short_diagonal_swipe"] then
|
||||
-- managed by gesture manager
|
||||
do end -- luacheck: ignore 541
|
||||
else
|
||||
-- trigger full refresh
|
||||
UIManager:setDirty(nil, "full")
|
||||
end
|
||||
-- trigger full refresh
|
||||
UIManager:setDirty(nil, "full")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user