mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Merge pull request #156 from chrox/landscape_ori
toggle landscape will change orientation for landscape mode
This commit is contained in:
@@ -10,6 +10,7 @@ KoptOptions = {
|
||||
name = "screen_mode",
|
||||
name_text = SCREEN_MODE_STR,
|
||||
toggle = {PORTRAIT_STR, LANDSCAPE_STR},
|
||||
alternate = false,
|
||||
args = {"portrait", "landscape"},
|
||||
default_arg = "portrait",
|
||||
current_func = function() return Screen:getScreenMode() end,
|
||||
|
||||
@@ -609,7 +609,7 @@ end
|
||||
--]]
|
||||
function GestureDetector:adjustGesCoordinate(ges)
|
||||
if Screen.cur_rotation_mode == 1 then
|
||||
-- in landscape mode
|
||||
-- in landscape mode rotated 270
|
||||
if ges.pos then
|
||||
ges.pos.x, ges.pos.y = (Screen.width - ges.pos.y), (ges.pos.x)
|
||||
end
|
||||
@@ -642,6 +642,40 @@ function GestureDetector:adjustGesCoordinate(ges)
|
||||
ges.direction = "horizontal"
|
||||
end
|
||||
end
|
||||
elseif Screen.cur_rotation_mode == 3 then
|
||||
-- in landscape mode rotated 90
|
||||
if ges.pos then
|
||||
ges.pos.x, ges.pos.y = (ges.pos.y), (Screen.height - ges.pos.x)
|
||||
end
|
||||
if ges.ges == "swipe" or ges.ges == "pan"
|
||||
or ges.ges == "two_finger_swipe"
|
||||
or ges.ges == "two_finger_pan" then
|
||||
if ges.direction == "north" then
|
||||
ges.direction = "west"
|
||||
elseif ges.direction == "south" then
|
||||
ges.direction = "east"
|
||||
elseif ges.direction == "east" then
|
||||
ges.direction = "north"
|
||||
elseif ges.direction == "west" then
|
||||
ges.direction = "south"
|
||||
elseif ges.direction == "northeast" then
|
||||
ges.direction = "northwest"
|
||||
elseif ges.direction == "northwest" then
|
||||
ges.direction = "southeast"
|
||||
elseif ges.direction == "southeast" then
|
||||
ges.direction = "northeast"
|
||||
elseif ges.direction == "southwest" then
|
||||
ges.direction = "southeast"
|
||||
end
|
||||
elseif ges.ges == "pinch" or ges.ges == "spread"
|
||||
or ges.ges == "inward_pan"
|
||||
or ges.ges == "outward_pan" then
|
||||
if ges.direction == "horizontal" then
|
||||
ges.direction = "vertical"
|
||||
elseif ges.direction == "vertical" then
|
||||
ges.direction = "horizontal"
|
||||
end
|
||||
end
|
||||
end
|
||||
return ges
|
||||
end
|
||||
|
||||
@@ -52,17 +52,17 @@ function ReaderRotation:onRotate(rotate_by)
|
||||
end
|
||||
|
||||
function ReaderRotation:onRotateGes(arg, ges)
|
||||
self.ratate_angle = ges.angle
|
||||
self.rotate_angle = ges.angle
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderRotation:onTwoFingerPanRelease(arg, ges)
|
||||
if self.ratate_angle and self.ratate_angle > self.ROTATE_ANGLE_THRESHOLD then
|
||||
if self.rotate_angle and self.rotate_angle > self.ROTATE_ANGLE_THRESHOLD then
|
||||
if Screen:getScreenMode() == "portrait" then
|
||||
self.ui:handleEvent(Event:new("SetScreenMode", "landscape"))
|
||||
else
|
||||
self.ui:handleEvent(Event:new("SetScreenMode", "portrait"))
|
||||
end
|
||||
self.ratate_angle = nil
|
||||
self.rotate_angle = nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -415,12 +415,17 @@ function ReaderView:PanningUpdate(dx, dy)
|
||||
return true
|
||||
end
|
||||
|
||||
function ReaderView:onSetScreenMode(new_mode)
|
||||
function ReaderView:onSetScreenMode(new_mode, rotation)
|
||||
if new_mode == "landscape" or new_mode == "portrait" then
|
||||
self.screen_mode = new_mode
|
||||
Screen:setScreenMode(new_mode)
|
||||
if rotation ~= nil then
|
||||
Screen:setRotationMode(rotation)
|
||||
else
|
||||
Screen:setScreenMode(new_mode)
|
||||
end
|
||||
self.ui:handleEvent(Event:new("SetDimensions", Screen:getSize()))
|
||||
end
|
||||
self.cur_rotation_mode = Screen.cur_rotation_mode
|
||||
|
||||
if new_mode == "landscape" and self.document.info.has_pages then
|
||||
self.ui:handleEvent(Event:new("SetZoomMode", "contentwidth"))
|
||||
@@ -473,7 +478,8 @@ function ReaderView:onReadSettings(config)
|
||||
local screen_mode = config:readSetting("screen_mode")
|
||||
if screen_mode then
|
||||
table.insert(self.ui.postInitCallback, function()
|
||||
self:onSetScreenMode(screen_mode) end)
|
||||
self:onSetScreenMode(screen_mode, config:readSetting("rotation_mode"))
|
||||
end)
|
||||
end
|
||||
self.state.gamma = config:readSetting("gamma") or DGLOBALGAMMA
|
||||
local full_screen = config:readSetting("kopt_full_screen")
|
||||
@@ -556,6 +562,7 @@ end
|
||||
function ReaderView:onCloseDocument()
|
||||
self.ui.doc_settings:saveSetting("render_mode", self.render_mode)
|
||||
self.ui.doc_settings:saveSetting("screen_mode", self.screen_mode)
|
||||
self.ui.doc_settings:saveSetting("rotation_mode", self.cur_rotation_mode)
|
||||
self.ui.doc_settings:saveSetting("gamma", self.state.gamma)
|
||||
self.ui.doc_settings:saveSetting("highlight", self.highlight.saved)
|
||||
end
|
||||
|
||||
@@ -74,12 +74,16 @@ end
|
||||
|
||||
function Screen:refresh(refesh_type)
|
||||
if self.native_rotation_mode == self.cur_rotation_mode then
|
||||
self.fb.bb:blitFrom(self.bb, 0, 0, 0, 0, self.width, self.height)
|
||||
elseif self.native_rotation_mode == 0 and self.cur_rotation_mode == 1 then
|
||||
self.fb.bb:blitFromRotate(self.bb, 270)
|
||||
elseif self.native_rotation_mode == 1 and self.cur_rotation_mode == 0 then
|
||||
self.fb.bb:blitFromRotate(self.bb, 90)
|
||||
end
|
||||
self.fb.bb:blitFrom(self.bb, 0, 0, 0, 0, self.width, self.height)
|
||||
elseif self.native_rotation_mode == 0 and self.cur_rotation_mode == 1 then
|
||||
self.fb.bb:blitFromRotate(self.bb, 270)
|
||||
elseif self.native_rotation_mode == 0 and self.cur_rotation_mode == 3 then
|
||||
self.fb.bb:blitFromRotate(self.bb, 90)
|
||||
elseif self.native_rotation_mode == 1 and self.cur_rotation_mode == 0 then
|
||||
self.fb.bb:blitFromRotate(self.bb, 90)
|
||||
elseif self.native_rotation_mode == 1 and self.cur_rotation_mode == 3 then
|
||||
self.fb.bb:blitFromRotate(self.bb, 180)
|
||||
end
|
||||
self.fb:refresh(refesh_type)
|
||||
end
|
||||
|
||||
@@ -159,8 +163,10 @@ function Screen:setScreenMode(mode)
|
||||
self:setRotationMode(0)
|
||||
end
|
||||
elseif mode == "landscape" then
|
||||
if self.cur_rotation_mode ~= 1 then
|
||||
if self.cur_rotation_mode == 0 or self.cur_rotation_mode == 2 then
|
||||
self:setRotationMode(1)
|
||||
elseif self.cur_rotation_mode == 1 or self.cur_rotation_mode == 3 then
|
||||
self:setRotationMode((self.cur_rotation_mode + 2) % 4)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user