2013-10-18 20:38:07 +00:00
|
|
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
2014-01-16 05:43:45 +00:00
|
|
|
local Device = require("ui/device")
|
2013-10-18 20:38:07 +00:00
|
|
|
local Screen = require("ui/screen")
|
|
|
|
local GestureRange = require("ui/gesturerange")
|
|
|
|
local UIManager = require("ui/uimanager")
|
2014-01-20 21:38:53 +00:00
|
|
|
local InfoMessage = require("ui/widget/infomessage")
|
|
|
|
local _ = require("gettext")
|
|
|
|
local DEBUG = require("dbg")
|
2013-03-06 14:36:51 +00:00
|
|
|
|
2013-10-18 20:38:07 +00:00
|
|
|
local ReaderScreenshot = InputContainer:new{}
|
2013-03-06 14:36:51 +00:00
|
|
|
|
|
|
|
function ReaderScreenshot:init()
|
2014-03-13 13:52:43 +00:00
|
|
|
local diagonal = math.sqrt(
|
|
|
|
math.pow(Screen:getWidth(), 2) +
|
|
|
|
math.pow(Screen:getHeight(), 2)
|
|
|
|
)
|
|
|
|
self.ges_events = {
|
2014-06-17 13:12:42 +00:00
|
|
|
TapDiagonal = {
|
2014-03-13 13:52:43 +00:00
|
|
|
GestureRange:new{
|
|
|
|
ges = "two_finger_tap",
|
2014-05-28 15:21:08 +00:00
|
|
|
scale = {diagonal - Screen:scaleByDPI(200), diagonal},
|
2014-03-13 13:52:43 +00:00
|
|
|
rate = 1.0,
|
|
|
|
}
|
|
|
|
},
|
2014-06-17 13:12:42 +00:00
|
|
|
SwipeDiagonal = {
|
|
|
|
GestureRange:new{
|
|
|
|
ges = "swipe",
|
|
|
|
scale = {diagonal - Screen:scaleByDPI(200), diagonal},
|
|
|
|
rate = 1.0,
|
|
|
|
}
|
|
|
|
},
|
2014-03-13 13:52:43 +00:00
|
|
|
}
|
2013-03-06 14:36:51 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderScreenshot:onScreenshot()
|
2014-05-28 15:21:08 +00:00
|
|
|
if os.execute("screenshot") ~= 0 then
|
|
|
|
Screen.bb:invert()
|
2014-03-13 13:52:43 +00:00
|
|
|
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)
|
2014-05-28 15:21:08 +00:00
|
|
|
Screen.bb:invert()
|
2014-03-13 13:52:43 +00:00
|
|
|
end
|
|
|
|
UIManager.full_refresh = true
|
|
|
|
return true
|
2013-03-06 14:36:51 +00:00
|
|
|
end
|
|
|
|
|
2014-06-17 13:12:42 +00:00
|
|
|
function ReaderScreenshot:onTapDiagonal()
|
|
|
|
return self:onScreenshot()
|
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderScreenshot:onSwipeDiagonal()
|
|
|
|
return self:onScreenshot()
|
|
|
|
end
|
|
|
|
|
2013-10-18 20:38:07 +00:00
|
|
|
return ReaderScreenshot
|