mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-29 19:55:37 +00:00
Make DateTimeComponent honor theme size values again.
This commit is contained in:
parent
a6a9fff50f
commit
2b3080f90b
|
@ -6,7 +6,7 @@
|
|||
|
||||
DateTimeComponent::DateTimeComponent(Window* window, DisplayMode dispMode) : GuiComponent(window),
|
||||
mEditing(false), mEditIndex(0), mDisplayMode(dispMode), mRelativeUpdateAccumulator(0),
|
||||
mColor(0x777777FF), mFont(Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT)), mUppercase(false), mSizeSet(false)
|
||||
mColor(0x777777FF), mFont(Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT)), mUppercase(false), mAutoSize(true)
|
||||
{
|
||||
updateTextCache();
|
||||
}
|
||||
|
@ -253,9 +253,12 @@ void DateTimeComponent::updateTextCache()
|
|||
std::shared_ptr<Font> font = getFont();
|
||||
mTextCache = std::unique_ptr<TextCache>(font->buildTextCache(dispString, 0, 0, mColor));
|
||||
|
||||
mSize = mTextCache->metrics.size;
|
||||
if(getParent())
|
||||
getParent()->onSizeChanged();
|
||||
if(mAutoSize)
|
||||
{
|
||||
mSize = mTextCache->metrics.size;
|
||||
if(getParent())
|
||||
getParent()->onSizeChanged();
|
||||
}
|
||||
|
||||
//set up cursor positions
|
||||
mCursorBoxes.clear();
|
||||
|
@ -299,7 +302,6 @@ void DateTimeComponent::setFont(std::shared_ptr<Font> font)
|
|||
|
||||
void DateTimeComponent::onSizeChanged()
|
||||
{
|
||||
mSizeSet = true;
|
||||
updateTextCache();
|
||||
}
|
||||
|
||||
|
@ -311,14 +313,20 @@ void DateTimeComponent::setUppercase(bool uppercase)
|
|||
|
||||
void DateTimeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const std::string& view, const std::string& element, unsigned int properties)
|
||||
{
|
||||
GuiComponent::applyTheme(theme, view, element, properties);
|
||||
|
||||
using namespace ThemeFlags;
|
||||
|
||||
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "datetime");
|
||||
if(!elem)
|
||||
return;
|
||||
|
||||
// We set mAutoSize BEFORE calling GuiComponent::applyTheme because it calls
|
||||
// setSize(), which will call updateTextCache(), which will reset mSize if
|
||||
// mAutoSize == true, ignoring the theme's value.
|
||||
if(properties & ThemeFlags::SIZE)
|
||||
mAutoSize = !elem->has("size");
|
||||
|
||||
GuiComponent::applyTheme(theme, view, element, properties);
|
||||
|
||||
using namespace ThemeFlags;
|
||||
|
||||
if(properties & COLOR && elem->has("color"))
|
||||
setColor(elem->get<unsigned int>("color"));
|
||||
|
||||
|
|
|
@ -62,5 +62,5 @@ private:
|
|||
std::shared_ptr<Font> mFont;
|
||||
bool mUppercase;
|
||||
|
||||
bool mSizeSet;
|
||||
bool mAutoSize;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue