mirror of
https://github.com/airstruck/luigi.git
synced 2025-11-18 12:25:06 +00:00
support vertical progress
This commit is contained in:
@@ -13,6 +13,7 @@ end)
|
||||
layout.flowToggle:onChange(function (event)
|
||||
layout.flowTest.flow = event.value and 'x' or 'y'
|
||||
layout.slidey.flow = event.value and 'y' or 'x'
|
||||
layout.progressBar.flow = event.value and 'y' or 'x'
|
||||
end)
|
||||
|
||||
layout.newButton:onPress(function (event)
|
||||
|
||||
@@ -9,11 +9,12 @@ between 0 and 1 (inclusive) to change the width of the bar.
|
||||
|
||||
return function (self)
|
||||
self.value = 0
|
||||
self.flow = 'x' -- TODO: support vertical progress?
|
||||
|
||||
local pad = self:addChild {
|
||||
width = 0,
|
||||
}
|
||||
local bar = self:addChild {
|
||||
type = 'progress.bar',
|
||||
width = 0,
|
||||
}
|
||||
|
||||
self:onChange(function ()
|
||||
@@ -23,8 +24,18 @@ return function (self)
|
||||
self:onReshape(function ()
|
||||
local x1, y1, w, h = self:getRectangle(true, true)
|
||||
local x2, y2 = x1 + w, y1 + h
|
||||
local min = bar.minwidth
|
||||
x1 = x1 + min
|
||||
bar.width = self.value * (x2 - x1) + min
|
||||
if self.flow == 'x' then
|
||||
local min = bar.minwidth or 0
|
||||
x1 = x1 + min
|
||||
bar.width = self.value * (x2 - x1) + min
|
||||
bar.height = false
|
||||
pad.height = 0
|
||||
else
|
||||
local min = bar.minheight or 0
|
||||
y1 = y1 + min
|
||||
bar.width = false
|
||||
bar.height = false
|
||||
pad.height = h - (self.value * (y2 - y1) + min)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user