raygui Documentation

A simple and easy-to-use immediate-mode gui library

RAW Doc

File: README.md

raygui is a simple and easy-to-use immediate-mode-gui library.

raygui was originally inspired by Unity IMGUI (immediate mode GUI API).

raygui was designed as an auxiliary module for raylib to create simple GUI interfaces using raylib graphic style (simple colors, plain rectangular shapes, wide borders...) but it can be adapted to other engines/frameworks.

raygui is intended for tools development; it has already been used to develop multiple published tools.

WARNING: Latest raygui from master branch is always aligned with latest raylib from master branch and all raylibtech tools. Make sure to use the latest versions.

WARNING: Latest raygui 5.0 introduces some API-BREAKING changes, now all functions return a result value.

NOTE: raygui is a single-file header-only library (despite its internal dependency on raylib), so, functions definition AND implementation reside in the same file raygui.h, when including raygui.h in a module, RAYGUI_IMPLEMENTATION must be previously defined to include the implementation part of raygui.h BUT only in one compilation unit, other modules could also include raygui.h but RAYGUI_IMPLEMENTATION must not be defined again.

features

  • Immediate-mode gui, no retained data
  • +25 controls provided (basic and advanced)
  • Powerful styling system for colors, font and metrics
  • Standalone usage mode supported (for other graphic libs)
  • Icons support, embedding a complete 1-bit icons pack
  • Multiple tools provided for raygui development

code sample

c
#include "raylib.h"

#define RAYGUI_IMPLEMENTATION
#include "raygui.h"

int main()
{
    InitWindow(400, 200, "raygui - controls test suite");
    SetTargetFPS(60);

    bool showMessageBox = false;

    while (!WindowShouldClose())
    {
        // Draw
        //----------------------------------------------------------------------------------
        BeginDrawing();
            ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)));

            if (GuiButton((Rectangle){ 24, 24, 120, 30 }, "#191#Show Message")) showMessageBox = true;

            if (showMessageBox)
            {
                int btnActive = -1;
                GuiMessageBox((Rectangle){ 85, 70, 250, 100 },
                    "#191#Message Box", "Hi! This is a message!", "Nice;Cool", &btnActive);

                if (btnActive >= 0) showMessageBox = false;
            }

        EndDrawing();
    }

    CloseWindow();
    return 0;
}

raygui controls

basic controls

text
Label       |  Button      |  LabelButton |  Toggle      |  ToggleGroup  |  ToggleSlider
CheckBox    |  ComboBox    |  DropdownBox |  TextBox     |  ValueBox     |  Spinner
Slider      |  SliderBar   |  ProgressBar |  StatusBar   |  DummyRec     |  Grid

container/separator controls

text
WindowBox   |  GroupBox    |  Line        |  Panel       |  ScrollPanel  | TabBar

advanced controls

text
ListView    |  ColorPicker |  MessageBox  |  TextInputBox

raygui styles

raygui comes with a default style automatically loaded at runtime:

Some additional styles are also provided for convenience, just check styles directory for details:

Custom styles can also be created very easily using rGuiStyler tool.

Styles can be loaded at runtime using raygui GuiLoadStyle() function. Simple and easy-to-use.

raygui icons

raygui supports custom icons, by default, a predefined set of icons is provided inside raygui as an array of binary data; it contains 512 possible icons defined as 16x16 pixels each; each pixel is codified using 1-bit. The total size of the array is 4096 bytes.

To use any of those icons just prefix the #iconId# number to any text written within raygui controls:

c
if (GuiButton(rec, "#05#Open Image")) { /* ACTION */ }

It's also possible to use the provided GuiIconText() function to prefix it automatically, using a clearer identifier (defined in raygui.h).

c
if (GuiButton(rec, GuiIconText(ICON_FILE_OPEN, "Open Image"))) { /* ACTION */ }

Provided set of icons can be reviewed and customized using rGuiIcons tool.

raygui support tools

  • rGuiStyler - A simple and easy-to-use raygui styles editor.

  • rGuiIcons - A simple and easy-to-use raygui icons editor.

  • rGuiLayout - A simple and easy-to-use raygui layouts editor.

building

raygui is intended to be used as a portable single-file header-only library, to be directly integrated into any C/C++ codebase but some users could require a shared/dynamic version of the library, for example, to create bindings:

  • Windows (MinGW, GCC)
text
copy src/raygui.h src/raygui.c
gcc -o src/raygui.dll src/raygui.c -shared -DRAYGUI_IMPLEMENTATION -DBUILD_LIBTYPE_SHARED -static-libgcc -lopengl32 -lgdi32 -lwinmm -Wl,--out-implib,src/librayguidll.a
  • Windows (MSVC)
text
copy src\raygui.h src\raygui.c
# For `cl` to be accessible open "Developer Command Prompt for VS 2022".
cl /O2 /I<RELATIVE_PATH_TO_RAYLIB_INCLUDE_DIR> /D_USRDLL /D_WINDLL /DRAYGUI_IMPLEMENTATION /DBUILD_LIBTYPE_SHARED src/raygui.c /LD /Feraygui.dll /link /LIBPATH <RELATIVE_PATH_TO_RAYLIB_IMPORT_LIBRARY> msvcrt.lib winmm.lib gdi32.lib user32.lib shell32.lib /subsystem:windows /machine:x64

# Example:
# cl /O2 /I../raylib-6_0_win64_msvc16/include /D_USRDLL /D_WINDLL /DRAYGUI_IMPLEMENTATION /DBUILD_LIBTYPE_SHARED src/raygui.c /LD /Feraygui.dll /link /LIBPATH ../raylib-6_0_win64_msvc16/lib/raylibdll.lib msvcrt.lib winmm.lib gdi32.lib user32.lib shell32.lib /subsystem:windows /machine:x64
  • Linux (GCC)
text
mv src/raygui.h src/raygui.c
gcc -o raygui.so src/raygui.c -shared -fpic -DRAYGUI_IMPLEMENTATION -lraylib -lGL -lm -lpthread -ldl -lrt -lX11
mv src/raygui.c src/raygui.h
  • Mac (clang, homebrew installed raylib)
text
cp src/raygui.h src/raygui.c
brew install raylib
gcc -o raygui.dynlib src/raygui.c -shared -fpic -DRAYGUI_IMPLEMENTATION -framework OpenGL -lm -lpthread -ldl $(pkg-config --libs --cflags raylib)

license

raygui is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check LICENSE for further details.


File: projects/CMake/README.md

raygui CMake Definitions

This provides CMake definition files for raygui.

Usage

text
cd projects/CMake
mkdir build
cd build
cmake ..
make

File: styles/lavanda/README.md

style: lavanda

Walking throught fields full of lavanda, it feels like a dream, a fantasy, just relax and close your eyes, could you feel it?

style: provided files

Several options are provided to add the style to a raygui application, choose the one that better fits the project.

file name description
style_lavanda.rgs Binary style file (raygui 4.0), font data compressed (recs, glyphs)
style_lavanda.txt.rgs Text style file, no font data, requires external font provided
style_lavanda.old.rgs Binary style file (raygui 3.x), font data uncompressed (recs, glyphs)
style_lavanda.h Embeddable style as code file, self-contained, includes font data
style_lavanda.png Style table image, contains rGSf chunk with binary rgs file data

screenshot

about font

"Cartridge" font by jeti

Licensed under CC BY 4.0, downloaded from dafont.com: cartridge


File: styles/jungle/README.md

style: jungle

Sunset in the jungle, trees do not let to see the last rays of sun on the horizon, small creek in the path, mug on the shoes, a touch of danger and the adventure feeling, get into your jeep and drive with this style.

style: provided files

Several options are provided to add the style to a raygui application, choose the one that better fits the project.

file name description
style_jungle.rgs Binary style file (raygui 4.0), font data compressed (recs, glyphs)
style_jungle.txt.rgs Text style file, no font data, requires external font provided
style_jungle.old.rgs Binary style file (raygui 3.x), font data uncompressed (recs, glyphs)
style_jungle.h Embeddable style as code file, self-contained, includes font data
style_jungle.png Style table image, contains rGSf chunk with binary rgs file data

screenshot

about font

"Pixel Intv" font by Pixel Sagas (Neale and Shayna Davidson).

100% free font, downloaded from dafont.com: pixel-intv


File: styles/enefete/README.md

style: enefete

Inspired by money and pain, a desperate jump into the trendings train, a train to nowhere. Don't stare at it for too long!

style: provided files

Several options are provided to add the style to a raygui application, choose the one that better fits the project.

file name description
style_enefete.rgs Binary style file (raygui 4.0), font data compressed (recs, glyphs)
style_enefete.txt.rgs Text style file, no font data, requires external font provided
style_enefete.old.rgs Binary style file (raygui 3.x), font data uncompressed (recs, glyphs)
style_enefete.h Embeddable style as code file, self-contained, includes font data
style_enefete.png Style table image, contains rGSf chunk with binary rgs file data

screenshot

about font

"Generic Mobile System" font by de Jayvee Enaguas.

CC0 1.0 Universal, downloaded from dafont.com: generic-mobile-system


File: styles/default/README.md

style: default

raylib style, simple and easy-to-use. Light colors, wide borders, a sophisticated touch.

style: provided files

Several options are provided to add the style to a raygui application, choose the one that better fits the project.

file name description
style_default.txt.rgs Text style file, no font data, uses raylib default font
style_default.png Style table image, contains rGSf chunk with binary rgs file data

screenshot

about font

raylib font by Ramon Santamaria (@raysan5).


File: styles/dark/README.md

style: dark

Classical dark style with an extra high-def colour touch! Elegant and professional, perfect for the expensive tools!

style: provided files

Several options are provided to add the style to a raygui application, choose the one that better fits the project.

file name description
style_dark.rgs Binary style file (raygui 4.0), font data compressed (recs, glyphs)
style_dark.txt.rgs Text style file, no font data, requires external font provided
style_dark.old.rgs Binary style file (raygui 3.x), font data uncompressed (recs, glyphs)
style_dark.h Embeddable style as code file, self-contained, includes font data
style_dark.png Style table image, contains rGSf chunk with binary rgs file data

screenshot

about font

"Pixel Operator" font by de Jayvee Enaguas.

CC0 1.0 Universal, downloaded from dafont.com: pixel-operator


File: styles/cyber/README.md

style: cyber

Future is now! Neons and shadows, city never sleeps! Robots waiting in the corners and expensive vending machines! You got the style!

style: provided files

Several options are provided to add the style to a raygui application, choose the one that better fits the project.

file name description
style_cyber.rgs Binary style file (raygui 4.0), font data compressed (recs, glyphs)
style_cyber.txt.rgs Text style file, no font data, requires external font provided
style_cyber.old.rgs Binary style file (raygui 3.x), font data uncompressed (recs, glyphs)
style_cyber.h Embeddable style as code file, self-contained, includes font data
style_cyber.png Style table image, contains rGSf chunk with binary rgs file data

screenshot

about font

"Grixel Kyrou 7 Wide" font by Nikos Giannakopoulos.

100% free font, downloaded from dafont.com: grixel-kyrou-7-wide


File: styles/cherry/README.md

style: cherry

Sweet with a touch of liquour, covered in chocolate, just give it a try! Not suitable for every palate, only the most demanding.

style: provided files

Several options are provided to add the style to a raygui application, choose the one that better fits the project.

file name description
style_cherry.rgs Binary style file (raygui 4.0), font data compressed (recs, glyphs)
style_cherry.txt.rgs Text style file, no font data, requires external font provided
style_cherry.old.rgs Binary style file (raygui 3.x), font data uncompressed (recs, glyphs)
style_cherry.h Embeddable style as code file, self-contained, includes font data
style_cherry.png Style table image, contains rGSf chunk with binary rgs file data

screenshot

about font

"Westington" font by Hazel Abbiati.

100% free font, downloaded from dafont.com: westington


File: styles/candy/README.md

style: candy

Sweet, colorful, tasty! Enjoy this funfair ride and be careful with the witch of the candy house!

style: provided files

Several options are provided to add the style to a raygui application, choose the one that better fits the project.

file name description
style_candy.rgs Binary style file (raygui 4.0), font data compressed (recs, glyphs)
style_candy.txt.rgs Text style file, no font data, requires external font provided
style_candy.old.rgs Binary style file (raygui 3.x), font data uncompressed (recs, glyphs)
style_candy.h Embeddable style as code file, self-contained, includes font data
style_candy.png Style table image, contains rGSf chunk with binary rgs file data

screenshot

about font

"V5 Eastergothic" font by vFive Digital (Roberto Christen).

100% free font, downloaded from dafont.com: v5eastergothic