adapt touch menu for small screen

pull/629/head
chrox 10 years ago
parent 53a41c0ce8
commit 427da958cb

@ -16,6 +16,7 @@ local IconButton = require("ui/widget/iconbutton")
local UIManager = require("ui/uimanager")
local Screen = require("ui/screen")
local Geom = require("ui/geometry")
local DEBUG = require("dbg")
local _ = require("gettext")
--[[
@ -84,7 +85,6 @@ end
TouchMenuBar widget
--]]
local TouchMenuBar = InputContainer:new{
height = Screen:scaleByDPI(70),
width = Screen:getWidth(),
icons = {},
-- touch menu that holds the bar, used for trigger repaint on icons
@ -93,17 +93,18 @@ local TouchMenuBar = InputContainer:new{
}
function TouchMenuBar:init()
self.show_parent = self.show_parent or self
self.dimen = Geom:new{
w = self.width,
h = self.height,
}
self.bar_icon_group = HorizontalGroup:new{}
local icon_sep_width = Screen:scaleByDPI(2)
local icons_sep_width = icon_sep_width * (#self.icons + 1)
-- we assume all icons are of the same width
local ib = IconButton:new{icon_file = self.icons[1]}
local content_width = ib:getSize().w * #self.icons + icons_sep_width
local spacing_width = (self.width - content_width)/(#self.icons*2)
local spacing = HorizontalSpan:new{
width = math.min(spacing_width, Screen:scaleByDPI(20))
}
self.height = ib:getSize().h + Screen:scaleByDPI(10)
self.show_parent = self.show_parent or self
self.bar_icon_group = HorizontalGroup:new{}
-- build up image widget for menu icon bar
self.icon_widgets = {}
-- hold icon seperators
@ -119,12 +120,6 @@ function TouchMenuBar:init()
callback = nil,
}
-- we assume all icons are of the same width
local content_width = ib:getSize().w * #self.icons + icons_sep_width
local spacing_width = (Screen:getWidth()-content_width)/(#self.icons*2)
local spacing = HorizontalSpan:new{
width = math.min(spacing_width, Screen:scaleByDPI(20))
}
table.insert(self.icon_widgets, HorizontalGroup:new{
spacing, ib, spacing,
})
@ -188,6 +183,7 @@ function TouchMenuBar:init()
self.bar_sep
},
}
self.dimen = Geom:new{ w = self.width, h = self.height }
end

Loading…
Cancel
Save