Merge branch 'rotate'

Conflicts:
	filechooser.lua

* merge rotate branch with search branch
* fix font display bug in font menu

not fully tested the new rotation implemention yet.
pull/2/merge
Qingping Hou 12 years ago
commit 417ef640a7

@ -54,33 +54,6 @@ function FileChooser:setPath(newPath)
return true
end
function FileChooser:rotationMode()
--[[
return code for four kinds of rotation mode:
0 for no rotation,
1 for landscape with bottom on the right side of screen, etc.
2
---------
| |
| |
| |
3 | | 1
| |
| |
| |
---------
0
--]]
if KEY_FW_DOWN == 116 then
return 0
end
orie_fd = assert(io.open("/sys/module/eink_fb_hal_broads/parameters/bs_orientation", "r"))
updown_fd = assert(io.open("/sys/module/eink_fb_hal_broads/parameters/bs_upside_down", "r"))
mode = orie_fd:read() + (updown_fd:read() * 2)
return mode
end
function FileChooser:choose(ypos, height)
local perpage = math.floor(height / self.spacing) - 1
@ -154,32 +127,13 @@ function FileChooser:choose(ypos, height)
end
local ev = input.waitForEvent()
if ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_PRESS then
print("key code:"..ev.code)
--print("key code:"..ev.code)
ev.code = adjustFWKey(ev.code)
if ev.code == KEY_FW_UP then
if self:rotationMode() == 0 then
prevItem()
elseif self:rotationMode() == 2 then
nextItem()
end
prevItem()
elseif ev.code == KEY_FW_DOWN then
if self:rotationMode() == 0 then
nextItem()
elseif self:rotationMode() == 2 then
prevItem()
end
elseif ev.code == KEY_FW_LEFT then
if self:rotationMode() == 1 then
prevItem()
elseif self:rotationMode() == 3 then
nextItem()
end
elseif ev.code == KEY_FW_RIGHT then
if self:rotationMode() == 1 then
nextItem()
elseif self:rotationMode() == 3 then
prevItem()
end
elseif ev.code == KEY_F then
nextItem()
elseif ev.code == KEY_F then -- invoke fontchooser menu
FontChooser:init()
newfont = FontChooser:choose(0, height)
if newfont ~= nil then
@ -187,8 +141,7 @@ function FileChooser:choose(ypos, height)
clearglyphcache()
end
pagedirty = true
elseif ev.code == KEY_S then
-- invoke search input
elseif ev.code == KEY_S then -- invoke search input
keywords = InputBox:input(height-100, 100, "Search:")
if keywords then -- display search result according to keywords
--[[

@ -188,6 +188,7 @@ function FileSearcher:choose(ypos, height, keywords)
local ev = input.waitForEvent()
if ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_PRESS then
ev.code = adjustFWKey(ev.code)
if ev.code == KEY_FW_UP then
prevItem()
elseif ev.code == KEY_FW_DOWN then

@ -31,8 +31,8 @@ FontChooser = {
}
function FontChooser:init()
clearglyphcache()
self.items = #self.fonts
table.sort(self.fonts)
end
@ -80,6 +80,7 @@ function FontChooser:choose(ypos, height)
renderUtf8Text(fb.bb, x, y, self.tface, self.tfhash,
"Fonts Menu", true)
-- draw font items
fb.bb:paintRect(0, ypos + self.title_H + 10, fb.bb:getWidth(), height - self.title_H, 0)
local c
for c = 1, perpage do
@ -89,6 +90,7 @@ function FontChooser:choose(ypos, height)
renderUtf8Text(fb.bb, 50, y, self.face, self.fhash, self.fonts[i], true)
end
end
-- draw footer
y = ypos + self.title_H + (self.spacing * perpage) + self.foot_H
x = (fb.bb:getWidth() / 2) - 50
@ -122,6 +124,7 @@ function FontChooser:choose(ypos, height)
local ev = input.waitForEvent()
if ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_PRESS then
ev.code = adjustFWKey(ev.code)
if ev.code == KEY_FW_UP then
prevItem()
elseif ev.code == KEY_FW_DOWN then

@ -96,8 +96,8 @@ function InputBox:input(ypos, height, title, d_text)
local ev = input.waitForEvent()
if ev.type == EV_KEY and ev.value == EVENT_VALUE_KEY_PRESS then
print("key code:"..ev.code)
--ev.code = adjustFWKey(ev.code)
--print("key code:"..ev.code)
ev.code = adjustFWKey(ev.code)
if ev.code == KEY_FW_UP then
elseif ev.code == KEY_FW_DOWN then
elseif ev.code == KEY_A then

@ -154,3 +154,75 @@ function set_emu_keycodes()
KEY_VPLUS = 95 -- F11
KEY_VMINUS = 96 -- F12
end
function getRotationMode()
--[[
return code for four kinds of rotation mode:
0 for no rotation,
1 for landscape with bottom on the right side of screen, etc.
2
-----------
| ------- |
| | | |
| | | |
| | | |
3 | | | | 1
| | | |
| | | |
| ------- |
| |
-----------
0
--]]
if KEY_FW_DOWN == 116 then -- in EMU mode always return 0
return 0
end
orie_fd = assert(io.open("/sys/module/eink_fb_hal_broads/parameters/bs_orientation", "r"))
updown_fd = assert(io.open("/sys/module/eink_fb_hal_broads/parameters/bs_upside_down", "r"))
mode = orie_fd:read() + (updown_fd:read() * 2)
return mode
end
function adjustFWKey(code)
if getRotationMode() == 0 then
return code
elseif getRotationMode() == 1 then
if code == KEY_FW_UP then
return KEY_FW_RIGHT
elseif code == KEY_FW_RIGHT then
return KEY_FW_DOWN
elseif code == KEY_FW_DOWN then
return KEY_FW_LEFT
elseif code == KEY_FW_LEFT then
return KEY_FW_UP
else
return code
end
elseif getRotationMode() == 2 then
if code == KEY_FW_UP then
return KEY_FW_DOWN
elseif code == KEY_FW_RIGHT then
return KEY_FW_LEFT
elseif code == KEY_FW_DOWN then
return KEY_FW_UP
elseif code == KEY_FW_LEFT then
return KEY_FW_RIGHT
else
return code
end
elseif getRotationMode() == 3 then
if code == KEY_FW_UP then
return KEY_FW_LEFT
elseif code == KEY_FW_RIGHT then
return KEY_FW_UP
elseif code == KEY_FW_DOWN then
return KEY_FW_RIGHT
elseif code == KEY_FW_LEFT then
return KEY_FW_DOWN
else
return code
end
end
end

Loading…
Cancel
Save