|
|
@ -16,6 +16,7 @@ local IconButton = require("ui/widget/iconbutton")
|
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
local Screen = require("ui/screen")
|
|
|
|
local Screen = require("ui/screen")
|
|
|
|
local Geom = require("ui/geometry")
|
|
|
|
local Geom = require("ui/geometry")
|
|
|
|
|
|
|
|
local DEBUG = require("dbg")
|
|
|
|
local _ = require("gettext")
|
|
|
|
local _ = require("gettext")
|
|
|
|
|
|
|
|
|
|
|
|
--[[
|
|
|
|
--[[
|
|
|
@ -84,7 +85,6 @@ end
|
|
|
|
TouchMenuBar widget
|
|
|
|
TouchMenuBar widget
|
|
|
|
--]]
|
|
|
|
--]]
|
|
|
|
local TouchMenuBar = InputContainer:new{
|
|
|
|
local TouchMenuBar = InputContainer:new{
|
|
|
|
height = Screen:scaleByDPI(70),
|
|
|
|
|
|
|
|
width = Screen:getWidth(),
|
|
|
|
width = Screen:getWidth(),
|
|
|
|
icons = {},
|
|
|
|
icons = {},
|
|
|
|
-- touch menu that holds the bar, used for trigger repaint on icons
|
|
|
|
-- touch menu that holds the bar, used for trigger repaint on icons
|
|
|
@ -93,17 +93,18 @@ local TouchMenuBar = InputContainer:new{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function TouchMenuBar:init()
|
|
|
|
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 icon_sep_width = Screen:scaleByDPI(2)
|
|
|
|
local icons_sep_width = icon_sep_width * (#self.icons + 1)
|
|
|
|
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
|
|
|
|
-- build up image widget for menu icon bar
|
|
|
|
self.icon_widgets = {}
|
|
|
|
self.icon_widgets = {}
|
|
|
|
-- hold icon seperators
|
|
|
|
-- hold icon seperators
|
|
|
@ -119,12 +120,6 @@ function TouchMenuBar:init()
|
|
|
|
callback = nil,
|
|
|
|
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{
|
|
|
|
table.insert(self.icon_widgets, HorizontalGroup:new{
|
|
|
|
spacing, ib, spacing,
|
|
|
|
spacing, ib, spacing,
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -188,6 +183,7 @@ function TouchMenuBar:init()
|
|
|
|
self.bar_sep
|
|
|
|
self.bar_sep
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
self.dimen = Geom:new{ w = self.width, h = self.height }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|