mirror of
https://github.com/airstruck/luigi.git
synced 2025-12-19 02:16:43 +00:00
add mouse wheel events and scroll attribute
This commit is contained in:
@@ -358,13 +358,17 @@ function Widget:calculatePosition (axis)
|
||||
return self.position[axis]
|
||||
end
|
||||
local parent = self.parent
|
||||
local scroll = 0
|
||||
if not parent then
|
||||
self.position[axis] = axis == 'x' and (self.left or 0)
|
||||
or axis == 'y' and (self.top or 0)
|
||||
return self.position[axis]
|
||||
elseif parent then
|
||||
scroll = axis == 'x' and (parent.scrollX or 0)
|
||||
or axis == 'y' and (parent.scrollY or 0)
|
||||
end
|
||||
local parentPos = parent:calculatePosition(axis)
|
||||
local p = parentPos
|
||||
local p = parentPos - scroll
|
||||
p = p + (parent.margin or 0)
|
||||
p = p + (parent.padding or 0)
|
||||
local parentFlow = parent.flow or 'y'
|
||||
@@ -422,6 +426,38 @@ function Widget:getHeight ()
|
||||
return self:calculateDimension('height')
|
||||
end
|
||||
|
||||
--[[--
|
||||
Get the content width.
|
||||
|
||||
Gets the combined width of the widget's children.
|
||||
|
||||
@treturn number
|
||||
The content width.
|
||||
--]]--
|
||||
function Widget:getContentWidth ()
|
||||
local width = 0
|
||||
for _, child in ipairs(self) do
|
||||
width = width + child:getWidth()
|
||||
end
|
||||
return width
|
||||
end
|
||||
|
||||
--[[--
|
||||
Get the content height.
|
||||
|
||||
Gets the combined height of the widget's children.
|
||||
|
||||
@treturn number
|
||||
The content height.
|
||||
--]]--
|
||||
function Widget:getContentHeight ()
|
||||
local height = 0
|
||||
for _, child in ipairs(self) do
|
||||
height = height + child:getHeight()
|
||||
end
|
||||
return height
|
||||
end
|
||||
|
||||
--[[--
|
||||
Get x/y/width/height values describing a rectangle within the widget.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user