From d996b565a55668d0c575109e0eec0fabe4afc27f Mon Sep 17 00:00:00 2001 From: Artem Nykolenko Date: Wed, 17 Jul 2019 00:44:36 -0400 Subject: [PATCH] Improve character window resizing (bug #4276) --- AUTHORS.md | 1 + CHANGELOG.md | 1 + apps/openmw/mwgui/statswindow.cpp | 39 ++++++++++++++++++++++++-- apps/openmw/mwgui/statswindow.hpp | 1 + files/mygui/openmw_stats_window.layout | 5 ++-- 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index f6a62c4ce2..5b848fab4d 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -29,6 +29,7 @@ Programmers Ardekantur Armin Preiml Artem Kotsynyak (greye) + Artem Nykolenko (anikm21) artemutin Arthur Moore (EmperorArthur) Assumeru diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ee3d46d76..e39da05a2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ Bug #3812: Wrong multiline tooltips width when word-wrapping is enabled 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 #4276: Resizing character window differs from vanilla Bug #4329: Removed birthsign abilities are restored after reloading the save Bug #4341: Error message about missing GDB is too vague Bug #4383: Bow model obscures crosshair when arrow is drawn diff --git a/apps/openmw/mwgui/statswindow.cpp b/apps/openmw/mwgui/statswindow.cpp index 91d414af30..8998e3a80a 100644 --- a/apps/openmw/mwgui/statswindow.cpp +++ b/apps/openmw/mwgui/statswindow.cpp @@ -40,8 +40,8 @@ namespace MWGui , mBounty(0) , mSkillWidgets() , mChanged(true) + , mMinFullWidth(mMainWidget->getSize().width) { - setCoord(0,0,498, 342); const char *names[][2] = { @@ -88,8 +88,41 @@ namespace MWGui void StatsWindow::onWindowResize(MyGUI::Window* window) { - mLeftPane->setCoord( MyGUI::IntCoord(0, 0, static_cast(0.44*window->getSize().width), window->getSize().height) ); - mRightPane->setCoord( MyGUI::IntCoord(static_cast(0.44*window->getSize().width), 0, static_cast(0.56*window->getSize().width), window->getSize().height) ); + int windowWidth = window->getSize().width; + 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(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(leftPaneRatio*windowWidth), windowHeight)); + mRightPane->setCoord(MyGUI::IntCoord(static_cast(leftPaneRatio*windowWidth), 0, static_cast(rightPaneRatio*windowWidth), windowHeight)); + } + // Canvas size must be expressed with VScroll disabled, otherwise MyGUI would expand the scroll area when the scrollbar is hidden mSkillView->setVisibleVScroll(false); mSkillView->setCanvasSize (mSkillView->getWidth(), mSkillView->getCanvasSize().height); diff --git a/apps/openmw/mwgui/statswindow.hpp b/apps/openmw/mwgui/statswindow.hpp index 8dab2f3d99..7d1be6a155 100644 --- a/apps/openmw/mwgui/statswindow.hpp +++ b/apps/openmw/mwgui/statswindow.hpp @@ -69,6 +69,7 @@ namespace MWGui std::set mExpelled; bool mChanged; + const int mMinFullWidth; protected: virtual void onPinToggled(); diff --git a/files/mygui/openmw_stats_window.layout b/files/mygui/openmw_stats_window.layout index f26f1d598e..77de3ac753 100644 --- a/files/mygui/openmw_stats_window.layout +++ b/files/mygui/openmw_stats_window.layout @@ -2,9 +2,10 @@ - - + + +