mirror of
https://github.com/OpenMW/openmw.git
synced 2025-07-10 02:41:35 +00:00
Merge branch 'widgets_rework' into 'master'
Make widgets more vanilla-friendly Closes #7875 and #7914 See merge request OpenMW/openmw!3941
This commit is contained in:
commit
8e1d790919
8 changed files with 44 additions and 13 deletions
|
@ -221,6 +221,8 @@
|
|||
Feature #7795: Support MaxNumberRipples INI setting
|
||||
Feature #7805: Lua Menu context
|
||||
Feature #7860: Lua: Expose NPC AI settings (fight, alarm, flee)
|
||||
Feature #7875: Disable MyGUI windows snapping
|
||||
Feature #7914: Do not allow to move GUI windows out of screen
|
||||
Task #5896: Do not use deprecated MyGUI properties
|
||||
Task #6085: Replace boost::filesystem with std::filesystem
|
||||
Task #6149: Dehardcode Lua API_REVISION
|
||||
|
|
|
@ -771,11 +771,6 @@ namespace MWGui
|
|||
return output.append(matches.front());
|
||||
}
|
||||
|
||||
void Console::onResChange(int width, int height)
|
||||
{
|
||||
setCoord(10, 10, width - 10, height / 2);
|
||||
}
|
||||
|
||||
void Console::updateSelectedObjectPtr(const MWWorld::Ptr& currentPtr, const MWWorld::Ptr& newPtr)
|
||||
{
|
||||
if (mPtr == currentPtr)
|
||||
|
|
|
@ -47,8 +47,6 @@ namespace MWGui
|
|||
|
||||
void onOpen() override;
|
||||
|
||||
void onResChange(int width, int height) override;
|
||||
|
||||
// Print a message to the console, in specified color.
|
||||
void print(const std::string& msg, std::string_view color = MWBase::WindowManager::sConsoleColor_Default);
|
||||
|
||||
|
|
|
@ -417,6 +417,8 @@ namespace MWGui
|
|||
|
||||
void InventoryWindow::onWindowResize(MyGUI::Window* _sender)
|
||||
{
|
||||
WindowBase::clampWindowCoordinates(_sender);
|
||||
|
||||
adjustPanes();
|
||||
const WindowSettingValues settings = getModeSettings(mGuiMode);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/windowmanager.hpp"
|
||||
|
||||
#include <components/settings/values.hpp>
|
||||
#include <components/widgets/imagebutton.hpp>
|
||||
|
||||
#include "draganddrop.hpp"
|
||||
|
@ -77,6 +78,34 @@ void WindowBase::center()
|
|||
mMainWidget->setCoord(coord);
|
||||
}
|
||||
|
||||
void WindowBase::clampWindowCoordinates(MyGUI::Window* window)
|
||||
{
|
||||
auto minSize = window->getMinSize();
|
||||
minSize.height = static_cast<int>(minSize.height * Settings::gui().mScalingFactor);
|
||||
minSize.width = static_cast<int>(minSize.width * Settings::gui().mScalingFactor);
|
||||
|
||||
// Window's minimum size is larger than the screen size, can not clamp coordinates
|
||||
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
if (minSize.width > viewSize.width || minSize.height > viewSize.height)
|
||||
return;
|
||||
|
||||
int left = std::max(0, window->getPosition().left);
|
||||
int top = std::max(0, window->getPosition().top);
|
||||
int width = std::clamp(window->getSize().width, 0, viewSize.width);
|
||||
int height = std::clamp(window->getSize().height, 0, viewSize.height);
|
||||
if (left + width > viewSize.width)
|
||||
left = viewSize.width - width;
|
||||
|
||||
if (top + height > viewSize.height)
|
||||
top = viewSize.height - height;
|
||||
|
||||
if (window->getSize().width != width || window->getSize().height != height)
|
||||
window->setSize(width, height);
|
||||
|
||||
if (window->getPosition().left != left || window->getPosition().top != top)
|
||||
window->setPosition(left, top);
|
||||
}
|
||||
|
||||
WindowModal::WindowModal(const std::string& parLayout)
|
||||
: WindowBase(parLayout)
|
||||
{
|
||||
|
|
|
@ -52,6 +52,8 @@ namespace MWGui
|
|||
virtual std::string_view getWindowIdForLua() const { return ""; }
|
||||
void setDisabledByLua(bool disabled) { mDisabledByLua = disabled; }
|
||||
|
||||
static void clampWindowCoordinates(MyGUI::Window* window);
|
||||
|
||||
protected:
|
||||
virtual void onTitleDoubleClicked();
|
||||
|
||||
|
|
|
@ -1200,6 +1200,8 @@ namespace MWGui
|
|||
const WindowRectSettingValues& rect = settings.mIsMaximized ? settings.mMaximized : settings.mRegular;
|
||||
window->setPosition(MyGUI::IntPoint(static_cast<int>(rect.mX * x), static_cast<int>(rect.mY * y)));
|
||||
window->setSize(MyGUI::IntSize(static_cast<int>(rect.mW * x), static_cast<int>(rect.mH * y)));
|
||||
|
||||
WindowBase::clampWindowCoordinates(window);
|
||||
}
|
||||
|
||||
for (const auto& window : mWindows)
|
||||
|
@ -1714,13 +1716,15 @@ namespace MWGui
|
|||
|
||||
const WindowRectSettingValues& rect = settings.mIsMaximized ? settings.mMaximized : settings.mRegular;
|
||||
|
||||
layout->mMainWidget->setPosition(
|
||||
MyGUI::Window* window = layout->mMainWidget->castType<MyGUI::Window>();
|
||||
window->setPosition(
|
||||
MyGUI::IntPoint(static_cast<int>(rect.mX * viewSize.width), static_cast<int>(rect.mY * viewSize.height)));
|
||||
layout->mMainWidget->setSize(
|
||||
window->setSize(
|
||||
MyGUI::IntSize(static_cast<int>(rect.mW * viewSize.width), static_cast<int>(rect.mH * viewSize.height)));
|
||||
|
||||
MyGUI::Window* window = layout->mMainWidget->castType<MyGUI::Window>();
|
||||
window->eventWindowChangeCoord += MyGUI::newDelegate(this, &WindowManager::onWindowChangeCoord);
|
||||
WindowBase::clampWindowCoordinates(window);
|
||||
|
||||
mTrackedWindows.emplace(window, settings);
|
||||
}
|
||||
|
||||
|
@ -1750,6 +1754,8 @@ namespace MWGui
|
|||
if (it == mTrackedWindows.end())
|
||||
return;
|
||||
|
||||
WindowBase::clampWindowCoordinates(window);
|
||||
|
||||
const WindowSettingValues& settings = it->second;
|
||||
|
||||
MyGUI::IntSize viewSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
|
|
|
@ -457,7 +457,6 @@
|
|||
|
||||
<Resource type="ResourceSkin" name="MW_Window" size="256 256">
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
<Property key="Snap" value="true"/>
|
||||
<Property key="MinSize" value="64 64"/>
|
||||
|
||||
<Child type="Widget" skin="BlackBG" offset="0 0 256 256" align="Stretch"/>
|
||||
|
@ -592,7 +591,6 @@
|
|||
|
||||
<Resource type="ResourceSkin" name="MW_Window_NoCaption" size="256 256">
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
<Property key="Snap" value="true"/>
|
||||
<Property key="MinSize" value="64 64"/>
|
||||
|
||||
<Child type="Widget" skin="BlackBG" offset=" 0 0 256 256" align="Stretch"/>
|
||||
|
@ -729,7 +727,6 @@
|
|||
|
||||
<Resource type="ResourceSkin" name="MW_Window_Pinnable" size="256 256">
|
||||
<Property key="TextAlign" value="Center"/>
|
||||
<Property key="Snap" value="true"/>
|
||||
<Property key="MinSize" value="64 64"/>
|
||||
|
||||
<Child type="Widget" skin="BlackBG" offset=" 0 0 256 256" align="Stretch"/>
|
||||
|
|
Loading…
Reference in a new issue