Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UX] Gesture manager: corner gestures #4878

Merged
merged 20 commits into from Apr 7, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

[UX] Migrate top-right corner to gesture manager

Cf. #4877.
  • Loading branch information...
Frenzie committed Apr 6, 2019
commit 110d26a6b5305ef6331fcaffd1ebae108474f916
@@ -73,7 +73,7 @@ DTAP_ZONE_CONFIG = {x = 1/8, y = 7/8, w = 3/4, h = 1/8}
DTAP_ZONE_MINIBAR = {x = 0, y = 31/32, w = 1, h = 1/32}
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_BOOKMARK = {x = 7/8, y = 0, w = 1/8, h = 1/8}
-- DTAP_ZONE_BOOKMARK = {x = 7/8, y = 0, w = 1/8, h = 1/8} --deprecated
DTAP_ZONE_FLIPPING = {x = 0, y = 0, w = 1/8, h = 1/8}

This comment has been minimized.

Copy link
@poire-z

poire-z Apr 6, 2019

Contributor

Can't you migrate these two to DTAP_ZONE_BOTTOM_LEFT like the other ones? And use where they are used

if DTAP_ZONE_BOOKMARK  then -- legacy global variable, may still be defined in default.persistent.lua
  -- use DTAP_ZONE_BOOKMARK
else
  -- use DTAP_ZONE_TOP_RIGHT
end

or luacheck would complain ?

This comment has been minimized.

Copy link
@Frenzie

Frenzie Apr 6, 2019

Author Member

No, should be fine.

DDOUBLE_TAP_ZONE_NEXT_CHAPTER = {x = 6/8, y = 0, w = 2/8, h = 2/8}
DDOUBLE_TAP_ZONE_PREV_CHAPTER = {x = 0, y = 0, w = 2/8, h = 2/8}
@@ -74,26 +74,6 @@ function ReaderDogear:resetLayout()
self._last_screen_width = new_screen_width

self[1].dimen.w = new_screen_width
if Device:isTouchDevice() then
self.ges_events = {
Tap = {
GestureRange:new{
ges = "tap",
range = Geom:new{
x = new_screen_width*DTAP_ZONE_BOOKMARK.x,
y = new_screen_height*DTAP_ZONE_BOOKMARK.y,
w = new_screen_width*DTAP_ZONE_BOOKMARK.w,
h = new_screen_height*DTAP_ZONE_BOOKMARK.h
}
}
}
}
end
end

function ReaderDogear:onTap()
self.ui:handleEvent(Event:new("ToggleBookmark"))
return true
end

function ReaderDogear:onSetDogearVisibility(visible)
@@ -67,6 +67,7 @@ local action_strings = {
wifi_off = _("Disable wifi"),
toggle_wifi = _("Toggle wifi"),

toggle_bookmark = _("Toggle bookmark"),
toggle_reflow = _("Toggle reflow"),

zoom_contentwidth = _("Zoom to fit content width"),
@@ -144,6 +145,7 @@ function ReaderGesture:init()
self.is_docless = self.ui == nil or self.ui.document == nil
self.ges_mode = self.is_docless and "gesture_fm" or "gesture_reader"
self.default_gesture = {
tap_top_right_corner = self.ges_mode == "gesture_reader" and "toggle_bookmark" or "nothing",
tap_right_bottom_corner = "nothing",
tap_left_bottom_corner = Device:hasFrontlight() and "toggle_frontlight" or "nothing",
short_diagonal_swipe = "full_refresh",
@@ -291,6 +293,10 @@ function ReaderGesture:addToMainMenu(menu_items)
},
-- NB If this changes from position 3, also update the position of this menu in multigesture recorder callback
self:genMultiswipeSubmenu(),
{
text = _("Tap top right corner"),
sub_item_table = self:buildMenu("tap_top_right_corner", self.default_gesture["tap_top_right_corner"]),
},
{
text = _("Tap bottom left corner"),
sub_item_table = self:buildMenu("tap_left_bottom_corner", self.default_gesture["tap_left_bottom_corner"]),
@@ -300,6 +306,7 @@ function ReaderGesture:addToMainMenu(menu_items)
sub_item_table = self:buildMenu("tap_right_bottom_corner", self.default_gesture["tap_right_bottom_corner"]),
separator = true,
},

{
text = _("Short diagonal swipe"),
sub_item_table = self:buildMenu("short_diagonal_swipe", self.default_gesture["short_diagonal_swipe"]),
@@ -402,6 +409,7 @@ function ReaderGesture:buildMenu(ges, default)
{"wifi_off", Device:hasWifiToggle()},
{"toggle_wifi", Device:hasWifiToggle(), true},

{"toggle_bookmark", not self.is_docless, true},
{"toggle_reflow", not self.is_docless, true},
{"zoom_contentwidth", not self.is_docless},
{"zoom_contentheight", not self.is_docless},
@@ -582,6 +590,18 @@ function ReaderGesture:setupGesture(ges, action)
east = true, west = true,
north = true, south = true,
}
elseif ges == "tap_top_right_corner" then
ges_type = "tap"
zone = {
ratio_x = 0.9, ratio_y = 0.0,
ratio_w = 0.1, ratio_h = 0.1,
}
if not self.is_docless then
overrides = {
"tap_backward",
"tap_forward",
}
end
elseif ges == "tap_right_bottom_corner" then
ges_type = "tap"
zone = {
@@ -796,6 +816,8 @@ function ReaderGesture:gestureAction(action, ges)
else
self.ui:handleEvent(Event:new("ShowFlDialog"))
end
elseif action == "toggle_bookmark" then
self.ui:handleEvent(Event:new("ToggleBookmark"))
elseif action == "toggle_frontlight" then
Device:getPowerDevice():toggleFrontlight()
self:onShowFLOnOff()
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.