raygui/README.md

163 lines
6.6 KiB
Markdown
Raw Normal View History

2018-02-12 12:20:15 +01:00
<img align="left" src="logo/raygui_256x256.png" width=256>
2017-07-02 13:37:07 +02:00
2021-10-05 12:47:54 +02:00
**raygui is a simple and easy-to-use immediate-mode-gui library.**
2016-09-07 18:25:06 +02:00
2022-06-01 19:55:02 +02:00
`raygui` was originally inspired by [Unity IMGUI](https://docs.unity3d.com/Manual/GUIScriptingGuide.html) (immediate mode GUI API).
2016-09-07 18:25:06 +02:00
2024-07-06 18:50:52 +05:30
`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.
2017-06-21 01:19:38 +02:00
2022-03-29 18:00:36 +02:00
`raygui` is intended for **tools development**; it has already been used to develop [multiple published tools](https://raylibtech.itch.io).
2017-08-06 10:58:09 +02:00
2018-07-21 13:47:07 +02:00
<br>
2023-05-27 10:18:45 +02:00
**WARNING: Latest `raygui` from master branch is always aligned with latest `raylib` from master branch. Make sure to use the appropiate versions.**
2022-10-08 12:08:49 +02:00
2023-09-18 19:45:57 +02:00
**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)**
2023-05-27 11:38:38 +02:00
2023-09-02 11:35:25 +02:00
*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.*
2021-10-05 12:47:54 +02:00
## features
2017-06-21 01:19:38 +02:00
2022-02-05 19:08:08 +01:00
- **Immediate-mode gui, no retained data**
- **+25** controls provided (basic and advanced)
2021-10-07 16:12:17 +02:00
- Powerful **styling system** for colors, font and metrics
2021-10-05 12:47:54 +02:00
- Standalone usage mode supported (for other graphic libs)
2021-10-07 16:12:17 +02:00
- **Icons support**, embedding a complete 1-bit icons pack
- Multiple **tools** provided for raygui development
2021-10-05 12:47:54 +02:00
2024-05-09 21:00:39 +02:00
## 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)
{
2024-05-09 21:01:17 +02:00
int result = GuiMessageBox((Rectangle){ 85, 70, 250, 100 },
"#191#Message Box", "Hi! This is a message!", "Nice;Cool");
2024-05-09 21:00:39 +02:00
if (result >= 0) showMessageBox = false;
}
EndDrawing();
}
CloseWindow();
return 0;
}
```
![screenshot000](https://github.com/raysan5/raygui/assets/5766837/170e2bce-b7ca-49dc-a263-32b673376546)
2021-10-05 12:47:54 +02:00
## raygui controls
### basic controls
2019-08-28 12:23:49 +02:00
```
2023-09-12 00:24:31 +02:00
Label | Button | LabelButton | Toggle | ToggleGroup | ToggleSlider
CheckBox | ComboBox | DropdownBox | TextBox | ValueBox | Spinner
2023-09-12 00:24:31 +02:00
Slider | SliderBar | ProgressBar | StatusBar | DummyRec | Grid
2019-08-28 12:23:49 +02:00
```
2022-01-05 21:56:29 +01:00
### container/separator controls
2019-08-28 12:23:49 +02:00
```
2023-09-12 00:24:31 +02:00
WindowBox | GroupBox | Line | Panel | ScrollPanel | TabBar
2019-08-28 12:23:49 +02:00
```
2022-03-11 10:40:04 +02:00
### advanced controls
2021-10-05 12:47:54 +02:00
```
2022-01-05 21:56:29 +01:00
ListView | ColorPicker | MessageBox | TextInputBox
2021-10-05 12:47:54 +02:00
```
2018-05-02 21:09:18 +02:00
2022-01-05 21:56:29 +01:00
2019-08-28 11:54:36 +02:00
## raygui styles
2021-10-05 12:47:54 +02:00
`raygui` comes with a [default](styles/default) style automatically loaded at runtime:
2019-08-28 11:54:36 +02:00
2023-09-12 00:23:23 +02:00
![raygui default style](styles/default/style_default.png)
2019-08-28 11:54:36 +02:00
Some additional styles are also provided for convenience, just check [styles directory](styles) for details:
![raygui additional styles](images/raygui_style_table_multi.png)
2021-07-28 12:55:58 +02:00
Custom styles can also be created very easily using [rGuiStyler](https://raylibtech.itch.io/rguistyler) tool.
2019-08-28 11:54:36 +02:00
Styles can be loaded at runtime using raygui `GuiLoadStyle()` function. Simple and easy-to-use.
2019-08-28 12:26:35 +02:00
2020-02-10 16:58:44 +01:00
## raygui icons
2019-08-28 11:54:36 +02:00
2021-10-12 15:13:41 +02:00
`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`.
2019-08-28 11:54:36 +02:00
<img align="right" src="images/raygui_ricons.png">
2021-10-12 15:13:41 +02:00
To use any of those icons just prefix the *#iconId#* number to **any text** written within `raygui` controls:
2019-08-28 11:54:36 +02:00
```c
if (GuiButton(rec, "#05#Open Image")) { /* ACTION */ }
2019-08-28 11:54:36 +02:00
```
2021-10-12 15:13:41 +02:00
It's also possible to use the provided `GuiIconText()` function to prefix it automatically, using a clearer identifier (defined in `raygui.h`).
2019-08-28 11:54:36 +02:00
```c
if (GuiButton(rec, GuiIconText(RICON_FILE_OPEN, "Open Image"))) { /* ACTION */ }
```
2021-10-05 16:00:25 +02:00
Provided set of icons can be reviewed and customized using [rGuiIcons](https://raylibtech.itch.io/rguiicons) tool.
2016-09-07 18:25:06 +02:00
2021-10-05 12:47:54 +02:00
## raygui support tools
2021-10-05 13:45:17 +02:00
- [**rGuiStyler**](https://raylibtech.itch.io/rguistyler) - A simple and easy-to-use raygui styles editor.
2021-10-05 12:47:54 +02:00
2021-10-05 13:45:17 +02:00
![rGuiStyler v3.1](images/rguistyler_v300.png)
2021-10-05 12:47:54 +02:00
2021-10-05 13:45:17 +02:00
- [**rGuiIcons**](https://raylibtech.itch.io/rguiicons) - A simple and easy-to-use raygui icons editor.
2021-10-05 12:47:54 +02:00
2021-10-05 13:45:17 +02:00
![rGuiIcons v1.0](images/rguiicons_v100.png)
2021-10-05 12:47:54 +02:00
2021-10-05 13:45:17 +02:00
- [**rGuiLayout**](https://raylibtech.itch.io/rguilayout) - A simple and easy-to-use raygui layouts editor.
2021-10-05 12:47:54 +02:00
2021-10-05 13:45:17 +02:00
![rGuiLayout v2.2](images/rguilayout_v220.png)
2021-10-05 12:47:54 +02:00
2021-10-05 13:45:17 +02:00
## building
2021-10-05 12:47:54 +02:00
2021-10-12 15:13:41 +02:00
`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:
2021-10-05 12:47:54 +02:00
2021-10-05 13:45:17 +02:00
- **Windows (MinGW, GCC)**
```
copy src/raygui.h src/raygui.c
2021-10-05 13:45:17 +02:00
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)**
```
copy src\raygui.h src\raygui.c
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
2021-10-05 13:45:17 +02:00
```
2021-10-05 13:45:17 +02:00
- **Linux (GCC)**
```
2021-10-05 13:45:17 +02:00
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
```
2022-03-19 02:58:05 -07:00
- **Mac (clang, homebrew installed raylib)**
```
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)
```
2021-10-05 12:47:54 +02:00
## license
2016-09-07 18:25:06 +02:00
2020-02-28 10:19:21 +01:00
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.