|
|
@ -80,12 +80,22 @@ local ImageViewer = InputContainer:new{
|
|
|
|
|
|
|
|
|
|
|
|
function ImageViewer:init()
|
|
|
|
function ImageViewer:init()
|
|
|
|
if Device:hasKeys() then
|
|
|
|
if Device:hasKeys() then
|
|
|
|
|
|
|
|
if type(self.image) == "table" then
|
|
|
|
|
|
|
|
-- if self.image is a table, then use hardware keys to change image
|
|
|
|
|
|
|
|
self.key_events = {
|
|
|
|
|
|
|
|
Close = { {Device.input.group.Back}, doc = "close viewer" },
|
|
|
|
|
|
|
|
ShowPrevImage = { {Device.input.group.PgBack}, doc = "Previous image" },
|
|
|
|
|
|
|
|
ShowNextImage = { {Device.input.group.PgFwd}, doc = "Next image" },
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
-- otherwise, use hardware keys to zoom in/out
|
|
|
|
self.key_events = {
|
|
|
|
self.key_events = {
|
|
|
|
Close = { {Device.input.group.Back}, doc = "close viewer" },
|
|
|
|
Close = { {Device.input.group.Back}, doc = "close viewer" },
|
|
|
|
ZoomIn = { {Device.input.group.PgBack}, doc = "Zoom In" },
|
|
|
|
ZoomIn = { {Device.input.group.PgBack}, doc = "Zoom In" },
|
|
|
|
ZoomOut = { {Device.input.group.PgFwd}, doc = "Zoom out" },
|
|
|
|
ZoomOut = { {Device.input.group.PgFwd}, doc = "Zoom out" },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
if Device:isTouchDevice() then
|
|
|
|
if Device:isTouchDevice() then
|
|
|
|
local range = Geom:new{
|
|
|
|
local range = Geom:new{
|
|
|
|
x = 0, y = 0,
|
|
|
|
x = 0, y = 0,
|
|
|
@ -449,6 +459,19 @@ function ImageViewer:switchToImageNum(image_num)
|
|
|
|
self:update()
|
|
|
|
self:update()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Image switching events
|
|
|
|
|
|
|
|
function ImageViewer:onShowNextImage()
|
|
|
|
|
|
|
|
if self._images_list_cur < self._images_list_nb then
|
|
|
|
|
|
|
|
self:switchToImageNum(self._images_list_cur + 1)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function ImageViewer:onShowPrevImage()
|
|
|
|
|
|
|
|
if self._images_list_cur > 1 then
|
|
|
|
|
|
|
|
self:switchToImageNum(self._images_list_cur - 1)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function ImageViewer:onTap(_, ges)
|
|
|
|
function ImageViewer:onTap(_, ges)
|
|
|
|
if ges.pos:notIntersectWith(self.main_frame.dimen) then
|
|
|
|
if ges.pos:notIntersectWith(self.main_frame.dimen) then
|
|
|
|
self:onClose()
|
|
|
|
self:onClose()
|
|
|
@ -479,13 +502,9 @@ function ImageViewer:onTap(_, ges)
|
|
|
|
show_next_image = not BD.mirroredUILayout()
|
|
|
|
show_next_image = not BD.mirroredUILayout()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if show_prev_image then
|
|
|
|
if show_prev_image then
|
|
|
|
if self._images_list_cur > 1 then
|
|
|
|
self:onShowPrevImage()
|
|
|
|
self:switchToImageNum(self._images_list_cur - 1)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
elseif show_next_image then
|
|
|
|
elseif show_next_image then
|
|
|
|
if self._images_list_cur < self._images_list_nb then
|
|
|
|
self:onShowNextImage()
|
|
|
|
self:switchToImageNum(self._images_list_cur + 1)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
else -- toggle buttons when tap on middle 1/3 of screen width
|
|
|
|
else -- toggle buttons when tap on middle 1/3 of screen width
|
|
|
|
self.buttons_visible = not self.buttons_visible
|
|
|
|
self.buttons_visible = not self.buttons_visible
|
|
|
|
self:update()
|
|
|
|
self:update()
|
|
|
|