mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user