add parameters to the dropdown

This commit is contained in:
jill 2021-09-18 13:39:28 +03:00
parent 033ea73c28
commit 6cf7753674

View file

@ -39,6 +39,14 @@ local function icons(keys)
return e
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)
return dropdowns[index]
end
@ -98,7 +106,8 @@ function self.createDropdowns()
width = dropdownWidth,
options = eases,
name = 'ease1',
icons = icons(eases)
icons = icons(eases),
params = params(eases)
})
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
@ -113,7 +122,8 @@ function self.createDropdowns()
width = dropdownWidth,
options = eases,
name = 'ease1',
icons = icons(eases)
icons = icons(eases),
params = params(eases)
})
insertDropdown(d, {
x = outerpadding + dropdownWidth + padding + dropdownWidth + padding,
@ -121,7 +131,8 @@ function self.createDropdowns()
width = dropdownWidth,
options = eases,
name = 'ease2',
icons = icons(eases)
icons = icons(eases),
params = params(eases)
})
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)
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::
end
@ -232,9 +258,9 @@ function self.render()
if #v.options > maxDropdown then
local displayed = maxDropdown / (#v.options)
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)
end
end