add scaleByDPI and use it in touchmenu

pull/2/merge
Qingping Hou 11 years ago
parent eadccf54d1
commit 495a173ed0

@ -18,7 +18,7 @@
--[[
Codes for rotation modes:
1 for no rotation,
1 for no rotation,
2 for landscape with bottom on the right side of screen, etc.
2
@ -26,8 +26,8 @@ Codes for rotation modes:
| +----------+ |
| | | |
| | Freedom! | |
| | | |
| | | |
| | | |
| | | |
3 | | | | 1
| | | |
| | | |
@ -99,6 +99,15 @@ function Screen:getDPI()
return Device:getModel() == "KindlePaperWhite" and 212 or 167
end
function Screen:scaleByDPI(px)
return (px * self:getDPI()/167)
end
-- make a shortcut to Screen:scaleByDPI
function scaleByDPI(px)
return Screen:scaleByDPI(px)
end
function Screen:getPitch()
return self.fb:getPitch()
end

@ -59,7 +59,7 @@ end
TouchMenuBar widget
--]]
TouchMenuBar = InputContainer:new{
height = 70 * Screen:getDPI()/167,
height = scaleByDPI(70),
width = Screen:getWidth(),
icons = {},
-- touch menu that holds the bar, used for trigger repaint on icons
@ -79,12 +79,12 @@ function TouchMenuBar:init()
local icon_sep = LineWidget:new{
dimen = Geom:new{
w = 2,
w = scaleByDPI(2),
h = self.height,
}
}
local icon_span = HorizontalSpan:new{ width = 20 }
local icon_span = HorizontalSpan:new{ width = scaleByDPI(20) }
-- build up image widget for menu icon bar
self.icon_widgets = {}
@ -113,7 +113,7 @@ function TouchMenuBar:init()
self.bar_sep = LineWidget:new{
dimen = Geom:new{
w = self.width,
h = 2,
h = scaleByDPI(2),
},
empty_segments = {
{
@ -162,9 +162,9 @@ TouchMenu = InputContainer:new{
item_table_stack = {},
item_table = nil,
--@TODO replace getDPI call (houqp)
item_height = 50 * Screen:getDPI()/167,
bordersize = 2 * Screen:getDPI()/167,
padding = 5 * Screen:getDPI()/167,
item_height = scaleByDPI(50),
bordersize = scaleByDPI(2),
padding = scaleByDPI(5),
width = Screen:getWidth(),
height = nil,
page = 1,
@ -277,7 +277,7 @@ function TouchMenu:updateItems()
if c ~= self.perpage then
table.insert(self.item_group, HorizontalGroup:new{
-- pad with spacing
HorizontalSpan:new{width = 10},
HorizontalSpan:new{width = scaleByDPI(10)},
LineWidget:new{
style = "dashed",
dimen = Geom:new{
@ -297,7 +297,7 @@ function TouchMenu:updateItems()
end -- if i <= self.items
end -- for c=1, self.perpage
table.insert(self.item_group, VerticalSpan:new{width = 2})
table.insert(self.item_group, VerticalSpan:new{width = scaleByDPI(2)})
table.insert(self.item_group, self.footer)
-- FIXME: this is a dirty hack to clear previous menus
-- refert to issue #664

Loading…
Cancel
Save