From e97b07b6a495aca1ee46492fdf42e1a227a41c30 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Mon, 7 Aug 2023 14:02:37 +0200 Subject: [PATCH] additional cleanup --- CMakeLists.txt | 2 +- apps/openmw/mwgui/formatting.cpp | 2 +- apps/openmw/mwgui/formatting.hpp | 2 +- apps/openmw/mwgui/spellview.cpp | 4 +-- apps/openmw/mwgui/tooltips.cpp | 6 ++-- components/lua_ui/widget.cpp | 4 --- components/lua_ui/window.cpp | 4 --- components/widgets/box.cpp | 6 ++-- components/widgets/box.hpp | 24 +++----------- components/widgets/fontwrapper.hpp | 40 ------------------------ components/widgets/numericeditbox.hpp | 3 +- components/widgets/sharedstatebutton.hpp | 4 +-- components/widgets/widgets.cpp | 3 -- extern/CMakeLists.txt | 4 +-- 14 files changed, 19 insertions(+), 89 deletions(-) delete mode 100644 components/widgets/fontwrapper.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ba0cd672cd..cad6290274 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -454,7 +454,7 @@ set(Boost_NO_WARN_NEW_VERSIONS ON) # ignore warnings about new releases of boos find_package(Boost 1.6.2 REQUIRED COMPONENTS ${BOOST_COMPONENTS} OPTIONAL_COMPONENTS ${BOOST_OPTIONAL_COMPONENTS}) if(OPENMW_USE_SYSTEM_MYGUI) - find_package(MyGUI 3.4.2 REQUIRED) + find_package(MyGUI 3.4.3 REQUIRED) endif() find_package(SDL2 2.0.9 REQUIRED) find_package(OpenAL REQUIRED) diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index 7f62bbf49c..c4f0f804a6 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -475,7 +475,7 @@ namespace MWGui::Formatting : GraphicElement(parent, pag, blockStyle) , mTextStyle(textStyle) { - Gui::EditBox* box = parent->createWidget("NormalText", + MyGUI::EditBox* box = parent->createWidget("NormalText", MyGUI::IntCoord(0, pag.getCurrentTop(), pag.getPageWidth(), 0), MyGUI::Align::Left | MyGUI::Align::Top, parent->getName() + MyGUI::utility::toString(parent->getChildCount())); box->setEditStatic(true); diff --git a/apps/openmw/mwgui/formatting.hpp b/apps/openmw/mwgui/formatting.hpp index 9a215b200b..f093a36dfe 100644 --- a/apps/openmw/mwgui/formatting.hpp +++ b/apps/openmw/mwgui/formatting.hpp @@ -161,7 +161,7 @@ namespace MWGui private: int currentFontHeight() const; TextStyle mTextStyle; - Gui::EditBox* mEditBox; + MyGUI::EditBox* mEditBox; }; class ImageElement : public GraphicElement diff --git a/apps/openmw/mwgui/spellview.cpp b/apps/openmw/mwgui/spellview.cpp index 678f6ffe1f..97de7dbc06 100644 --- a/apps/openmw/mwgui/spellview.cpp +++ b/apps/openmw/mwgui/spellview.cpp @@ -238,7 +238,7 @@ namespace MWGui mLines.emplace_back(separator, (MyGUI::Widget*)nullptr, NoSpellIndex); } - MyGUI::TextBox* groupWidget = mScrollView->createWidget("SandBrightText", + MyGUI::TextBox* groupWidget = mScrollView->createWidget("SandBrightText", MyGUI::IntCoord(0, 0, mScrollView->getWidth(), 24), MyGUI::Align::Left | MyGUI::Align::Top); groupWidget->setCaptionWithReplacing(label); groupWidget->setTextAlign(MyGUI::Align::Left); @@ -246,7 +246,7 @@ namespace MWGui if (!label2.empty()) { - MyGUI::TextBox* groupWidget2 = mScrollView->createWidget("SandBrightText", + MyGUI::TextBox* groupWidget2 = mScrollView->createWidget("SandBrightText", MyGUI::IntCoord(0, 0, mScrollView->getWidth(), 24), MyGUI::Align::Left | MyGUI::Align::Top); groupWidget2->setCaptionWithReplacing(label2); groupWidget2->setTextAlign(MyGUI::Align::Right); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 323579317a..929d78f3b1 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -443,7 +443,7 @@ namespace MWGui const std::string realImage = Misc::ResourceHelpers::correctIconPath(image, MWBase::Environment::get().getResourceSystem()->getVFS()); - Gui::EditBox* captionWidget = mDynamicToolTipBox->createWidget( + MyGUI::EditBox* captionWidget = mDynamicToolTipBox->createWidget( "NormalText", MyGUI::IntCoord(0, 0, 300, 300), MyGUI::Align::Left | MyGUI::Align::Top, "ToolTipCaption"); captionWidget->setEditStatic(true); captionWidget->setNeedKeyFocus(false); @@ -452,7 +452,7 @@ namespace MWGui int captionHeight = std::max(!caption.empty() ? captionSize.height : 0, imageSize); - Gui::EditBox* textWidget = mDynamicToolTipBox->createWidget("SandText", + MyGUI::EditBox* textWidget = mDynamicToolTipBox->createWidget("SandText", MyGUI::IntCoord(0, captionHeight + imageCaptionVPadding, 300, 300 - captionHeight - imageCaptionVPadding), MyGUI::Align::Stretch, "ToolTipText"); textWidget->setEditStatic(true); @@ -474,7 +474,7 @@ namespace MWGui MyGUI::ImageBox* icon = mDynamicToolTipBox->createWidget("MarkerButton", MyGUI::IntCoord(padding.left, totalSize.height + padding.top, 8, 8), MyGUI::Align::Default); icon->setColour(MyGUI::Colour(1.0f, 0.3f, 0.3f)); - Gui::EditBox* edit = mDynamicToolTipBox->createWidget("SandText", + MyGUI::EditBox* edit = mDynamicToolTipBox->createWidget("SandText", MyGUI::IntCoord(padding.left + 8 + 4, totalSize.height + padding.top, 300 - padding.left - 8 - 4, 300 - totalSize.height), MyGUI::Align::Default); diff --git a/components/lua_ui/widget.cpp b/components/lua_ui/widget.cpp index ff9f4d90a2..eacaec37bd 100644 --- a/components/lua_ui/widget.cpp +++ b/components/lua_ui/widget.cpp @@ -73,11 +73,7 @@ namespace LuaUi w->eventMouseButtonPressed.clear(); w->eventMouseButtonReleased.clear(); w->eventMouseMove.clear(); -#if MYGUI_VERSION <= MYGUI_DEFINE_VERSION(3, 4, 2) - w->eventMouseDrag.m_event.clear(); -#else w->eventMouseDrag.clear(); -#endif w->eventMouseSetFocus.clear(); w->eventMouseLostFocus.clear(); diff --git a/components/lua_ui/window.cpp b/components/lua_ui/window.cpp index 3ee7336a78..5da2ae4ca4 100644 --- a/components/lua_ui/window.cpp +++ b/components/lua_ui/window.cpp @@ -16,11 +16,7 @@ namespace LuaUi for (auto& [w, _] : mActionWidgets) { w->eventMouseButtonPressed.clear(); -#if MYGUI_VERSION <= MYGUI_DEFINE_VERSION(3, 4, 2) - w->eventMouseDrag.m_event.clear(); -#else w->eventMouseDrag.clear(); -#endif } mActionWidgets.clear(); diff --git a/components/widgets/box.cpp b/components/widgets/box.cpp index 2d81152b3a..ce32939315 100644 --- a/components/widgets/box.cpp +++ b/components/widgets/box.cpp @@ -48,7 +48,7 @@ namespace Gui } else { - Gui::TextBox::setPropertyOverride(_key, _value); + TextBox::setPropertyOverride(_key, _value); } } @@ -115,7 +115,7 @@ namespace Gui } else { - Gui::EditBox::setPropertyOverride(_key, _value); + EditBox::setPropertyOverride(_key, _value); } } @@ -144,7 +144,7 @@ namespace Gui } else { - Gui::Button::setPropertyOverride(_key, _value); + Button::setPropertyOverride(_key, _value); } } diff --git a/components/widgets/box.hpp b/components/widgets/box.hpp index 699009c21f..0029bc938a 100644 --- a/components/widgets/box.hpp +++ b/components/widgets/box.hpp @@ -7,25 +7,9 @@ #include #include -#include "fontwrapper.hpp" namespace Gui { - class Button : public FontWrapper - { - MYGUI_RTTI_DERIVED(Button) - }; - - class TextBox : public FontWrapper - { - MYGUI_RTTI_DERIVED(TextBox) - }; - - class EditBox : public FontWrapper - { - MYGUI_RTTI_DERIVED(EditBox) - }; - class AutoSizedWidget { public: @@ -44,7 +28,7 @@ namespace Gui MyGUI::Align mExpandDirection; }; - class AutoSizedTextBox : public AutoSizedWidget, public TextBox + class AutoSizedTextBox : public AutoSizedWidget, public MyGUI::TextBox { MYGUI_RTTI_DERIVED(AutoSizedTextBox) @@ -57,7 +41,7 @@ namespace Gui std::string mFontSize; }; - class AutoSizedEditBox : public AutoSizedWidget, public EditBox + class AutoSizedEditBox : public AutoSizedWidget, public MyGUI::EditBox { MYGUI_RTTI_DERIVED(AutoSizedEditBox) @@ -76,7 +60,7 @@ namespace Gui int mMaxWidth = 0; }; - class AutoSizedButton : public AutoSizedWidget, public Button + class AutoSizedButton : public AutoSizedWidget, public MyGUI::Button { MYGUI_RTTI_DERIVED(AutoSizedButton) @@ -156,7 +140,7 @@ namespace Gui void align() override; MyGUI::IntSize getRequestedSize() override; - void setPropertyOverride(std::string_view _key, std::string_view _value); + void setPropertyOverride(std::string_view _key, std::string_view _value) override; void onWidgetCreated(MyGUI::Widget* _widget) override; }; diff --git a/components/widgets/fontwrapper.hpp b/components/widgets/fontwrapper.hpp deleted file mode 100644 index f2c30376b9..0000000000 --- a/components/widgets/fontwrapper.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef OPENMW_WIDGETS_WRAPPER_H -#define OPENMW_WIDGETS_WRAPPER_H - -#include - -#include "components/settings/values.hpp" - -#include - -namespace Gui -{ - template - class FontWrapper : public T - { -#if MYGUI_VERSION <= MYGUI_DEFINE_VERSION(3, 4, 2) - public: - void setFontName(const std::string& name) override - { - T::setFontName(name); - T::setPropertyOverride("FontHeight", std::to_string(Settings::gui().mFontSize)); - } - - protected: - void setPropertyOverride(const std::string& _key, const std::string& _value) override - { - T::setPropertyOverride(_key, _value); - - // https://github.com/MyGUI/mygui/issues/113 - // There is a bug in MyGUI: when it initializes the FontName property, it reset the font height. - // We should restore it. - if (_key == "FontName") - { - T::setPropertyOverride("FontHeight", std::to_string(Settings::gui().mFontSize)); - } - } -#endif - }; -} - -#endif diff --git a/components/widgets/numericeditbox.hpp b/components/widgets/numericeditbox.hpp index ee8ef39a59..8e5de984c8 100644 --- a/components/widgets/numericeditbox.hpp +++ b/components/widgets/numericeditbox.hpp @@ -3,7 +3,6 @@ #include -#include "fontwrapper.hpp" namespace Gui { @@ -11,7 +10,7 @@ namespace Gui /** * @brief A variant of the EditBox that only allows integer inputs */ - class NumericEditBox final : public FontWrapper + class NumericEditBox final : public MyGUI::EditBox { MYGUI_RTTI_DERIVED(NumericEditBox) diff --git a/components/widgets/sharedstatebutton.hpp b/components/widgets/sharedstatebutton.hpp index 688d949f6e..99f597360c 100644 --- a/components/widgets/sharedstatebutton.hpp +++ b/components/widgets/sharedstatebutton.hpp @@ -3,8 +3,6 @@ #include -#include "fontwrapper.hpp" - namespace Gui { @@ -14,7 +12,7 @@ namespace Gui /// @brief A button that applies its own state changes to other widgets, to do this you define it as part of a /// ButtonGroup. - class SharedStateButton final : public FontWrapper + class SharedStateButton final : public MyGUI::Button { MYGUI_RTTI_DERIVED(SharedStateButton) diff --git a/components/widgets/widgets.cpp b/components/widgets/widgets.cpp index d27d7e5fc9..097f84c62f 100644 --- a/components/widgets/widgets.cpp +++ b/components/widgets/widgets.cpp @@ -18,12 +18,9 @@ namespace Gui MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 9a536069e6..cf7a3bcf70 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -77,8 +77,8 @@ if(NOT OPENMW_USE_SYSTEM_MYGUI) include(FetchContent) FetchContent_Declare(mygui - URL https://github.com/MyGUI/mygui/archive/refs/tags/MyGUI3.4.2.zip - URL_HASH SHA512=d15de716102237ca55b952c2ab52f84b91766332a0357a50b17c20cf2f168666ddaab52d088d7bb8f713ad0fc27e19d74e6ae2673f310a8f60a3b5754f0a0ba7 + URL https://github.com/MyGUI/mygui/archive/refs/tags/MyGUI3.4.3.zip + URL_HASH SHA512=c804ef665e786076582367f171082cd2181fdbd214300ddcca4a4245c5a0f45e62e72778ee2d96ec46b393e22477dd729f9bb3006e6eecbf536674e34a057721 SOURCE_DIR fetched/mygui ) FetchContent_MakeAvailableExcludeFromAll(mygui)