I just wanted to let You know that I didn't disapperead with my ideas. I believe there is still some improvement possible:
For xml->controls conversion:
current solution results in code duplication - for example:
Code:
CLabelInfo labelInfo;
GetLabelInfo(pControlNode, labelInfo);
is copied in all control types that uses text rendering attributes
What I was thinking is to define some interfaces that controls could inherit (f.e. ITextureAttribute, IFocusableAttributes, ITextRenderingAttributes - naming would need some thinking about obviously). In CGUIControlFactory::Create use dynamic_cast to test if class inherits ITextureAttribute - if it does - parse xml for <texture> attribute and set it in control using method inherited from ITextureAttribute. This would abstract process of control creation - CGUIControlFactory will not need to know that Control X have Y,Z attributes - it would be enough that Control X know that it have Y,Z attributes. Of course this would require changes to control constructors. What's more this could get help in getting rid of heap of temporary variables in CGUIControlFactory::Create.
Here's some example:
Code:
class ITextRenderingAttributes
{
protected:
ITextRenderingAttributes() { } //only for inheriting purposes
CLabelInfo m_labelInfo; //structure containing text rendering attributes
public:
CLabelInfo& GetLabelInfo(); //return m_labelInfo
};
Controls that render text (buttons, labels, etc) would inherit it (it will need removing of member m_labelInfo in these controls)
In CGUIControlFactory::Create (or even in CGUIControlFactory::GetLabelInfo itself):
Code:
ITextRenderingAttributes* textRendering = dynamic_cast<ITextRenderingAttributes*>( control);
if (textRendering) // if control inherit ITextRenderingAttributes then load labelinfo
{
GetLabelInfo(pControlNode, textRendering->GetLabelInfo());
}
Question here is - is it worth to do extra work for it? Is dynamic_cast ok for this? Are there better ways to abstract process of control creation?
Sorry I'm such pain in the ..., I may have (some) knowledge abound coding, but I'm lacking the wisdom and experience
---
As for the other branch: Keeping window objects in memory, after making changes You have stated in comments and adding 'const' and '&' here and there I think it will be ready to request pulling