From 941fa013b6372b5aa507a1d85441bdb5959ec576 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 15 Jan 2023 18:24:08 +0100 Subject: [PATCH] Added support for applying per-variant transition profiles from included theme configuration files. --- es-core/src/ThemeData.cpp | 39 ++++++++++++++++++++++++--------------- es-core/src/ThemeData.h | 1 + 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 6590344d3..33bc85487 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -1502,6 +1502,8 @@ void ThemeData::parseIncludes(const pugi::xml_node& root) if (!theme) throw error << ": Missing tag"; + if (!mLegacyTheme) + parseTransitions(theme); parseVariables(theme); if (!mLegacyTheme) parseColorSchemes(theme); @@ -1578,21 +1580,7 @@ void ThemeData::parseVariants(const pugi::xml_node& root) mOverrideVariant}; if (variant == viewKey || viewKey == "all") { - const pugi::xml_node& transitions {node.child("transitions")}; - if (transitions != nullptr) { - const std::string& transitionsValue {transitions.text().as_string()}; - if (std::find_if(mCurrentThemeSet->second.capabilities.transitions.cbegin(), - mCurrentThemeSet->second.capabilities.transitions.cend(), - [&transitionsValue](const ThemeTransitions transitions) { - return transitions.name == transitionsValue; - }) == - mCurrentThemeSet->second.capabilities.transitions.cend()) { - throw error << ": value \"" << transitionsValue - << "\" is not matching any defined transitions"; - } - mVariantDefinedTransitions = transitionsValue; - } - + parseTransitions(node); parseVariables(node); parseColorSchemes(node); parseIncludes(node); @@ -1686,6 +1674,27 @@ void ThemeData::parseAspectRatios(const pugi::xml_node& root) } } +void ThemeData::parseTransitions(const pugi::xml_node& root) +{ + ThemeException error; + error << "ThemeData::parseTransitions(): "; + error.setFiles(mPaths); + + const pugi::xml_node& transitions {root.child("transitions")}; + if (transitions != nullptr) { + const std::string& transitionsValue {transitions.text().as_string()}; + if (std::find_if(mCurrentThemeSet->second.capabilities.transitions.cbegin(), + mCurrentThemeSet->second.capabilities.transitions.cend(), + [&transitionsValue](const ThemeTransitions transitions) { + return transitions.name == transitionsValue; + }) == mCurrentThemeSet->second.capabilities.transitions.cend()) { + throw error << ": value \"" << transitionsValue + << "\" is not matching any defined transitions"; + } + mVariantDefinedTransitions = transitionsValue; + } +} + void ThemeData::parseVariables(const pugi::xml_node& root) { ThemeException error; diff --git a/es-core/src/ThemeData.h b/es-core/src/ThemeData.h index f09e60aed..5c7f9444c 100644 --- a/es-core/src/ThemeData.h +++ b/es-core/src/ThemeData.h @@ -297,6 +297,7 @@ private: void parseVariants(const pugi::xml_node& root); void parseColorSchemes(const pugi::xml_node& root); void parseAspectRatios(const pugi::xml_node& root); + void parseTransitions(const pugi::xml_node& root); void parseVariables(const pugi::xml_node& root); void parseViews(const pugi::xml_node& root); void parseView(const pugi::xml_node& root, ThemeView& view);