welcome.md 2.1 KB

State-Mode GUI API

Welcome to the manual for the SMGUI, the state-mode graphical user interface toolkit.

The main concept of a state-mode UI is, that you already have your variables, so you reference those from a layout, which has no callbacks neither requires immediate-mode calls, it is just uses those already existing variables for rendering the GUI states.

HINT: This manual can be used off-line. From the right-click pop-up menu, choose "Save As".

Including

This library is self-contained in one single header file and can be used either in header-only mode or in implementation mode. The header-only mode is used by default when included and allows including this header in other headers and does not contain the actual implementation. The implementation mode requires defining the preprocessor macro UI_IMPLEMENTATION in exactly one .c/.cpp file right before including this file.

The base library is entirely platform and backend agnostic. You can select which backend and font driver module to use just by including before ui.h.

#include "ui_glfw.h"
#include "ui_psf2.h"
#define UI_IMPLEMENTATION
#include "ui.h"

The reference implementation for backend uses GLFW3, SDL2/3 and X11; for fonts PC-Screen-Font (same that Linux Console uses), and Scalable Screen Font (much more efficient than TTF or OTF, and any font, be it bitmap, vector or pixel font, can be converted into SSFN).

By default, if no other modules included beforehand, then ui.h includes the GLFW3 backend and PSF2 fonts and also embeds a minimal ASCII-only font (2080 bytes compiled).

Return Codes

Unless stated otherwise, all functions return a negative error code.

Define Description
UI_OK Successful, no error
UI_ERR_BADINP Bad input argument
UI_ERR_BACKEND Error intializing the backend
UI_ERR_NOMEM Memory allocation error