1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

FormSpec: Add universal style selector * (#9718)

This commit is contained in:
v-rob 2020-05-06 10:36:02 -07:00 committed by GitHub
parent 4f9a5f67ee
commit 664800b2ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 6 deletions

View file

@ -4609,20 +4609,32 @@ StyleSpec GUIFormSpecMenu::getDefaultStyleForElement(const std::string &type,
return getStyleForElement(type, name, parent_type)[StyleSpec::STATE_DEFAULT];
}
std::array<StyleSpec, StyleSpec::NUM_STATES> GUIFormSpecMenu::getStyleForElement(const std::string &type,
const std::string &name, const std::string &parent_type)
std::array<StyleSpec, StyleSpec::NUM_STATES> GUIFormSpecMenu::getStyleForElement(
const std::string &type, const std::string &name, const std::string &parent_type)
{
std::array<StyleSpec, StyleSpec::NUM_STATES> ret;
auto it = theme_by_type.find("*");
if (it != theme_by_type.end()) {
for (const StyleSpec &spec : it->second)
ret[(u32)spec.getState()] |= spec;
}
it = theme_by_name.find("*");
if (it != theme_by_name.end()) {
for (const StyleSpec &spec : it->second)
ret[(u32)spec.getState()] |= spec;
}
if (!parent_type.empty()) {
auto it = theme_by_type.find(parent_type);
it = theme_by_type.find(parent_type);
if (it != theme_by_type.end()) {
for (const StyleSpec &spec : it->second)
ret[(u32)spec.getState()] |= spec;
}
}
auto it = theme_by_type.find(type);
it = theme_by_type.find(type);
if (it != theme_by_type.end()) {
for (const StyleSpec &spec : it->second)
ret[(u32)spec.getState()] |= spec;