Look and Feel
Mouse Pointer
int ui_swcursor(ui_t *ctx, ui_image_t *cursor);
Disables hardware mouse cursor and replaces it with an image cursor from software.
Parameter |
Description |
ctx |
Pointer to UI context |
cursor |
A cursor [image] |
Returns 0 on success, an error code otherwise.
int ui_hwcursor(ui_t *ctx);
Disables software cursor and enables hardware mouse cursor.
Parameter |
Description |
ctx |
Pointer to UI context |
Returns 0 on success, an error code otherwise.
Color Theme
SMGUI supports color themes, which are basically palettes. Each palette entry corresponds to a specific UI element's color.
These are in order:
- foreground color
- popup and menu title color
- popup and menu background color
- popup and menu shadow color
- [toggle] active foreground color
- toggle active background color
- [menu] highlight foreground color
- menu highlight background color
- disabled foreground color
- disabled background color
- scrollbar background color
- input box foreground color
- input box light border color
- input box dark border color
- input box background color
- input box selected foreground color
- input box selected border color
- input box selected cursor color
- button foreground color
- button shadow color
- button normal outter border color
- button selected foreground color
- button selected shadow color
- button selected outter border color
- button light inner border color
- button dark inner border color
- button light background color
- button dark background color
- progressbar light color
- progressbar background color
- progressbar dark color
int ui_theme(ui_t *ctx, uint32_t *theme);
Sets a custom theme. The theme[]
array has as many elements as UI colors, see the list above.
Parameter |
Description |
ctx |
Pointer to UI context |
theme |
Pointer to a palette |
Returns 0 on success, an error code otherwise.
Skin
SMGUI supports skins, which are images, each corresponding to a specific part of the UI. These are in order:
- the mouse cursor (hotspot at the centre)
- popup and menu top left corner
- popup and menu top middle
- popup and menu top right corner
- popup and menu left
- popup and menu background
- popup and menu right
- popup and menu bottom left corner
- popup and menu bottom middle
- popup and menu bottom right corner
- popup and menu title background
- popup and menu close button
- popup and menu alternative top left corner
- popup and menu alternative top middle
- popup and menu alternative top right corner
- popup and menu alternative left
- popup and menu alternative background
- popup and menu alternative right
- popup and menu alternative bottom left corner
- popup and menu alternative bottom middle
- popup and menu alternative bottom right corner
- popup and menu alternative title background
- popup and menu alternative close button
- menu alternative left side
- menu alternative background
- menu alternative right side
- menu highlight background
- input box background
- progressbar button background
- slider left side
- slider background
- slider right side
- slider button
- vertical scrollbar top
- vertical scrollbar background
- vertical scrollbar bottom
- vertical scrollbar button top
- vertical scrollbar button middle
- vertical scrollbar button bottom
- horizontal scrollbar top
- horizontal scrollbar background
- horizontal scrollbar bottom
- horizontal scrollbar button top
- horizontal scrollbar button middle
- horizontal scrollbar button bottom
- checkbox unchecked
- checkbox checked
- radiobutton unchecked
- radiobutton checked
- normal button left side
- normal button background
- normal button right side
- pressed button left side
- pressed button background
- pressed button right side
- selected button left side
- selected button background
- selected button right side
- left arrow button
- down arrow button
- right arrow button
- pressed left arrow button
- pressed down arrow button
- pressed right arrow button
- selected left arrow button
- selected down arrow button
- selected right arrow button
int ui_skin(ui_t *ctx, ui_image_t *skin);
Sets a custom skin. The skin[]
array has as many elements as UI elements, see the list above.
Parameter |
Description |
ctx |
Pointer to UI context |
skin |
Array of skin [image]s |
Returns 0 on success, an error code otherwise.
If you include stb_image.h
before ui.h, then you can also use the following function to load skin from a single PNG file:
int ui_pngskin(ui_t *ctx, uint8_t *png, int size);
Sets a custom skin from a packed PNG file.
Parameter |
Description |
ctx |
Pointer to UI context |
png |
Pointer to a PNG image |
size |
Size of the PNG image |
Returns 0 on success, an error code otherwise.
The packed PNG must have a comment, with x
, y
, w
, h
ASCII decimal numbers in each line that describe areas on the image.
To create such packed skin PNGs, you can use for example sprpack with the -cdt
flags, like:
sprpack -cdt skin.png mouse.png popup_topleft.png popup_topmiddle.png ...
You must list all separate UI element PNGs and in the exact same order as listed above, otherwise the skin PNG won't work.