mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
customizable tap zones for page flipping and bookmarking
This commit is contained in:
@@ -43,9 +43,11 @@ DSHOWHIDDENFILES = false
|
||||
-- y: y coordinate of top left corner in proportion of screen height
|
||||
-- w: width of tap zone in proportion of screen width
|
||||
-- h: height of tap zone in proportion of screen height
|
||||
DTAP_ZONE_CONFIG = {x = 0, y = 11/12, w = 1, h = 1/12}
|
||||
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_CONFIG = {x = 0, y = 11/12, w = 1, h = 1/12}
|
||||
DTAP_ZONE_BOOKMARK = {x = 7/8, y = 0, w = 1/8, h = 1/8}
|
||||
DTAP_ZONE_FLIPPING = {x = 0, y = 0, w = 1/8, h = 1/8}
|
||||
|
||||
-- koptreader config defaults
|
||||
DKOPTREADER_CONFIG_FONT_SIZE = 1.0 -- range from 0.1 to 3.0
|
||||
|
||||
@@ -25,21 +25,6 @@ function ReaderBookmark:init()
|
||||
self.ui.menu:registerToMainMenu(self)
|
||||
end
|
||||
|
||||
function ReaderBookmark:initGesListener()
|
||||
self.ges_events = {
|
||||
ToggleBookmark = {
|
||||
GestureRange:new{
|
||||
ges = "tap",
|
||||
range = Geom:new{
|
||||
x = Screen:getWidth()*7/8, y = 0,
|
||||
w = Screen:getWidth()/8,
|
||||
h = Screen:getHeight()/8
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
function ReaderBookmark:onReadSettings(config)
|
||||
self.bookmarks = config:readSetting("bookmarks") or {}
|
||||
end
|
||||
@@ -48,13 +33,6 @@ function ReaderBookmark:onCloseDocument()
|
||||
self.ui.doc_settings:saveSetting("bookmarks", self.bookmarks)
|
||||
end
|
||||
|
||||
function ReaderBookmark:onSetDimensions(dimen)
|
||||
-- update listening according to new screen dimen
|
||||
if Device:isTouchDevice() then
|
||||
self:initGesListener()
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderBookmark:onToggleBookmark()
|
||||
local pn_or_xp = nil
|
||||
if self.ui.document.getXPointer then
|
||||
@@ -65,6 +43,7 @@ function ReaderBookmark:onToggleBookmark()
|
||||
self:toggleBookmark(pn_or_xp)
|
||||
self.view.dogear_visible = not self.view.dogear_visible
|
||||
UIManager:setDirty(self.view.dialog, "partial")
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderBookmark:setDogearVisibility(pn_or_xp)
|
||||
|
||||
@@ -1,17 +1,42 @@
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local RightContainer = require("ui/widget/container/rightcontainer")
|
||||
local ImageWidget = require("ui/widget/imagewidget")
|
||||
local GestureRange = require("ui/gesturerange")
|
||||
local Device = require("ui/device")
|
||||
local Geom = require("ui/geometry")
|
||||
local Screen = require("ui/screen")
|
||||
local Event = require("ui/event")
|
||||
|
||||
local ReaderDogear = RightContainer:new{}
|
||||
local ReaderDogear = InputContainer:new{}
|
||||
|
||||
function ReaderDogear:init()
|
||||
local widget = ImageWidget:new{
|
||||
file = "resources/icons/dogear.png",
|
||||
}
|
||||
local icon_size = widget:getSize()
|
||||
self.dimen = Geom:new{w = Screen:getWidth(), h = icon_size.h}
|
||||
self[1] = widget
|
||||
self[1] = RightContainer:new{
|
||||
dimen = Geom:new{w = Screen:getWidth(), h = widget:getSize().h},
|
||||
widget,
|
||||
}
|
||||
if Device:isTouchDevice() then
|
||||
self.ges_events = {
|
||||
Tap = {
|
||||
GestureRange:new{
|
||||
ges = "tap",
|
||||
range = Geom:new{
|
||||
x = Screen:getWidth()*DTAP_ZONE_BOOKMARK.x,
|
||||
y = Screen:getHeight()*DTAP_ZONE_BOOKMARK.y,
|
||||
w = Screen:getWidth()*DTAP_ZONE_BOOKMARK.w,
|
||||
h = Screen:getHeight()*DTAP_ZONE_BOOKMARK.h
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderDogear:onTap()
|
||||
self.ui:handleEvent(Event:new("ToggleBookmark"))
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderDogear:onSetDogearVisibility(visible)
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local LeftContainer = require("ui/widget/container/leftcontainer")
|
||||
local ImageWidget = require("ui/widget/imagewidget")
|
||||
local GestureRange = require("ui/gesturerange")
|
||||
local Device = require("ui/device")
|
||||
local Geom = require("ui/geometry")
|
||||
local Screen = require("ui/screen")
|
||||
local Event = require("ui/event")
|
||||
|
||||
local ReaderFlipping = LeftContainer:new{
|
||||
local ReaderFlipping = InputContainer:new{
|
||||
orig_reflow_mode = 0,
|
||||
}
|
||||
|
||||
@@ -11,9 +15,30 @@ function ReaderFlipping:init()
|
||||
local widget = ImageWidget:new{
|
||||
file = "resources/icons/appbar.book.open.png",
|
||||
}
|
||||
local icon_size = widget:getSize()
|
||||
self.dimen = Geom:new{w = Screen:getWidth(), h = icon_size.h}
|
||||
self[1] = widget
|
||||
self[1] = LeftContainer:new{
|
||||
dimen = Geom:new{w = Screen:getWidth(), h = widget:getSize().h},
|
||||
widget,
|
||||
}
|
||||
if Device:isTouchDevice() then
|
||||
self.ges_events = {
|
||||
Tap = {
|
||||
GestureRange:new{
|
||||
ges = "tap",
|
||||
range = Geom:new{
|
||||
x = Screen:getWidth()*DTAP_ZONE_FLIPPING.x,
|
||||
y = Screen:getHeight()*DTAP_ZONE_FLIPPING.y,
|
||||
w = Screen:getWidth()*DTAP_ZONE_FLIPPING.w,
|
||||
h = Screen:getHeight()*DTAP_ZONE_FLIPPING.h
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
function ReaderFlipping:onTap()
|
||||
self.ui:handleEvent(Event:new("ToggleFlipping"))
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderFlipping:onSetFlippingMode(flipping_mode)
|
||||
|
||||
@@ -80,16 +80,6 @@ function ReaderPaging:initGesListener()
|
||||
}
|
||||
}
|
||||
},
|
||||
ToggleFlipping = {
|
||||
GestureRange:new{
|
||||
ges = "tap",
|
||||
range = Geom:new{
|
||||
x = 0, y = 0,
|
||||
w = Screen:getWidth()/8,
|
||||
h = Screen:getHeight()/8
|
||||
}
|
||||
}
|
||||
},
|
||||
Swipe = {
|
||||
GestureRange:new{
|
||||
ges = "swipe",
|
||||
|
||||
@@ -68,6 +68,7 @@ end
|
||||
function ReaderView:resetLayout()
|
||||
self.dogear = ReaderDogear:new{
|
||||
view = self,
|
||||
ui = self.ui,
|
||||
}
|
||||
self.footer = ReaderFooter:new{
|
||||
view = self,
|
||||
@@ -75,6 +76,7 @@ function ReaderView:resetLayout()
|
||||
}
|
||||
self.flipping = ReaderFlipping:new{
|
||||
view = self,
|
||||
ui = self.ui,
|
||||
}
|
||||
self[1] = self.dogear
|
||||
self[2] = self.footer
|
||||
|
||||
Reference in New Issue
Block a user