From e6d0da998b844aadca541f9d69af5d890a82fe3f Mon Sep 17 00:00:00 2001 From: Aloshi Date: Tue, 31 Dec 2013 23:39:22 -0600 Subject: [PATCH] Theme applicators have become the virtual method GuiComponent::applyTheme(theme, view, element, properties). Applying fonts works now. --- CMakeLists.txt | 1 - src/GuiComponent.cpp | 18 +++ src/GuiComponent.h | 5 + src/ThemeData.cpp | 50 ++++++- src/ThemeData.h | 40 +++--- src/ThemeData_applicators.cpp | 146 -------------------- src/components/GuiFastSelect.cpp | 6 +- src/components/GuiMenu.cpp | 2 +- src/components/ImageComponent.cpp | 35 +++++ src/components/ImageComponent.h | 2 + src/components/NinePatchComponent.cpp | 15 ++ src/components/NinePatchComponent.h | 2 + src/components/TextComponent.cpp | 22 +++ src/components/TextComponent.h | 2 + src/components/TextListComponent.h | 24 ++++ src/resources/Font.cpp | 19 +++ src/resources/Font.h | 4 + src/views/SystemView.cpp | 4 +- src/views/gamelist/BasicGameListView.cpp | 2 +- src/views/gamelist/DetailedGameListView.cpp | 3 +- src/views/gamelist/ISimpleGameListView.cpp | 6 +- 21 files changed, 230 insertions(+), 178 deletions(-) delete mode 100644 src/ThemeData_applicators.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f01347c1..dafd0fd26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,7 +233,6 @@ set(ES_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/Sound.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/SystemData.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/ThemeData.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/ThemeData_applicators.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/VolumeControl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/Window.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/XMLReader.cpp diff --git a/src/GuiComponent.cpp b/src/GuiComponent.cpp index 9f5f6f1f1..8889fc5af 100644 --- a/src/GuiComponent.cpp +++ b/src/GuiComponent.cpp @@ -3,6 +3,7 @@ #include "Log.h" #include "Renderer.h" #include "animations/AnimationController.h" +#include "ThemeData.h" GuiComponent::GuiComponent(Window* window) : mWindow(window), mParent(NULL), mOpacity(255), mPosition(Eigen::Vector3f::Zero()), mSize(Eigen::Vector2f::Zero()), mTransform(Eigen::Affine3f::Identity()) @@ -225,3 +226,20 @@ void GuiComponent::stopAnimation(unsigned char slot) mAnimationMap[slot] = NULL; } } + +void GuiComponent::applyTheme(const std::shared_ptr& theme, const std::string& view, const std::string& element, unsigned int properties) +{ + Eigen::Vector2f scale = getParent() ? getParent()->getSize() : Eigen::Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight()); + + const ThemeData::ThemeElement* elem = theme->getElement(view, element, ""); + + using namespace ThemeFlags; + if(properties & POSITION && elem->has("pos")) + { + Eigen::Vector2f denormalized = elem->get("pos").cwiseProduct(scale); + setPosition(Eigen::Vector3f(denormalized.x(), denormalized.y(), 0)); + } + + if(properties & ThemeFlags::SIZE && elem->has("size")) + setSize(elem->get("size").cwiseProduct(scale)); +} diff --git a/src/GuiComponent.h b/src/GuiComponent.h index be58769ee..63aedd43c 100644 --- a/src/GuiComponent.h +++ b/src/GuiComponent.h @@ -8,6 +8,7 @@ class Window; class Animation; class AnimationController; +class ThemeData; class GuiComponent { @@ -66,6 +67,10 @@ public: virtual void onFocusGained() {}; virtual void onFocusLost() {}; + // Default implementation just handles and tags as normalized float pairs. + // You probably want to keep this behavior for any derived classes as well as add your own. + virtual void applyTheme(const std::shared_ptr& theme, const std::string& view, const std::string& element, unsigned int properties); + protected: void renderChildren(const Eigen::Affine3f& transform) const; diff --git a/src/ThemeData.cpp b/src/ThemeData.cpp index f8a4d9b9f..5a7a084e9 100644 --- a/src/ThemeData.cpp +++ b/src/ThemeData.cpp @@ -209,6 +209,7 @@ void ThemeData::parseElement(const pugi::xml_node& root, const std::mapsecond.elements.find(element); + if(elemIt == viewIt->second.elements.end()) return NULL; + + if(elemIt->second.type != expectedType && !expectedType.empty()) + { + LOG(LogWarning) << " requested mismatched theme type for [" << view << "." << element << "] - expected \"" + << expectedType << "\", got \"" << elemIt->second.type << "\""; + return NULL; + } + + return &elemIt->second; +} + +void ThemeData::playSound(const std::string& elementName) +{ + const ThemeElement* elem = getElement("common", elementName, "sound"); + if(!elem) + return; + + if(elem->has("path")) + { + const std::string path = elem->get("path"); + auto cacheIt = mSoundCache.find(path); + if(cacheIt != mSoundCache.end()) + { + cacheIt->second->play(); + return; + } + + std::shared_ptr sound = std::shared_ptr(new Sound(path)); + sound->play(); + mSoundCache[path] = sound; + } +} diff --git a/src/ThemeData.h b/src/ThemeData.h index d1eccc01b..cf1e187ec 100644 --- a/src/ThemeData.h +++ b/src/ThemeData.h @@ -69,7 +69,7 @@ ThemeException& operator<<(ThemeException& e, T appendMsg) class ThemeData { -private: +public: class ThemeElement { @@ -80,11 +80,12 @@ private: std::map< std::string, boost::variant > properties; template - T get(const std::string& prop) { return boost::get(properties.at(prop)); } + T get(const std::string& prop) const { return boost::get(properties.at(prop)); } - inline bool has(const std::string& prop) { return (properties.find(prop) != properties.end()); } + inline bool has(const std::string& prop) const { return (properties.find(prop) != properties.end()); } }; +private: class ThemeView { private: @@ -119,17 +120,10 @@ public: void renderExtras(const std::string& view, Window* window, const Eigen::Affine3f& transform); - void applyToImage(const std::string& view, const std::string& element, ImageComponent* image, unsigned int properties); - void applyToNinePatch(const std::string& view, const std::string& element, NinePatchComponent* patch, unsigned int properties); - void applyToText(const std::string& view, const std::string& element, TextComponent* text, unsigned int properties); - - template - void applyToTextList(const std::string& view, const std::string& element, TextListComponent* list, unsigned int properties); - void playSound(const std::string& name); -private: - void applyPosAndSize(ThemeElement* elem, GuiComponent* comp, unsigned int properties); + // If expectedType is an empty string, will do no type checking. + const ThemeElement* getElement(const std::string& view, const std::string& element, const std::string& expectedType) const; private: static std::map< std::string, std::map > sElementMap; @@ -142,16 +136,24 @@ private: void parseView(const pugi::xml_node& viewNode, ThemeView& view); void parseElement(const pugi::xml_node& elementNode, const std::map& typeMap, ThemeElement& element); - ThemeElement* getElement(const std::string& viewName, const std::string& elementName); - std::map mViews; std::map< std::string, std::shared_ptr > mSoundCache; }; -template -void ThemeData::applyToTextList(const std::string& view, const std::string& element, TextListComponent* list, unsigned int properties) -{ - -} +// okay ideas for applying themes to GuiComponents: +// 1. ThemeData::applyToImage(component, args) +// NO, BECAUSE: +// - for templated types (TextListComponent) have to include the whole template in a header +// - inconsistent definitions if mixing templated types (some in a .cpp, some in a .h/.inl) +// 2. template ThemeData::apply(component, args) with specialized templates +// NO, BECAUSE: +// - doesn't solve the first drawback +// - can't customize arguments for specific types +// 3. GuiComponent::applyTheme(theme, args) - WINNER +// NO, BECAUSE: +// - can't access private members of ThemeData +// - can't this be solved with enough getters? +// - theme->hasElement and theme->getProperty will require 2x as many map lookups (4 vs 2) +// - why not just return a const ThemeElement... \ No newline at end of file diff --git a/src/ThemeData_applicators.cpp b/src/ThemeData_applicators.cpp deleted file mode 100644 index 1e2b6c17f..000000000 --- a/src/ThemeData_applicators.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include "ThemeData.h" - -#include "Renderer.h" -#include "components/ImageComponent.h" -#include "components/NinePatchComponent.h" -#include "components/TextComponent.h" -#include "Sound.h" -#include "Log.h" - -using namespace ThemeFlags; - - -Eigen::Vector2f getScale(GuiComponent* comp) -{ - if(comp && comp->getParent()) - return comp->getParent()->getSize(); - - return Eigen::Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight()); -} - -void ThemeData::applyPosAndSize(ThemeElement* elem, GuiComponent* comp, unsigned int properties) -{ - Eigen::Vector2f scale = getScale(comp); - - if(properties & POSITION && elem->has("pos")) - { - Eigen::Vector2f denormalized = elem->get("pos").cwiseProduct(scale); - comp->setPosition(Eigen::Vector3f(denormalized.x(), denormalized.y(), 0)); - } - - if(properties & ThemeFlags::SIZE && elem->has("size")) - comp->setSize(elem->get("size").cwiseProduct(scale)); -} - -ThemeData::ThemeElement* ThemeData::getElement(const std::string& viewName, const std::string& elementName) -{ - auto viewIt = mViews.find(viewName); - if(viewIt == mViews.end()) - return NULL; - - auto elemIt = viewIt->second.elements.find(elementName); - if(elemIt == viewIt->second.elements.end()) - return NULL; - - return &elemIt->second; -} - -void ThemeData::applyToImage(const std::string& viewName, const std::string& elementName, ImageComponent* image, unsigned int properties) -{ - LOG(LogInfo) << " req image [" << viewName << "." << elementName << "] (flags: " << properties << ")"; - - ThemeElement* elem = getElement(viewName, elementName); - if(!elem) - { - LOG(LogInfo) << " (missing)"; - return; - } - - Eigen::Vector2f scale = getScale(image); - - if(properties & POSITION && elem->has("pos")) - { - Eigen::Vector2f denormalized = elem->get("pos").cwiseProduct(scale); - image->setPosition(Eigen::Vector3f(denormalized.x(), denormalized.y(), 0)); - } - - if(properties & ThemeFlags::SIZE && elem->has("size")) - image->setResize(elem->get("size").cwiseProduct(scale), true); - - if(properties & ORIGIN && elem->has("origin")) - image->setOrigin(elem->get("origin")); - - if(properties & PATH && elem->has("path")) - image->setImage(elem->get("path")); - - if(properties & TILING && elem->has("tile")) - image->setTiling(elem->get("tile")); -} - -void ThemeData::applyToNinePatch(const std::string& viewName, const std::string& elementName, NinePatchComponent* patch, unsigned int properties) -{ - ThemeElement* elem = getElement(viewName, elementName); - if(!elem) - return; - - Eigen::Vector2f scale = getScale(patch); - - if(properties & POSITION && elem->has("pos")) - { - Eigen::Vector2f denormalized = elem->get("pos").cwiseProduct(scale); - patch->setPosition(Eigen::Vector3f(denormalized.x(), denormalized.y(), 0)); - } - - applyPosAndSize(elem, patch, properties); -} - -void ThemeData::applyToText(const std::string& viewName, const std::string& elementName, TextComponent* text, unsigned int properties) -{ - ThemeElement* elem = getElement(viewName, elementName); - if(!elem) - return; - - Eigen::Vector2f scale = getScale(text); - - if(properties & POSITION && elem->has("pos")) - { - Eigen::Vector2f denormalized = elem->get("pos").cwiseProduct(scale); - text->setPosition(Eigen::Vector3f(denormalized.x(), denormalized.y(), 0)); - } - - if(properties & ThemeFlags::SIZE && elem->has("size")) - text->setSize(elem->get("size").cwiseProduct(scale)); - - if(properties & COLOR && elem->has("color")) - text->setColor(elem->get("color")); - - if(properties & CENTER && elem->has("center")) - text->setCentered(elem->get("center")); - - if(properties & TEXT && elem->has("text")) - text->setText(elem->get("text")); - - // TODO - fonts -} - -void ThemeData::playSound(const std::string& elementName) -{ - ThemeElement* elem = getElement("common", elementName); - if(!elem) - return; - - if(elem->has("path")) - { - const std::string path = elem->get("path"); - auto cacheIt = mSoundCache.find(path); - if(cacheIt != mSoundCache.end()) - { - cacheIt->second->play(); - return; - } - - std::shared_ptr sound = std::shared_ptr(new Sound(path)); - sound->play(); - mSoundCache[path] = sound; - } -} diff --git a/src/components/GuiFastSelect.cpp b/src/components/GuiFastSelect.cpp index 78914057e..d200f7477 100644 --- a/src/components/GuiFastSelect.cpp +++ b/src/components/GuiFastSelect.cpp @@ -14,20 +14,20 @@ GuiFastSelect::GuiFastSelect(Window* window, IGameListView* gamelist) : GuiCompo const std::shared_ptr& theme = mGameList->getTheme(); using namespace ThemeFlags; - theme->applyToNinePatch("fastSelect", "background", &mBackground, PATH); + mBackground.applyTheme(theme, "fastSelect", "background", PATH); mBackground.fitTo(mSize); addChild(&mBackground); mLetterText.setSize(mSize.x(), mSize.y() * 0.75f); mLetterText.setCentered(true); - theme->applyToText("fastSelect", "letter", &mLetterText, FONT_PATH | COLOR); + mLetterText.applyTheme(theme, "fastSelect", "letter", FONT_PATH | COLOR); // TODO - set font size addChild(&mLetterText); mSortText.setPosition(0, mSize.y() * 0.75f); mSortText.setSize(mSize.x(), mSize.y() * 0.25f); mSortText.setCentered(true); - theme->applyToText("fastSelect", "subtext", &mSortText, FONT_PATH | COLOR); + mSortText.applyTheme(theme, "fastSelect", "subtext", FONT_PATH | COLOR); // TODO - set font size addChild(&mSortText); diff --git a/src/components/GuiMenu.cpp b/src/components/GuiMenu.cpp index 5a48fd57d..396a39b5f 100644 --- a/src/components/GuiMenu.cpp +++ b/src/components/GuiMenu.cpp @@ -40,7 +40,7 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mBackground(window, ":/ mTheme = std::make_shared(); using namespace ThemeFlags; - mTheme->applyToTextList< std::function >("common", "menu", &mList, FONT_PATH | COLOR); + mList.applyTheme(mTheme, "common", "menu", FONT_PATH | COLOR); mList.setSelectorColor(0xBBBBBBFF); mList.setColor(0, 0x0000FFFF); mList.setColor(1, 0xFF0000FF); diff --git a/src/components/ImageComponent.cpp b/src/components/ImageComponent.cpp index 41e39502e..f28cde28d 100644 --- a/src/components/ImageComponent.cpp +++ b/src/components/ImageComponent.cpp @@ -4,6 +4,7 @@ #include #include "../Log.h" #include "../Renderer.h" +#include "../ThemeData.h" Eigen::Vector2i ImageComponent::getTextureSize() const { @@ -243,3 +244,37 @@ void ImageComponent::copyScreen() resize(); } + +void ImageComponent::applyTheme(const std::shared_ptr& theme, const std::string& view, const std::string& element, unsigned int properties) +{ + LOG(LogInfo) << " req image [" << view << "." << element << "] (flags: " << properties << ")"; + + using namespace ThemeFlags; + + const ThemeData::ThemeElement* elem = theme->getElement(view, element, "image"); + if(!elem) + { + LOG(LogInfo) << " (missing)"; + return; + } + + Eigen::Vector2f scale = getParent() ? getParent()->getSize() : Eigen::Vector2f((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight()); + + if(properties & POSITION && elem->has("pos")) + { + Eigen::Vector2f denormalized = elem->get("pos").cwiseProduct(scale); + setPosition(Eigen::Vector3f(denormalized.x(), denormalized.y(), 0)); + } + + if(properties & ThemeFlags::SIZE && elem->has("size")) + setResize(elem->get("size").cwiseProduct(scale), true); + + if(properties & ORIGIN && elem->has("origin")) + setOrigin(elem->get("origin")); + + if(properties & PATH && elem->has("path")) + setImage(elem->get("path")); + + if(properties & TILING && elem->has("tile")) + setTiling(elem->get("tile")); +} diff --git a/src/components/ImageComponent.h b/src/components/ImageComponent.h index 725723f61..f3e6532c6 100644 --- a/src/components/ImageComponent.h +++ b/src/components/ImageComponent.h @@ -41,6 +41,8 @@ public: void render(const Eigen::Affine3f& parentTrans) override; + virtual void applyTheme(const std::shared_ptr& theme, const std::string& view, const std::string& element, unsigned int properties) override; + private: Eigen::Vector2f mTargetSize; Eigen::Vector2f mOrigin; diff --git a/src/components/NinePatchComponent.cpp b/src/components/NinePatchComponent.cpp index 4fdc62a30..8cda3e697 100644 --- a/src/components/NinePatchComponent.cpp +++ b/src/components/NinePatchComponent.cpp @@ -2,6 +2,7 @@ #include "../Window.h" #include "../Log.h" #include "../Renderer.h" +#include "../ThemeData.h" NinePatchComponent::NinePatchComponent(Window* window, const std::string& path, unsigned int edgeColor, unsigned int centerColor) : GuiComponent(window), mEdgeColor(edgeColor), mCenterColor(centerColor), @@ -193,3 +194,17 @@ void NinePatchComponent::setCenterColor(unsigned int centerColor) mCenterColor = centerColor; updateColors(); } + +void NinePatchComponent::applyTheme(const std::shared_ptr& 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, "ninepatch"); + if(!elem) + return; + + if(properties & PATH && elem->has("path")) + setImagePath(elem->get("path")); +} diff --git a/src/components/NinePatchComponent.h b/src/components/NinePatchComponent.h index fad6feb65..471490cd4 100644 --- a/src/components/NinePatchComponent.h +++ b/src/components/NinePatchComponent.h @@ -18,6 +18,8 @@ public: void setEdgeColor(unsigned int edgeColor); void setCenterColor(unsigned int centerColor); + virtual void applyTheme(const std::shared_ptr& theme, const std::string& view, const std::string& element, unsigned int properties) override; + private: Eigen::Vector2f getCornerSize() const; diff --git a/src/components/TextComponent.cpp b/src/components/TextComponent.cpp index 62337433a..090b6281f 100644 --- a/src/components/TextComponent.cpp +++ b/src/components/TextComponent.cpp @@ -138,3 +138,25 @@ std::string TextComponent::getValue() const { return mText; } + +void TextComponent::applyTheme(const std::shared_ptr& 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, "text"); + if(!elem) + return; + + if(properties & COLOR && elem->has("color")) + setColor(elem->get("color")); + + if(properties & CENTER && elem->has("center")) + setCentered(elem->get("center")); + + if(properties & TEXT && elem->has("text")) + setText(elem->get("text")); + + setFont(Font::getFromTheme(elem, properties, mFont)); +} diff --git a/src/components/TextComponent.h b/src/components/TextComponent.h index 1c3410293..e9906f67b 100644 --- a/src/components/TextComponent.h +++ b/src/components/TextComponent.h @@ -28,6 +28,8 @@ public: std::shared_ptr getFont() const; + virtual void applyTheme(const std::shared_ptr& theme, const std::string& view, const std::string& element, unsigned int properties) override; + private: void calculateExtent(); diff --git a/src/components/TextListComponent.h b/src/components/TextListComponent.h index c89946c71..00c62ca8f 100644 --- a/src/components/TextListComponent.h +++ b/src/components/TextListComponent.h @@ -24,6 +24,7 @@ public: bool input(InputConfig* config, Input input) override; void update(int deltaTime) override; void render(const Eigen::Affine3f& parentTrans) override; + void applyTheme(const std::shared_ptr& theme, const std::string& view, const std::string& element, unsigned int properties) override; struct ListRow { @@ -405,4 +406,27 @@ void TextListComponent::onCursorChanged(CursorState state) mCursorChangedCallback(state); } +template +void TextListComponent::applyTheme(const std::shared_ptr& theme, const std::string& view, const std::string& element, unsigned int properties) +{ + GuiComponent::applyTheme(theme, view, element, properties); + + const ThemeData::ThemeElement* elem = theme->getElement(view, element, "textlist"); + + using namespace ThemeFlags; + if(properties & COLOR) + { + if(elem->has("selectorColor")) + setSelectorColor(elem->get("selectorColor")); + if(elem->has("selectedColor")) + setSelectedColor(elem->get("selectedColor")); + if(elem->has("primaryColor")) + setColor(0, elem->get("primaryColor")); + if(elem->has("secondaryColor")) + setColor(1, elem->get("secondaryColor")); + } + + setFont(Font::getFromTheme(elem, properties, mFont)); +} + #endif diff --git a/src/resources/Font.cpp b/src/resources/Font.cpp index f4e671980..bbbc88ae8 100644 --- a/src/resources/Font.cpp +++ b/src/resources/Font.cpp @@ -553,3 +553,22 @@ void TextCache::setColor(unsigned int color) { Renderer::buildGLColorArray(const_cast(colors), color, vertCount); } + +std::shared_ptr Font::getFromTheme(const ThemeData::ThemeElement* elem, unsigned int properties, const std::shared_ptr& orig) +{ + using namespace ThemeFlags; + if(!(properties & FONT_PATH) && !(properties & FONT_SIZE)) + return orig; + + std::shared_ptr font; + int size = (orig ? orig->mSize : FONT_SIZE_MEDIUM); + std::string path = (orig ? orig->mPath : getDefaultPath()); + + float sh = (float)Renderer::getScreenHeight(); + if(properties & FONT_SIZE && elem->has("fontSize")) + size = (int)(sh * elem->get("fontSize")); + if(properties & FONT_PATH && elem->has("fontPath")) + path = elem->get("fontPath"); + + return get(size, path); +} diff --git a/src/resources/Font.h b/src/resources/Font.h index d04f25083..8cc3f501b 100644 --- a/src/resources/Font.h +++ b/src/resources/Font.h @@ -8,6 +8,7 @@ #include FT_FREETYPE_H #include #include "ResourceManager.h" +#include "../ThemeData.h" class TextCache; @@ -69,6 +70,9 @@ public: int getSize() const; static std::string getDefaultPath(); + + static std::shared_ptr getFromTheme(const ThemeData::ThemeElement* elem, unsigned int properties, const std::shared_ptr& orig); + private: static int getDpiX(); static int getDpiY(); diff --git a/src/views/SystemView.cpp b/src/views/SystemView.cpp index a215ad59b..6a69bd308 100644 --- a/src/views/SystemView.cpp +++ b/src/views/SystemView.cpp @@ -38,7 +38,7 @@ void SystemView::updateData() using namespace ThemeFlags; mHeaderImage.setImage(""); - mSystem->getTheme()->applyToImage("common", "header", &mHeaderImage, PATH); + mHeaderImage.applyTheme(mSystem->getTheme(), "system", "header", PATH); // header if(mHeaderImage.hasImage()) @@ -51,7 +51,7 @@ void SystemView::updateData() mHeaderText.setText(mSystem->getFullName()); } - mSystem->getTheme()->applyToImage("common", "system", &mImage, PATH); + mImage.applyTheme(mSystem->getTheme(), "system", "system", PATH); } bool SystemView::input(InputConfig* config, Input input) diff --git a/src/views/gamelist/BasicGameListView.cpp b/src/views/gamelist/BasicGameListView.cpp index 7f165c5b7..dfa670767 100644 --- a/src/views/gamelist/BasicGameListView.cpp +++ b/src/views/gamelist/BasicGameListView.cpp @@ -19,7 +19,7 @@ void BasicGameListView::onThemeChanged(const std::shared_ptr& theme) { ISimpleGameListView::onThemeChanged(theme); using namespace ThemeFlags; - theme->applyToTextList(getName(), "gamelist", &mList, POSITION | ThemeFlags::SIZE | COLOR | SOUND); + mList.applyTheme(theme, getName(), "gamelist", POSITION | ThemeFlags::SIZE | COLOR | SOUND | FONT_PATH | FONT_SIZE); } void BasicGameListView::onFileChanged(FileData* file, FileChangeType change) diff --git a/src/views/gamelist/DetailedGameListView.cpp b/src/views/gamelist/DetailedGameListView.cpp index aff14d0bd..adcc47ece 100644 --- a/src/views/gamelist/DetailedGameListView.cpp +++ b/src/views/gamelist/DetailedGameListView.cpp @@ -26,6 +26,7 @@ DetailedGameListView::DetailedGameListView(Window* window, FileData* root) : mDescContainer.setAutoScroll((int)(1600 + mDescContainer.getSize().x()), 0.025f); addChild(&mDescContainer); + mDescription.setFont(Font::get(FONT_SIZE_SMALL)); mDescription.setSize(mDescContainer.getSize().x(), 0); mDescContainer.addChild(&mDescription); @@ -41,7 +42,7 @@ void DetailedGameListView::onThemeChanged(const std::shared_ptr& them mHeaderImage.setResize(0, mSize.y() * 0.185f, true); using namespace ThemeFlags; - theme->applyToText("detailed", "description", &mDescription, POSITION | FONT_PATH | FONT_SIZE); + mDescription.applyTheme(theme, getName(), "description", POSITION | FONT_PATH | FONT_SIZE | COLOR); } void DetailedGameListView::updateInfoPanel() diff --git a/src/views/gamelist/ISimpleGameListView.cpp b/src/views/gamelist/ISimpleGameListView.cpp index 082ac118b..5b92351f7 100644 --- a/src/views/gamelist/ISimpleGameListView.cpp +++ b/src/views/gamelist/ISimpleGameListView.cpp @@ -24,9 +24,9 @@ ISimpleGameListView::ISimpleGameListView(Window* window, FileData* root) : IGame void ISimpleGameListView::onThemeChanged(const std::shared_ptr& theme) { using namespace ThemeFlags; - theme->applyToImage(getName(), "background", &mBackground, PATH | TILING); - theme->applyToImage(getName(), "header", &mHeaderImage, PATH); - + mBackground.applyTheme(theme, getName(), "background", PATH | TILING); + mHeaderImage.applyTheme(theme, getName(), "header", PATH); + if(mHeaderImage.hasImage()) { removeChild(&mHeaderText);