2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00
koreader/frontend/apps/reader/modules/readerscreenshot.lua
Hans-Werner Hilse 5982e24d57 unify color specification
colors were a mixture of 4bpp integers (0=white, 15=black) and
fractional blackness levels (0=white, 1.0=black) before. This is
now unified to use the color specification of the Blitbuffer API.
2014-10-24 13:48:42 +02:00

58 lines
1.6 KiB
Lua

local InputContainer = require("ui/widget/container/inputcontainer")
local Device = require("ui/device")
local Screen = require("ui/screen")
local GestureRange = require("ui/gesturerange")
local UIManager = require("ui/uimanager")
local InfoMessage = require("ui/widget/infomessage")
local _ = require("gettext")
local DEBUG = require("dbg")
local ReaderScreenshot = InputContainer:new{}
function ReaderScreenshot:init()
local diagonal = math.sqrt(
math.pow(Screen:getWidth(), 2) +
math.pow(Screen:getHeight(), 2)
)
self.ges_events = {
TapDiagonal = {
GestureRange:new{
ges = "two_finger_tap",
scale = {diagonal - Screen:scaleByDPI(200), diagonal},
rate = 1.0,
}
},
SwipeDiagonal = {
GestureRange:new{
ges = "swipe",
scale = {diagonal - Screen:scaleByDPI(200), diagonal},
rate = 1.0,
}
},
}
end
function ReaderScreenshot:onScreenshot()
if os.execute("screenshot") ~= 0 then
local screenshot_name = os.date("screenshots/Screenshot_%Y-%B-%d_%Hh%M.pam")
UIManager:show(InfoMessage:new{
text = _("Writing screen to ")..screenshot_name,
timeout = 2,
})
Screen.bb:writePAM(screenshot_name)
DEBUG(screenshot_name)
end
UIManager.full_refresh = true
return true
end
function ReaderScreenshot:onTapDiagonal()
return self:onScreenshot()
end
function ReaderScreenshot:onSwipeDiagonal()
return self:onScreenshot()
end
return ReaderScreenshot