Use Flex, don't force re-renders on layout table changes

pull/3227/head
uramer 3 years ago
parent aea2c019de
commit 1f5e3b78d4

@ -55,8 +55,7 @@ namespace LuaUi
{
WidgetExtension* ext = children[i];
sol::table newLayout = content.at(i);
if (ext->widget()->getTypeName() == widgetType(newLayout)
&& ext->getLayout() == newLayout)
if (ext->widget()->getTypeName() == widgetType(newLayout))
{
updateWidget(ext, newLayout);
}

@ -71,6 +71,7 @@ namespace LuaUi
w->forcePosition(childPosition);
primary(size) += static_cast<int>(growFactor * getGrow(w));
w->forceSize(size);
w->updateCoord();
primary(childPosition) += primary(size);
w->updateCoord();
}

@ -19,32 +19,30 @@ local function renderSetting(groupName, setting, value, index)
local group = common.getGroup(groupName)
group:set(setting.name, value)
local element = groupOptions[groupName].element
element.layout.content[setting.name] = renderSetting(groupName, setting, value, index)
local settingLayout = renderSetting(groupName, setting, value, index)
settingLayout.name = setting.name
element.layout.content[setting.name] = settingLayout
element:update()
end)
layout.name = setting.name
-- temporary hacky position and size
layout.props = layout.props or {}
layout.props.position = util.vector2(0, 100 * (index - 1))
layout.props.size = util.vector2(400, 100)
return layout
end
local function onGroupRegistered(groupName)
local group = common.groups:get(groupName)
local layout = {
type = ui.TYPE.Flex,
content = ui.content{},
}
local searchHints = { groupName }
local count = 0
for _, setting in pairs(group) do
count = count + 1
layout.content:add(renderSetting(groupName, setting, setting.default, count))
local settingLayout = renderSetting(groupName, setting, setting.default, count)
settingLayout.name = setting.name
layout.content:add(settingLayout)
table.insert(searchHints, setting.name)
end
layout.props = {
size = util.vector2(400, 100 * count)
}
local options = {
name = groupName,
element = ui.create(layout),

Loading…
Cancel
Save