Improve character window resizing (bug #4276)

pull/541/head
Artem Nykolenko 6 years ago
parent 366906ac51
commit d996b565a5

@ -29,6 +29,7 @@ Programmers
Ardekantur Ardekantur
Armin Preiml Armin Preiml
Artem Kotsynyak (greye) Artem Kotsynyak (greye)
Artem Nykolenko (anikm21)
artemutin artemutin
Arthur Moore (EmperorArthur) Arthur Moore (EmperorArthur)
Assumeru Assumeru

@ -17,6 +17,7 @@
Bug #3812: Wrong multiline tooltips width when word-wrapping is enabled Bug #3812: Wrong multiline tooltips width when word-wrapping is enabled
Bug #4202: Open .omwaddon files without needing toopen openmw-cs first Bug #4202: Open .omwaddon files without needing toopen openmw-cs first
Bug #4240: Ash storm origin coordinates and hand shielding animation behavior are incorrect Bug #4240: Ash storm origin coordinates and hand shielding animation behavior are incorrect
Bug #4276: Resizing character window differs from vanilla
Bug #4329: Removed birthsign abilities are restored after reloading the save Bug #4329: Removed birthsign abilities are restored after reloading the save
Bug #4341: Error message about missing GDB is too vague Bug #4341: Error message about missing GDB is too vague
Bug #4383: Bow model obscures crosshair when arrow is drawn Bug #4383: Bow model obscures crosshair when arrow is drawn

@ -40,8 +40,8 @@ namespace MWGui
, mBounty(0) , mBounty(0)
, mSkillWidgets() , mSkillWidgets()
, mChanged(true) , mChanged(true)
, mMinFullWidth(mMainWidget->getSize().width)
{ {
setCoord(0,0,498, 342);
const char *names[][2] = const char *names[][2] =
{ {
@ -88,8 +88,41 @@ namespace MWGui
void StatsWindow::onWindowResize(MyGUI::Window* window) void StatsWindow::onWindowResize(MyGUI::Window* window)
{ {
mLeftPane->setCoord( MyGUI::IntCoord(0, 0, static_cast<int>(0.44*window->getSize().width), window->getSize().height) ); int windowWidth = window->getSize().width;
mRightPane->setCoord( MyGUI::IntCoord(static_cast<int>(0.44*window->getSize().width), 0, static_cast<int>(0.56*window->getSize().width), window->getSize().height) ); int windowHeight = window->getSize().height;
//initial values defined in openmw_stats_window.layout, if custom options are not present in .layout, a default is loaded
float leftPaneRatio = 0.44;
if (mLeftPane->isUserString("LeftPaneRatio"))
leftPaneRatio = MyGUI::utility::parseFloat(mLeftPane->getUserString("LeftPaneRatio"));
int leftOffsetWidth = 24;
if (mLeftPane->isUserString("LeftOffsetWidth"))
leftOffsetWidth = MyGUI::utility::parseInt(mLeftPane->getUserString("LeftOffsetWidth"));
float rightPaneRatio = 1.f - leftPaneRatio;
int minLeftWidth = static_cast<int>(mMinFullWidth * leftPaneRatio);
int minLeftOffsetWidth = minLeftWidth + leftOffsetWidth;
//if there's no space for right pane
mRightPane->setVisible(windowWidth >= minLeftOffsetWidth);
if (!mRightPane->getVisible())
{
mLeftPane->setCoord(MyGUI::IntCoord(0, 0, windowWidth - leftOffsetWidth, windowHeight));
}
//if there's some space for right pane
else if (windowWidth < mMinFullWidth)
{
mLeftPane->setCoord(MyGUI::IntCoord(0, 0, minLeftWidth, windowHeight));
mRightPane->setCoord(MyGUI::IntCoord(minLeftWidth, 0, windowWidth - minLeftWidth, windowHeight));
}
//if there's enough space for both panes
else
{
mLeftPane->setCoord(MyGUI::IntCoord(0, 0, static_cast<int>(leftPaneRatio*windowWidth), windowHeight));
mRightPane->setCoord(MyGUI::IntCoord(static_cast<int>(leftPaneRatio*windowWidth), 0, static_cast<int>(rightPaneRatio*windowWidth), windowHeight));
}
// Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden // Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden
mSkillView->setVisibleVScroll(false); mSkillView->setVisibleVScroll(false);
mSkillView->setCanvasSize (mSkillView->getWidth(), mSkillView->getCanvasSize().height); mSkillView->setCanvasSize (mSkillView->getWidth(), mSkillView->getCanvasSize().height);

@ -69,6 +69,7 @@ namespace MWGui
std::set<std::string> mExpelled; std::set<std::string> mExpelled;
bool mChanged; bool mChanged;
const int mMinFullWidth;
protected: protected:
virtual void onPinToggled(); virtual void onPinToggled();

@ -2,9 +2,10 @@
<MyGUI type="Layout"> <MyGUI type="Layout">
<Widget type="Window" skin="MW_Window_Pinnable" layer="Windows" position="0 0 500 342" name="_Main"> <Widget type="Window" skin="MW_Window_Pinnable" layer="Windows" position="0 0 500 342" name="_Main">
<Property key="MinSize" value="40 40"/> <Property key="MinSize" value="244 114"/>
<Widget type="Widget" skin="" name="LeftPane" position="0 0 220 342"> <Widget type="Widget" skin="" name="LeftPane" position="0 0 220 342">
<UserString key="LeftOffsetWidth" value="24"/>
<UserString key="LeftPaneRatio" value="0.44"/>
<!-- Player health stats --> <!-- Player health stats -->
<Widget type="Widget" skin="MW_Box" position="8 8 212 62" align="Left Top HStretch"> <Widget type="Widget" skin="MW_Box" position="8 8 212 62" align="Left Top HStretch">

Loading…
Cancel
Save