Original (upstream) author: Alexandre Bodelot alexandre.bodelot@gmail.com
License: MIT License (See the LICENSE
file.)
- Adapted to the upcoming SFML v3 API
- Compiling as C++20 now (to embrace recent C++ features; SFML3 is C++17 already)
- Richer, more flexible API, new features, bugfixes, improvements
- Default quick-start assets included (and removed the non-free ones)
- Windows build (MSVC & GCC (via w64devkit, so MingW should also work))
- Auto download & setup the latest SFML-master locally (mostly for GitHub workflows)
- Reshuffled repo tree (to allow growth & to help integrating into other projects)
For other (both planned and completed) changes see the issues!
- Moderately sized package with no external dependencies beyond SFML
- Simple, straightforward, but versatile API
- Visual styling via spritesheets (small image files to customize borders, markers etc.)
- Simple optional callbacks for "update" actions (supporting both
[]()
and[](Widget*)
lambda signatures) (Any other event handlers can also be overridden in derived widgets, of course.) - Easy layouts: automatically (and dynamically re)align widgets
- No CMake. (Well, since I never got to learn it, now I just declare this a feature. ;) Use e.g. TGUI if you don't feel warm and cozy without CMake.)
- Run
make
to build the lib (in thelib
folder) and the example/demo/test executables.
- Run
nmake -f Makefile.msvc
for the same.
(See the Makefiles for options.)
- Integrate (via env. vars, or just copy) the
include
&lib
dirs to your project. (Copy theasset
dir, too, if you want to use the stock defaults.) #include "sfw/GUI.hpp"
.- Optionally (but typically) customize the theme: the styling texture image, font, colors etc.
- Create the top-level GUI manager object, connecting it to your SFML window (like:
sfw::GUI myGUI(window);
), usually with your custom theme config (sfw::GUI myGUI(window, myConfig);
) - Add containers (layouts) and widgets with
add(sfw::SomeWidget(...))
, or if you prefer:add(new sfw::OtherWidget)
calls, set their properties (typically with method chaining, likeadd(new TextBox)->set("hi")->setCallback(...)
) etc. Note: widget objects will be managed (e.g. deleted) implicitly. - Pass events to the GUI (in your app's event loop):
myGUI.process(event);
. - Draw the GUI (in your frame refresh loop; i.e. the event loop in single-treaded apps):
myGUI.render();
. - Have fun!
- a minimal example (or another, with a polling event loop)
- a fairly comprehensive example:
demo.cpp
- see the headers in the
include
dir for an authoritative reference (they're easy to read)