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

Container component that positions child objects relative to itself. More...

#include <panel_component.hpp>

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

Public Member Functions

void registerChild (GameObject *childIn)
 Registers a child at a zero offset.
 
void registerChild (PanelChild *childIn)
 Registers a child with a predefined offset.
 
void firstFrame () override
 Called once before the first frame update.
 
void frame (double _dt) override
 Called every frame to update the component.
 
void setRectColor (Color colorIn) override
 Sets the rectangle fill color.
 
void setRectWidth (int widthIn) override
 Sets the rectangle width.
 
void setRectHeight (int heightIn) override
 Sets the rectangle height.
 
void setOffset (GameObject *gameobject, Vector3 offsetIn)
 Sets the offset for a child object.
 
void setOffset (PanelChild *panelChild, Vector3 offsetIn)
 Sets the offset for a child descriptor.
 
PanelChild * getPanelObject (GameObject *gameObject)
 Finds the child descriptor for a game object.
 
Vector3 getWorldPosition (GameObject *gameObject)
 Computes a child's world position (panel position + offset).
 
Vector3 getOffset (GameObject *go)
 Returns a child's offset relative to the panel.
 
 ~PanelComponent ()
 
- Public Member Functions inherited from cangine::QuadRendererComponent
void firstFrame () override
 Called once before the first frame update.
 
void frame (double deltaTime) override
 Called every frame to update the component.
 
virtual void setTexture (Texture &t)
 Sets the texture applied to the quad.
 
Rectangle * getRect ()
 Returns the underlying rectangle.
 
Vector3 getRectPos ()
 Returns the rectangle's position.
 
Vector2 getRectSize ()
 Returns the rectangle's size.
 
- Public Member Functions inherited from cangine::IComponent
 IComponent (GameObject *gameObject=nullptr)
 Constructs the component, optionally bound to a game object.
 
virtual ~IComponent ()
 
GameObject * getGameObject () const
 Returns the game object this component is attached to.
 
virtual void onMouseEvent (const MouseEvent *e)
 Called when a mouse event is dispatched to the owning object.
 

Public Attributes

float padding = 5
 Inner padding in pixels.
 
float width = 350
 Panel width in pixels.
 
float height = 150
 Panel height in pixels.
 
Color color = Color(53, 53, 53, 1)
 Panel background color.
 
- Public Attributes inherited from cangine::IComponent
bool isUnique = true
 If true, only one of this component type may exist per object.
 

Private Attributes

std::vector< PanelChild * > children
 Registered children and their offsets.
 
Vector3 pos
 Panel position used as the offset origin.
 

Friends

class Panel
 

Additional Inherited Members

- Protected Attributes inherited from cangine::QuadRendererComponent
QuadRenderer * qr
 Renderer used to draw the quad.
 
Texture * texture
 Texture applied to the quad, if any.
 
Transform * transform
 Cached transform of the owning object.
 
Rectangle rect
 Rectangle geometry to draw.
 

Detailed Description

Container component that positions child objects relative to itself.

Draws a panel rectangle (via QuadRendererComponent) and keeps each registered child positioned at its stored offset, so moving the panel moves its children.

Constructor & Destructor Documentation

◆ ~PanelComponent()

cangine::PanelComponent::~PanelComponent ( )

Member Function Documentation

◆ firstFrame()

void cangine::PanelComponent::firstFrame ( )
overridevirtual

Called once before the first frame update.

Reimplemented from cangine::IComponent.

◆ frame()

void cangine::PanelComponent::frame ( double  deltaTime)
overridevirtual

Called every frame to update the component.

Parameters
deltaTimeSeconds elapsed since the previous frame.

Reimplemented from cangine::IComponent.

◆ getOffset()

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

Returns a child's offset relative to the panel.

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

◆ getPanelObject()

PanelChild * cangine::PanelComponent::getPanelObject ( GameObject *  gameObject)

Finds the child descriptor for a game object.

Parameters
gameObjectObject to look up.
Returns
The matching PanelChild, or nullptr if not a child.

◆ getWorldPosition()

Vector3 cangine::PanelComponent::getWorldPosition ( GameObject *  gameObject)

Computes a child's world position (panel position + offset).

Parameters
gameObjectChild object to query.
Returns
The child's world position.

◆ registerChild() [1/2]

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

Registers a child at a zero offset.

Parameters
childInChild game object to add.

◆ registerChild() [2/2]

void cangine::PanelComponent::registerChild ( PanelChild *  childIn)

Registers a child with a predefined offset.

Parameters
childInChild descriptor (object + offset) to add.

◆ setOffset() [1/2]

void cangine::PanelComponent::setOffset ( GameObject *  gameobject,
Vector3  offsetIn 
)

Sets the offset for a child object.

Parameters
gameobjectChild object to reposition.
offsetInNew offset relative to the panel.

◆ setOffset() [2/2]

void cangine::PanelComponent::setOffset ( PanelChild *  panelChild,
Vector3  offsetIn 
)

Sets the offset for a child descriptor.

Parameters
panelChildChild descriptor to reposition.
offsetInNew offset relative to the panel.

◆ setRectColor()

void cangine::PanelComponent::setRectColor ( Color  colorIn)
overridevirtual

Sets the rectangle fill color.

Parameters
colorInNew color.

Reimplemented from cangine::QuadRendererComponent.

◆ setRectHeight()

void cangine::PanelComponent::setRectHeight ( int  heightIn)
overridevirtual

Sets the rectangle height.

Parameters
heightInNew height.

Reimplemented from cangine::QuadRendererComponent.

◆ setRectWidth()

void cangine::PanelComponent::setRectWidth ( int  widthIn)
overridevirtual

Sets the rectangle width.

Parameters
widthInNew width.

Reimplemented from cangine::QuadRendererComponent.

Friends And Related Symbol Documentation

◆ Panel

friend class Panel
friend

Member Data Documentation

◆ children

std::vector<PanelChild*> cangine::PanelComponent::children
private

Registered children and their offsets.

◆ color

Color cangine::PanelComponent::color = Color(53, 53, 53, 1)

Panel background color.

◆ height

float cangine::PanelComponent::height = 150

Panel height in pixels.

◆ padding

float cangine::PanelComponent::padding = 5

Inner padding in pixels.

◆ pos

Vector3 cangine::PanelComponent::pos
private

Panel position used as the offset origin.

◆ width

float cangine::PanelComponent::width = 350

Panel width in pixels.


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