mirror of
https://github.com/airstruck/luigi.git
synced 2025-12-19 02:16:43 +00:00
allow events bound to widget classes
This commit is contained in:
@@ -2,36 +2,32 @@ local Widget = require((...):gsub('%.[^.]*$', ''))
|
||||
|
||||
local Sash = Widget:extend()
|
||||
|
||||
function Sash:constructor (layout, data)
|
||||
Widget.constructor(self, layout, data)
|
||||
Sash:onPressDrag(function (event)
|
||||
local self = event.target
|
||||
local axis = self.parent.flow
|
||||
if axis == 'x' then
|
||||
dimension = 'width'
|
||||
else
|
||||
axis = 'y'
|
||||
dimension = 'height'
|
||||
end
|
||||
local prevSibling = self:getPrevious()
|
||||
local nextSibling = self:getNext()
|
||||
local prevSize = prevSibling and prevSibling[dimension]
|
||||
local nextSize = nextSibling and nextSibling[dimension]
|
||||
if prevSize then
|
||||
prevSibling:setDimension(dimension,
|
||||
event[axis] - prevSibling:calculatePosition(axis))
|
||||
end
|
||||
if nextSize then
|
||||
nextSibling:setDimension(dimension,
|
||||
nextSibling:calculatePosition(axis) +
|
||||
nextSibling[dimension] - event[axis])
|
||||
end
|
||||
|
||||
self:onPressDrag(function (event)
|
||||
local axis = self.parent.flow
|
||||
if axis == 'x' then
|
||||
dimension = 'width'
|
||||
else
|
||||
axis = 'y'
|
||||
dimension = 'height'
|
||||
end
|
||||
local prevSibling = self:getPrevious()
|
||||
local nextSibling = self:getNext()
|
||||
local prevSize = prevSibling and prevSibling[dimension]
|
||||
local nextSize = nextSibling and nextSibling[dimension]
|
||||
if prevSize then
|
||||
prevSibling:setDimension(dimension,
|
||||
event[axis] - prevSibling:calculatePosition(axis))
|
||||
end
|
||||
if nextSize then
|
||||
nextSibling:setDimension(dimension,
|
||||
nextSibling:calculatePosition(axis) +
|
||||
nextSibling[dimension] - event[axis])
|
||||
end
|
||||
|
||||
prevSibling:reflow()
|
||||
nextSibling:reflow()
|
||||
self:reflow()
|
||||
end)
|
||||
|
||||
end
|
||||
prevSibling:reflow()
|
||||
nextSibling:reflow()
|
||||
self:reflow()
|
||||
end)
|
||||
|
||||
return Sash
|
||||
|
||||
Reference in New Issue
Block a user