add parameters to the dropdown
This commit is contained in:
parent
033ea73c28
commit
6cf7753674
1 changed files with 31 additions and 5 deletions
36
dropdown.lua
36
dropdown.lua
|
@ -39,6 +39,14 @@ local function icons(keys)
|
||||||
return e
|
return e
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function params(keys)
|
||||||
|
local e = {}
|
||||||
|
for i,v in ipairs(keys) do
|
||||||
|
table.insert(e, ease.eases[v].params)
|
||||||
|
end
|
||||||
|
return e
|
||||||
|
end
|
||||||
|
|
||||||
function self.get(index)
|
function self.get(index)
|
||||||
return dropdowns[index]
|
return dropdowns[index]
|
||||||
end
|
end
|
||||||
|
@ -98,7 +106,8 @@ function self.createDropdowns()
|
||||||
width = dropdownWidth,
|
width = dropdownWidth,
|
||||||
options = eases,
|
options = eases,
|
||||||
name = 'ease1',
|
name = 'ease1',
|
||||||
icons = icons(eases)
|
icons = icons(eases),
|
||||||
|
params = params(eases)
|
||||||
})
|
})
|
||||||
local _e = ease.eases[d[dropdownId].options[d[dropdownId].selected]]
|
local _e = ease.eases[d[dropdownId].options[d[dropdownId].selected]]
|
||||||
param1[1] = slider.kvalue(_e.name .. 'param11') or (_e.params[1] and _e.params[1].default) or 1
|
param1[1] = slider.kvalue(_e.name .. 'param11') or (_e.params[1] and _e.params[1].default) or 1
|
||||||
|
@ -113,7 +122,8 @@ function self.createDropdowns()
|
||||||
width = dropdownWidth,
|
width = dropdownWidth,
|
||||||
options = eases,
|
options = eases,
|
||||||
name = 'ease1',
|
name = 'ease1',
|
||||||
icons = icons(eases)
|
icons = icons(eases),
|
||||||
|
params = params(eases)
|
||||||
})
|
})
|
||||||
insertDropdown(d, {
|
insertDropdown(d, {
|
||||||
x = outerpadding + dropdownWidth + padding + dropdownWidth + padding,
|
x = outerpadding + dropdownWidth + padding + dropdownWidth + padding,
|
||||||
|
@ -121,7 +131,8 @@ function self.createDropdowns()
|
||||||
width = dropdownWidth,
|
width = dropdownWidth,
|
||||||
options = eases,
|
options = eases,
|
||||||
name = 'ease2',
|
name = 'ease2',
|
||||||
icons = icons(eases)
|
icons = icons(eases),
|
||||||
|
params = params(eases)
|
||||||
})
|
})
|
||||||
|
|
||||||
local _e1 = ease.eases[d[dropdownId - 1].options[d[dropdownId - 1].selected]]
|
local _e1 = ease.eases[d[dropdownId - 1].options[d[dropdownId - 1].selected]]
|
||||||
|
@ -224,6 +235,21 @@ function self.render()
|
||||||
love.graphics.print(v.options[i], x + 2, y + 2)
|
love.graphics.print(v.options[i], x + 2, y + 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if v.params and v.params[i] then
|
||||||
|
local str = ''
|
||||||
|
for _,p in ipairs(v.params[i]) do
|
||||||
|
str = str .. ' ' .. string.sub(p.name, 1, 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
love.graphics.push()
|
||||||
|
love.graphics.translate(x + w, y + lineWidth/2)
|
||||||
|
love.graphics.shear(-0.2, 0)
|
||||||
|
love.graphics.scale(0.8, 0.8)
|
||||||
|
love.graphics.setColor(0.8, 0.8, 1, 0.8 * a)
|
||||||
|
love.graphics.printf(str, -w, -lineWidth/2, w - 2, 'right')
|
||||||
|
love.graphics.pop()
|
||||||
|
end
|
||||||
|
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -232,9 +258,9 @@ function self.render()
|
||||||
if #v.options > maxDropdown then
|
if #v.options > maxDropdown then
|
||||||
local displayed = maxDropdown / (#v.options)
|
local displayed = maxDropdown / (#v.options)
|
||||||
local scroll = math.abs(dropdownScrollE) / (#v.options - maxDropdown + 1)
|
local scroll = math.abs(dropdownScrollE) / (#v.options - maxDropdown + 1)
|
||||||
local size = margin
|
local size = 3
|
||||||
|
|
||||||
love.graphics.setColor(1, 1, 1, 0.9 * v.open)
|
love.graphics.setColor(1, 1, 1, 0.8 * v.open)
|
||||||
love.graphics.rectangle('fill', x + w - size, y + h + scroll * (1 - displayed) * (maxDropdown - 1) * h * v.open, size, displayed * (maxDropdown - 1) * h * v.open)
|
love.graphics.rectangle('fill', x + w - size, y + h + scroll * (1 - displayed) * (maxDropdown - 1) * h * v.open, size, displayed * (maxDropdown - 1) * h * v.open)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue