Commit 2b3080f9 authored by Aloshi's avatar Aloshi

Make DateTimeComponent honor theme size values again.

parent a6a9fff5
......@@ -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;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment