Added support for applying per-variant transition profiles from included theme configuration files.

This commit is contained in:
Leon Styhre 2023-01-15 18:24:08 +01:00
parent 597375c68c
commit 941fa013b6
2 changed files with 25 additions and 15 deletions

View file

@ -1502,6 +1502,8 @@ void ThemeData::parseIncludes(const pugi::xml_node& root)
if (!theme)
throw error << ": Missing <theme> 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 << ": <transitions> 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 << ": <transitions> value \"" << transitionsValue
<< "\" is not matching any defined transitions";
}
mVariantDefinedTransitions = transitionsValue;
}
}
void ThemeData::parseVariables(const pugi::xml_node& root)
{
ThemeException error;

View file

@ -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);