mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-30 12:05:39 +00:00
Fixed draw order for extra elements.
This commit is contained in:
parent
81a9941645
commit
997751f56a
|
@ -211,6 +211,9 @@ void ThemeData::parseView(const pugi::xml_node& root, ThemeView& view)
|
||||||
|
|
||||||
parseElement(node, elemTypeIt->second,
|
parseElement(node, elemTypeIt->second,
|
||||||
view.elements.insert(std::make_pair<std::string, ThemeElement>(elemKey, ThemeElement())).first->second);
|
view.elements.insert(std::make_pair<std::string, ThemeElement>(elemKey, ThemeElement())).first->second);
|
||||||
|
|
||||||
|
if(std::find(view.orderedKeys.begin(), view.orderedKeys.end(), elemKey) == view.orderedKeys.end())
|
||||||
|
view.orderedKeys.push_back(elemKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,18 +328,19 @@ std::vector<GuiComponent*> ThemeData::makeExtras(const std::shared_ptr<ThemeData
|
||||||
if(viewIt == theme->mViews.end())
|
if(viewIt == theme->mViews.end())
|
||||||
return comps;
|
return comps;
|
||||||
|
|
||||||
for(auto it = viewIt->second.elements.begin(); it != viewIt->second.elements.end(); it++)
|
for(auto it = viewIt->second.orderedKeys.begin(); it != viewIt->second.orderedKeys.end(); it++)
|
||||||
{
|
{
|
||||||
if(it->second.extra)
|
ThemeElement& elem = viewIt->second.elements.at(*it);
|
||||||
|
if(elem.extra)
|
||||||
{
|
{
|
||||||
GuiComponent* comp = NULL;
|
GuiComponent* comp = NULL;
|
||||||
const std::string& t = it->second.type;
|
const std::string& t = elem.type;
|
||||||
if(t == "image")
|
if(t == "image")
|
||||||
comp = new ImageComponent(window);
|
comp = new ImageComponent(window);
|
||||||
else if(t == "text")
|
else if(t == "text")
|
||||||
comp = new TextComponent(window);
|
comp = new TextComponent(window);
|
||||||
|
|
||||||
comp->applyTheme(theme, view, it->first, ThemeFlags::ALL);
|
comp->applyTheme(theme, view, *it, ThemeFlags::ALL);
|
||||||
comps.push_back(comp);
|
comps.push_back(comp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,12 +73,11 @@ class ThemeExtras : public GuiComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ThemeExtras(Window* window) : GuiComponent(window) {};
|
ThemeExtras(Window* window) : GuiComponent(window) {};
|
||||||
|
virtual ~ThemeExtras();
|
||||||
|
|
||||||
// will take ownership of the components within extras (delete them in destructor or when setExtras is called again)
|
// will take ownership of the components within extras (delete them in destructor or when setExtras is called again)
|
||||||
void setExtras(const std::vector<GuiComponent*>& extras);
|
void setExtras(const std::vector<GuiComponent*>& extras);
|
||||||
|
|
||||||
virtual ~ThemeExtras();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<GuiComponent*> mExtras;
|
std::vector<GuiComponent*> mExtras;
|
||||||
};
|
};
|
||||||
|
@ -106,6 +105,7 @@ private:
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::map<std::string, ThemeElement> elements;
|
std::map<std::string, ThemeElement> elements;
|
||||||
|
std::vector<std::string> orderedKeys;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -147,19 +147,3 @@ private:
|
||||||
|
|
||||||
std::map<std::string, ThemeView> mViews;
|
std::map<std::string, ThemeView> mViews;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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<typename T> 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...
|
|
Loading…
Reference in a new issue