optimize UIWidget for largers NPC trades

master
Eduardo Bart 12 years ago
parent ec9ea9e33d
commit 3f689e0edf

@ -148,7 +148,7 @@ local function refreshTradeItems()
for key,item in pairs(currentTradeItems) do for key,item in pairs(currentTradeItems) do
local itemBox = createWidget('NPCItemBox', itemsPanel) local itemBox = createWidget('NPCItemBox', itemsPanel)
itemBox.item = item itemBox.item = item
local name = item.name local name = item.name
local weight = string.format('%.2f', item.weight) .. ' ' .. WEIGHT_UNIT local weight = string.format('%.2f', item.weight) .. ' ' .. WEIGHT_UNIT
local price = item.price .. ' ' .. CURRENCY local price = item.price .. ' ' .. CURRENCY

@ -19,7 +19,7 @@ NPCItemBox < UICheckBox
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
margin-top: 5 margin-top: 5
$checked: $checked:
border-color: #ffffff border-color: #ffffff
$hover !checked: $hover !checked:

@ -133,6 +133,8 @@ void UIWidget::addChild(const UIWidgetPtr& child)
return; return;
} }
UIWidgetPtr oldLastChild = getLastChild();
m_children.push_back(child); m_children.push_back(child);
child->setParent(asUIWidget()); child->setParent(asUIWidget());
@ -145,7 +147,12 @@ void UIWidget::addChild(const UIWidgetPtr& child)
// update new child states // update new child states
child->updateStates(); child->updateStates();
updateChildrenIndexStates();
// update old child index states
if(oldLastChild) {
oldLastChild->updateState(Fw::MiddleState);
oldLastChild->updateState(Fw::LastState);
}
g_ui.onWidgetAppear(child); g_ui.onWidgetAppear(child);
} }
@ -714,8 +721,15 @@ void UIWidget::destroyChildren()
if(layout) if(layout)
layout->disableUpdates(); layout->disableUpdates();
while(!m_children.empty()) m_focusedChild = nullptr;
m_children[0]->destroy(); m_lockedChildren.clear();
while(!m_children.empty()) {
UIWidgetPtr child = m_children.front();
m_children.pop_front();
child->setParent(nullptr);
m_layout->removeWidget(child);
child->destroy();
}
layout->enableUpdates(); layout->enableUpdates();
} }

Loading…
Cancel
Save