spell window: don't manually recalculate edit box width every update

pull/541/head
Ilya Zhuravlev 6 years ago
parent e1ce15efb5
commit e057ea171f

@ -34,27 +34,28 @@ namespace MWGui
: WindowPinnableBase("openmw_spell_window.layout")
, NoDrop(drag, mMainWidget)
, mSpellView(nullptr)
, mDeleteButton(nullptr)
, mUpdateTimer(0.0f)
{
mSpellIcons = new SpellIcons();
MyGUI::Widget* deleteButton;
getWidget(deleteButton, "DeleteSpellButton");
getWidget(mSpellView, "SpellView");
getWidget(mEffectBox, "EffectsBox");
getWidget(mFilterEdit, "FilterEdit");
getWidget(mDeleteButton, "DeleteSpellButton");
mFilterEdit->setUserString("IgnoreTabKey", "y");
mSpellView->eventSpellClicked += MyGUI::newDelegate(this, &SpellWindow::onModelIndexSelected);
mFilterEdit->eventEditTextChange += MyGUI::newDelegate(this, &SpellWindow::onFilterChanged);
mDeleteButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellWindow::onDeleteClicked);
deleteButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellWindow::onDeleteClicked);
setCoord(498, 300, 302, 300);
MyGUI::Window* t = mMainWidget->castType<MyGUI::Window>();
t->eventWindowChangeCoord += MyGUI::newDelegate(this, &SpellWindow::onWindowResize);
onWindowResize(t);
// Adjust the spell filtering widget size because of MyGUI limitations.
int filterWidth = mSpellView->getSize().width - deleteButton->getSize().width - 3;
mFilterEdit->setSize(filterWidth, mFilterEdit->getSize().height);
}
SpellWindow::~SpellWindow()
@ -258,10 +259,4 @@ namespace MWGui
else
onSpellSelected(spell.mId);
}
void SpellWindow::onWindowResize(MyGUI::Window* window) {
MyGUI::IntSize sz = mFilterEdit->getSize();
sz.width = window->getSize().width - mDeleteButton->getSize().width - 40;
mFilterEdit->setSize(sz);
}
}

@ -36,7 +36,6 @@ namespace MWGui
void onDeleteClicked(MyGUI::Widget *widget);
void onDeleteSpellAccept();
void askDeleteSpell(const std::string& spellId);
void onWindowResize(MyGUI::Window* window);
virtual void onPinToggled();
virtual void onTitleDoubleClicked();
@ -45,7 +44,6 @@ namespace MWGui
SpellView* mSpellView;
SpellIcons* mSpellIcons;
MyGUI::EditBox* mFilterEdit;
MyGUI::Button* mDeleteButton;
private:
float mUpdateTimer;

@ -13,17 +13,17 @@
<Widget type="SpellView" skin="MW_SpellView" position="8 38 268 490" align="Left Top Stretch" name="SpellView">
</Widget>
<Widget type="Widget" position="8 535 268 23" align="Left Bottom HStretch">
<Widget type="HBox" position="8 535 268 23" align="Right Bottom HStretch">
<Widget type="Spacer"/>
<!-- Spell deletion button -->
<Widget type="AutoSizedButton" skin="MW_Button" align="Right Bottom" position="268 0 0 24" name="DeleteSpellButton">
<Property key="ExpandDirection" value="Left"/>
<Widget type="AutoSizedButton" skin="MW_Button" align="Right Bottom" position="8 535 0 23" name="DeleteSpellButton">
<Property key="Caption" value="#{sDelete}"/>
<Property key="NeedKey" value="false"/>
</Widget>
</Widget>
<!-- Search box-->
<Widget type="EditBox" skin="MW_TextBoxEditWithBorder" position="0 0 100 23" align="Left Bottom HStretch" name="FilterEdit">
</Widget>
<Widget type="EditBox" skin="MW_TextBoxEditWithBorder" position="8 535 268 23" align="Left Bottom HStretch" name="FilterEdit">
</Widget>
</Widget>

Loading…
Cancel
Save