Simple GUI Library
Sgl::Parent Class Reference
Inheritance diagram for Sgl::Parent:
Collaboration diagram for Sgl::Parent:

Public Member Functions

virtual ComponentgetHitComponent (int32_t x, int32_t y) override
 
virtual void render (const Sml::Rectangle< int32_t > &targetRegion) override
 
virtual void layout () override final
 
virtual void prerender () override final
 
virtual bool containsComponent (Component *component) override final
 
virtual bool isResizable () const override
 
void addChild (Component *child)
 Convenience method for adding a child to Parent. More...
 
void addChildren ()
 
template<typename Head , typename... Tail>
void addChildren (Head head, Tail... tail)
 Convenience method for adding multiple children to Parent. More...
 
void removeChild (Component *child)
 Convenience method for removing a child to Parent. More...
 
void removeChildren ()
 
std::list< Component * > & getChildren ()
 
const std::list< Component * > & getChildrenReadonly () const
 
Sml::Texture * getSnapshot ()
 
bool needLayoutPass () const
 
void requestLayoutPass ()
 
const BackgroundgetBackground () const
 
void setBackground (const Background *background)
 
const BordergetBorder () const
 
void setBorder (const Border *border)
 
Insets getInsets () const
 
Sml::Rectangle< int32_t > getContentArea () const
 
Insets getPadding () const
 
void setPadding (const Insets &padding)
 
void setPrefWidth (int32_t width)
 
void setPrefHeight (int32_t height)
 
void setMinWidth (int32_t width)
 
void setMinHeight (int32_t height)
 
void setMaxWidth (int32_t width)
 
void setMaxHeight (int32_t height)
 
int32_t getPrefWidth () const
 
int32_t getPrefHeight () const
 
int32_t getMinWidth () const
 
int32_t getMinHeight () const
 
int32_t getMaxWidth () const
 
int32_t getMaxHeight () const
 
virtual int32_t computePrefWidth (int32_t height=-1) const override final
 
virtual int32_t computePrefHeight (int32_t width=-1) const override final
 
virtual int32_t computeMinWidth (int32_t height=-1) const override final
 
virtual int32_t computeMinHeight (int32_t width=-1) const override final
 
virtual int32_t computeMaxWidth (int32_t height=-1) const override final
 
virtual int32_t computeMaxHeight (int32_t width=-1) const override final
 
- Public Member Functions inherited from Sgl::Component
virtual Sml::EventDispatchChain * buildEventDispatchChain (Sml::EventDispatchChain *chain) override
 
bool isVisible () const
 
void setVisible (bool visible)
 
bool isInteractable () const
 
void setInteractable (bool interactable)
 
Visibility getVisibility () const
 
void setVisibility (Visibility visibility)
 
bool isFocused () const
 
bool isHovered () const
 
void requestFocus ()
 
void requestDrag ()
 
const ShadowgetShadow () const
 
void setShadow (const ShadowSpecification *specification)
 
GuiEventDispatchergetEventDispatcher ()
 
ScenegetScene ()
 
void setScene (Scene *scene)
 
const ParentgetParent () const
 
ParentgetModifiableParent ()
 
void setParent (Parent *parent)
 
Sml::Vec2i computeLocalToScenePos (const Sml::Vec2i &localPos) const
 
Sml::Vec2i computeSceneToLocalPos (const Sml::Vec2i &scenePos) const
 
Sml::Rectangle< int32_t > getOriginBounds () const
 
const Sml::Rectangle< int32_t > & getLayoutBounds () const
 
const Sml::Vec2i & getLayoutPos () const
 
int32_t getLayoutX () const
 
int32_t getLayoutY () const
 
int32_t getLayoutWidth () const
 
int32_t getLayoutHeight () const
 
void setLayoutX (int32_t x)
 
void setLayoutY (int32_t y)
 
void setLayoutWidth (int32_t width)
 
void setLayoutHeight (int32_t height)
 
Sml::Vec2i computeScenePos ()
 

Protected Member Functions

virtual void setSceneInSceneTree (Scene *scene) override final
 
virtual void layoutChildren ()
 
virtual void prerenderSelf ()
 
void updateSnapshotSize ()
 
virtual int32_t computeCustomPrefWidth (int32_t height=-1) const
 
virtual int32_t computeCustomPrefHeight (int32_t width=-1) const
 
virtual int32_t computeCustomMinWidth (int32_t height=-1) const
 
virtual int32_t computeCustomMinHeight (int32_t width=-1) const
 
virtual int32_t computeCustomMaxWidth (int32_t height=-1) const
 
virtual int32_t computeCustomMaxHeight (int32_t width=-1) const
 
- Protected Member Functions inherited from Sgl::Component
void updateShadow ()
 
void renderShadow (const Sml::Rectangle< int32_t > &targetRegion)
 

Protected Attributes

std::list< Component * > m_Children
 
Sml::Texture * m_Snapshot = nullptr
 
bool m_NeedLayoutPass = false
 
const Backgroundm_Background = nullptr
 
const Borderm_Border = nullptr
 
Insets m_Padding = Insets::EMPTY
 
int32_t m_PrefWidth = USE_COMPUTED_SIZE
 
int32_t m_PrefHeight = USE_COMPUTED_SIZE
 
int32_t m_MinWidth = USE_COMPUTED_SIZE
 
int32_t m_MinHeight = USE_COMPUTED_SIZE
 
int32_t m_MaxWidth = USE_COMPUTED_SIZE
 
int32_t m_MaxHeight = USE_COMPUTED_SIZE
 
- Protected Attributes inherited from Sgl::Component
Visibility m_Visibility = Visibility::VISIBLE_INTERACTABLE
 
bool m_Focused = false
 
bool m_Hovered = false
 
Shadow m_Shadow
 
GuiEventDispatcher m_Dispatcher
 
Scenem_Scene = nullptr
 
Parentm_Parent = nullptr
 
Sml::Rectangle< int32_t > m_LayoutBounds = {{0, 0}, 0, 0}
 

Additional Inherited Members

- Public Types inherited from Sgl::Component
enum class  Visibility { INVISIBLE_DISABLED = 0b00 , INVISIBLE_INTERACTABLE = 0b01 , VISIBLE_DISABLED = 0b10 , VISIBLE_INTERACTABLE = 0b11 }
 Used to determine if Component should be rendered and targeted by events. More...
 
- Public Attributes inherited from Sgl::Component
friend Scene
 
- Static Public Attributes inherited from Sgl::Component
static const int32_t USE_COMPUTED_SIZE = INT32_MIN
 
static const int32_t UNLIMITED_SIZE = INT32_MAX
 

Detailed Description

Definition at line 18 of file parent.h.

Member Function Documentation

◆ addChild()

void Sgl::Parent::addChild ( Component child)

Convenience method for adding a child to Parent.

Attention
For Control this should only be used by custom skins! It's undefined behavior if you simply add children to a Control. For Container this method can easily be used for adding any number of custom components.
Parameters
child

Definition at line 129 of file parent.cpp.

◆ addChildren() [1/2]

void Sgl::Parent::addChildren ( )
inline

Definition at line 43 of file parent.h.

◆ addChildren() [2/2]

template<typename Head , typename... Tail>
void Sgl::Parent::addChildren ( Head  head,
Tail...  tail 
)
inline

Convenience method for adding multiple children to Parent.

Parameters
children
See also
addChild() for more information on the restrictions.

Definition at line 53 of file parent.h.

◆ computeCustomMaxHeight()

int32_t Sgl::Parent::computeCustomMaxHeight ( int32_t  width = -1) const
protectedvirtual

Definition at line 264 of file parent.cpp.

◆ computeCustomMaxWidth()

int32_t Sgl::Parent::computeCustomMaxWidth ( int32_t  height = -1) const
protectedvirtual

Definition at line 263 of file parent.cpp.

◆ computeCustomMinHeight()

int32_t Sgl::Parent::computeCustomMinHeight ( int32_t  width = -1) const
protectedvirtual

Definition at line 261 of file parent.cpp.

◆ computeCustomMinWidth()

int32_t Sgl::Parent::computeCustomMinWidth ( int32_t  height = -1) const
protectedvirtual

Definition at line 260 of file parent.cpp.

◆ computeCustomPrefHeight()

int32_t Sgl::Parent::computeCustomPrefHeight ( int32_t  width = -1) const
protectedvirtual

Definition at line 254 of file parent.cpp.

◆ computeCustomPrefWidth()

int32_t Sgl::Parent::computeCustomPrefWidth ( int32_t  height = -1) const
protectedvirtual

Definition at line 249 of file parent.cpp.

◆ computeMaxHeight()

int32_t Sgl::Parent::computeMaxHeight ( int32_t  width = -1) const
finaloverridevirtual

Implements Sgl::Component.

Definition at line 243 of file parent.cpp.

◆ computeMaxWidth()

int32_t Sgl::Parent::computeMaxWidth ( int32_t  height = -1) const
finaloverridevirtual

Implements Sgl::Component.

Definition at line 237 of file parent.cpp.

◆ computeMinHeight()

int32_t Sgl::Parent::computeMinHeight ( int32_t  width = -1) const
finaloverridevirtual

Implements Sgl::Component.

Definition at line 231 of file parent.cpp.

◆ computeMinWidth()

int32_t Sgl::Parent::computeMinWidth ( int32_t  height = -1) const
finaloverridevirtual

Implements Sgl::Component.

Definition at line 225 of file parent.cpp.

◆ computePrefHeight()

int32_t Sgl::Parent::computePrefHeight ( int32_t  width = -1) const
finaloverridevirtual

Implements Sgl::Component.

Definition at line 219 of file parent.cpp.

◆ computePrefWidth()

int32_t Sgl::Parent::computePrefWidth ( int32_t  height = -1) const
finaloverridevirtual

Implements Sgl::Component.

Definition at line 213 of file parent.cpp.

◆ containsComponent()

bool Sgl::Parent::containsComponent ( Component component)
finaloverridevirtual

Reimplemented from Sgl::Component.

Definition at line 96 of file parent.cpp.

◆ getBackground()

const Background * Sgl::Parent::getBackground ( ) const

Definition at line 168 of file parent.cpp.

◆ getBorder()

const Border * Sgl::Parent::getBorder ( ) const

Definition at line 171 of file parent.cpp.

◆ getChildren()

std::list< Component * > & Sgl::Parent::getChildren ( )

Definition at line 160 of file parent.cpp.

◆ getChildrenReadonly()

const std::list< Component * > & Sgl::Parent::getChildrenReadonly ( ) const

Definition at line 161 of file parent.cpp.

◆ getContentArea()

Sml::Rectangle< int32_t > Sgl::Parent::getContentArea ( ) const

Definition at line 179 of file parent.cpp.

◆ getHitComponent()

Component * Sgl::Parent::getHitComponent ( int32_t  x,
int32_t  y 
)
overridevirtual

Reimplemented from Sgl::Component.

Definition at line 14 of file parent.cpp.

◆ getInsets()

Insets Sgl::Parent::getInsets ( ) const

Definition at line 174 of file parent.cpp.

◆ getMaxHeight()

int32_t Sgl::Parent::getMaxHeight ( ) const

Definition at line 209 of file parent.cpp.

◆ getMaxWidth()

int32_t Sgl::Parent::getMaxWidth ( ) const

Definition at line 208 of file parent.cpp.

◆ getMinHeight()

int32_t Sgl::Parent::getMinHeight ( ) const

Definition at line 206 of file parent.cpp.

◆ getMinWidth()

int32_t Sgl::Parent::getMinWidth ( ) const

Definition at line 205 of file parent.cpp.

◆ getPadding()

Insets Sgl::Parent::getPadding ( ) const

Definition at line 190 of file parent.cpp.

◆ getPrefHeight()

int32_t Sgl::Parent::getPrefHeight ( ) const

Definition at line 203 of file parent.cpp.

◆ getPrefWidth()

int32_t Sgl::Parent::getPrefWidth ( ) const

Definition at line 202 of file parent.cpp.

◆ getSnapshot()

Sml::Texture * Sgl::Parent::getSnapshot ( )

Definition at line 163 of file parent.cpp.

◆ isResizable()

bool Sgl::Parent::isResizable ( ) const
overridevirtual

Implements Sgl::Component.

Definition at line 127 of file parent.cpp.

◆ layout()

void Sgl::Parent::layout ( )
finaloverridevirtual

Reimplemented from Sgl::Component.

Definition at line 64 of file parent.cpp.

◆ layoutChildren()

void Sgl::Parent::layoutChildren ( )
protectedvirtual

Definition at line 118 of file parent.cpp.

◆ needLayoutPass()

bool Sgl::Parent::needLayoutPass ( ) const

Definition at line 165 of file parent.cpp.

◆ prerender()

void Sgl::Parent::prerender ( )
finaloverridevirtual

Reimplemented from Sgl::Component.

Definition at line 76 of file parent.cpp.

◆ prerenderSelf()

void Sgl::Parent::prerenderSelf ( )
protectedvirtual

Definition at line 116 of file parent.cpp.

◆ removeChild()

void Sgl::Parent::removeChild ( Component child)

Convenience method for removing a child to Parent.

Attention
For Control this should only be used by custom skins! It's undefined behavior if you simply remove children from a Control. For Container this method can easily be used for removing children from it.
Parameters
child

Definition at line 146 of file parent.cpp.

◆ removeChildren()

void Sgl::Parent::removeChildren ( )
Warning
Doesn't delete the children!

Definition at line 155 of file parent.cpp.

◆ render()

void Sgl::Parent::render ( const Sml::Rectangle< int32_t > &  targetRegion)
overridevirtual

Implements Sgl::Component.

Definition at line 36 of file parent.cpp.

◆ requestLayoutPass()

void Sgl::Parent::requestLayoutPass ( )

Definition at line 166 of file parent.cpp.

◆ setBackground()

void Sgl::Parent::setBackground ( const Background background)

Definition at line 169 of file parent.cpp.

◆ setBorder()

void Sgl::Parent::setBorder ( const Border border)

Definition at line 172 of file parent.cpp.

◆ setMaxHeight()

void Sgl::Parent::setMaxHeight ( int32_t  height)

Definition at line 200 of file parent.cpp.

◆ setMaxWidth()

void Sgl::Parent::setMaxWidth ( int32_t  width)

Definition at line 199 of file parent.cpp.

◆ setMinHeight()

void Sgl::Parent::setMinHeight ( int32_t  height)

Definition at line 197 of file parent.cpp.

◆ setMinWidth()

void Sgl::Parent::setMinWidth ( int32_t  width)

Definition at line 196 of file parent.cpp.

◆ setPadding()

void Sgl::Parent::setPadding ( const Insets padding)

Definition at line 191 of file parent.cpp.

◆ setPrefHeight()

void Sgl::Parent::setPrefHeight ( int32_t  height)

Definition at line 194 of file parent.cpp.

◆ setPrefWidth()

void Sgl::Parent::setPrefWidth ( int32_t  width)

Definition at line 193 of file parent.cpp.

◆ setSceneInSceneTree()

void Sgl::Parent::setSceneInSceneTree ( Scene scene)
finaloverrideprotectedvirtual

Reimplemented from Sgl::Component.

Definition at line 288 of file parent.cpp.

◆ updateSnapshotSize()

void Sgl::Parent::updateSnapshotSize ( )
protected

Definition at line 266 of file parent.cpp.

Member Data Documentation

◆ m_Background

const Background* Sgl::Parent::m_Background = nullptr
protected

Definition at line 127 of file parent.h.

◆ m_Border

const Border* Sgl::Parent::m_Border = nullptr
protected

Definition at line 128 of file parent.h.

◆ m_Children

std::list<Component*> Sgl::Parent::m_Children
protected

Definition at line 123 of file parent.h.

◆ m_MaxHeight

int32_t Sgl::Parent::m_MaxHeight = USE_COMPUTED_SIZE
protected

Definition at line 136 of file parent.h.

◆ m_MaxWidth

int32_t Sgl::Parent::m_MaxWidth = USE_COMPUTED_SIZE
protected

Definition at line 135 of file parent.h.

◆ m_MinHeight

int32_t Sgl::Parent::m_MinHeight = USE_COMPUTED_SIZE
protected

Definition at line 134 of file parent.h.

◆ m_MinWidth

int32_t Sgl::Parent::m_MinWidth = USE_COMPUTED_SIZE
protected

Definition at line 133 of file parent.h.

◆ m_NeedLayoutPass

bool Sgl::Parent::m_NeedLayoutPass = false
protected

Definition at line 126 of file parent.h.

◆ m_Padding

Insets Sgl::Parent::m_Padding = Insets::EMPTY
protected

Definition at line 129 of file parent.h.

◆ m_PrefHeight

int32_t Sgl::Parent::m_PrefHeight = USE_COMPUTED_SIZE
protected

Definition at line 132 of file parent.h.

◆ m_PrefWidth

int32_t Sgl::Parent::m_PrefWidth = USE_COMPUTED_SIZE
protected

Definition at line 131 of file parent.h.

◆ m_Snapshot

Sml::Texture* Sgl::Parent::m_Snapshot = nullptr
protected

Definition at line 124 of file parent.h.


The documentation for this class was generated from the following files: