[RFC] Make default UI tapzones more generous (#6918)

* Top menu & bottom menu tapzones are now full-width, thanks to the now sane override system.
* A separate, extra tapzone was also created for each of them to provide a taller, but narrower tapzone extension (one that doesn't clash with the prev/next tapzones).
* The footer tapzone was made much taller.
pull/6948/head
NiLuJe 3 years ago committed by GitHub
parent 059ffc0040
commit 493eab92c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -26,7 +26,9 @@ read_globals = {
"DOVERLAPPIXELS", "DOVERLAPPIXELS",
"FOLLOW_LINK_TIMEOUT", "FOLLOW_LINK_TIMEOUT",
"DTAP_ZONE_MENU", "DTAP_ZONE_MENU",
"DTAP_ZONE_MENU_EXT",
"DTAP_ZONE_CONFIG", "DTAP_ZONE_CONFIG",
"DTAP_ZONE_CONFIG_EXT",
"DTAP_ZONE_MINIBAR", "DTAP_ZONE_MINIBAR",
"DTAP_ZONE_FORWARD", "DTAP_ZONE_FORWARD",
"DTAP_ZONE_BACKWARD", "DTAP_ZONE_BACKWARD",

@ -72,9 +72,11 @@ FOLLOW_LINK_TIMEOUT = 0.5
-- y: y coordinate of top left corner in proportion to screen height -- y: y coordinate of top left corner in proportion to screen height
-- w: tap zone width in proportion to screen width -- w: tap zone width in proportion to screen width
-- h: tap zone height in proportion to screen height -- h: tap zone height in proportion to screen height
DTAP_ZONE_MENU = {x = 1/8, y = 0, w = 3/4, h = 1/8} DTAP_ZONE_MENU = {x = 0, y = 0, w = 1, h = 1/8}
DTAP_ZONE_CONFIG = {x = 1/8, y = 7/8, w = 3/4, h = 1/8} DTAP_ZONE_MENU_EXT = {x = 1/4, y = 0, w = 2/4, h = 1/5} -- taller, narrower extension
DTAP_ZONE_MINIBAR = {x = 0, y = 31/32, w = 1, h = 1/32} DTAP_ZONE_CONFIG = {x = 0, y = 7/8, w = 1, h = 1/8}
DTAP_ZONE_CONFIG_EXT = {x = 1/4, y = 2/3, w = 2/4, h = 1/5} -- taller, narrower extension
DTAP_ZONE_MINIBAR = {x = 0, y = 12/13, w = 1, h = 1/13}
DTAP_ZONE_FORWARD = {x = 1/4, y = 0, w = 3/4, h = 1} DTAP_ZONE_FORWARD = {x = 1/4, y = 0, w = 3/4, h = 1}
DTAP_ZONE_BACKWARD = {x = 0, y = 0, w = 1/4, h = 1} DTAP_ZONE_BACKWARD = {x = 0, y = 0, w = 1/4, h = 1}
-- DTAP_ZONE_BOOKMARK = {x = 7/8, y = 0, w = 1/8, h = 1/8} -- deprecated -- DTAP_ZONE_BOOKMARK = {x = 7/8, y = 0, w = 1/8, h = 1/8} -- deprecated

@ -72,6 +72,18 @@ function FileManagerMenu:initGesListener()
}, },
handler = function(ges) return self:onTapShowMenu(ges) end, handler = function(ges) return self:onTapShowMenu(ges) end,
}, },
{
id = "filemanager_ext_tap",
ges = "tap",
screen_zone = {
ratio_x = DTAP_ZONE_MENU_EXT.x, ratio_y = DTAP_ZONE_MENU_EXT.y,
ratio_w = DTAP_ZONE_MENU_EXT.w, ratio_h = DTAP_ZONE_MENU_EXT.h,
},
overrides = {
"filemanager_tap",
},
handler = function(ges) return self:onTapShowMenu(ges) end,
},
{ {
id = "filemanager_swipe", id = "filemanager_swipe",
ges = "swipe", ges = "swipe",
@ -85,6 +97,18 @@ function FileManagerMenu:initGesListener()
}, },
handler = function(ges) return self:onSwipeShowMenu(ges) end, handler = function(ges) return self:onSwipeShowMenu(ges) end,
}, },
{
id = "filemanager_ext_swipe",
ges = "swipe",
screen_zone = {
ratio_x = DTAP_ZONE_MENU_EXT.x, ratio_y = DTAP_ZONE_MENU_EXT.y,
ratio_w = DTAP_ZONE_MENU_EXT.w, ratio_h = DTAP_ZONE_MENU_EXT.h,
},
overrides = {
"filemanager_swipe",
},
handler = function(ges) return self:onSwipeShowMenu(ges) end,
},
}) })
end end

@ -50,6 +50,18 @@ function ReaderConfig:initGesListener()
}, },
handler = function() return self:onTapShowConfigMenu() end, handler = function() return self:onTapShowConfigMenu() end,
}, },
{
id = "readerconfigmenu_ext_tap",
ges = "tap",
screen_zone = {
ratio_x = DTAP_ZONE_CONFIG_EXT.x, ratio_y = DTAP_ZONE_CONFIG_EXT.y,
ratio_w = DTAP_ZONE_CONFIG_EXT.w, ratio_h = DTAP_ZONE_CONFIG_EXT.h,
},
overrides = {
"readerconfigmenu_tap",
},
handler = function() return self:onTapShowConfigMenu() end,
},
{ {
id = "readerconfigmenu_swipe", id = "readerconfigmenu_swipe",
ges = "swipe", ges = "swipe",
@ -63,6 +75,18 @@ function ReaderConfig:initGesListener()
}, },
handler = function(ges) return self:onSwipeShowConfigMenu(ges) end, handler = function(ges) return self:onSwipeShowConfigMenu(ges) end,
}, },
{
id = "readerconfigmenu_ext_swipe",
ges = "swipe",
screen_zone = {
ratio_x = DTAP_ZONE_CONFIG_EXT.x, ratio_y = DTAP_ZONE_CONFIG_EXT.y,
ratio_w = DTAP_ZONE_CONFIG_EXT.w, ratio_h = DTAP_ZONE_CONFIG_EXT.h,
},
overrides = {
"readerconfigmenu_swipe",
},
handler = function(ges) return self:onSwipeShowConfigMenu(ges) end,
},
{ {
id = "readerconfigmenu_pan", id = "readerconfigmenu_pan",
ges = "pan", ges = "pan",
@ -76,6 +100,18 @@ function ReaderConfig:initGesListener()
}, },
handler = function(ges) return self:onSwipeShowConfigMenu(ges) end, handler = function(ges) return self:onSwipeShowConfigMenu(ges) end,
}, },
{
id = "readerconfigmenu_ext_pan",
ges = "pan",
screen_zone = {
ratio_x = DTAP_ZONE_CONFIG_EXT.x, ratio_y = DTAP_ZONE_CONFIG_EXT.y,
ratio_w = DTAP_ZONE_CONFIG_EXT.w, ratio_h = DTAP_ZONE_CONFIG_EXT.h,
},
overrides = {
"readerconfigmenu_pan",
},
handler = function(ges) return self:onSwipeShowConfigMenu(ges) end,
},
}) })
end end

@ -632,9 +632,10 @@ function ReaderFooter:setupTouchZones()
screen_zone = footer_screen_zone, screen_zone = footer_screen_zone,
handler = function(ges) return self:onTapFooter(ges) end, handler = function(ges) return self:onTapFooter(ges) end,
overrides = { overrides = {
"readerconfigmenu_ext_tap",
"readerconfigmenu_tap",
"tap_forward", "tap_forward",
"tap_backward", "tap_backward",
"readerconfigmenu_tap",
}, },
-- (Low priority: tap on existing highlights -- (Low priority: tap on existing highlights
-- or links have priority) -- or links have priority)

@ -192,15 +192,17 @@ function ReaderHighlight:setupTouchZones()
-- Tap on existing highlights have priority over -- Tap on existing highlights have priority over
-- everything but tap on links (as links can be -- everything but tap on links (as links can be
-- part of some highlighted text) -- part of some highlighted text)
"tap_forward",
"tap_backward",
"readermenu_tap",
"readerconfigmenu_tap",
"readerfooter_tap",
"tap_top_left_corner", "tap_top_left_corner",
"tap_top_right_corner", "tap_top_right_corner",
"tap_left_bottom_corner", "tap_left_bottom_corner",
"tap_right_bottom_corner", "tap_right_bottom_corner",
"readerfooter_tap",
"readerconfigmenu_ext_tap",
"readerconfigmenu_tap",
"readermenu_ext_tap",
"readermenu_tap",
"tap_forward",
"tap_backward",
}, },
handler = function(ges) return self:onTap(nil, ges) end handler = function(ges) return self:onTap(nil, ges) end
}, },

@ -56,16 +56,18 @@ function ReaderLink:init()
overrides = { overrides = {
-- Tap on links have priority over everything (it can -- Tap on links have priority over everything (it can
-- be disabled with "Tap to follow links" menu item) -- be disabled with "Tap to follow links" menu item)
"tap_forward",
"tap_backward",
"readermenu_tap",
"readerconfigmenu_tap",
"readerhighlight_tap", "readerhighlight_tap",
"readerfooter_tap",
"tap_top_left_corner", "tap_top_left_corner",
"tap_top_right_corner", "tap_top_right_corner",
"tap_left_bottom_corner", "tap_left_bottom_corner",
"tap_right_bottom_corner", "tap_right_bottom_corner",
"readerfooter_tap",
"readerconfigmenu_ext_tap",
"readerconfigmenu_tap",
"readermenu_ext_tap",
"readermenu_tap",
"tap_forward",
"tap_backward",
}, },
handler = function(ges) return self:onTap(_, ges) end, handler = function(ges) return self:onTap(_, ges) end,
}, },

@ -101,6 +101,18 @@ function ReaderMenu:onReaderReady()
}, },
handler = function(ges) return self:onTapShowMenu(ges) end, handler = function(ges) return self:onTapShowMenu(ges) end,
}, },
{
id = "readermenu_ext_tap",
ges = "tap",
screen_zone = {
ratio_x = DTAP_ZONE_MENU_EXT.x, ratio_y = DTAP_ZONE_MENU_EXT.y,
ratio_w = DTAP_ZONE_MENU_EXT.w, ratio_h = DTAP_ZONE_MENU_EXT.h,
},
overrides = {
"readermenu_tap",
},
handler = function(ges) return self:onTapShowMenu(ges) end,
},
{ {
id = "readermenu_swipe", id = "readermenu_swipe",
ges = "swipe", ges = "swipe",
@ -114,6 +126,18 @@ function ReaderMenu:onReaderReady()
}, },
handler = function(ges) return self:onSwipeShowMenu(ges) end, handler = function(ges) return self:onSwipeShowMenu(ges) end,
}, },
{
id = "readermenu_ext_swipe",
ges = "swipe",
screen_zone = {
ratio_x = DTAP_ZONE_MENU_EXT.x, ratio_y = DTAP_ZONE_MENU_EXT.y,
ratio_w = DTAP_ZONE_MENU_EXT.w, ratio_h = DTAP_ZONE_MENU_EXT.h,
},
overrides = {
"readermenu_swipe",
},
handler = function(ges) return self:onSwipeShowMenu(ges) end,
},
{ {
id = "readermenu_pan", id = "readermenu_pan",
ges = "pan", ges = "pan",
@ -127,6 +151,18 @@ function ReaderMenu:onReaderReady()
}, },
handler = function(ges) return self:onSwipeShowMenu(ges) end, handler = function(ges) return self:onSwipeShowMenu(ges) end,
}, },
{
id = "readermenu_ext_pan",
ges = "pan",
screen_zone = {
ratio_x = DTAP_ZONE_MENU_EXT.x, ratio_y = DTAP_ZONE_MENU_EXT.y,
ratio_w = DTAP_ZONE_MENU_EXT.w, ratio_h = DTAP_ZONE_MENU_EXT.h,
},
overrides = {
"readermenu_pan",
},
handler = function(ges) return self:onSwipeShowMenu(ges) end,
},
}) })
end end

@ -1379,8 +1379,14 @@ function ConfigDialog:onSwipeCloseMenu(arg, ges_ev)
w = DTAP_ZONE_CONFIG.w * Screen:getWidth(), w = DTAP_ZONE_CONFIG.w * Screen:getWidth(),
h = DTAP_ZONE_CONFIG.h * Screen:getHeight(), h = DTAP_ZONE_CONFIG.h * Screen:getHeight(),
} }
local range_ext = {
x = DTAP_ZONE_CONFIG_EXT.x * Screen:getWidth(),
y = DTAP_ZONE_CONFIG_EXT.y * Screen:getHeight(),
w = DTAP_ZONE_CONFIG_EXT.w * Screen:getWidth(),
h = DTAP_ZONE_CONFIG_EXT.h * Screen:getHeight(),
}
if ges_ev.direction == "south" and (ges_ev.pos:intersectWith(self.dialog_frame.dimen) if ges_ev.direction == "south" and (ges_ev.pos:intersectWith(self.dialog_frame.dimen)
or ges_ev.pos:intersectWith(range)) then or ges_ev.pos:intersectWith(range) or ges_ev.pos:intersectWith(range_ext)) then
self:closeDialog() self:closeDialog()
return true return true
end end

@ -823,18 +823,22 @@ function Gestures:setupGesture(ges)
local overrides_swipe_pan, overrides_swipe_pan_release local overrides_swipe_pan, overrides_swipe_pan_release
if self.is_docless then if self.is_docless then
overrides_tap_corner = { overrides_tap_corner = {
"filemanager_ext_tap",
"filemanager_tap", "filemanager_tap",
} }
overrides_horizontal_edge = { overrides_horizontal_edge = {
"filemanager_ext_swipe",
"filemanager_swipe", "filemanager_swipe",
} }
else else
overrides_tap_corner = { overrides_tap_corner = {
"tap_backward",
"tap_forward",
"readermenu_tap",
"readerconfigmenu_tap",
"readerfooter_tap", "readerfooter_tap",
"readerconfigmenu_ext_tap",
"readerconfigmenu_tap",
"readermenu_ext_tap",
"readermenu_tap",
"tap_forward",
"tap_backward",
} }
overrides_hold_corner = { overrides_hold_corner = {
-- As hold corners are "ignored" by default, and we have -- As hold corners are "ignored" by default, and we have
@ -844,17 +848,21 @@ function Gestures:setupGesture(ges)
"readerfooter_hold", "readerfooter_hold",
} }
overrides_vertical_edge = { overrides_vertical_edge = {
"readerconfigmenu_ext_swipe",
"readerconfigmenu_swipe",
"readermenu_ext_swipe",
"readermenu_swipe",
"paging_swipe", "paging_swipe",
"rolling_swipe", "rolling_swipe",
"readermenu_swipe",
"readerconfigmenu_swipe",
} }
overrides_horizontal_edge = { overrides_horizontal_edge = {
"swipe_link", "swipe_link",
"readerconfigmenu_ext_swipe",
"readerconfigmenu_swipe",
"readermenu_ext_swipe",
"readermenu_swipe",
"paging_swipe", "paging_swipe",
"rolling_swipe", "rolling_swipe",
"readermenu_swipe",
"readerconfigmenu_swipe",
} }
overrides_pan = { overrides_pan = {
"paging_swipe", "paging_swipe",
@ -1034,13 +1042,15 @@ function Gestures:setupGesture(ges)
distance = "short" distance = "short"
if self.is_docless then if self.is_docless then
overrides = { overrides = {
"filemanager_ext_tap",
"filemanager_tap", "filemanager_tap",
"filemanager_swipe" "filemanager_ext_swipe",
"filemanager_swipe",
} }
else else
overrides = { overrides = {
"rolling_swipe",
"paging_swipe", "paging_swipe",
"rolling_swipe",
} }
end end
elseif ges == "spread_gesture" then elseif ges == "spread_gesture" then

@ -8,7 +8,7 @@ describe("defaults module", function()
it("should load all defaults from defaults.lua", function() it("should load all defaults from defaults.lua", function()
Defaults:init() Defaults:init()
assert.is_same(98, #Defaults.defaults_name) assert.is_same(100, #Defaults.defaults_name)
end) end)
it("should save changes to defaults.persistent.lua", function() it("should save changes to defaults.persistent.lua", function()
@ -16,7 +16,7 @@ describe("defaults module", function()
os.remove(persistent_filename) os.remove(persistent_filename)
-- To see indices and help updating this when new settings are added: -- To see indices and help updating this when new settings are added:
-- for i=1, 98 do print(i.." ".. Defaults.defaults_name[i]) end -- for i=1, 100 do print(i.." ".. Defaults.defaults_name[i]) end
-- not in persistent but checked in defaults -- not in persistent but checked in defaults
Defaults.changed[20] = true Defaults.changed[20] = true
@ -24,7 +24,7 @@ describe("defaults module", function()
Defaults.changed[56] = true Defaults.changed[56] = true
Defaults.changed[85] = true Defaults.changed[85] = true
Defaults:saveSettings() Defaults:saveSettings()
assert.is_same(98, #Defaults.defaults_name) assert.is_same(100, #Defaults.defaults_name)
assert.is_same("DTAP_ZONE_BACKWARD", Defaults.defaults_name[85]) assert.is_same("DTAP_ZONE_BACKWARD", Defaults.defaults_name[85])
assert.is_same("DCREREADER_CONFIG_WORD_SPACING_LARGE", Defaults.defaults_name[50]) assert.is_same("DCREREADER_CONFIG_WORD_SPACING_LARGE", Defaults.defaults_name[50])
assert.is_same("DCREREADER_CONFIG_H_MARGIN_SIZES_XXX_LARGE", Defaults.defaults_name[20]) assert.is_same("DCREREADER_CONFIG_H_MARGIN_SIZES_XXX_LARGE", Defaults.defaults_name[20])

Loading…
Cancel
Save