mirror of
https://github.com/airstruck/luigi.git
synced 2025-12-19 02:16:43 +00:00
scissor me baby
This commit is contained in:
@@ -8,7 +8,7 @@ between 0 and 1 (inclusive) to change the width of the bar.
|
||||
--]]--
|
||||
|
||||
return function (self)
|
||||
self.value = 0
|
||||
self.value = self.value or 0
|
||||
|
||||
local pad = self:addChild {
|
||||
width = 0,
|
||||
@@ -35,7 +35,7 @@ return function (self)
|
||||
y1 = y1 + min
|
||||
bar.width = false
|
||||
bar.height = false
|
||||
pad.height = h - (self.value * (y2 - y1) + min)
|
||||
pad.height = math.ceil(h - (self.value * (y2 - y1) + min))
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -44,8 +44,6 @@ local function setDimension (widget, name, size)
|
||||
or (widget.minheight or 0)
|
||||
|
||||
widget[name] = math.max(size, min)
|
||||
|
||||
return widget[name]
|
||||
end
|
||||
|
||||
|
||||
@@ -79,10 +77,9 @@ return function (self)
|
||||
end
|
||||
if nextSize then
|
||||
setDimension(nextSibling, dimension,
|
||||
nextSibling:calculatePosition(axis) +
|
||||
nextSibling:calculateDimension(dimension) - event[axis])
|
||||
nextSibling:calculatePosition(axis) + nextSize - event[axis])
|
||||
end
|
||||
|
||||
self.parent:reshape()
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
@@ -21,13 +21,22 @@ return function (self)
|
||||
self[index] = nil
|
||||
end
|
||||
|
||||
local decrement = self:addChild { type = 'stepper.left' }
|
||||
local before = self:addChild { type = 'stepper.left' }
|
||||
local view = self:addChild()
|
||||
local increment = self:addChild { type = 'stepper.right' }
|
||||
local after = self:addChild { type = 'stepper.right' }
|
||||
|
||||
self:onReshape(function (event)
|
||||
decrement.width = decrement:getHeight()
|
||||
increment.width = increment:getHeight()
|
||||
if self.flow == 'x' then
|
||||
before.height = false
|
||||
after.height = false
|
||||
before.width = 0
|
||||
after.width = 0
|
||||
else
|
||||
before.width = false
|
||||
after.width = false
|
||||
before.height = 0
|
||||
after.height = 0
|
||||
end
|
||||
end)
|
||||
|
||||
local function updateValue ()
|
||||
@@ -35,25 +44,33 @@ return function (self)
|
||||
self.value = item.value
|
||||
view[1] = nil
|
||||
view:addChild(item)
|
||||
item:reshape()
|
||||
view:reshape()
|
||||
end
|
||||
|
||||
decrement:onPress(function (event)
|
||||
local function decrement ()
|
||||
if not self.items then return end
|
||||
self.index = self.index - 1
|
||||
if self.index < 1 then
|
||||
self.index = #self.items
|
||||
end
|
||||
updateValue()
|
||||
end)
|
||||
end
|
||||
|
||||
increment:onPress(function (event)
|
||||
local function increment ()
|
||||
if not self.items then return end
|
||||
self.index = self.index + 1
|
||||
if self.index > #self.items then
|
||||
self.index = 1
|
||||
end
|
||||
updateValue()
|
||||
end
|
||||
|
||||
before:onPress(function (event)
|
||||
if self.flow == 'x' then decrement() else increment() end
|
||||
end)
|
||||
|
||||
after:onPress(function (event)
|
||||
if self.flow == 'x' then increment() else decrement() end
|
||||
end)
|
||||
|
||||
updateValue()
|
||||
|
||||
Reference in New Issue
Block a user