Merge branch 'font_fix' into 'master'

Fix TrueType fonts scaling

See merge request OpenMW/openmw!3541
macos_ci_fix
Alexei Kotov 1 year ago
commit 4445a55084

@ -475,7 +475,7 @@ namespace MWGui::Formatting
: GraphicElement(parent, pag, blockStyle)
, mTextStyle(textStyle)
{
MyGUI::EditBox* box = parent->createWidget<MyGUI::EditBox>("NormalText",
Gui::EditBox* box = parent->createWidget<Gui::EditBox>("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);

@ -161,7 +161,7 @@ namespace MWGui
private:
int currentFontHeight() const;
TextStyle mTextStyle;
MyGUI::EditBox* mEditBox;
Gui::EditBox* mEditBox;
};
class ImageElement : public GraphicElement

@ -238,7 +238,7 @@ namespace MWGui
mLines.emplace_back(separator, (MyGUI::Widget*)nullptr, NoSpellIndex);
}
MyGUI::TextBox* groupWidget = mScrollView->createWidget<MyGUI::TextBox>("SandBrightText",
MyGUI::TextBox* groupWidget = mScrollView->createWidget<Gui::TextBox>("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<MyGUI::TextBox>("SandBrightText",
MyGUI::TextBox* groupWidget2 = mScrollView->createWidget<Gui::TextBox>("SandBrightText",
MyGUI::IntCoord(0, 0, mScrollView->getWidth(), 24), MyGUI::Align::Left | MyGUI::Align::Top);
groupWidget2->setCaptionWithReplacing(label2);
groupWidget2->setTextAlign(MyGUI::Align::Right);

@ -443,7 +443,7 @@ namespace MWGui
const std::string realImage
= Misc::ResourceHelpers::correctIconPath(image, MWBase::Environment::get().getResourceSystem()->getVFS());
MyGUI::EditBox* captionWidget = mDynamicToolTipBox->createWidget<MyGUI::EditBox>(
Gui::EditBox* captionWidget = mDynamicToolTipBox->createWidget<Gui::EditBox>(
"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);
MyGUI::EditBox* textWidget = mDynamicToolTipBox->createWidget<MyGUI::EditBox>("SandText",
Gui::EditBox* textWidget = mDynamicToolTipBox->createWidget<Gui::EditBox>("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<MyGUI::ImageBox>("MarkerButton",
MyGUI::IntCoord(padding.left, totalSize.height + padding.top, 8, 8), MyGUI::Align::Default);
icon->setColour(MyGUI::Colour(1.0f, 0.3f, 0.3f));
MyGUI::EditBox* edit = mDynamicToolTipBox->createWidget<MyGUI::EditBox>("SandText",
Gui::EditBox* edit = mDynamicToolTipBox->createWidget<Gui::EditBox>("SandText",
MyGUI::IntCoord(padding.left + 8 + 4, totalSize.height + padding.top, 300 - padding.left - 8 - 4,
300 - totalSize.height),
MyGUI::Align::Default);

@ -48,7 +48,7 @@ namespace Gui
}
else
{
TextBox::setPropertyOverride(_key, _value);
Gui::TextBox::setPropertyOverride(_key, _value);
}
}
@ -115,7 +115,7 @@ namespace Gui
}
else
{
EditBox::setPropertyOverride(_key, _value);
Gui::EditBox::setPropertyOverride(_key, _value);
}
}
@ -144,7 +144,7 @@ namespace Gui
}
else
{
Button::setPropertyOverride(_key, _value);
Gui::Button::setPropertyOverride(_key, _value);
}
}

@ -7,8 +7,25 @@
#include <MyGUI_TextBox.h>
#include <MyGUI_Widget.h>
#include "fontwrapper.hpp"
namespace Gui
{
class Button : public FontWrapper<MyGUI::Button>
{
MYGUI_RTTI_DERIVED(Button)
};
class TextBox : public FontWrapper<MyGUI::TextBox>
{
MYGUI_RTTI_DERIVED(TextBox)
};
class EditBox : public FontWrapper<MyGUI::EditBox>
{
MYGUI_RTTI_DERIVED(EditBox)
};
class AutoSizedWidget
{
public:
@ -27,7 +44,7 @@ namespace Gui
MyGUI::Align mExpandDirection;
};
class AutoSizedTextBox : public AutoSizedWidget, public MyGUI::TextBox
class AutoSizedTextBox : public AutoSizedWidget, public TextBox
{
MYGUI_RTTI_DERIVED(AutoSizedTextBox)
@ -40,7 +57,7 @@ namespace Gui
std::string mFontSize;
};
class AutoSizedEditBox : public AutoSizedWidget, public MyGUI::EditBox
class AutoSizedEditBox : public AutoSizedWidget, public EditBox
{
MYGUI_RTTI_DERIVED(AutoSizedEditBox)
@ -59,7 +76,7 @@ namespace Gui
int mMaxWidth = 0;
};
class AutoSizedButton : public AutoSizedWidget, public MyGUI::Button
class AutoSizedButton : public AutoSizedWidget, public Button
{
MYGUI_RTTI_DERIVED(AutoSizedButton)

@ -0,0 +1,25 @@
#ifndef OPENMW_WIDGETS_WRAPPER_H
#define OPENMW_WIDGETS_WRAPPER_H
#include <MyGUI_Prerequest.h>
#include "components/settings/values.hpp"
#include <string>
namespace Gui
{
/// Wrapper to tell UI element to use font size from settings.cfg
template <class T>
class FontWrapper : public T
{
public:
void setFontName(std::string_view name) override
{
T::setFontName(name);
T::setPropertyOverride("FontHeight", std::to_string(Settings::gui().mFontSize));
}
};
}
#endif

@ -3,13 +3,15 @@
#include <MyGUI_EditBox.h>
#include "fontwrapper.hpp"
namespace Gui
{
/**
* @brief A variant of the EditBox that only allows integer inputs
*/
class NumericEditBox final : public MyGUI::EditBox
class NumericEditBox final : public FontWrapper<MyGUI::EditBox>
{
MYGUI_RTTI_DERIVED(NumericEditBox)

@ -3,6 +3,8 @@
#include <MyGUI_Button.h>
#include "fontwrapper.hpp"
namespace Gui
{
@ -12,7 +14,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 MyGUI::Button
class SharedStateButton final : public FontWrapper<MyGUI::Button>
{
MYGUI_RTTI_DERIVED(SharedStateButton)

@ -18,9 +18,12 @@ namespace Gui
MyGUI::FactoryManager::getInstance().registerFactory<Gui::HBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::Spacer>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::VBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::EditBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::TextBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::AutoSizedTextBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::AutoSizedEditBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::AutoSizedButton>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::Button>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::ImageButton>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::NumericEditBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::SharedStateButton>("Widget");

Loading…
Cancel
Save