mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Viewer: use an inch as the limit for the back tap zone rather than 100px
This commit is contained in:
parent
31b0c321fc
commit
5e758211f1
@ -2,9 +2,9 @@
|
|||||||
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
# License: GPL v3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
from __python__ import bound_methods, hash_literals
|
from __python__ import bound_methods, hash_literals
|
||||||
|
|
||||||
from read_book.globals import get_boss, ui_operations, ltr_page_progression
|
from read_book.globals import get_boss, ltr_page_progression, ui_operations
|
||||||
from read_book.viewport import scroll_viewport
|
|
||||||
from read_book.settings import opts
|
from read_book.settings import opts
|
||||||
|
from read_book.viewport import get_unit_size_in_pixels, scroll_viewport
|
||||||
|
|
||||||
HOLD_THRESHOLD = 750 # milliseconds
|
HOLD_THRESHOLD = 750 # milliseconds
|
||||||
TAP_THRESHOLD = 8 # pixels
|
TAP_THRESHOLD = 8 # pixels
|
||||||
@ -233,6 +233,13 @@ class TouchHandler:
|
|||||||
return
|
return
|
||||||
self.handle_gesture(gesture)
|
self.handle_gesture(gesture)
|
||||||
|
|
||||||
|
def inch_in_pixels():
|
||||||
|
ans = inch_in_pixels().ans
|
||||||
|
if not ans:
|
||||||
|
ans = inch_in_pixels.ans = max(2, get_unit_size_in_pixels('in'))
|
||||||
|
return ans
|
||||||
|
|
||||||
|
|
||||||
class BookTouchHandler(TouchHandler):
|
class BookTouchHandler(TouchHandler):
|
||||||
|
|
||||||
def __init__(self, for_side_margin=None):
|
def __init__(self, for_side_margin=None):
|
||||||
@ -250,21 +257,23 @@ class BookTouchHandler(TouchHandler):
|
|||||||
return
|
return
|
||||||
if not gesture.active:
|
if not gesture.active:
|
||||||
if self.for_side_margin or not tap_on_link(gesture):
|
if self.for_side_margin or not tap_on_link(gesture):
|
||||||
|
inch = inch_in_pixels()
|
||||||
if gesture.viewport_y < min(100, scroll_viewport.height() / 4):
|
if gesture.viewport_y < min(100, scroll_viewport.height() / 4):
|
||||||
gesture.type = 'show-chrome'
|
gesture.type = 'show-chrome'
|
||||||
else:
|
else:
|
||||||
|
limit = inch
|
||||||
# default, books that go left to right.
|
# default, books that go left to right.
|
||||||
if ltr_page_progression() and not opts.reverse_page_turn_zones:
|
if ltr_page_progression() and not opts.reverse_page_turn_zones:
|
||||||
if gesture.viewport_x < min(100, scroll_viewport.width() / 4):
|
if gesture.viewport_x < min(limit, scroll_viewport.width() / 4):
|
||||||
gesture.type = 'prev-page'
|
gesture.type = 'prev-page'
|
||||||
else:
|
else:
|
||||||
gesture.type = 'next-page'
|
gesture.type = 'next-page'
|
||||||
# We swap the sizes in RTL mode, so that going to the next page is always the bigger touch region.
|
# We swap the sizes in RTL mode, so that going to the next page is always the bigger touch region.
|
||||||
else:
|
else:
|
||||||
# The "going back" area should not be more than 100 units big,
|
# The "going back" area should not be more than limit units big,
|
||||||
# even if 1/4 of the scroll viewport is more than 100 units.
|
# even if 1/4 of the scroll viewport is more than limit units.
|
||||||
# Checking against the larger of the width minus the 100 units and 3/4 of the width will accomplish that.
|
# Checking against the larger of the width minus the limit units and 3/4 of the width will accomplish that.
|
||||||
if gesture.viewport_x > max(scroll_viewport.width() - 100, scroll_viewport.width() * (3/4)):
|
if gesture.viewport_x > max(scroll_viewport.width() - limit, scroll_viewport.width() * (3/4)):
|
||||||
gesture.type = 'prev-page'
|
gesture.type = 'prev-page'
|
||||||
else:
|
else:
|
||||||
gesture.type = 'next-page'
|
gesture.type = 'next-page'
|
||||||
|
@ -116,12 +116,15 @@ def show_controls_help():
|
|||||||
return set_css(E.div(txt), padding='1ex 1em', text_align='center', margin='auto')
|
return set_css(E.div(txt), padding='1ex 1em', text_align='center', margin='auto')
|
||||||
|
|
||||||
left_msg = msg(_('Tap to turn back'))
|
left_msg = msg(_('Tap to turn back'))
|
||||||
left_width = '25vw'
|
left_width = 'min(25vw, 1in)'
|
||||||
right_msg = msg(_('Tap to turn page'))
|
right_msg = msg(_('Tap to turn page'))
|
||||||
right_width = '75vw'
|
right_width = 'auto'
|
||||||
|
left_grow = 0
|
||||||
|
right_grow = 1
|
||||||
if rtl_page_progression():
|
if rtl_page_progression():
|
||||||
left_msg, right_msg = right_msg, left_msg
|
left_msg, right_msg = right_msg, left_msg
|
||||||
left_width, right_width = right_width, left_width
|
left_width, right_width = right_width, left_width
|
||||||
|
left_grow, right_grow = right_grow, left_grow
|
||||||
|
|
||||||
# Clear it out if this is not the first time it's created.
|
# Clear it out if this is not the first time it's created.
|
||||||
# Needed to correctly show it again in a different page progression direction.
|
# Needed to correctly show it again in a different page progression direction.
|
||||||
@ -139,11 +142,11 @@ def show_controls_help():
|
|||||||
style="display: flex; align-items: stretch; flex-grow: 10",
|
style="display: flex; align-items: stretch; flex-grow: 10",
|
||||||
E.div(
|
E.div(
|
||||||
left_msg,
|
left_msg,
|
||||||
style=f'width: {left_width}; display:flex; align-items: center; border-right: solid 2px currentColor',
|
style=f'width: {left_width}; flex-grow: {left_grow}; display:flex; align-items: center; border-right: solid 2px currentColor',
|
||||||
),
|
),
|
||||||
E.div(
|
E.div(
|
||||||
right_msg,
|
right_msg,
|
||||||
style=f'width: {right_width}; display:flex; align-items: center',
|
style=f'width: {right_width}; display:flex; flex-grow: {right_grow}; align-items: center',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user