cangine
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
cangine::Panel Class Reference

Container game object that groups and positions child objects. More...

#include <panel_object.hpp>

Inheritance diagram for cangine::Panel:
Inheritance graph
[legend]
Collaboration diagram for cangine::Panel:
Collaboration graph
[legend]

Public Member Functions

 Panel (int padding=5)
 Constructs a panel.
 
void onDisable () override
 Called when the object becomes inactive.
 
void onEnable () override
 Called when the object becomes active.
 
void setPadding (int paddingIn)
 Sets the inner padding.
 
void registerChild (GameObject *childIn)
 Adds a child object to the panel.
 
void setRectColor (Color colorIn)
 Sets the panel background color.
 
void setRectWidth (int widthIn)
 Sets the panel width.
 
void setRectHeight (int heightIn)
 Sets the panel height.
 
void setOffset (GameObject *go, Vector3 offset)
 Sets a child's offset relative to the panel.
 
Vector3 getOffset (GameObject *go)
 Returns a child's offset relative to the panel.
 
Vector2 getRectSize ()
 Returns the panel's size.
 
- Public Member Functions inherited from cangine::GameObject
 GameObject ()
 
virtual ~GameObject ()
 
virtual void onUpdate (double deltaTime)
 Per-frame update hook.
 
virtual void onMouseEvent (const MouseEvent *e)
 Mouse event hook.
 
void destroy ()
 Marks the object for destruction by the ObjectManager.
 
template<typename T >
void appendComponent (T *component)
 Attaches an existing component to this object.
 
template<typename T >
void destroyComponent ()
 Destroys and removes the first component of a type.
 
template<typename T >
T * getComponent ()
 Returns the first attached component of a type.
 
template<typename T >
std::vector< T * > getComponents ()
 Returns all attached components of a type.
 
template<typename T , typename... Args>
T * newComponent (Args &&... args)
 Constructs a component in place and attaches it.
 
void setActive (bool a)
 Activates or deactivates the object.
 
bool isActive ()
 Reports whether the object is active.
 

Private Attributes

PanelComponent * pc = nullptr
 Component implementing panel layout.
 
std::unordered_set< PanelChild * > notActive
 Children that were inactive before the panel was disabled.
 

Detailed Description

Container game object that groups and positions child objects.

Backed by a PanelComponent: children are placed relative to the panel, and enabling/disabling the panel cascades to its children.

Constructor & Destructor Documentation

◆ Panel()

cangine::Panel::Panel ( int  padding = 5)

Constructs a panel.

Parameters
paddingInner padding in pixels.

Member Function Documentation

◆ getOffset()

Vector3 cangine::Panel::getOffset ( GameObject *  go)

Returns a child's offset relative to the panel.

Parameters
goChild object to query.
Returns
The child's offset.

◆ getRectSize()

Vector2 cangine::Panel::getRectSize ( )

Returns the panel's size.

Returns
Width and height as a vector.

◆ onDisable()

void cangine::Panel::onDisable ( )
overridevirtual

Called when the object becomes inactive.

Reimplemented from cangine::GameObject.

◆ onEnable()

void cangine::Panel::onEnable ( )
overridevirtual

Called when the object becomes active.

Reimplemented from cangine::GameObject.

◆ registerChild()

void cangine::Panel::registerChild ( GameObject *  childIn)

Adds a child object to the panel.

Parameters
childInChild game object to add.

◆ setOffset()

void cangine::Panel::setOffset ( GameObject *  go,
Vector3  offset 
)

Sets a child's offset relative to the panel.

Parameters
goChild object to reposition.
offsetNew offset.

◆ setPadding()

void cangine::Panel::setPadding ( int  paddingIn)

Sets the inner padding.

Parameters
paddingInNew padding in pixels.

◆ setRectColor()

void cangine::Panel::setRectColor ( Color  colorIn)

Sets the panel background color.

Parameters
colorInNew color.

◆ setRectHeight()

void cangine::Panel::setRectHeight ( int  heightIn)

Sets the panel height.

Parameters
heightInNew height in pixels.

◆ setRectWidth()

void cangine::Panel::setRectWidth ( int  widthIn)

Sets the panel width.

Parameters
widthInNew width in pixels.

Member Data Documentation

◆ notActive

std::unordered_set<PanelChild*> cangine::Panel::notActive
private

Children that were inactive before the panel was disabled.

◆ pc

PanelComponent* cangine::Panel::pc = nullptr
private

Component implementing panel layout.


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