2018-06-18 09:43:39 +00:00
|
|
|
#ifndef OPENMW_WIDGETS_WRAPPER_H
|
|
|
|
#define OPENMW_WIDGETS_WRAPPER_H
|
|
|
|
|
2023-05-21 16:21:42 +00:00
|
|
|
#include <MyGUI_Prerequest.h>
|
2023-07-16 18:46:54 +00:00
|
|
|
|
|
|
|
#include "components/settings/values.hpp"
|
2018-06-18 09:43:39 +00:00
|
|
|
|
2022-08-15 21:04:54 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2018-06-18 09:43:39 +00:00
|
|
|
namespace Gui
|
|
|
|
{
|
|
|
|
template <class T>
|
|
|
|
class FontWrapper : public T
|
|
|
|
{
|
2023-05-21 16:21:42 +00:00
|
|
|
#if MYGUI_VERSION <= MYGUI_DEFINE_VERSION(3, 4, 2)
|
2018-06-18 09:43:39 +00:00
|
|
|
public:
|
2020-10-16 18:18:54 +00:00
|
|
|
void setFontName(const std::string& name) override
|
2018-06-18 09:43:39 +00:00
|
|
|
{
|
|
|
|
T::setFontName(name);
|
2023-07-16 18:46:54 +00:00
|
|
|
T::setPropertyOverride("FontHeight", std::to_string(Settings::gui().mFontSize));
|
2018-06-18 09:43:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2020-10-16 18:18:54 +00:00
|
|
|
void setPropertyOverride(const std::string& _key, const std::string& _value) override
|
2018-06-18 09:43:39 +00:00
|
|
|
{
|
|
|
|
T::setPropertyOverride(_key, _value);
|
|
|
|
|
2023-05-21 16:21:42 +00:00
|
|
|
// https://github.com/MyGUI/mygui/issues/113
|
2018-06-18 09:43:39 +00:00
|
|
|
// There is a bug in MyGUI: when it initializes the FontName property, it reset the font height.
|
|
|
|
// We should restore it.
|
|
|
|
if (_key == "FontName")
|
|
|
|
{
|
2023-07-16 18:46:54 +00:00
|
|
|
T::setPropertyOverride("FontHeight", std::to_string(Settings::gui().mFontSize));
|
2018-06-18 09:43:39 +00:00
|
|
|
}
|
|
|
|
}
|
2023-05-21 16:21:42 +00:00
|
|
|
#endif
|
2023-07-15 13:02:27 +00:00
|
|
|
};
|
2018-06-18 09:43:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|