|
Velvet 0.1a
A beginner-friendly C++ GUI framework built on SFML.
|
This page is a practical 5-minute guide to get a usable UI on screen.
Use the umbrella include:
This includes all the core basic layout and widget components needed for velvet to function.
The application runs inside a Window, constructed with the width, height, and the title as parameters.
Velvet uses a Stack for layout and positioning. Stacks exist in Vertical or Horizontal directions and can be declared as follows:
For convenience, you can use the shorthand HStack and VStack declarations:
gap is the spacing between child elements of the layout stacks (similar to flexbox gap in CSS)
Example:
Create widgets and add them to layout stacks using add( ... ).
The add() function exists on both Widget and Stack. It accepts 'n' widgets or pointers to widgets.
zoom in the current code so far is a Slider, which has the onchange callback:
Similarly, Button with onclick:
Ensure you add all the Stack layouts to the base window:

Some widgets load assets like fonts/textures with relative paths (example src/assets/...). Run your app from the project root, or provide paths that are valid for your execution directory. See Button and Label custom fonts and Image paths.
Head on over to the Widget Guide to find API references on all the widgets you can use within Velvet.