2
0
mirror of https://github.com/koreader/koreader synced 2024-11-13 19:11:25 +00:00
koreader/frontend/apps/reader/modules/readerdogear.lua

75 lines
2.3 KiB
Lua
Raw Normal View History

local InputContainer = require("ui/widget/container/inputcontainer")
2013-10-18 20:38:07 +00:00
local RightContainer = require("ui/widget/container/rightcontainer")
local ImageWidget = require("ui/widget/imagewidget")
local GestureRange = require("ui/gesturerange")
local Device = require("device")
2013-10-18 20:38:07 +00:00
local Geom = require("ui/geometry")
local Screen = require("device").screen
local Event = require("ui/event")
local ReaderDogear = InputContainer:new{}
function ReaderDogear:init()
2014-03-13 13:52:43 +00:00
local widget = ImageWidget:new{
file = "resources/icons/dogear.png",
alpha = true,
2014-03-13 13:52:43 +00:00
}
self[1] = RightContainer:new{
dimen = Geom:new{w = Screen:getWidth(), h = widget:getSize().h},
widget,
}
self:resetLayout()
end
function ReaderDogear:resetLayout()
local new_screen_width = Screen:getWidth()
if new_screen_width == self._last_screen_width then return end
local new_screen_height = Screen:getHeight()
self._last_screen_width = new_screen_width
self[1].dimen.w = new_screen_width
2014-03-13 13:52:43 +00:00
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
2014-03-13 13:52:43 +00:00
}
}
},
Hold = {
GestureRange:new{
ges = "hold",
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
2014-03-13 13:52:43 +00:00
}
}
}
}
end
end
function ReaderDogear:onTap()
2014-03-13 13:52:43 +00:00
self.ui:handleEvent(Event:new("ToggleBookmark"))
return true
end
function ReaderDogear:onHold()
2014-03-13 13:52:43 +00:00
self.ui:handleEvent(Event:new("ToggleBookmarkFlipping"))
return true
end
function ReaderDogear:onSetDogearVisibility(visible)
2014-03-13 13:52:43 +00:00
self.view.dogear_visible = visible
return true
2013-03-12 17:18:53 +00:00
end
2013-10-18 20:38:07 +00:00
return ReaderDogear