From 2554aee7a315c18fdfde2b636d92db121b6dc31a Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sat, 25 Nov 2023 05:03:05 +0100 Subject: [PATCH] Gestures: Make the edge swipe zones configurable As "global defaults" (i.e., "advanced settings" in the UI). These were the only zones not available there, for some reason (probably they were new and we try to avoid adding new defaults). Fix #11142 --- defaults.lua | 4 ++++ plugins/gestures.koplugin/main.lua | 28 ++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/defaults.lua b/defaults.lua index 8db96f6a9..f5b030f98 100644 --- a/defaults.lua +++ b/defaults.lua @@ -69,6 +69,10 @@ DTAP_ZONE_BOTTOM_LEFT = {x = 0, y = 7/8, w = 1/8, h = 1/8}, DTAP_ZONE_BOTTOM_RIGHT = {x = 7/8, y = 7/8, w = 1/8, h = 1/8}, DDOUBLE_TAP_ZONE_NEXT_CHAPTER = {x = 1/4, y = 0, w = 3/4, h = 1}, DDOUBLE_TAP_ZONE_PREV_CHAPTER = {x = 0, y = 0, w = 1/4, h = 1}, +DSWIPE_ZONE_LEFT_EDGE = { x = 0, y = 0, w = 1/8, h = 1}, +DSWIPE_ZONE_RIGHT_EDGE = { x = 7/8, y = 0, w = 1/8, h = 1}, +DSWIPE_ZONE_TOP_EDGE = { x = 0, y = 0, w = 1, h = 1/8}, +DSWIPE_ZONE_BOTTOM_EDGE = { x = 0, y = 7/8, w = 1, h = 1/8}, -- koptreader config defaults DKOPTREADER_CONFIG_FONT_SIZE = 1.0, -- range from 0.1 to 3.0 diff --git a/plugins/gestures.koplugin/main.lua b/plugins/gestures.koplugin/main.lua index ef73d9bc5..ecab724b2 100644 --- a/plugins/gestures.koplugin/main.lua +++ b/plugins/gestures.koplugin/main.lua @@ -784,21 +784,33 @@ function Gestures:setupGesture(ges) ratio_w = 1, ratio_h = 1, } + local dswipe_zone_left_edge = G_defaults:readSetting("DSWIPE_ZONE_LEFT_EDGE") local zone_left_edge = { - ratio_x = 0, ratio_y = 0, - ratio_w = 1/8, ratio_h = 1, + ratio_x = dswipe_zone_left_edge.x, + ratio_y = dswipe_zone_left_edge.y, + ratio_w = dswipe_zone_left_edge.w, + ratio_h = dswipe_zone_left_edge.h, } + local dswipe_zone_right_edge = G_defaults:readSetting("DSWIPE_ZONE_RIGHT_EDGE") local zone_right_edge = { - ratio_x = 7/8, ratio_y = 0, - ratio_w = 1/8, ratio_h = 1, + ratio_x = dswipe_zone_right_edge.x, + ratio_y = dswipe_zone_right_edge.y, + ratio_w = dswipe_zone_right_edge.w, + ratio_h = dswipe_zone_right_edge.h, } + local dswipe_zone_top_edge = G_defaults:readSetting("DSWIPE_ZONE_TOP_EDGE") local zone_top_edge = { - ratio_x = 0, ratio_y = 0, - ratio_w = 1, ratio_h = 1/8, + ratio_x = dswipe_zone_top_edge.x, + ratio_y = dswipe_zone_top_edge.y, + ratio_w = dswipe_zone_top_edge.w, + ratio_h = dswipe_zone_top_edge.h, } + local dswipe_zone_bottom_edge = G_defaults:readSetting("DSWIPE_ZONE_BOTTOM_EDGE") local zone_bottom_edge = { - ratio_x = 0, ratio_y = 7/8, - ratio_w = 1, ratio_h = 1/8, + ratio_x = dswipe_zone_bottom_edge.x, + ratio_y = dswipe_zone_bottom_edge.y, + ratio_w = dswipe_zone_bottom_edge.w, + ratio_h = dswipe_zone_bottom_edge.h, } local dtap_zone_top_left = G_defaults:readSetting("DTAP_ZONE_TOP_LEFT")