Add horizontal_padding to IconButton (#3213)

TouchMenu (top menu) and ConfigDialog (bottom menu) updated
to make use of that. This provides a wider sensitivity to
menu buttons.
This commit is contained in:
poire-z
2017-09-13 10:12:29 +02:00
committed by Frans de Jonge
parent b617efa21f
commit bccbf95080
3 changed files with 42 additions and 18 deletions

View File

@@ -2,6 +2,8 @@
Button with a big icon image! Designed for touch devices.
--]]
local HorizontalGroup = require("ui/widget/horizontalgroup")
local HorizontalSpan = require("ui/widget/horizontalspan")
local InputContainer = require("ui/widget/container/inputcontainer")
local ImageWidget = require("ui/widget/imagewidget")
local GestureRange = require("ui/gesturerange")
@@ -13,6 +15,7 @@ local IconButton = InputContainer:new{
-- show_parent is used for UIManager:setDirty, so we can trigger repaint
show_parent = nil,
scale_for_dpi = true,
horizontal_padding = 0,
callback = function() end,
}
@@ -23,11 +26,27 @@ function IconButton:init()
}
self.show_parent = self.show_parent or self
self.button = HorizontalGroup:new{}
table.insert(self.button, HorizontalSpan:new{})
table.insert(self.button, self.image)
table.insert(self.button, HorizontalSpan:new{})
self[1] = self.button
self:update()
end
function IconButton:update()
self.button[1].width = self.horizontal_padding
self.button[3].width = self.horizontal_padding
self.dimen = self.image:getSize()
self.dimen.w = self.dimen.w + 2*self.horizontal_padding
self:initGesListener()
end
self[1] = self.image
function IconButton:setHorizontalPadding(padding)
self.horizontal_padding = padding
self:update()
end
function IconButton:initGesListener()