support old placeholder format as a fallback

Signed-off-by: Sophia Hadash <sophiahadash@gmail.com>
This commit is contained in:
Sophia Hadash 2021-10-11 23:27:11 +02:00
parent f74b2761bf
commit c388c7fd12

View file

@ -118,25 +118,54 @@ void SystemView::populate()
} }
// Placeholder Text. // Placeholder Text.
auto* text = const ThemeData::ThemeElement* logoPlaceholderText =
new TextComponent(mWindow, (*it)->getName(), Font::get(FONT_SIZE_LARGE), theme->getElement("system", "logoPlaceholderText", "text");
0x000000FF, ALIGN_CENTER); if (logoPlaceholderText) {
text->setSize(mCarousel.logoSize * mCarousel.logoScale); // Element 'logoPlaceholderText' found in theme: place text
if (mCarousel.type == VERTICAL || mCarousel.type == VERTICAL_WHEEL) { auto* text =
text->setHorizontalAlignment(mCarousel.logoAlignment); new TextComponent(mWindow, (*it)->getName(), Font::get(FONT_SIZE_LARGE),
text->setVerticalAlignment(ALIGN_CENTER); 0x000000FF, ALIGN_CENTER);
text->setSize(mCarousel.logoSize * mCarousel.logoScale);
if (mCarousel.type == VERTICAL || mCarousel.type == VERTICAL_WHEEL) {
text->setHorizontalAlignment(mCarousel.logoAlignment);
text->setVerticalAlignment(ALIGN_CENTER);
}
else {
text->setHorizontalAlignment(ALIGN_CENTER);
text->setVerticalAlignment(mCarousel.logoAlignment);
}
text->applyTheme((*it)->getTheme(), "system", "logoPlaceholderText",
ThemeFlags::ALL);
if (!e.data.logo) {
e.data.logo = std::shared_ptr<GuiComponent>(text);
offsetLogo = text->getPosition() - center;
}
else {
e.data.logoPlaceholderText = std::shared_ptr<GuiComponent>(text);
offsetLogoPlaceholderText = text->getPosition() - center;
}
} }
else { else {
text->setHorizontalAlignment(ALIGN_CENTER); // Fallback to legacy centered placeholder text.
text->setVerticalAlignment(mCarousel.logoAlignment); TextComponent* text =
} new TextComponent(mWindow, (*it)->getName(), Font::get(FONT_SIZE_LARGE),
text->applyTheme((*it)->getTheme(), "system", "logoPlaceholderText", 0x000000FF, ALIGN_CENTER);
ThemeFlags::ALL); text->setSize(mCarousel.logoSize * mCarousel.logoScale);
offsetLogoPlaceholderText = text->getPosition() - center; text->applyTheme((*it)->getTheme(), "system", "logoText",
if (!e.data.logo) ThemeFlags::FONT_PATH | ThemeFlags::FONT_SIZE |
ThemeFlags::COLOR | ThemeFlags::FORCE_UPPERCASE |
ThemeFlags::LINE_SPACING | ThemeFlags::TEXT);
e.data.logo = std::shared_ptr<GuiComponent>(text); e.data.logo = std::shared_ptr<GuiComponent>(text);
else
e.data.logoPlaceholderText = std::shared_ptr<GuiComponent>(text); if (mCarousel.type == VERTICAL || mCarousel.type == VERTICAL_WHEEL) {
text->setHorizontalAlignment(mCarousel.logoAlignment);
text->setVerticalAlignment(ALIGN_CENTER);
}
else {
text->setHorizontalAlignment(ALIGN_CENTER);
text->setVerticalAlignment(mCarousel.logoAlignment);
}
}
} }
if (mCarousel.type == VERTICAL || mCarousel.type == VERTICAL_WHEEL) { if (mCarousel.type == VERTICAL || mCarousel.type == VERTICAL_WHEEL) {