mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-19 19:39:41 +00:00
Remove more cruft in MessageBox. Fixes inconsistent sizing when close to a newline.
This commit is contained in:
parent
bb70deabb1
commit
742e0e014d
3 changed files with 10 additions and 33 deletions
|
@ -141,7 +141,6 @@ namespace MWGui
|
|||
, mMaxTime(0)
|
||||
{
|
||||
// defines
|
||||
mFixedWidth = 300;
|
||||
mBottomPadding = 20;
|
||||
mNextBoxPadding = 20;
|
||||
|
||||
|
@ -149,41 +148,21 @@ namespace MWGui
|
|||
|
||||
mMessageWidget->setOverflowToTheLeft(true);
|
||||
mMessageWidget->setCaptionWithReplacing(mMessage);
|
||||
|
||||
MyGUI::IntSize size;
|
||||
size.width = mFixedWidth;
|
||||
size.height = 100; // dummy
|
||||
|
||||
mMessageWidget->setSize(size);
|
||||
|
||||
MyGUI::IntSize textSize = mMessageWidget->getTextSize();
|
||||
|
||||
size.height = mHeight = textSize.height + 20; // this is the padding between the text and the box
|
||||
|
||||
mMainWidget->setSize(size);
|
||||
size.width -= 15; // this is to center the text (see messagebox.layout, Widget type="Edit" position="-2 -3 0 0")
|
||||
mMessageWidget->setSize(size);
|
||||
}
|
||||
|
||||
void MessageBox::update (int height)
|
||||
{
|
||||
MyGUI::IntSize gameWindowSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
MyGUI::IntCoord coord;
|
||||
coord.left = (gameWindowSize.width - mFixedWidth)/2;
|
||||
coord.top = (gameWindowSize.height - mHeight - height - mBottomPadding);
|
||||
MyGUI::IntPoint pos;
|
||||
pos.left = (gameWindowSize.width - mMainWidget->getWidth())/2;
|
||||
pos.top = (gameWindowSize.height - mMainWidget->getHeight() - height - mBottomPadding);
|
||||
|
||||
MyGUI::IntSize size;
|
||||
size.width = mFixedWidth;
|
||||
size.height = mHeight;
|
||||
|
||||
mMainWidget->setCoord(coord);
|
||||
mMainWidget->setSize(size);
|
||||
mMainWidget->setVisible(true);
|
||||
mMainWidget->setPosition(pos);
|
||||
}
|
||||
|
||||
int MessageBox::getHeight ()
|
||||
{
|
||||
return mHeight+mNextBoxPadding; // 20 is the padding between this and the next MessageBox
|
||||
return mMainWidget->getHeight()+mNextBoxPadding; // 20 is the padding between this and the next MessageBox
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -63,10 +63,8 @@ namespace MWGui
|
|||
|
||||
protected:
|
||||
MessageBoxManager& mMessageBoxManager;
|
||||
int mHeight;
|
||||
const std::string& mMessage;
|
||||
MyGUI::EditBox* mMessageWidget;
|
||||
int mFixedWidth;
|
||||
int mBottomPadding;
|
||||
int mNextBoxPadding;
|
||||
};
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Layout">
|
||||
<!--Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 0 0" name="_Main">
|
||||
<Widget type="TextBox" skin="TextBox" position="4 4 4 4" name="message"/>
|
||||
</Widget-->
|
||||
<Widget type="Window" skin="MW_Dialog" layer="Notification" position="0 0 0 0" name="_Main">
|
||||
<Widget type="EditBox" skin="MW_TextEditClient" position="5 -5 0 0" name="message" align="Left Top Stretch">
|
||||
<Widget type="VBox" skin="MW_Dialog" layer="Notification" position="0 0 0 0" name="_Main">
|
||||
<Property key="Padding" value="10"/>
|
||||
<Property key="AutoResize" value="true"/>
|
||||
|
||||
<Widget type="AutoSizedEditBox" skin="MW_TextEditClient" position="0 0 300 0" name="message" align="Left Top">
|
||||
<Property key="FontName" value="Default"/>
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
<Property key="TextColour" value="0.75 0.6 0.35"/>
|
||||
|
|
Loading…
Reference in a new issue