|
| 1 | +<img align="left" src="logo/raygui_256x256.png" width=256> |
| 2 | + |
| 3 | +**raygui is a simple and easy-to-use immediate-mode-gui library.** |
| 4 | + |
| 5 | +`raygui` was originally inspired by [Unity IMGUI](https://docs.unity3d.com/Manual/GUIScriptingGuide.html) (immediate mode GUI API). |
| 6 | + |
| 7 | +`raygui` was designed as an auxiliary module for [raylib](https://github.com/raysan5/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. |
| 8 | + |
| 9 | +`raygui` is intended for **tools development**; it has already been used to develop [multiple published tools](https://raylibtech.itch.io). |
| 10 | + |
| 11 | +<br> |
| 12 | + |
| 13 | +**WARNING: Latest `raygui` from master branch is always aligned with latest `raylib` from master branch. Make sure to use the appropiate versions.** |
| 14 | + |
| 15 | +**WARNING: Latest `raygui 4.0` is an API-BREAKING redesign from previous versions (3.x), now all functions are more consistent and coherent, you can read the details about this breaking change in issue [283](https://github.com/raysan5/raygui/issues/283)** |
| 16 | + |
| 17 | +*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.* |
| 18 | + |
| 19 | +## features |
| 20 | + |
| 21 | + - **Immediate-mode gui, no retained data** |
| 22 | + - **+25** controls provided (basic and advanced) |
| 23 | + - Powerful **styling system** for colors, font and metrics |
| 24 | + - Standalone usage mode supported (for other graphic libs) |
| 25 | + - **Icons support**, embedding a complete 1-bit icons pack |
| 26 | + - Multiple **tools** provided for raygui development |
| 27 | + |
| 28 | +## code sample |
| 29 | +```c |
| 30 | +#include "raylib.h" |
| 31 | + |
| 32 | +#define RAYGUI_IMPLEMENTATION |
| 33 | +#include "raygui.h" |
| 34 | + |
| 35 | +int main() |
| 36 | +{ |
| 37 | + InitWindow(400, 200, "raygui - controls test suite"); |
| 38 | + SetTargetFPS(60); |
| 39 | + |
| 40 | + bool showMessageBox = false; |
| 41 | + |
| 42 | + while (!WindowShouldClose()) |
| 43 | + { |
| 44 | + // Draw |
| 45 | + //---------------------------------------------------------------------------------- |
| 46 | + BeginDrawing(); |
| 47 | + ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR))); |
| 48 | + |
| 49 | + if (GuiButton((Rectangle){ 24, 24, 120, 30 }, "#191#Show Message")) showMessageBox = true; |
| 50 | + |
| 51 | + if (showMessageBox) |
| 52 | + { |
| 53 | + int result = GuiMessageBox((Rectangle){ 85, 70, 250, 100 }, |
| 54 | + "#191#Message Box", "Hi! This is a message!", "Nice;Cool"); |
| 55 | + |
| 56 | + if (result >= 0) showMessageBox = false; |
| 57 | + } |
| 58 | + |
| 59 | + EndDrawing(); |
| 60 | + } |
| 61 | + |
| 62 | + CloseWindow(); |
| 63 | + return 0; |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | + |
| 68 | +## raygui controls |
| 69 | + |
| 70 | +### basic controls |
| 71 | +``` |
| 72 | +Label | Button | LabelButton | Toggle | ToggleGroup | ToggleSlider |
| 73 | +CheckBox | ComboBox | DropdownBox | TextBox | ValueBox | Spinner |
| 74 | +Slider | SliderBar | ProgressBar | StatusBar | DummyRec | Grid |
| 75 | +``` |
| 76 | +### container/separator controls |
| 77 | +``` |
| 78 | +WindowBox | GroupBox | Line | Panel | ScrollPanel | TabBar |
| 79 | +``` |
| 80 | +### advanced controls |
| 81 | +``` |
| 82 | +ListView | ColorPicker | MessageBox | TextInputBox |
| 83 | +``` |
| 84 | + |
| 85 | + |
| 86 | +## raygui styles |
| 87 | + |
| 88 | +`raygui` comes with a [default](styles/default) style automatically loaded at runtime: |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | +Some additional styles are also provided for convenience, just check [styles directory](styles) for details: |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | +Custom styles can also be created very easily using [rGuiStyler](https://raylibtech.itch.io/rguistyler) tool. |
| 97 | + |
| 98 | +Styles can be loaded at runtime using raygui `GuiLoadStyle()` function. Simple and easy-to-use. |
| 99 | + |
| 100 | +## raygui icons |
| 101 | + |
| 102 | +`raygui` supports custom icons, by default, a predefined set of icons is provided inside `raygui` as an array of binary data; it contains **256 possible icons** defined as **16x16 pixels** each; each pixel is codified using **1-bit**. The total size of the array is `2048 bytes`. |
| 103 | + |
| 104 | +<img align="right" src="images/raygui_ricons.png"> |
| 105 | + |
| 106 | +To use any of those icons just prefix the *#iconId#* number to **any text** written within `raygui` controls: |
| 107 | +```c |
| 108 | +if (GuiButton(rec, "#05#Open Image")) { /* ACTION */ } |
| 109 | +``` |
| 110 | +It's also possible to use the provided `GuiIconText()` function to prefix it automatically, using a clearer identifier (defined in `raygui.h`). |
| 111 | +```c |
| 112 | +if (GuiButton(rec, GuiIconText(RICON_FILE_OPEN, "Open Image"))) { /* ACTION */ } |
| 113 | +``` |
| 114 | +Provided set of icons can be reviewed and customized using [rGuiIcons](https://raylibtech.itch.io/rguiicons) tool. |
| 115 | + |
| 116 | +## raygui support tools |
| 117 | + |
| 118 | + - [**rGuiStyler**](https://raylibtech.itch.io/rguistyler) - A simple and easy-to-use raygui styles editor. |
| 119 | + |
| 120 | +  |
| 121 | + |
| 122 | + - [**rGuiIcons**](https://raylibtech.itch.io/rguiicons) - A simple and easy-to-use raygui icons editor. |
| 123 | + |
| 124 | +  |
| 125 | + |
| 126 | + - [**rGuiLayout**](https://raylibtech.itch.io/rguilayout) - A simple and easy-to-use raygui layouts editor. |
| 127 | + |
| 128 | +  |
| 129 | + |
| 130 | +## building |
| 131 | + |
| 132 | +`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: |
| 133 | + |
| 134 | + - **Windows (MinGW, GCC)** |
| 135 | +``` |
| 136 | +copy src/raygui.h src/raygui.c |
| 137 | +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 |
| 138 | +``` |
| 139 | + |
| 140 | + - **Windows (MSVC)** |
| 141 | +``` |
| 142 | +copy src\raygui.h src\raygui.c |
| 143 | +cl /O2 /I../raylib/src/ /D_USRDLL /D_WINDLL /DRAYGUI_IMPLEMENTATION /DBUILD_LIBTYPE_SHARED src/raygui.c /LD /Feraygui.dll /link /LIBPATH ../raylib/build/raylib/Release/raylib.lib /subsystem:windows /machine:x64 |
| 144 | +``` |
| 145 | + |
| 146 | + - **Linux (GCC)** |
| 147 | +``` |
| 148 | +mv src/raygui.h src/raygui.c |
| 149 | +gcc -o raygui.so src/raygui.c -shared -fpic -DRAYGUI_IMPLEMENTATION -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 |
| 150 | +mv src/raygui.c src/raygui.h |
| 151 | +``` |
| 152 | + |
| 153 | +- **Mac (clang, homebrew installed raylib)** |
| 154 | +``` |
| 155 | +cp src/raygui.h src/raygui.c |
| 156 | +brew install raylib |
| 157 | +gcc -o raygui.dynlib src/raygui.c -shared -fpic -DRAYGUI_IMPLEMENTATION -framework OpenGL -lm -lpthread -ldl $(pkg-config --libs --cflags raylib) |
| 158 | +``` |
| 159 | + |
| 160 | + |
| 161 | +## license |
| 162 | + |
| 163 | +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](LICENSE) for further details. |
0 commit comments