mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-30 12:05:39 +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),
|
DateTimeComponent::DateTimeComponent(Window* window, DisplayMode dispMode) : GuiComponent(window),
|
||||||
mEditing(false), mEditIndex(0), mDisplayMode(dispMode), mRelativeUpdateAccumulator(0),
|
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();
|
updateTextCache();
|
||||||
}
|
}
|
||||||
|
@ -253,9 +253,12 @@ void DateTimeComponent::updateTextCache()
|
||||||
std::shared_ptr<Font> font = getFont();
|
std::shared_ptr<Font> font = getFont();
|
||||||
mTextCache = std::unique_ptr<TextCache>(font->buildTextCache(dispString, 0, 0, mColor));
|
mTextCache = std::unique_ptr<TextCache>(font->buildTextCache(dispString, 0, 0, mColor));
|
||||||
|
|
||||||
mSize = mTextCache->metrics.size;
|
if(mAutoSize)
|
||||||
if(getParent())
|
{
|
||||||
getParent()->onSizeChanged();
|
mSize = mTextCache->metrics.size;
|
||||||
|
if(getParent())
|
||||||
|
getParent()->onSizeChanged();
|
||||||
|
}
|
||||||
|
|
||||||
//set up cursor positions
|
//set up cursor positions
|
||||||
mCursorBoxes.clear();
|
mCursorBoxes.clear();
|
||||||
|
@ -299,7 +302,6 @@ void DateTimeComponent::setFont(std::shared_ptr<Font> font)
|
||||||
|
|
||||||
void DateTimeComponent::onSizeChanged()
|
void DateTimeComponent::onSizeChanged()
|
||||||
{
|
{
|
||||||
mSizeSet = true;
|
|
||||||
updateTextCache();
|
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)
|
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");
|
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "datetime");
|
||||||
if(!elem)
|
if(!elem)
|
||||||
return;
|
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"))
|
if(properties & COLOR && elem->has("color"))
|
||||||
setColor(elem->get<unsigned int>("color"));
|
setColor(elem->get<unsigned int>("color"));
|
||||||
|
|
||||||
|
|
|
@ -62,5 +62,5 @@ private:
|
||||||
std::shared_ptr<Font> mFont;
|
std::shared_ptr<Font> mFont;
|
||||||
bool mUppercase;
|
bool mUppercase;
|
||||||
|
|
||||||
bool mSizeSet;
|
bool mAutoSize;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue