Skip to content

Instantly share code, notes, and snippets.

@deephack1982
Created September 10, 2019 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deephack1982/07b5a6c4b234e8f24b34fa03d39b782a to your computer and use it in GitHub Desktop.
Save deephack1982/07b5a6c4b234e8f24b34fa03d39b782a to your computer and use it in GitHub Desktop.
class CGuiWidget
{
...
public:
void Render();
virtual void RenderInternal();
CRect<uint64> ConvertToBounds( CRect<uint64> Frame )
{ ... }
CRect<uint64> GetBounds() const
{ return ConvertToBounds(m_Frame); }
bool ClipsToBounds() const
{ return m_ClipsToBounds; }
private:
CGuiWidget* m_Parent;
std::list<CGuiWidget *> m_Children;
bool m_isHidden = false;
CRect<uint64> m_Frame; // Local coordinates in Parent
bool m_ClipsToBounds = true;
};
void Render()
{
CRect<uint64> Bounds = this->GetBounds(Frame);
if ( m_Parent && m_Parent->ClipsToBounds() &&
m_Parent->GetBounds().Intersects( Bounds ) == false )
{
return;
}
if ( m_isHidden )
{
return;
}
RenderInternal();
for (auto const& child : m_Children)
{
child->Render();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment