mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 19:36:40 +00:00
Use Flex, don't force re-renders on layout table changes
This commit is contained in:
parent
aea2c019de
commit
1f5e3b78d4
3 changed files with 9 additions and 11 deletions
|
@ -55,8 +55,7 @@ namespace LuaUi
|
||||||
{
|
{
|
||||||
WidgetExtension* ext = children[i];
|
WidgetExtension* ext = children[i];
|
||||||
sol::table newLayout = content.at(i);
|
sol::table newLayout = content.at(i);
|
||||||
if (ext->widget()->getTypeName() == widgetType(newLayout)
|
if (ext->widget()->getTypeName() == widgetType(newLayout))
|
||||||
&& ext->getLayout() == newLayout)
|
|
||||||
{
|
{
|
||||||
updateWidget(ext, newLayout);
|
updateWidget(ext, newLayout);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@ namespace LuaUi
|
||||||
w->forcePosition(childPosition);
|
w->forcePosition(childPosition);
|
||||||
primary(size) += static_cast<int>(growFactor * getGrow(w));
|
primary(size) += static_cast<int>(growFactor * getGrow(w));
|
||||||
w->forceSize(size);
|
w->forceSize(size);
|
||||||
|
w->updateCoord();
|
||||||
primary(childPosition) += primary(size);
|
primary(childPosition) += primary(size);
|
||||||
w->updateCoord();
|
w->updateCoord();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,32 +19,30 @@ local function renderSetting(groupName, setting, value, index)
|
||||||
local group = common.getGroup(groupName)
|
local group = common.getGroup(groupName)
|
||||||
group:set(setting.name, value)
|
group:set(setting.name, value)
|
||||||
local element = groupOptions[groupName].element
|
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()
|
element:update()
|
||||||
end)
|
end)
|
||||||
layout.name = setting.name
|
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
|
return layout
|
||||||
end
|
end
|
||||||
|
|
||||||
local function onGroupRegistered(groupName)
|
local function onGroupRegistered(groupName)
|
||||||
local group = common.groups:get(groupName)
|
local group = common.groups:get(groupName)
|
||||||
local layout = {
|
local layout = {
|
||||||
|
type = ui.TYPE.Flex,
|
||||||
content = ui.content{},
|
content = ui.content{},
|
||||||
}
|
}
|
||||||
local searchHints = { groupName }
|
local searchHints = { groupName }
|
||||||
local count = 0
|
local count = 0
|
||||||
for _, setting in pairs(group) do
|
for _, setting in pairs(group) do
|
||||||
count = count + 1
|
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)
|
table.insert(searchHints, setting.name)
|
||||||
end
|
end
|
||||||
layout.props = {
|
|
||||||
size = util.vector2(400, 100 * count)
|
|
||||||
}
|
|
||||||
local options = {
|
local options = {
|
||||||
name = groupName,
|
name = groupName,
|
||||||
element = ui.create(layout),
|
element = ui.create(layout),
|
||||||
|
|
Loading…
Reference in a new issue