Velvet 0.1a
A beginner-friendly C++ GUI framework built on SFML.
Loading...
Searching...
No Matches
Stack Class Reference

Container widget that arranges children in a row or column. More...

#include <Stack.hpp>

+ Inheritance diagram for Stack:

Public Member Functions

 Stack (StackDirection dir, float gap=0)
 Construct a stack with direction and optional gap.
 
void render (sf::RenderWindow &window) override
 Render stack background and child widgets.
 
void add (Widget *widget)
 Add a child widget pointer.
 
template<typename... Ts>
void add (Ts &&... widgets)
 Add one or more child widgets (pointer or reference forms).
 
void setPosition (float x, float y) override
 Set stack position (top-left).
 
sf::Vector2f getDimensions () override
 Get total stack dimensions including padding.
 
void handleEvent (const sf::Event &event, sf::RenderWindow &window) override
 Forward input events to all children.
 
void setGap (float g)
 Set spacing between children.
 
float getGap () const
 Get current child gap.
 
void setJustifyContent (StackJustify value)
 Set main-axis content alignment.
 
void setJustifyContent (const std::string &value)
 Set main-axis alignment from string (start|center|end).
 
void setAlignItems (StackAlign value)
 Set cross-axis child alignment.
 
void setAlignItems (const std::string &value)
 Set cross-axis alignment from string (start|center|end).
 
void setSize (float width, float height)
 Set explicit content size used for alignment calculations.
 
void setWidth (float width)
 Set explicit content width.
 
void setHeight (float height)
 Set explicit content height.
 
void setPadding (float p)
 Set uniform padding on all sides.
 
void setPadding (float horizontal, float vertical)
 Set horizontal and vertical padding.
 
void setPadding (float left, float right, float top, float bottom)
 Set side-specific padding.
 
void setBackgroundColor (sf::Color color)
 Set container background color.
 
- Public Member Functions inherited from Widget
 Widget ()
 Construct a widget with default font loading.
 

Additional Inherited Members

- Public Attributes inherited from Widget
sf::Font font
 Shared font loaded by the base widget.
 
- Protected Attributes inherited from Widget
float x
 
float y
 

Detailed Description

Container widget that arranges children in a row or column.

Stack is Velvet's primary layout primitive.

  • Horizontal mode (HStack): children left-to-right
  • Vertical mode (VStack): children top-to-bottom

It supports gap, padding, explicit size, justify/align options, and optional background color.

Constructor & Destructor Documentation

◆ Stack()

Stack::Stack ( StackDirection  dir,
float  gap = 0 
)
inline

Construct a stack with direction and optional gap.

Member Function Documentation

◆ add() [1/2]

template<typename... Ts>
void Stack::add ( Ts &&...  widgets)
inline

Add one or more child widgets (pointer or reference forms).

◆ add() [2/2]

void Stack::add ( Widget widget)
inline

Add a child widget pointer.

Child widgets must outlive the stack.

◆ getDimensions()

sf::Vector2f Stack::getDimensions ( )
inlineoverridevirtual

Get total stack dimensions including padding.

Implements Widget.

◆ getGap()

float Stack::getGap ( ) const
inline

Get current child gap.

◆ handleEvent()

void Stack::handleEvent ( const sf::Event &  event,
sf::RenderWindow &  window 
)
inlineoverridevirtual

Forward input events to all children.

Reimplemented from Widget.

◆ render()

void Stack::render ( sf::RenderWindow &  window)
inlineoverridevirtual

Render stack background and child widgets.

Reimplemented from Widget.

◆ setAlignItems() [1/2]

void Stack::setAlignItems ( const std::string &  value)
inline

Set cross-axis alignment from string (start|center|end).

◆ setAlignItems() [2/2]

void Stack::setAlignItems ( StackAlign  value)
inline

Set cross-axis child alignment.

◆ setBackgroundColor()

void Stack::setBackgroundColor ( sf::Color  color)
inline

Set container background color.

◆ setGap()

void Stack::setGap ( float  g)
inline

Set spacing between children.

◆ setHeight()

void Stack::setHeight ( float  height)
inline

Set explicit content height.

◆ setJustifyContent() [1/2]

void Stack::setJustifyContent ( const std::string &  value)
inline

Set main-axis alignment from string (start|center|end).

◆ setJustifyContent() [2/2]

void Stack::setJustifyContent ( StackJustify  value)
inline

Set main-axis content alignment.

◆ setPadding() [1/3]

void Stack::setPadding ( float  horizontal,
float  vertical 
)
inline

Set horizontal and vertical padding.

◆ setPadding() [2/3]

void Stack::setPadding ( float  left,
float  right,
float  top,
float  bottom 
)
inline

Set side-specific padding.

Parameters
leftLeft padding.
rightRight padding.
topTop padding.
bottomBottom padding.

◆ setPadding() [3/3]

void Stack::setPadding ( float  p)
inline

Set uniform padding on all sides.

◆ setPosition()

void Stack::setPosition ( float  x,
float  y 
)
inlineoverridevirtual

Set stack position (top-left).

Implements Widget.

◆ setSize()

void Stack::setSize ( float  width,
float  height 
)
inline

Set explicit content size used for alignment calculations.

◆ setWidth()

void Stack::setWidth ( float  width)
inline

Set explicit content width.


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