mirror of
https://github.com/raysan5/raygui.git
synced 2025-12-25 10:22:33 -05:00
Compare commits
139 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| af51e4ccf7 | |||
| 61c6bd22f9 | |||
| 0d3dc299cd | |||
| ba2fdec93b | |||
| a5068756be | |||
| 22c0b5754a | |||
| e4db44518e | |||
| 4e1a1d2348 | |||
| 405f7ab7e8 | |||
| e86d0dc2bf | |||
| a456bcb763 | |||
| 31a38d34fc | |||
| a770a93fb2 | |||
| 1a9f0fbe9c | |||
| 283716857c | |||
| 2fa812484c | |||
| f822fb1468 | |||
| 8c70f3315a | |||
| 8993f07c94 | |||
| 7c63e389b8 | |||
| 0ed765cd8b | |||
| f1853f50e7 | |||
| b0dfa6dcbf | |||
| f7abbc055f | |||
| 46243ef6d2 | |||
| 2bb3e17c1e | |||
| 734d067335 | |||
| e81fd89b6d | |||
| c1af7c3edd | |||
| 469496d177 | |||
| 653ee23f58 | |||
| 181f41cee0 | |||
| d45a0f55f1 | |||
| 3e1162bb9a | |||
| fc43382050 | |||
| c1d906855b | |||
| d871bc0641 | |||
| 8197be08d8 | |||
| 424ad14d3c | |||
| c3dc43d4c5 | |||
| cf45f9bccf | |||
| 873c6a95b3 | |||
| 24e0dd6600 | |||
| 2083c6984a | |||
| 0907bee71b | |||
| 65e39bb4bc | |||
| bad9c8bb58 | |||
| d5856e5182 | |||
| 76c6184c49 | |||
| 6edd0865c0 | |||
| a4a6ff98b3 | |||
| 78f24a3868 | |||
| 045d4856f0 | |||
| d215533b5a | |||
| 806b216e20 | |||
| d77bd5f3ef | |||
| c2bee39e0b | |||
| d2752e9a47 | |||
| 6b216626ec | |||
| 13aac618ad | |||
| a11fb5f38d | |||
| ef99aafee9 | |||
| 3749de3ef8 | |||
| 0cbbb48410 | |||
| 3627bb960a | |||
| 28d7584fc1 | |||
| b4288f969c | |||
| 7dae5b06f7 | |||
| f5bd6c08f8 | |||
| 3b44da667b | |||
| 60605f01b6 | |||
| a380ef80c1 | |||
| 7eda4008e2 | |||
| b73eb56f3c | |||
| 07b30c30af | |||
| 95b225b90c | |||
| 6d2d6819fa | |||
| 4eda62925c | |||
| 3e61557f25 | |||
| 65bad19e26 | |||
| 4643d3769d | |||
| 8c33be58b2 | |||
| 8a38a8028e | |||
| 76d734bb30 | |||
| 4758b45676 | |||
| fa8b958a91 | |||
| feb1a6c874 | |||
| e689c710e4 | |||
| 0fdacc87f6 | |||
| 5191022a6b | |||
| 3e1d420e60 | |||
| 7f4794c31d | |||
| 6346ae2246 | |||
| b2974f3d28 | |||
| 18a32e61ab | |||
| 6cf73a3054 | |||
| 9d911f7104 | |||
| d3c810311c | |||
| d878d38e40 | |||
| 9d1e48bfe6 | |||
| 24de442135 | |||
| 6f80bfbbd1 | |||
| ffdeef8d17 | |||
| b8932dab26 | |||
| d297b5d7d9 | |||
| 1f088bf174 | |||
| fd349ca95c | |||
| 8d5f8f28a4 | |||
| efe2a42cee | |||
| 4fb2b73a15 | |||
| aa28f6c759 | |||
| e1e296583e | |||
| 962661b7ea | |||
| 4047b43b10 | |||
| 146068751c | |||
| fce438cd1c | |||
| 09d583687a | |||
| 9f589be0c2 | |||
| 40ceed83cc | |||
| 0843425e4e | |||
| f296f53a1c | |||
| 1beef1c0e0 | |||
| 9fd0f91dea | |||
| 1cc900bff9 | |||
| a2c5ffc272 | |||
| 58307af091 | |||
| 72eac06c29 | |||
| 416df0ad4e | |||
| b312ba5f78 | |||
| 48c355315b | |||
| e9833c1a4f | |||
| 2c96d4a157 | |||
| f164f744ac | |||
| 00fb56245d | |||
| 6469c92b69 | |||
| d3b2f49da3 | |||
| 5572d37fe0 | |||
| b888ce73ef | |||
| ffb1d9f9a8 |
28
.gitignore
vendored
28
.gitignore
vendored
@ -34,3 +34,31 @@
|
|||||||
|
|
||||||
# VSCode files
|
# VSCode files
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
|
|
||||||
|
# Ignore files build by Visual Studio
|
||||||
|
[Dd]ebug
|
||||||
|
[Rr]elease
|
||||||
|
*.vs
|
||||||
|
*.obj
|
||||||
|
*.pdb
|
||||||
|
*.aps
|
||||||
|
*.user
|
||||||
|
# *.vcproj
|
||||||
|
# *.vcxproj*
|
||||||
|
# *.sln
|
||||||
|
*.vspscc
|
||||||
|
*_i.c
|
||||||
|
*.i
|
||||||
|
*.icf
|
||||||
|
*_p.c
|
||||||
|
*.ncb
|
||||||
|
*.suo
|
||||||
|
*.tlb
|
||||||
|
*.tlh
|
||||||
|
*.bak
|
||||||
|
*.cache
|
||||||
|
*.ilk
|
||||||
|
*.log
|
||||||
|
|
||||||
|
build
|
||||||
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
zlib License
|
zlib License
|
||||||
|
|
||||||
Copyright (c) 2014-2019 Ramon Santamaria (@raysan5)
|
Copyright (c) 2014-2021 Ramon Santamaria (@raysan5)
|
||||||
|
|
||||||
This software is provided "as-is", without any express or implied warranty. In no event
|
This software is provided "as-is", without any express or implied warranty. In no event
|
||||||
will the authors be held liable for any damages arising from the use of this software.
|
will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
|||||||
90
README.md
90
README.md
@ -1,35 +1,44 @@
|
|||||||
<img align="left" src="logo/raygui_256x256.png" width=256>
|
<img align="left" src="logo/raygui_256x256.png" width=256>
|
||||||
|
|
||||||
**raygui** is a simple and easy-to-use immediate-mode-gui library.
|
**raygui is a simple and easy-to-use immediate-mode-gui library.**
|
||||||
|
|
||||||
raygui was initially inspired by [Unity IMGUI](https://docs.unity3d.com/Manual/GUIScriptingGuide.html) (immediate mode GUI API).
|
`raygui` was initially inspired by [Unity IMGUI](https://docs.unity3d.com/Manual/GUIScriptingGuide.html) (immediate mode GUI API).
|
||||||
|
|
||||||
raygui was originated as an auxiliar module for [raylib](https://github.com/raysan5/raylib) to create simple GUI interfaces using raylib graphic style (simple colors, plain rectangular shapes, wide borders, raylib default font...).
|
`raygui` was originated as an auxiliar module for [raylib](https://github.com/raysan5/raylib) to create simple GUI interfaces using raylib graphic style (simple colors, plain rectangular shapes, wide borders...).
|
||||||
|
|
||||||
raygui is intended for **tools development**; it has already been used to develop the following tools: [rFXGen](https://github.com/raysan5/rfxgen), [rTexViewer](https://raylibtech.itch.io/rtexviewer), [rGuiStyler](https://raylibtech.itch.io/rguistyler) and [rGuiLayout](https://raylibtech.itch.io/rguilayout).
|
`raygui` is intended for **tools development**; it has already been used to develop [multiple published tools](https://raylibtech.itch.io/rguiicons).
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## raygui provided controls
|
## features
|
||||||
|
|
||||||
#### Container/separator controls
|
- **Immediate-mode** gui, no retained data
|
||||||
|
- **+28** basic and advance controls provided
|
||||||
|
- 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
|
||||||
|
|
||||||
|
## raygui controls
|
||||||
|
|
||||||
|
### basic controls
|
||||||
```
|
```
|
||||||
WindowBox | GroupBox | Line | Panel
|
Label | Button | LabelButton | Toggle | ToggleGroup | CheckBox
|
||||||
```
|
|
||||||
#### Basic controls
|
|
||||||
```
|
|
||||||
Label | Button | LabelButton | ImageButton | Toggle | ToggleGroup | CheckBox
|
|
||||||
ComboBox | DropdownBox | TextBox | TextBoxMulti | ValueBox | Spinner | Slider
|
ComboBox | DropdownBox | TextBox | TextBoxMulti | ValueBox | Spinner | Slider
|
||||||
SliderBar | ProgressBar | StatusBar | ScrollBar | ScrollPanel | DummyRec | Grid
|
SliderBar | ProgressBar | StatusBar | ScrollBar | ScrollPanel | DummyRec | Grid
|
||||||
```
|
```
|
||||||
#### Advance controls
|
### advance controls
|
||||||
```
|
```
|
||||||
ListView | ColorPicker | MessageBox | TextInputBox
|
ListView | ColorPicker | MessageBox | TextInputBox
|
||||||
```
|
```
|
||||||
|
### container/separator controls
|
||||||
|
```
|
||||||
|
WindowBox | GroupBox | Line | Panel
|
||||||
|
```
|
||||||
|
|
||||||
## raygui styles
|
## raygui styles
|
||||||
|
|
||||||
raygui comes with a [default](styles/default) style automatically loaded at runtime:
|
`raygui` comes with a [default](styles/default) style automatically loaded at runtime:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@ -41,31 +50,52 @@ Custom styles can also be created very easily using [rGuiStyler](https://raylibt
|
|||||||
|
|
||||||
Styles can be loaded at runtime using raygui `GuiLoadStyle()` function. Simple and easy-to-use.
|
Styles can be loaded at runtime using raygui `GuiLoadStyle()` function. Simple and easy-to-use.
|
||||||
|
|
||||||

|
## raygui icons
|
||||||
|
|
||||||
*rGuiStyler v3.1 - raygui styles editor, useful to create custom styles*
|
`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`.
|
||||||
|
|
||||||
## raygui icons: ricons
|
|
||||||
|
|
||||||
`raygui` includes a separate module with a set of custom handcrafter icons, ready to be used and integrated in a easy way with `raygui`. This module is called `ricons.h` and can be automatically included just defining `RAYGUI_SUPPORT_RICONS` before including `raygui`.
|
|
||||||
|
|
||||||
<img align="right" src="images/raygui_ricons.png">
|
<img align="right" src="images/raygui_ricons.png">
|
||||||
|
|
||||||
|
To use any of those icons just prefix the *#iconId#* number to **any text** written within `raygui` controls:
|
||||||
```c
|
```c
|
||||||
#define RAYGUI_IMPLEMENTATION
|
if (GuiButton(rec, "#05#Open Image")) { /* ACTION */ }
|
||||||
#define RAYGUI_SUPPORT_RICONS
|
|
||||||
#include "raygui.h"
|
|
||||||
```
|
```
|
||||||
To use any of those icons in your gui, just preprend *iconId* to any text written within `raygui` controls:
|
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, "#05#Open Image") { /* ACTION */ }
|
|
||||||
```
|
|
||||||
or use the provided `GuiIconText()` function to prepend it automatically, using a clearer identifier.
|
|
||||||
```c
|
```c
|
||||||
if (GuiButton(rec, GuiIconText(RICON_FILE_OPEN, "Open Image"))) { /* ACTION */ }
|
if (GuiButton(rec, GuiIconText(RICON_FILE_OPEN, "Open Image"))) { /* ACTION */ }
|
||||||
```
|
```
|
||||||
|
Provided set of icons can be reviewed and customized using [rGuiIcons](https://raylibtech.itch.io/rguiicons) tool.
|
||||||
|
|
||||||
license
|
## raygui support tools
|
||||||
-------
|
|
||||||
|
|
||||||
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.md) for further details.
|
- [**rGuiStyler**](https://raylibtech.itch.io/rguistyler) - A simple and easy-to-use raygui styles editor.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- [**rGuiIcons**](https://raylibtech.itch.io/rguiicons) - A simple and easy-to-use raygui icons editor.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
- [**rGuiLayout**](https://raylibtech.itch.io/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)**
|
||||||
|
```
|
||||||
|
copy src/raylib.h src/raylib.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
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Linux (GCC)**
|
||||||
|
```
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
## 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](LICENSE) for further details.
|
||||||
|
|||||||
@ -352,7 +352,8 @@ EXAMPLES = \
|
|||||||
image_raw_importer/image_raw_importer \
|
image_raw_importer/image_raw_importer \
|
||||||
portable_window/portable_window \
|
portable_window/portable_window \
|
||||||
scroll_panel/gui_scroll_panel \
|
scroll_panel/gui_scroll_panel \
|
||||||
text_box_selection/gui_text_box
|
text_box_selection/textbox_extended_demo \
|
||||||
|
text_editor/text_editor
|
||||||
|
|
||||||
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
|
CURRENT_MAKEFILE = $(lastword $(MAKEFILE_LIST))
|
||||||
|
|
||||||
|
|||||||
@ -22,25 +22,24 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* DEPENDENCIES:
|
* DEPENDENCIES:
|
||||||
* raylib 2.6-dev - Windowing/input management and drawing.
|
* raylib 4.0 - Windowing/input management and drawing.
|
||||||
* raygui 2.6-dev - Immediate-mode GUI controls.
|
* raygui 3.0 - Immediate-mode GUI controls.
|
||||||
*
|
*
|
||||||
* COMPILATION (Windows - MinGW):
|
* COMPILATION (Windows - MinGW):
|
||||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
||||||
*
|
*
|
||||||
* LICENSE: zlib/libpng
|
* LICENSE: zlib/libpng
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019 raylib technologies (@raylibtech)
|
* Copyright (c) 2016-2021 Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
#define RAYGUI_IMPLEMENTATION
|
#define RAYGUI_IMPLEMENTATION
|
||||||
#define RAYGUI_SUPPORT_RICONS
|
|
||||||
#include "../../src/raygui.h"
|
#include "../../src/raygui.h"
|
||||||
|
|
||||||
#undef RAYGUI_IMPLEMENTATION // Avoid including raygui implementation again
|
#include <string.h> // Required for: strcpy()
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
@ -49,8 +48,8 @@ int main()
|
|||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
int screenWidth = 690;
|
const int screenWidth = 690;
|
||||||
int screenHeight = 560;
|
const int screenHeight = 560;
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raygui - controls test suite");
|
InitWindow(screenWidth, screenHeight, "raygui - controls test suite");
|
||||||
SetExitKey(0);
|
SetExitKey(0);
|
||||||
@ -80,7 +79,7 @@ int main()
|
|||||||
int listViewExFocus = -1;
|
int listViewExFocus = -1;
|
||||||
const char *listViewExList[8] = { "This", "is", "a", "list view", "with", "disable", "elements", "amazing!" };
|
const char *listViewExList[8] = { "This", "is", "a", "list view", "with", "disable", "elements", "amazing!" };
|
||||||
|
|
||||||
char multiTextBoxText[141] = "Multi text box";
|
char multiTextBoxText[256] = "Multi text box";
|
||||||
bool multiTextBoxEditMode = false;
|
bool multiTextBoxEditMode = false;
|
||||||
Color colorPickerValue = RED;
|
Color colorPickerValue = RED;
|
||||||
|
|
||||||
@ -127,10 +126,10 @@ int main()
|
|||||||
|
|
||||||
if (IsFileDropped())
|
if (IsFileDropped())
|
||||||
{
|
{
|
||||||
int dropsCount = 0;
|
int dropFileCount = 0;
|
||||||
char **droppedFiles = GetDroppedFiles(&dropsCount);
|
char **droppedFiles = GetDroppedFiles(&dropFileCount);
|
||||||
|
|
||||||
if ((dropsCount > 0) && IsFileExtension(droppedFiles[0], ".rgs")) GuiLoadStyle(droppedFiles[0]);
|
if ((dropFileCount > 0) && IsFileExtension(droppedFiles[0], ".rgs")) GuiLoadStyle(droppedFiles[0]);
|
||||||
|
|
||||||
ClearDroppedFiles(); // Clear internal buffers
|
ClearDroppedFiles(); // Clear internal buffers
|
||||||
}
|
}
|
||||||
@ -145,6 +144,7 @@ int main()
|
|||||||
// raygui: controls drawing
|
// raygui: controls drawing
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (dropDown000EditMode || dropDown001EditMode) GuiLock();
|
if (dropDown000EditMode || dropDown001EditMode) GuiLock();
|
||||||
|
else if (!dropDown000EditMode && !dropDown001EditMode) GuiUnlock();
|
||||||
//GuiDisable();
|
//GuiDisable();
|
||||||
|
|
||||||
// First GUI column
|
// First GUI column
|
||||||
@ -163,13 +163,13 @@ int main()
|
|||||||
if (GuiButton((Rectangle){ 25, 255, 125, 30 }, GuiIconText(RICON_FILE_SAVE, "Save File"))) showTextInputBox = true;
|
if (GuiButton((Rectangle){ 25, 255, 125, 30 }, GuiIconText(RICON_FILE_SAVE, "Save File"))) showTextInputBox = true;
|
||||||
|
|
||||||
GuiGroupBox((Rectangle){ 25, 310, 125, 150 }, "STATES");
|
GuiGroupBox((Rectangle){ 25, 310, 125, 150 }, "STATES");
|
||||||
GuiLock();
|
//GuiLock();
|
||||||
GuiSetState(GUI_STATE_NORMAL); if (GuiButton((Rectangle){ 30, 320, 115, 30 }, "NORMAL")) { }
|
GuiSetState(GUI_STATE_NORMAL); if (GuiButton((Rectangle){ 30, 320, 115, 30 }, "NORMAL")) { }
|
||||||
GuiSetState(GUI_STATE_FOCUSED); if (GuiButton((Rectangle){ 30, 355, 115, 30 }, "FOCUSED")) { }
|
GuiSetState(GUI_STATE_FOCUSED); if (GuiButton((Rectangle){ 30, 355, 115, 30 }, "FOCUSED")) { }
|
||||||
GuiSetState(GUI_STATE_PRESSED); if (GuiButton((Rectangle){ 30, 390, 115, 30 }, "#15#PRESSED")) { }
|
GuiSetState(GUI_STATE_PRESSED); if (GuiButton((Rectangle){ 30, 390, 115, 30 }, "#15#PRESSED")) { }
|
||||||
GuiSetState(GUI_STATE_DISABLED); if (GuiButton((Rectangle){ 30, 425, 115, 30 }, "DISABLED")) { }
|
GuiSetState(GUI_STATE_DISABLED); if (GuiButton((Rectangle){ 30, 425, 115, 30 }, "DISABLED")) { }
|
||||||
GuiSetState(GUI_STATE_NORMAL);
|
GuiSetState(GUI_STATE_NORMAL);
|
||||||
GuiUnlock();
|
//GuiUnlock();
|
||||||
|
|
||||||
comboBoxActive = GuiComboBox((Rectangle){ 25, 470, 125, 30 }, "ONE;TWO;THREE;FOUR", comboBoxActive);
|
comboBoxActive = GuiComboBox((Rectangle){ 25, 470, 125, 30 }, "ONE;TWO;THREE;FOUR", comboBoxActive);
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ int main()
|
|||||||
toggleGroupActive = GuiToggleGroup((Rectangle){ 165, 400, 140, 25 }, "#1#ONE\n#3#TWO\n#8#THREE\n#23#", toggleGroupActive);
|
toggleGroupActive = GuiToggleGroup((Rectangle){ 165, 400, 140, 25 }, "#1#ONE\n#3#TWO\n#8#THREE\n#23#", toggleGroupActive);
|
||||||
|
|
||||||
// Third GUI column
|
// Third GUI column
|
||||||
if (GuiTextBoxMulti((Rectangle){ 320, 25, 225, 140 }, multiTextBoxText, 141, multiTextBoxEditMode)) multiTextBoxEditMode = !multiTextBoxEditMode;
|
if (GuiTextBoxMulti((Rectangle){ 320, 25, 225, 140 }, multiTextBoxText, 256, multiTextBoxEditMode)) multiTextBoxEditMode = !multiTextBoxEditMode;
|
||||||
colorPickerValue = GuiColorPicker((Rectangle){ 320, 185, 196, 192 }, colorPickerValue);
|
colorPickerValue = GuiColorPicker((Rectangle){ 320, 185, 196, 192 }, colorPickerValue);
|
||||||
|
|
||||||
sliderValue = GuiSlider((Rectangle){ 355, 400, 165, 20 }, "TEST", TextFormat("%2.2f", (float)sliderValue), sliderValue, -50, 100);
|
sliderValue = GuiSlider((Rectangle){ 355, 400, 165, 20 }, "TEST", TextFormat("%2.2f", (float)sliderValue), sliderValue, -50, 100);
|
||||||
@ -228,8 +228,6 @@ int main()
|
|||||||
strcpy(textInput, "\0");
|
strcpy(textInput, "\0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiUnlock();
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|||||||
@ -3,26 +3,24 @@
|
|||||||
* raygui - custom file dialog to load image
|
* raygui - custom file dialog to load image
|
||||||
*
|
*
|
||||||
* DEPENDENCIES:
|
* DEPENDENCIES:
|
||||||
* raylib 2.6-dev - Windowing/input management and drawing.
|
* raylib 4.0 - Windowing/input management and drawing.
|
||||||
* raygui 2.6-dev - Immediate-mode GUI controls.
|
* raygui 3.0 - Immediate-mode GUI controls.
|
||||||
*
|
*
|
||||||
* COMPILATION (Windows - MinGW):
|
* COMPILATION (Windows - MinGW):
|
||||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
||||||
*
|
*
|
||||||
* LICENSE: zlib/libpng
|
* LICENSE: zlib/libpng
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019 raylib technologies (@raylibtech)
|
* Copyright (c) 2016-2021 Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
#define RAYGUI_IMPLEMENTATION
|
#define RAYGUI_IMPLEMENTATION
|
||||||
#define RAYGUI_SUPPORT_RICONS
|
|
||||||
#include "../../src/raygui.h"
|
#include "../../src/raygui.h"
|
||||||
|
|
||||||
#undef RAYGUI_IMPLEMENTATION // Avoid including raygui implementation again
|
#undef RAYGUI_IMPLEMENTATION // Avoid including raygui implementation again
|
||||||
|
|
||||||
#define GUI_FILE_DIALOG_IMPLEMENTATION
|
#define GUI_FILE_DIALOG_IMPLEMENTATION
|
||||||
#include "gui_file_dialog.h"
|
#include "gui_file_dialog.h"
|
||||||
|
|
||||||
@ -40,7 +38,7 @@ int main()
|
|||||||
SetExitKey(0);
|
SetExitKey(0);
|
||||||
|
|
||||||
// Custom file dialog
|
// Custom file dialog
|
||||||
GuiFileDialogState fileDialogState = InitGuiFileDialog();
|
GuiFileDialogState fileDialogState = InitGuiFileDialog(420, 310, GetWorkingDirectory(), false);
|
||||||
|
|
||||||
bool exitWindow = false;
|
bool exitWindow = false;
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************************
|
/*******************************************************************************************
|
||||||
*
|
*
|
||||||
* FileDialog v1.0.0 - Modal file dialog to open/save files
|
* FileDialog v1.1 - Modal file dialog to open/save files
|
||||||
*
|
*
|
||||||
* MODULE USAGE:
|
* MODULE USAGE:
|
||||||
* #define GUI_FILE_DIALOG_IMPLEMENTATION
|
* #define GUI_FILE_DIALOG_IMPLEMENTATION
|
||||||
@ -16,13 +16,24 @@
|
|||||||
* - DirectoryExists()
|
* - DirectoryExists()
|
||||||
* - FileExists()
|
* - FileExists()
|
||||||
*
|
*
|
||||||
* LICENSE: Propietary License
|
* LICENSE: zlib/libpng
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019 raylib technologies (@raylibtech). All Rights Reserved.
|
* Copyright (c) 2019-2021 Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
* Unauthorized copying of this file, via any medium is strictly prohibited
|
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||||
* This project is proprietary and confidential unless the owner allows
|
* will the authors be held liable for any damages arising from the use of this software.
|
||||||
* usage in any other form by expresely written permission.
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose, including commercial
|
||||||
|
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
||||||
|
* wrote the original software. If you use this software in a product, an acknowledgment
|
||||||
|
* in the product documentation would be appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
||||||
|
* as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
*
|
*
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
|
|
||||||
@ -37,6 +48,7 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Vector2 position;
|
Vector2 position;
|
||||||
|
Vector2 size;
|
||||||
|
|
||||||
bool fileDialogActive;
|
bool fileDialogActive;
|
||||||
|
|
||||||
@ -52,6 +64,7 @@ typedef struct {
|
|||||||
bool SelectFilePressed;
|
bool SelectFilePressed;
|
||||||
bool CancelFilePressed;
|
bool CancelFilePressed;
|
||||||
int fileTypeActive;
|
int fileTypeActive;
|
||||||
|
int itemFocused;
|
||||||
|
|
||||||
// Custom state variables (depend on development software)
|
// Custom state variables (depend on development software)
|
||||||
// NOTE: This variables should be added manually if required
|
// NOTE: This variables should be added manually if required
|
||||||
@ -89,7 +102,7 @@ extern "C" { // Prevents name mangling of functions
|
|||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module Functions Declaration
|
// Module Functions Declaration
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
GuiFileDialogState InitGuiFileDialog(void);
|
GuiFileDialogState InitGuiFileDialog(int width, int height, const char *initPath, bool active);
|
||||||
void GuiFileDialog(GuiFileDialogState *state);
|
void GuiFileDialog(GuiFileDialogState *state);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -128,12 +141,15 @@ typedef struct FileInfo {
|
|||||||
int type;
|
int type;
|
||||||
int icon;
|
int icon;
|
||||||
} FileInfo;
|
} FileInfo;
|
||||||
|
#else
|
||||||
|
// Filename only
|
||||||
|
typedef char *FileInfo;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Global Variables Definition
|
// Global Variables Definition
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
char **dirFilesIcon = NULL;
|
FileInfo *dirFilesIcon = NULL;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Internal Module Functions Definition
|
// Internal Module Functions Definition
|
||||||
@ -143,19 +159,22 @@ static char **ReadDirectoryFiles(const char *dir, int *filesCount, char *filterE
|
|||||||
|
|
||||||
#if defined(USE_CUSTOM_LISTVIEW_FILEINFO)
|
#if defined(USE_CUSTOM_LISTVIEW_FILEINFO)
|
||||||
// List View control for files info with extended parameters
|
// List View control for files info with extended parameters
|
||||||
static int GuiListViewFiles(Rectangle bounds, FileInfo *files, int count, int *focus, int *scrollIndex, int active)
|
static int GuiListViewFiles(Rectangle bounds, FileInfo *files, int count, int *focus, int *scrollIndex, int active);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module Functions Definition
|
// Module Functions Definition
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
GuiFileDialogState InitGuiFileDialog(void)
|
GuiFileDialogState InitGuiFileDialog(int width, int height, const char *initPath, bool active)
|
||||||
{
|
{
|
||||||
GuiFileDialogState state = { 0 };
|
GuiFileDialogState state = { 0 };
|
||||||
|
|
||||||
state.position = (Vector2){ GetScreenWidth()/2 - 480/2, GetScreenHeight()/2 - 305/2 };
|
// Default dialog size is 440x310
|
||||||
|
state.size.x = width == -1 ? 440 : width;
|
||||||
|
state.size.y = height == -1 ? 310 : height;
|
||||||
|
state.position = (Vector2){ GetScreenWidth()/2 - state.size.x/2, GetScreenHeight()/2 - state.size.y/2 };
|
||||||
|
|
||||||
state.fileDialogActive = false;
|
state.fileDialogActive = active;
|
||||||
state.dirPathEditMode = false;
|
state.dirPathEditMode = false;
|
||||||
|
|
||||||
state.filesListActive = -1;
|
state.filesListActive = -1;
|
||||||
@ -169,58 +188,91 @@ GuiFileDialogState InitGuiFileDialog(void)
|
|||||||
|
|
||||||
state.fileTypeActive = 0;
|
state.fileTypeActive = 0;
|
||||||
|
|
||||||
|
strcpy(state.fileNameText, "\0");
|
||||||
|
|
||||||
// Custom variables initialization
|
// Custom variables initialization
|
||||||
strcpy(state.dirPathText, GetWorkingDirectory());
|
if (initPath && DirectoryExists(initPath))
|
||||||
|
{
|
||||||
|
strcpy(state.dirPathText, initPath);
|
||||||
|
}
|
||||||
|
else if (initPath && FileExists(initPath))
|
||||||
|
{
|
||||||
|
strcpy(state.dirPathText, GetDirectoryPath(initPath));
|
||||||
|
strcpy(state.fileNameText, GetFileName(initPath));
|
||||||
|
}
|
||||||
|
else strcpy(state.dirPathText, GetWorkingDirectory());
|
||||||
|
|
||||||
strcpy(state.dirPathTextCopy, state.dirPathText);
|
strcpy(state.dirPathTextCopy, state.dirPathText);
|
||||||
|
strcpy(state.fileNameTextCopy, state.fileNameText);
|
||||||
|
|
||||||
strcpy(state.filterExt, "all");
|
strcpy(state.filterExt, "all");
|
||||||
|
|
||||||
state.dirFilesCount = 0;
|
state.dirFilesCount = 0;
|
||||||
state.dirFiles = NULL; // NOTE: Loaded lazily on window active
|
state.dirFiles = NULL; // NOTE: Loaded lazily on window active
|
||||||
|
|
||||||
strcpy(state.fileNameText, "\0");
|
|
||||||
strcpy(state.fileNameTextCopy, state.fileNameText);
|
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read files in new path
|
||||||
|
static void FD_RELOAD_DIRPATH(GuiFileDialogState *state)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < state->dirFilesCount; i++) RL_FREE(state->dirFiles[i]);
|
||||||
|
RL_FREE(state->dirFiles);
|
||||||
|
|
||||||
|
state->dirFiles = ReadDirectoryFiles(state->dirPathText, &state->dirFilesCount, state->filterExt);
|
||||||
|
state->itemFocused = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update and draw file dialog
|
||||||
void GuiFileDialog(GuiFileDialogState *state)
|
void GuiFileDialog(GuiFileDialogState *state)
|
||||||
{
|
{
|
||||||
if (state->fileDialogActive)
|
if (state->fileDialogActive)
|
||||||
{
|
{
|
||||||
|
const int winWidth = state->size.x;
|
||||||
|
const int winHeight = state->size.y;
|
||||||
|
|
||||||
// Load dirFilesIcon and state->dirFiles lazily on windows open
|
// Load dirFilesIcon and state->dirFiles lazily on windows open
|
||||||
// NOTE: they are automatically unloaded at fileDialog closing
|
// NOTE: they are automatically unloaded at fileDialog closing
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
if (dirFilesIcon == NULL)
|
if (dirFilesIcon == NULL)
|
||||||
{
|
{
|
||||||
dirFilesIcon = (char **)RL_MALLOC(MAX_DIRECTORY_FILES*sizeof(char *)); // Max files to read
|
dirFilesIcon = (FileInfo *)RL_MALLOC(MAX_DIRECTORY_FILES*sizeof(FileInfo)); // Max files to read
|
||||||
for (int i = 0; i < MAX_DIRECTORY_FILES; i++) dirFilesIcon[i] = (char *)calloc(MAX_DIR_PATH_LENGTH, 1); // Max file name length
|
for (int i = 0; i < MAX_DIRECTORY_FILES; i++) dirFilesIcon[i] = (char *)calloc(MAX_DIR_PATH_LENGTH, 1); // Max file name length
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->dirFiles == NULL) state->dirFiles = ReadDirectoryFiles(state->dirPathText, &state->dirFilesCount, state->filterExt);
|
if (state->dirFiles == NULL)
|
||||||
|
{
|
||||||
|
state->dirFiles = ReadDirectoryFiles(state->dirPathText, &state->dirFilesCount, state->filterExt);
|
||||||
|
|
||||||
|
for(int f = 0; f < state->dirFilesCount; f++)
|
||||||
|
{
|
||||||
|
if (strcmp(state->fileNameText, state->dirFiles[f]) == 0)
|
||||||
|
{
|
||||||
|
if (state->filesListActive != f) state->filesListScrollIndex = state->filesListActive = f; // Make it active and visible only on first call
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
|
|
||||||
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)), 0.85f));
|
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)), 0.85f));
|
||||||
state->fileDialogActive = !GuiWindowBox((Rectangle){ state->position.x + 0, state->position.y + 0, 480, 310 }, "#198#Select File Dialog");
|
state->fileDialogActive = !GuiWindowBox((Rectangle){ state->position.x + 0, state->position.y + 0, winWidth, winHeight }, "#198# Select File Dialog");
|
||||||
|
|
||||||
if (GuiButton((Rectangle){ state->position.x + 430, state->position.y + 35, 40, 25 }, "< .."))
|
if (GuiButton((Rectangle){ state->position.x + winWidth - 50, state->position.y + 35, 40, 25 }, "< ..")) // || IsKeyReleased(KEY_DPAD_Y))
|
||||||
{
|
{
|
||||||
// Move dir path one level up
|
// Move dir path one level up
|
||||||
strcpy(state->dirPathText, GetPrevDirectoryPath(state->dirPathText));
|
strcpy(state->dirPathText, GetPrevDirectoryPath(state->dirPathText));
|
||||||
|
|
||||||
// RL_FREE previous dirFiles (reloaded by ReadDirectoryFiles())
|
// RL_FREE previous dirFiles (reloaded by ReadDirectoryFiles())
|
||||||
for (int i = 0; i < state->dirFilesCount; i++) RL_FREE(state->dirFiles[i]);
|
FD_RELOAD_DIRPATH(state);
|
||||||
RL_FREE(state->dirFiles);
|
|
||||||
|
|
||||||
// Read files in the new path
|
|
||||||
state->dirFiles = ReadDirectoryFiles(state->dirPathText, &state->dirFilesCount, state->filterExt);
|
|
||||||
|
|
||||||
state->filesListActive = -1;
|
state->filesListActive = -1;
|
||||||
strcpy(state->fileNameText, "\0");
|
strcpy(state->fileNameText, "\0");
|
||||||
strcpy(state->fileNameTextCopy, state->fileNameText);
|
strcpy(state->fileNameTextCopy, state->fileNameText);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GuiTextBox((Rectangle){ state->position.x + 10, state->position.y + 35, 410, 25 }, state->dirPathText, 256, state->dirPathEditMode))
|
if (GuiTextBox((Rectangle){ state->position.x + 10, state->position.y + 35, winWidth - 65, 25 }, state->dirPathText, 256, state->dirPathEditMode))
|
||||||
{
|
{
|
||||||
if (state->dirPathEditMode)
|
if (state->dirPathEditMode)
|
||||||
{
|
{
|
||||||
@ -228,11 +280,7 @@ void GuiFileDialog(GuiFileDialogState *state)
|
|||||||
if (DirectoryExists(state->dirPathText))
|
if (DirectoryExists(state->dirPathText))
|
||||||
{
|
{
|
||||||
// RL_FREE previous dirFiles (reloaded by ReadDirectoryFiles())
|
// RL_FREE previous dirFiles (reloaded by ReadDirectoryFiles())
|
||||||
for (int i = 0; i < state->dirFilesCount; i++) RL_FREE(state->dirFiles[i]);
|
FD_RELOAD_DIRPATH(state);
|
||||||
RL_FREE(state->dirFiles);
|
|
||||||
|
|
||||||
// Read files in new path
|
|
||||||
state->dirFiles = ReadDirectoryFiles(state->dirPathText, &state->dirFilesCount, state->filterExt);
|
|
||||||
|
|
||||||
strcpy(state->dirPathTextCopy, state->dirPathText);
|
strcpy(state->dirPathTextCopy, state->dirPathText);
|
||||||
}
|
}
|
||||||
@ -243,33 +291,34 @@ void GuiFileDialog(GuiFileDialogState *state)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int prevTextAlignment = GuiGetStyle(LISTVIEW, TEXT_ALIGNMENT);
|
int prevTextAlignment = GuiGetStyle(LISTVIEW, TEXT_ALIGNMENT);
|
||||||
int prevElementsHeight = GuiGetStyle(LISTVIEW, ELEMENTS_HEIGHT);
|
int prevElementsHeight = GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT);
|
||||||
GuiSetStyle(LISTVIEW, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT);
|
GuiSetStyle(LISTVIEW, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT);
|
||||||
GuiSetStyle(LISTVIEW, ELEMENTS_HEIGHT, 24);
|
GuiSetStyle(LISTVIEW, LIST_ITEMS_HEIGHT, 24);
|
||||||
|
|
||||||
// TODO: ListViewElements should be aligned left
|
// TODO: ListViewElements should be aligned left
|
||||||
state->filesListActive = GuiListViewEx((Rectangle){ state->position.x + 10, state->position.y + 70, 460, 164 }, dirFilesIcon, state->dirFilesCount, NULL, &state->filesListScrollIndex, state->filesListActive);
|
# if defined(USE_CUSTOM_LISTVIEW_FILEINFO)
|
||||||
|
FileInfo fileInfo;
|
||||||
|
state->filesListActive = GuiListViewFiles((Rectangle){ state->position.x + 10, state->position.y + 70, winWidth - 20, winHeight - 135 }, fileInfo, state->dirFilesCount, &state->itemFocused, &state->filesListScrollIndex, state->filesListActive);
|
||||||
|
# else
|
||||||
|
state->filesListActive = GuiListViewEx((Rectangle){ state->position.x + 10, state->position.y + 70, winWidth - 20, winHeight - 135 }, (const char**)dirFilesIcon, state->dirFilesCount, &state->itemFocused, &state->filesListScrollIndex, state->filesListActive);
|
||||||
|
# endif
|
||||||
GuiSetStyle(LISTVIEW, TEXT_ALIGNMENT, prevTextAlignment);
|
GuiSetStyle(LISTVIEW, TEXT_ALIGNMENT, prevTextAlignment);
|
||||||
GuiSetStyle(LISTVIEW, ELEMENTS_HEIGHT, prevElementsHeight);
|
GuiSetStyle(LISTVIEW, LIST_ITEMS_HEIGHT, prevElementsHeight);
|
||||||
|
|
||||||
if ((state->filesListActive >= 0) && (state->filesListActive != state->prevFilesListActive))
|
if ((state->filesListActive >= 0) && (state->filesListActive != state->prevFilesListActive))
|
||||||
|
//&& (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) || IsKeyPressed(KEY_ENTER) || IsKeyPressed(KEY_DPAD_A)))
|
||||||
{
|
{
|
||||||
strcpy(state->fileNameText, state->dirFiles[state->filesListActive]);
|
strcpy(state->fileNameText, state->dirFiles[state->filesListActive]);
|
||||||
|
|
||||||
if (DirectoryExists(TextFormat("%s\\%s", state->dirPathText, state->fileNameText)))
|
if (DirectoryExists(TextFormat("%s/%s", state->dirPathText, state->fileNameText)))
|
||||||
{
|
{
|
||||||
if (TextIsEqual(state->fileNameText, "..")) strcpy(state->dirPathText, GetPrevDirectoryPath(state->dirPathText));
|
if (TextIsEqual(state->fileNameText, "..")) strcpy(state->dirPathText, GetPrevDirectoryPath(state->dirPathText));
|
||||||
else strcpy(state->dirPathText, TextFormat("%s\\%s", state->dirPathText, state->fileNameText));
|
else strcpy(state->dirPathText, TextFormat("%s/%s", strcmp(state->dirPathText, "/")==0 ? "" : state->dirPathText, state->fileNameText));
|
||||||
|
|
||||||
strcpy(state->dirPathTextCopy, state->dirPathText);
|
strcpy(state->dirPathTextCopy, state->dirPathText);
|
||||||
|
|
||||||
// RL_FREE previous dirFiles (reloaded by ReadDirectoryFiles())
|
// RL_FREE previous dirFiles (reloaded by ReadDirectoryFiles())
|
||||||
for (int i = 0; i < state->dirFilesCount; i++) RL_FREE(state->dirFiles[i]);
|
FD_RELOAD_DIRPATH(state);
|
||||||
RL_FREE(state->dirFiles);
|
|
||||||
|
|
||||||
// Read files in new path
|
|
||||||
state->dirFiles = ReadDirectoryFiles(state->dirPathText, &state->dirFilesCount, state->filterExt);
|
|
||||||
|
|
||||||
strcpy(state->dirPathTextCopy, state->dirPathText);
|
strcpy(state->dirPathTextCopy, state->dirPathText);
|
||||||
|
|
||||||
@ -281,11 +330,11 @@ void GuiFileDialog(GuiFileDialogState *state)
|
|||||||
state->prevFilesListActive = state->filesListActive;
|
state->prevFilesListActive = state->filesListActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiLabel((Rectangle){ state->position.x + 10, state->position.y + 245, 68, 25 }, "File name:");
|
GuiLabel((Rectangle){ state->position.x + 10, state->position.y + winHeight - 60, 68, 25 }, "File name:");
|
||||||
|
|
||||||
if (GuiTextBox((Rectangle){ state->position.x + 75, state->position.y + 245, 275, 25 }, state->fileNameText, 128, state->fileNameEditMode))
|
if (GuiTextBox((Rectangle){ state->position.x + 75, state->position.y + winHeight - 60, winWidth - 200, 25 }, state->fileNameText, 128, state->fileNameEditMode))
|
||||||
{
|
{
|
||||||
if (state->fileNameText)
|
if (*state->fileNameText)
|
||||||
{
|
{
|
||||||
// Verify if a valid filename has been introduced
|
// Verify if a valid filename has been introduced
|
||||||
if (FileExists(TextFormat("%s/%s", state->dirPathText, state->fileNameText)))
|
if (FileExists(TextFormat("%s/%s", state->dirPathText, state->fileNameText)))
|
||||||
@ -310,14 +359,22 @@ void GuiFileDialog(GuiFileDialogState *state)
|
|||||||
state->fileNameEditMode = !state->fileNameEditMode;
|
state->fileNameEditMode = !state->fileNameEditMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
state->fileTypeActive = GuiComboBox((Rectangle){ state->position.x + 75, state->position.y + 275, 275, 25 }, "All files", state->fileTypeActive);
|
state->fileTypeActive = GuiComboBox((Rectangle){ state->position.x + 75, state->position.y + winHeight - 30, winWidth - 200, 25 }, "All files", state->fileTypeActive);
|
||||||
GuiLabel((Rectangle){ state->position.x + 10, state->position.y + 275, 68, 25 }, "File filter:");
|
GuiLabel((Rectangle){ state->position.x + 10, state->position.y + winHeight - 30, 68, 25 }, "File filter:");
|
||||||
|
|
||||||
state->SelectFilePressed = GuiButton((Rectangle){ state->position.x + 360, state->position.y + 245, 110, 25 }, "Select");
|
state->SelectFilePressed = GuiButton((Rectangle){ state->position.x + winWidth - 120, state->position.y + winHeight - 60, 110,
|
||||||
|
#ifdef PLATFORM_DESKTOP
|
||||||
|
25
|
||||||
|
#else
|
||||||
|
25 + 30
|
||||||
|
#endif
|
||||||
|
}, "Select");// || IsKeyPressed(KEY_ENTER) || IsKeyPressed(KEY_DPAD_A);
|
||||||
|
|
||||||
if (state->SelectFilePressed) state->fileDialogActive = false;
|
if (state->SelectFilePressed) state->fileDialogActive = false;
|
||||||
|
|
||||||
if (GuiButton((Rectangle){ state->position.x + 360, state->position.y + 275, 110, 25 }, "Cancel")) state->fileDialogActive = false;
|
#ifdef PLATFORM_DESKTOP
|
||||||
|
if (GuiButton((Rectangle){ state->position.x + winWidth - 120, state->position.y + winHeight - 30, 110, 25 }, "Quit")) state->fileDialogActive = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
// File dialog has been closed!
|
// File dialog has been closed!
|
||||||
if (!state->fileDialogActive)
|
if (!state->fileDialogActive)
|
||||||
@ -338,6 +395,21 @@ void GuiFileDialog(GuiFileDialogState *state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compare two files from a directory
|
||||||
|
static inline int FileCompare(const char *d1, const char *d2, const char *dir)
|
||||||
|
{
|
||||||
|
const bool b1 = DirectoryExists(TextFormat("%s/%s", dir, d1));
|
||||||
|
const bool b2 = DirectoryExists(TextFormat("%s/%s", dir, d2));
|
||||||
|
|
||||||
|
if (b1 && !b2) return -1;
|
||||||
|
if (!b1 && b2) return 1;
|
||||||
|
|
||||||
|
if (!FileExists(TextFormat("%s/%s", dir, d1))) return 1;
|
||||||
|
if (!FileExists(TextFormat("%s/%s", dir, d2))) return -1;
|
||||||
|
|
||||||
|
return strcmp(d1, d2);
|
||||||
|
}
|
||||||
|
|
||||||
// Read all filenames from directory (supported file types)
|
// Read all filenames from directory (supported file types)
|
||||||
static char **ReadDirectoryFiles(const char *dir, int *filesCount, char *filterExt)
|
static char **ReadDirectoryFiles(const char *dir, int *filesCount, char *filterExt)
|
||||||
{
|
{
|
||||||
@ -352,6 +424,39 @@ static char **ReadDirectoryFiles(const char *dir, int *filesCount, char *filterE
|
|||||||
int dirFilesCount = 0;
|
int dirFilesCount = 0;
|
||||||
char **files = GetDirectoryFiles(dir, &dirFilesCount);
|
char **files = GetDirectoryFiles(dir, &dirFilesCount);
|
||||||
|
|
||||||
|
// Sort files and directories: dir by name + files by name
|
||||||
|
// https://en.wikibooks.org/wiki/Algorithm_Implementation/Sorting/Quicksort#C
|
||||||
|
if (dirFilesCount > 1)
|
||||||
|
{
|
||||||
|
const int MAX = 64;
|
||||||
|
unsigned int left = 0, stack[64], pos = 0, seed = rand(), len = dirFilesCount;
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
for (; left + 1 < len; len++) // Sort left to len - 1
|
||||||
|
{
|
||||||
|
if (pos == MAX) len = stack[pos = 0]; // Stack overflow, reset
|
||||||
|
char *pivot = files[left + seed%(len - left)]; // Pick random pivot
|
||||||
|
seed = seed*69069 + 1; // Next pseudo-random number
|
||||||
|
stack[pos++] = len; // Sort right part later
|
||||||
|
|
||||||
|
for (unsigned int right = left - 1;;) // Inner loop: partitioning
|
||||||
|
{
|
||||||
|
while (FileCompare(files[++right], pivot, dir) < 0); // Look for greater element
|
||||||
|
while (FileCompare(pivot, files[--len], dir) < 0); // Look for smaller element
|
||||||
|
if (right >= len) break; // Partition point found?
|
||||||
|
char *temp = files[right];
|
||||||
|
files[right] = files[len]; // The only swap
|
||||||
|
files[len] = temp;
|
||||||
|
} // Partitioned, continue left part
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos == 0) break; // Stack empty?
|
||||||
|
left = len; // Left to right is sorted
|
||||||
|
len = stack[--pos]; // Get next range to sort
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (TextIsEqual(extensions[0], "all")) filterExtensions = false;
|
if (TextIsEqual(extensions[0], "all")) filterExtensions = false;
|
||||||
|
|
||||||
for (int i = 0; (i < dirFilesCount) && (validFilesCount < MAX_DIRECTORY_FILES); i++)
|
for (int i = 0; (i < dirFilesCount) && (validFilesCount < MAX_DIRECTORY_FILES); i++)
|
||||||
@ -360,10 +465,10 @@ static char **ReadDirectoryFiles(const char *dir, int *filesCount, char *filterE
|
|||||||
|
|
||||||
if (!filterExtensions)
|
if (!filterExtensions)
|
||||||
{
|
{
|
||||||
strcpy(validFiles[validFilesCount], files[i]);
|
strncpy(validFiles[validFilesCount], files[i], MAX_DIR_PATH_LENGTH);
|
||||||
|
|
||||||
// Only filter files by extensions, directories should be available
|
// Only filter files by extensions, directories should be available
|
||||||
if (DirectoryExists(TextFormat("%s\\%s", dir, files[i]))) strcpy(dirFilesIcon[validFilesCount], TextFormat("#%i#%s", 1, files[i]));
|
if (DirectoryExists(TextFormat("%s/%s", dir, files[i]))) strcpy(dirFilesIcon[validFilesCount], TextFormat("#%i#%s", 1, files[i]));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO: Assign custom filetype icons depending on file extension (image, audio, text, video, models...)
|
// TODO: Assign custom filetype icons depending on file extension (image, audio, text, video, models...)
|
||||||
@ -393,8 +498,6 @@ static char **ReadDirectoryFiles(const char *dir, int *filesCount, char *filterE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Sort files and directories: dir by name + files by name
|
|
||||||
|
|
||||||
ClearDirectoryFiles();
|
ClearDirectoryFiles();
|
||||||
|
|
||||||
*filesCount = validFilesCount;
|
*filesCount = validFilesCount;
|
||||||
@ -411,18 +514,18 @@ static int GuiListViewFiles(Rectangle bounds, FileInfo *files, int count, int *f
|
|||||||
|
|
||||||
// Check if we need a scroll bar
|
// Check if we need a scroll bar
|
||||||
bool useScrollBar = false;
|
bool useScrollBar = false;
|
||||||
if ((GuiGetStyle(LISTVIEW, ELEMENTS_HEIGHT) + GuiGetStyle(LISTVIEW, ELEMENTS_PADDING))*count > bounds.height) useScrollBar = true;
|
if ((GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING))*count > bounds.height) useScrollBar = true;
|
||||||
|
|
||||||
// Define base item rectangle [0]
|
// Define base item rectangle [0]
|
||||||
Rectangle itemBounds = { 0 };
|
Rectangle itemBounds = { 0 };
|
||||||
itemBounds.x = bounds.x + GuiGetStyle(LISTVIEW, ELEMENTS_PADDING);
|
itemBounds.x = bounds.x + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING);
|
||||||
itemBounds.y = bounds.y + GuiGetStyle(LISTVIEW, ELEMENTS_PADDING) + GuiGetStyle(DEFAULT, BORDER_WIDTH);
|
itemBounds.y = bounds.y + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING) + GuiGetStyle(DEFAULT, BORDER_WIDTH);
|
||||||
itemBounds.width = bounds.width - 2*GuiGetStyle(LISTVIEW, ELEMENTS_PADDING) - GuiGetStyle(DEFAULT, BORDER_WIDTH);
|
itemBounds.width = bounds.width - 2*GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING) - GuiGetStyle(DEFAULT, BORDER_WIDTH);
|
||||||
itemBounds.height = GuiGetStyle(LISTVIEW, ELEMENTS_HEIGHT);
|
itemBounds.height = GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT);
|
||||||
if (useScrollBar) itemBounds.width -= GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH);
|
if (useScrollBar) itemBounds.width -= GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH);
|
||||||
|
|
||||||
// Get items on the list
|
// Get items on the list
|
||||||
int visibleItems = bounds.height/(GuiGetStyle(LISTVIEW, ELEMENTS_HEIGHT) + GuiGetStyle(LISTVIEW, ELEMENTS_PADDING));
|
int visibleItems = bounds.height/(GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING));
|
||||||
if (visibleItems > count) visibleItems = count;
|
if (visibleItems > count) visibleItems = count;
|
||||||
|
|
||||||
int startIndex = (scrollIndex == NULL)? 0 : *scrollIndex;
|
int startIndex = (scrollIndex == NULL)? 0 : *scrollIndex;
|
||||||
@ -451,7 +554,7 @@ static int GuiListViewFiles(Rectangle bounds, FileInfo *files, int count, int *f
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update item rectangle y position for next item
|
// Update item rectangle y position for next item
|
||||||
itemBounds.y += (GuiGetStyle(LISTVIEW, ELEMENTS_HEIGHT) + GuiGetStyle(LISTVIEW, ELEMENTS_PADDING));
|
itemBounds.y += (GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useScrollBar)
|
if (useScrollBar)
|
||||||
@ -469,7 +572,7 @@ static int GuiListViewFiles(Rectangle bounds, FileInfo *files, int count, int *f
|
|||||||
else itemFocused = -1;
|
else itemFocused = -1;
|
||||||
|
|
||||||
// Reset item rectangle y to [0]
|
// Reset item rectangle y to [0]
|
||||||
itemBounds.y = bounds.y + GuiGetStyle(LISTVIEW, ELEMENTS_PADDING) + GuiGetStyle(DEFAULT, BORDER_WIDTH);
|
itemBounds.y = bounds.y + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING) + GuiGetStyle(DEFAULT, BORDER_WIDTH);
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
@ -521,7 +624,7 @@ static int GuiListViewFiles(Rectangle bounds, FileInfo *files, int count, int *f
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update item rectangle y position for next item
|
// Update item rectangle y position for next item
|
||||||
itemBounds.y += (GuiGetStyle(LISTVIEW, ELEMENTS_HEIGHT) + GuiGetStyle(LISTVIEW, ELEMENTS_PADDING));
|
itemBounds.y += (GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useScrollBar)
|
if (useScrollBar)
|
||||||
@ -536,15 +639,15 @@ static int GuiListViewFiles(Rectangle bounds, FileInfo *files, int count, int *f
|
|||||||
float percentVisible = (float)(endIndex - startIndex)/count;
|
float percentVisible = (float)(endIndex - startIndex)/count;
|
||||||
float sliderSize = bounds.height*percentVisible;
|
float sliderSize = bounds.height*percentVisible;
|
||||||
|
|
||||||
int prevSliderSize = GuiGetStyle(SCROLLBAR, SLIDER_SIZE); // Save default slider size
|
int prevSliderSize = GuiGetStyle(SCROLLBAR, SLIDER_WIDTH); // Save default slider size
|
||||||
int prevScrollSpeed = GuiGetStyle(SCROLLBAR, SCROLL_SPEED); // Save default scroll speed
|
int prevScrollSpeed = GuiGetStyle(SCROLLBAR, SCROLL_SPEED); // Save default scroll speed
|
||||||
GuiSetStyle(SCROLLBAR, SLIDER_SIZE, sliderSize); // Change slider size
|
GuiSetStyle(SCROLLBAR, SLIDER_WIDTH, sliderSize); // Change slider size
|
||||||
GuiSetStyle(SCROLLBAR, SCROLL_SPEED, count - visibleItems); // Change scroll speed
|
GuiSetStyle(SCROLLBAR, SCROLL_SPEED, count - visibleItems); // Change scroll speed
|
||||||
|
|
||||||
startIndex = GuiScrollBar(scrollBarBounds, startIndex, 0, count - visibleItems);
|
startIndex = GuiScrollBar(scrollBarBounds, startIndex, 0, count - visibleItems);
|
||||||
|
|
||||||
GuiSetStyle(SCROLLBAR, SCROLL_SPEED, prevScrollSpeed); // Reset scroll speed to default
|
GuiSetStyle(SCROLLBAR, SCROLL_SPEED, prevScrollSpeed); // Reset scroll speed to default
|
||||||
GuiSetStyle(SCROLLBAR, SLIDER_SIZE, prevSliderSize); // Reset slider size to default
|
GuiSetStyle(SCROLLBAR, SLIDER_WIDTH, prevSliderSize); // Reset slider size to default
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -3,25 +3,23 @@
|
|||||||
* raygui - image exporter
|
* raygui - image exporter
|
||||||
*
|
*
|
||||||
* DEPENDENCIES:
|
* DEPENDENCIES:
|
||||||
* raylib 2.1 - Windowing/input management and drawing.
|
* raylib 4.0 - Windowing/input management and drawing.
|
||||||
* raygui 2.0 - Immediate-mode GUI controls.
|
* raygui 3.0 - Immediate-mode GUI controls.
|
||||||
*
|
*
|
||||||
* COMPILATION (Windows - MinGW):
|
* COMPILATION (Windows - MinGW):
|
||||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
||||||
*
|
*
|
||||||
* LICENSE: zlib/libpng
|
* LICENSE: zlib/libpng
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019 raylib technologies (@raylibtech)
|
* Copyright (c) 2015-2021 Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
#define RAYGUI_IMPLEMENTATION
|
#define RAYGUI_IMPLEMENTATION
|
||||||
#define RAYGUI_SUPPORT_RICONS
|
|
||||||
#include "../../src/raygui.h"
|
#include "../../src/raygui.h"
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// Program main entry point
|
// Program main entry point
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
@ -54,7 +52,7 @@ int main(int argc, char *argv[0])
|
|||||||
|
|
||||||
bool imageLoaded = false;
|
bool imageLoaded = false;
|
||||||
float imageScale = 1.0f;
|
float imageScale = 1.0f;
|
||||||
Rectangle imageRec = { 0.0f };
|
Rectangle imageRec = { 0 };
|
||||||
|
|
||||||
bool btnExport = false;
|
bool btnExport = false;
|
||||||
|
|
||||||
@ -102,12 +100,12 @@ int main(int argc, char *argv[0])
|
|||||||
|
|
||||||
if (fileFormatActive == 0) // PNG
|
if (fileFormatActive == 0) // PNG
|
||||||
{
|
{
|
||||||
if ((GetExtension(fileName) == NULL) || (!IsFileExtension(fileName, ".png"))) strcat(fileName, ".png\0"); // No extension provided
|
if ((GetFileExtension(fileName) == NULL) || (!IsFileExtension(fileName, ".png"))) strcat(fileName, ".png\0"); // No extension provided
|
||||||
ExportImage(image, fileName);
|
ExportImage(image, fileName);
|
||||||
}
|
}
|
||||||
else if (fileFormatActive == 1) // RAW
|
else if (fileFormatActive == 1) // RAW
|
||||||
{
|
{
|
||||||
if ((GetExtension(fileName) == NULL) || (!IsFileExtension(fileName, ".raw"))) strcat(fileName, ".raw\0"); // No extension provided
|
if ((GetFileExtension(fileName) == NULL) || (!IsFileExtension(fileName, ".raw"))) strcat(fileName, ".raw\0"); // No extension provided
|
||||||
|
|
||||||
int dataSize = GetPixelDataSize(image.width, image.height, image.format);
|
int dataSize = GetPixelDataSize(image.width, image.height, image.format);
|
||||||
|
|
||||||
@ -147,7 +145,7 @@ int main(int argc, char *argv[0])
|
|||||||
DrawTextureEx(texture, (Vector2){ screenWidth/2 - (float)texture.width*imageScale/2, screenHeight/2 - (float)texture.height*imageScale/2 }, 0.0f, imageScale, WHITE);
|
DrawTextureEx(texture, (Vector2){ screenWidth/2 - (float)texture.width*imageScale/2, screenHeight/2 - (float)texture.height*imageScale/2 }, 0.0f, imageScale, WHITE);
|
||||||
|
|
||||||
DrawRectangleLinesEx(imageRec, 1, CheckCollisionPointRec(GetMousePosition(), imageRec) ? RED : DARKGRAY);
|
DrawRectangleLinesEx(imageRec, 1, CheckCollisionPointRec(GetMousePosition(), imageRec) ? RED : DARKGRAY);
|
||||||
DrawText(FormatText("SCALE: %.2f%%", imageScale*100.0f), 20, screenHeight - 40, 20, GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)));
|
DrawText(TextFormat("SCALE: %.2f%%", imageScale*100.0f), 20, screenHeight - 40, 20, GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,22 +3,21 @@
|
|||||||
* raygui - image raw importer
|
* raygui - image raw importer
|
||||||
*
|
*
|
||||||
* DEPENDENCIES:
|
* DEPENDENCIES:
|
||||||
* raylib 2.1 - Windowing/input management and drawing.
|
* raylib 4.0 - Windowing/input management and drawing.
|
||||||
* raygui 2.0 - Immediate-mode GUI controls.
|
* raygui 3.0 - Immediate-mode GUI controls.
|
||||||
*
|
*
|
||||||
* COMPILATION (Windows - MinGW):
|
* COMPILATION (Windows - MinGW):
|
||||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
||||||
*
|
*
|
||||||
* LICENSE: zlib/libpng
|
* LICENSE: zlib/libpng
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019 raylib technologies (@raylibtech)
|
* Copyright (c) 2015-2021 Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
#define RAYGUI_IMPLEMENTATION
|
#define RAYGUI_IMPLEMENTATION
|
||||||
#define RAYGUI_SUPPORT_RICONS
|
|
||||||
#include "../../src/raygui.h"
|
#include "../../src/raygui.h"
|
||||||
|
|
||||||
#include <string.h> // Required for: strcpy()
|
#include <string.h> // Required for: strcpy()
|
||||||
@ -128,17 +127,17 @@ int main()
|
|||||||
// Select correct format depending on channels and bpp
|
// Select correct format depending on channels and bpp
|
||||||
if (bpp == 8)
|
if (bpp == 8)
|
||||||
{
|
{
|
||||||
if (channels == 1) format = UNCOMPRESSED_GRAYSCALE;
|
if (channels == 1) format = PIXELFORMAT_UNCOMPRESSED_GRAYSCALE;
|
||||||
else if (channels == 2) format = UNCOMPRESSED_GRAY_ALPHA;
|
else if (channels == 2) format = PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA;
|
||||||
else if (channels == 3) format = UNCOMPRESSED_R8G8B8;
|
else if (channels == 3) format = PIXELFORMAT_UNCOMPRESSED_R8G8B8;
|
||||||
else if (channels == 4) format = UNCOMPRESSED_R8G8B8A8;
|
else if (channels == 4) format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
|
||||||
}
|
}
|
||||||
else if (bpp == 32)
|
else if (bpp == 32)
|
||||||
{
|
{
|
||||||
if (channels == 1) format = UNCOMPRESSED_R32;
|
if (channels == 1) format = PIXELFORMAT_UNCOMPRESSED_R32;
|
||||||
else if (channels == 2) TraceLog(LOG_WARNING, "Channel bit-depth not supported!");
|
else if (channels == 2) TraceLog(LOG_WARNING, "Channel bit-depth not supported!");
|
||||||
else if (channels == 3) format = UNCOMPRESSED_R32G32B32;
|
else if (channels == 3) format = PIXELFORMAT_UNCOMPRESSED_R32G32B32;
|
||||||
else if (channels == 4) format = UNCOMPRESSED_R32G32B32A32;
|
else if (channels == 4) format = PIXELFORMAT_UNCOMPRESSED_R32G32B32A32;
|
||||||
}
|
}
|
||||||
else if (bpp == 16) TraceLog(LOG_WARNING, "Channel bit-depth not supported!");
|
else if (bpp == 16) TraceLog(LOG_WARNING, "Channel bit-depth not supported!");
|
||||||
}
|
}
|
||||||
@ -174,7 +173,7 @@ int main()
|
|||||||
if (texture.id != 0)
|
if (texture.id != 0)
|
||||||
{
|
{
|
||||||
DrawTextureEx(texture, (Vector2){ screenWidth/2 - texture.width*imageScale/2, screenHeight/2 - texture.height*imageScale/2 }, 0, imageScale, WHITE);
|
DrawTextureEx(texture, (Vector2){ screenWidth/2 - texture.width*imageScale/2, screenHeight/2 - texture.height*imageScale/2 }, 0, imageScale, WHITE);
|
||||||
DrawText(FormatText("SCALE x%.0f", imageScale), 20, screenHeight - 40, 20, GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)));
|
DrawText(TextFormat("SCALE x%.0f", imageScale), 20, screenHeight - 40, 20, GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)));
|
||||||
}
|
}
|
||||||
else DrawText("drag & drop RAW image file", 320, 180, 10, GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)));
|
else DrawText("drag & drop RAW image file", 320, 180, 10, GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)));
|
||||||
|
|
||||||
@ -187,13 +186,13 @@ int main()
|
|||||||
GuiLabel((Rectangle){ windowOffset.x + 10, windowOffset.y + 30, 65, 20 }, "Import file:");
|
GuiLabel((Rectangle){ windowOffset.x + 10, windowOffset.y + 30, 65, 20 }, "Import file:");
|
||||||
GuiLabel((Rectangle){ windowOffset.x + 85, windowOffset.y + 30, 75, 20 }, fileName);
|
GuiLabel((Rectangle){ windowOffset.x + 85, windowOffset.y + 30, 75, 20 }, fileName);
|
||||||
GuiLabel((Rectangle){ windowOffset.x + 10, windowOffset.y + 50, 65, 20 }, "File size:");
|
GuiLabel((Rectangle){ windowOffset.x + 10, windowOffset.y + 50, 65, 20 }, "File size:");
|
||||||
GuiLabel((Rectangle){ windowOffset.x + 85, windowOffset.y + 50, 75, 20 }, FormatText("%i bytes", dataSize));
|
GuiLabel((Rectangle){ windowOffset.x + 85, windowOffset.y + 50, 75, 20 }, TextFormat("%i bytes", dataSize));
|
||||||
GuiGroupBox((Rectangle){ windowOffset.x + 10, windowOffset.y + 85, 180, 80 }, "Resolution");
|
GuiGroupBox((Rectangle){ windowOffset.x + 10, windowOffset.y + 85, 180, 80 }, "Resolution");
|
||||||
GuiLabel((Rectangle){ windowOffset.x + 20, windowOffset.y + 100, 33, 25 }, "Width:");
|
GuiLabel((Rectangle){ windowOffset.x + 20, windowOffset.y + 100, 33, 25 }, "Width:");
|
||||||
if (GuiValueBox((Rectangle){ windowOffset.x + 60, windowOffset.y + 100, 80, 25 }, &widthValue, 0, 8192, widthEditMode)) widthEditMode = !widthEditMode;
|
if (GuiValueBox((Rectangle){ windowOffset.x + 60, windowOffset.y + 100, 80, 25 }, NULL, &widthValue, 0, 8192, widthEditMode)) widthEditMode = !widthEditMode;
|
||||||
GuiLabel((Rectangle){ windowOffset.x + 145, windowOffset.y + 100, 30, 25 }, "pixels");
|
GuiLabel((Rectangle){ windowOffset.x + 145, windowOffset.y + 100, 30, 25 }, "pixels");
|
||||||
GuiLabel((Rectangle){ windowOffset.x + 20, windowOffset.y + 130, 33, 25 }, "Height:");
|
GuiLabel((Rectangle){ windowOffset.x + 20, windowOffset.y + 130, 33, 25 }, "Height:");
|
||||||
if (GuiValueBox((Rectangle){ windowOffset.x + 60, windowOffset.y + 130, 80, 25 }, &heightValue, 0, 8192, heightEditMode)) heightEditMode = !heightEditMode;
|
if (GuiValueBox((Rectangle){ windowOffset.x + 60, windowOffset.y + 130, 80, 25 }, NULL, &heightValue, 0, 8192, heightEditMode)) heightEditMode = !heightEditMode;
|
||||||
GuiLabel((Rectangle){ windowOffset.x + 145, windowOffset.y + 130, 30, 25 }, "pixels");
|
GuiLabel((Rectangle){ windowOffset.x + 145, windowOffset.y + 130, 30, 25 }, "pixels");
|
||||||
GuiGroupBox((Rectangle){ windowOffset.x + 10, windowOffset.y + 180, 180, 160 }, "Pixel Format");
|
GuiGroupBox((Rectangle){ windowOffset.x + 10, windowOffset.y + 180, 180, 160 }, "Pixel Format");
|
||||||
pixelFormatActive = GuiComboBox((Rectangle){ windowOffset.x + 20, windowOffset.y + 195, 160, 25 }, TextJoin(pixelFormatTextList, 8, ";"), pixelFormatActive);
|
pixelFormatActive = GuiComboBox((Rectangle){ windowOffset.x + 20, windowOffset.y + 195, 160, 25 }, TextJoin(pixelFormatTextList, 8, ";"), pixelFormatActive);
|
||||||
@ -208,7 +207,7 @@ int main()
|
|||||||
|
|
||||||
GuiGroupBox((Rectangle){ windowOffset.x + 10, windowOffset.y + 355, 180, 50 }, "Header");
|
GuiGroupBox((Rectangle){ windowOffset.x + 10, windowOffset.y + 355, 180, 50 }, "Header");
|
||||||
GuiLabel((Rectangle){ windowOffset.x + 25, windowOffset.y + 370, 27, 25 }, "Size:");
|
GuiLabel((Rectangle){ windowOffset.x + 25, windowOffset.y + 370, 27, 25 }, "Size:");
|
||||||
if (GuiValueBox((Rectangle){ windowOffset.x + 55, windowOffset.y + 370, 85, 25 }, &headerSizeValue, 0, 10000, headerSizeEditMode)) headerSizeEditMode = !headerSizeEditMode;
|
if (GuiValueBox((Rectangle){ windowOffset.x + 55, windowOffset.y + 370, 85, 25 }, NULL, &headerSizeValue, 0, 10000, headerSizeEditMode)) headerSizeEditMode = !headerSizeEditMode;
|
||||||
GuiLabel((Rectangle){ windowOffset.x + 145, windowOffset.y + 370, 30, 25 }, "bytes");
|
GuiLabel((Rectangle){ windowOffset.x + 145, windowOffset.y + 370, 30, 25 }, "bytes");
|
||||||
|
|
||||||
btnLoadPressed = GuiButton((Rectangle){ windowOffset.x + 10, windowOffset.y + 420, 180, 30 }, "Import RAW");
|
btnLoadPressed = GuiButton((Rectangle){ windowOffset.x + 10, windowOffset.y + 420, 180, 30 }, "Import RAW");
|
||||||
|
|||||||
@ -3,15 +3,15 @@
|
|||||||
* raygui - portable window
|
* raygui - portable window
|
||||||
*
|
*
|
||||||
* DEPENDENCIES:
|
* DEPENDENCIES:
|
||||||
* raylib 2.1 - Windowing/input management and drawing.
|
* raylib 4.0 - Windowing/input management and drawing.
|
||||||
* raygui 2.0 - Immediate-mode GUI controls.
|
* raygui 3.0 - Immediate-mode GUI controls.
|
||||||
*
|
*
|
||||||
* COMPILATION (Windows - MinGW):
|
* COMPILATION (Windows - MinGW):
|
||||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
||||||
*
|
*
|
||||||
* LICENSE: zlib/libpng
|
* LICENSE: zlib/libpng
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019 raylib technologies (@raylibtech)
|
* Copyright (c) 2016-2021 Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
|
|
||||||
@ -27,8 +27,8 @@ int main()
|
|||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//---------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------
|
||||||
int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
int screenHeight = 600;
|
const int screenHeight = 600;
|
||||||
|
|
||||||
SetConfigFlags(FLAG_WINDOW_UNDECORATED);
|
SetConfigFlags(FLAG_WINDOW_UNDECORATED);
|
||||||
InitWindow(screenWidth, screenHeight, "raygui - portable window");
|
InitWindow(screenWidth, screenHeight, "raygui - portable window");
|
||||||
@ -79,9 +79,9 @@ int main()
|
|||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
exitWindow = GuiWindowBox((Rectangle){ 0, 0, screenWidth, screenHeight }, "PORTABLE WINDOW");
|
exitWindow = GuiWindowBox((Rectangle){ 0, 0, screenWidth, screenHeight }, "#198# PORTABLE WINDOW");
|
||||||
|
|
||||||
DrawText(FormatText("Mouse Position: [ %.0f, %.0f ]", mousePosition.x, mousePosition.y), 10, 40, 10, DARKGRAY);
|
DrawText(TextFormat("Mouse Position: [ %.0f, %.0f ]", mousePosition.x, mousePosition.y), 10, 40, 10, DARKGRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|||||||
867
examples/property_list/dm_property_list.h
Normal file
867
examples/property_list/dm_property_list.h
Normal file
@ -0,0 +1,867 @@
|
|||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* PropertyListControl v1.0.1 - A custom control that displays a set of properties as a list
|
||||||
|
*
|
||||||
|
* UPDATES: last updated - 10 march 2020 (v1.0.1)
|
||||||
|
* v1.0.1 - Made it work with latest raygui version
|
||||||
|
* - Added `GuiDMSaveProperties()` for saving properties to a text file
|
||||||
|
* - A `GuiDMLoadProperties()` is planed but not implemented yet
|
||||||
|
* - Added a section property that can work as a way to group multiple properties
|
||||||
|
* - Fixed issue with section not having the correct height
|
||||||
|
* v1.0.0 - Initial release
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* MODULE USAGE:
|
||||||
|
* #define GUI_PROPERTY_LIST_IMPLEMENTATION
|
||||||
|
* #include "dm_property_list.h"
|
||||||
|
*
|
||||||
|
* INIT: GuiDMProperty props[] = { // initialize a set of properties first
|
||||||
|
PCOLOR(),
|
||||||
|
PINT(),
|
||||||
|
PFLOAT(),
|
||||||
|
...
|
||||||
|
};
|
||||||
|
* DRAW: GuiDMPropertyList(bounds, props, sizeof(props)/sizeof(props[0]), ...);
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* NOTE: This module also contains 2 extra controls used internally by the property list
|
||||||
|
* - GuiDMValueBox() - a value box that supports displaying float values
|
||||||
|
* - GuiDMSpinner() - a `better` GuiSpinner()
|
||||||
|
*
|
||||||
|
* LICENSE: zlib/libpng
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 Vlad Adrian (@Demizdor - https://github.com/Demizdor).
|
||||||
|
*
|
||||||
|
**********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
// WARNING: raygui implementation is expected to be defined before including this header
|
||||||
|
#undef RAYGUI_IMPLEMENTATION
|
||||||
|
#include "../../src/raygui.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GUI_PROPERTY_LIST_H
|
||||||
|
#define GUI_PROPERTY_LIST_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" { // Prevents name mangling of functions
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Defines and Macros
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// A bunch of usefull macros for modifying the flags of each property
|
||||||
|
|
||||||
|
// Set flag `F` of property `P`. `P` must be a pointer!
|
||||||
|
#define PROP_SET_FLAG(P, F) ((P)->flags |= (F))
|
||||||
|
// Clear flag `F` of property `P`. `P` must be a pointer!
|
||||||
|
#define PROP_CLEAR_FLAG(P, F) ((P)->flags &= ~(F))
|
||||||
|
// Toggles flag `F` of property `P`. `P` must be a pointer!
|
||||||
|
#define PROP_TOGGLE_FLAG(P, F) ((P)->flags ^= (F))
|
||||||
|
// Checks if flag `F` of property `P` is set . `P` must be a pointer!
|
||||||
|
#define PROP_CHECK_FLAG(P, F) ((P)->flags & (F))
|
||||||
|
|
||||||
|
// Some usefull macros for creating properties
|
||||||
|
|
||||||
|
// Create a bool property with name `N`, flags `F` and value `V`
|
||||||
|
#define PBOOL(N, F, V) RAYGUI_CLITERAL(GuiDMProperty){N, GUI_PROP_BOOL, F, .value.vbool = V}
|
||||||
|
// Create a int property with name `N`, flags `F` and value `V`
|
||||||
|
#define PINT(N, F, V) RAYGUI_CLITERAL(GuiDMProperty){N, GUI_PROP_INT, F, .value.vint = {V,0,0,1}}
|
||||||
|
// Create a ranged int property within `MIN` and `MAX` with name `N`, flags `F` value `V`.
|
||||||
|
// Pressing the spinner buttons will increase/decrease the value by `S`.
|
||||||
|
#define PINT_RANGE(N, F, V, S, MIN, MAX) RAYGUI_CLITERAL(GuiDMProperty){N, GUI_PROP_INT, F, .value.vint = {V,MIN,MAX,S}}
|
||||||
|
// Create a float property with name `N`, flags `F` and value `V`
|
||||||
|
#define PFLOAT(N, F, V) RAYGUI_CLITERAL(GuiDMProperty){N, GUI_PROP_FLOAT, F, .value.vfloat = {V,0.f,0.f,1.0f,3}}
|
||||||
|
// Create a ranged float property within `MIN` and `MAX` with name `N`, flags `F` value `V` with `P` decimal digits to show.
|
||||||
|
// Pressing the spinner buttons will increase/decrease the value by `S`.
|
||||||
|
#define PFLOAT_RANGE(N, F, V, S, P, MIN, MAX) RAYGUI_CLITERAL(GuiDMProperty){N, GUI_PROP_FLOAT, F, .value.vfloat = {V,MIN,MAX,S,P}}
|
||||||
|
// Create a text property with name `N`, flags `F` value `V` and max text size `S`
|
||||||
|
#define PTEXT(N, F, V, S) RAYGUI_CLITERAL(GuiDMProperty){N, GUI_PROP_TEXT, F, .value.vtext = {V, S} }
|
||||||
|
// Create a text property with name `N`, flags `F` value `V` and max text size `S`
|
||||||
|
#define PSELECT(N, F, V, A) RAYGUI_CLITERAL(GuiDMProperty){N, GUI_PROP_SELECT, F, .value.vselect = {V, A} }
|
||||||
|
// Create a 2D vector property with name `N`, flags `F` and the `X`, `Y` coordinates
|
||||||
|
#define PVEC2(N, F, X, Y) RAYGUI_CLITERAL(GuiDMProperty){N, GUI_PROP_VECTOR2, F, .value.v2 = {X, Y} }
|
||||||
|
// Create a 3D vector property with name `N`, flags `F` and the `X`, `Y`, `Z` coordinates
|
||||||
|
#define PVEC3(N, F, X, Y, Z) RAYGUI_CLITERAL(GuiDMProperty){N, GUI_PROP_VECTOR3, F, .value.v3 = {X, Y, Z} }
|
||||||
|
// Create a 4D vector property with name `N`, flags `F` and the `X`, `Y`, `Z`, `W` coordinates
|
||||||
|
#define PVEC4(N, F, X, Y, Z, W) RAYGUI_CLITERAL(GuiDMProperty){N, GUI_PROP_VECTOR4, F, .value.v4 = {X, Y, Z, W} }
|
||||||
|
// Create a rectangle property with name `N`, flags `F`, `X`, `Y` coordinates and `W` and `H` size
|
||||||
|
#define PRECT(N, F, X, Y, W, H) RAYGUI_CLITERAL(GuiDMProperty){N, GUI_PROP_RECT, F, .value.vrect = {X, Y, W, H} }
|
||||||
|
// Create a 3D vector property with name `N`, flags `F` and the `R`, `G`, `B`, `A` channel values
|
||||||
|
#define PCOLOR(N, F, R, G, B, A) RAYGUI_CLITERAL(GuiDMProperty){N, GUI_PROP_COLOR, F, .value.vcolor = {R, G, B, A} }
|
||||||
|
// Create a collapsable section named `N` with `F` flags and the next `C` properties as children.
|
||||||
|
// !! A section cannot hold another section as a child !!
|
||||||
|
#define PSECTION(N, F, C) RAYGUI_CLITERAL(GuiDMProperty){N, GUI_PROP_SECTION, F, .value.vsection = (C)}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Types and Structures Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
enum GuiDMPropertyTypes {
|
||||||
|
GUI_PROP_BOOL = 0,
|
||||||
|
GUI_PROP_INT,
|
||||||
|
GUI_PROP_FLOAT,
|
||||||
|
GUI_PROP_TEXT,
|
||||||
|
GUI_PROP_SELECT,
|
||||||
|
GUI_PROP_VECTOR2,
|
||||||
|
GUI_PROP_VECTOR3,
|
||||||
|
GUI_PROP_VECTOR4,
|
||||||
|
GUI_PROP_RECT,
|
||||||
|
GUI_PROP_COLOR,
|
||||||
|
GUI_PROP_SECTION,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum GuiDMPropertyFlags {
|
||||||
|
GUI_PFLAG_COLLAPSED = 1 << 0, // is the property expanded or collapsed?
|
||||||
|
GUI_PFLAG_DISABLED = 1 << 1, // is this property disabled or enabled?
|
||||||
|
};
|
||||||
|
|
||||||
|
// Data structure for each property
|
||||||
|
typedef struct {
|
||||||
|
char* name;
|
||||||
|
short type;
|
||||||
|
short flags;
|
||||||
|
union {
|
||||||
|
bool vbool;
|
||||||
|
struct { int val; int min; int max; int step; } vint;
|
||||||
|
struct { float val; float min; float max; float step; int precision; } vfloat;
|
||||||
|
struct { char* val; int size; } vtext;
|
||||||
|
struct { char* val; int active; } vselect;
|
||||||
|
int vsection;
|
||||||
|
Vector2 v2;
|
||||||
|
Vector3 v3;
|
||||||
|
Vector4 v4;
|
||||||
|
Rectangle vrect;
|
||||||
|
Color vcolor;
|
||||||
|
} value;
|
||||||
|
} GuiDMProperty;
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Global Variables Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
//...
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Module Functions Declaration
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// A more advanced `GuiValueBox()` supporting float/int values with specified `precision`, cursor movements, cut/copy/paste and
|
||||||
|
// other keybord shortcuts. Needed by `GuiDMSpinner()` !!
|
||||||
|
// `precision` should be between 1-7 for float values and 0 for int values (maybe 15 for doubles but that was not tested)
|
||||||
|
// WARNING: The bounds should be set big enough else the text will overflow and things will break
|
||||||
|
// WARNING: Sometimes the last decimal value could differ, this is probably due to rounding
|
||||||
|
double GuiDMValueBox(Rectangle bounds, double value, double minValue, double maxValue, int precision, bool editMode);
|
||||||
|
|
||||||
|
// A more advanced `GuiSpinner()` using `GuiDMValueBox()` for displaying the values.
|
||||||
|
// This was needed because `GuiSpinner()` can't display float values and editing values is somewhat hard.
|
||||||
|
// This is by no means perfect but should be more user friendly than the default control provided by raygui.
|
||||||
|
double GuiDMSpinner(Rectangle bounds, double value, double minValue, double maxValue, double step, int precision, bool editMode);
|
||||||
|
|
||||||
|
// Works just like `GuiListViewEx()` but with an array of properties instead of text.
|
||||||
|
void GuiDMPropertyList(Rectangle bounds, GuiDMProperty* props, int count, int* focus, int* scrollIndex);
|
||||||
|
|
||||||
|
// Handy function to save properties to a file. Returns false on failure or true otherwise.
|
||||||
|
bool GuiDMSaveProperties(const char* file, GuiDMProperty* props, int count);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // GUI_PROPERTY_LIST_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************************
|
||||||
|
*
|
||||||
|
* GUI_PROPERTY_LIST_IMPLEMENTATION
|
||||||
|
*
|
||||||
|
************************************************************************************/
|
||||||
|
#if defined(GUI_PROPERTY_LIST_IMPLEMENTATION)
|
||||||
|
|
||||||
|
#include "../../src/raygui.h"
|
||||||
|
|
||||||
|
#include <stdlib.h> // for calloc()
|
||||||
|
#include <string.h> // for memmove(), strlen()
|
||||||
|
#include <stdio.h> // for sscanf(), snprintf()
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
#if __STDC_VERSION__ >= 199901L
|
||||||
|
#include <stdbool.h> // for bool if >= C99
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
double GuiDMValueBox(Rectangle bounds, double value, double minValue, double maxValue, int precision, bool editMode) {
|
||||||
|
// FIXME: Hope all those `memmove()` functions are correctly used so we won't leak memory or overflow the buffer !!!
|
||||||
|
static int framesCounter = 0; // Required for blinking cursor
|
||||||
|
static int cursor = 0; // Required for tracking the cursor position (only for a single active valuebox)
|
||||||
|
|
||||||
|
enum {cursorTimer = 6, maxChars = 31, textPadding = 2};
|
||||||
|
|
||||||
|
GuiControlState state = GuiGetState();
|
||||||
|
|
||||||
|
// Make sure value is in range
|
||||||
|
if(maxValue != minValue){
|
||||||
|
if(value < minValue) value = minValue;
|
||||||
|
if(value > maxValue) value = maxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
char textValue[maxChars + 1] = "\0";
|
||||||
|
snprintf(textValue, maxChars, "%.*f", precision, value); // NOTE: use `snprintf` here so we don't overflow the buffer
|
||||||
|
int len = strlen(textValue);
|
||||||
|
|
||||||
|
bool valueHasChanged = false;
|
||||||
|
|
||||||
|
// Update control
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
if ((state != GUI_STATE_DISABLED) && !guiLocked)
|
||||||
|
{
|
||||||
|
if (editMode)
|
||||||
|
{
|
||||||
|
// Make sure cursor position is correct
|
||||||
|
if(cursor > len) cursor = len;
|
||||||
|
if(cursor < 0) cursor = 0;
|
||||||
|
|
||||||
|
state = GUI_STATE_PRESSED;
|
||||||
|
framesCounter++;
|
||||||
|
|
||||||
|
if(IsKeyPressed(KEY_RIGHT) || (IsKeyDown(KEY_RIGHT) && (framesCounter%cursorTimer == 0))) {
|
||||||
|
// MOVE CURSOR TO RIGHT
|
||||||
|
++cursor;
|
||||||
|
framesCounter = 0;
|
||||||
|
} else if(IsKeyPressed(KEY_LEFT) || (IsKeyDown(KEY_LEFT) && (framesCounter%cursorTimer == 0))) {
|
||||||
|
// MOVE CURSOR TO LEFT
|
||||||
|
--cursor;
|
||||||
|
framesCounter = 0;
|
||||||
|
} else if (IsKeyPressed(KEY_BACKSPACE) || (IsKeyDown(KEY_BACKSPACE) && (framesCounter%cursorTimer) == 0)) {
|
||||||
|
// HANDLE BACKSPACE
|
||||||
|
if(cursor > 0) {
|
||||||
|
if(textValue[cursor-1] != '.') {
|
||||||
|
if(cursor < len )
|
||||||
|
memmove(&textValue[cursor-1], &textValue[cursor], len-cursor);
|
||||||
|
textValue[len - 1] = '\0';
|
||||||
|
valueHasChanged = true;
|
||||||
|
}
|
||||||
|
--cursor;
|
||||||
|
}
|
||||||
|
framesCounter = 0;
|
||||||
|
} else if (IsKeyPressed(KEY_DELETE) || (IsKeyDown(KEY_DELETE) && (framesCounter%cursorTimer) == 0)) {
|
||||||
|
// HANDLE DEL
|
||||||
|
if(len > 0 && cursor < len && textValue[cursor] != '.') {
|
||||||
|
memmove(&textValue[cursor], &textValue[cursor+1], len-cursor);
|
||||||
|
textValue[len] = '\0';
|
||||||
|
len -= 1;
|
||||||
|
valueHasChanged = true;
|
||||||
|
}
|
||||||
|
} else if (IsKeyPressed(KEY_HOME)) {
|
||||||
|
// MOVE CURSOR TO START
|
||||||
|
cursor = 0;
|
||||||
|
} else if (IsKeyPressed(KEY_END)) {
|
||||||
|
// MOVE CURSOR TO END
|
||||||
|
cursor = len;
|
||||||
|
} else if (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_C)) {
|
||||||
|
// COPY
|
||||||
|
SetClipboardText(textValue);
|
||||||
|
} else if (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_X)) {
|
||||||
|
// CUT
|
||||||
|
SetClipboardText(textValue);
|
||||||
|
textValue[0] = '\0';
|
||||||
|
cursor = len = 0;
|
||||||
|
value = 0.0; // set it to 0 and pretend the value didn't change
|
||||||
|
} else if (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_V)) {
|
||||||
|
// PASTE
|
||||||
|
const char* clip = GetClipboardText();
|
||||||
|
int clipLen = strlen(clip);
|
||||||
|
clipLen = clipLen > maxChars ? maxChars : clipLen;
|
||||||
|
memcpy(textValue, clip, clipLen);
|
||||||
|
len = clipLen;
|
||||||
|
textValue[len] = '\0';
|
||||||
|
valueHasChanged = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// HANDLE KEY PRESS
|
||||||
|
int key = GetKeyPressed();
|
||||||
|
if( ((len < maxChars) && (key >= 48) && (key <= 57)) || (key == 46) || (key == 45) ) // only allow 0..9, minus(-) and dot(.)
|
||||||
|
{
|
||||||
|
if(precision != 0 && cursor < len) { // when we have decimals we can't insert at the end
|
||||||
|
memmove(&textValue[cursor], &textValue[cursor-1], len+1-cursor);
|
||||||
|
textValue[len+1] = '\0';
|
||||||
|
textValue[cursor] = (char)key;
|
||||||
|
cursor++;
|
||||||
|
valueHasChanged = true;
|
||||||
|
}
|
||||||
|
else if(precision == 0) {
|
||||||
|
if(cursor < len) memmove(&textValue[cursor], &textValue[cursor-1], len+1-cursor);
|
||||||
|
len += 1;
|
||||||
|
textValue[len+1] = '\0';
|
||||||
|
textValue[cursor] = (char)key;
|
||||||
|
cursor++;
|
||||||
|
valueHasChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure cursor position is correct
|
||||||
|
if(cursor > len) cursor = len;
|
||||||
|
if(cursor < 0) cursor = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (CheckCollisionPointRec(GetMousePosition(), bounds))
|
||||||
|
{
|
||||||
|
state = GUI_STATE_FOCUSED;
|
||||||
|
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) framesCounter = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw control
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
DrawRectangleLinesEx(bounds, GuiGetStyle(VALUEBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(VALUEBOX, BORDER + (state*3))), guiAlpha));
|
||||||
|
|
||||||
|
Rectangle textBounds = {bounds.x + GuiGetStyle(VALUEBOX, BORDER_WIDTH) + textPadding, bounds.y + GuiGetStyle(VALUEBOX, BORDER_WIDTH),
|
||||||
|
bounds.width - 2*(GuiGetStyle(VALUEBOX, BORDER_WIDTH) + textPadding), bounds.height - 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH)};
|
||||||
|
|
||||||
|
int textWidth = GetTextWidth(textValue);
|
||||||
|
if(textWidth > textBounds.width) textBounds.width = textWidth;
|
||||||
|
|
||||||
|
if (state == GUI_STATE_PRESSED)
|
||||||
|
{
|
||||||
|
DrawRectangle(bounds.x + GuiGetStyle(VALUEBOX, BORDER_WIDTH), bounds.y + GuiGetStyle(VALUEBOX, BORDER_WIDTH), bounds.width - 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH), bounds.height - 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(VALUEBOX, BASE_COLOR_PRESSED)), guiAlpha));
|
||||||
|
|
||||||
|
// Draw blinking cursor
|
||||||
|
// NOTE: ValueBox internal text is always centered
|
||||||
|
if (editMode && ((framesCounter/20)%2 == 0)) {
|
||||||
|
// Measure text until the cursor
|
||||||
|
int textWidthCursor = -2;
|
||||||
|
if(cursor > 0) {
|
||||||
|
char c = textValue[cursor];
|
||||||
|
textValue[cursor] = '\0';
|
||||||
|
textWidthCursor = GetTextWidth(textValue);
|
||||||
|
textValue[cursor] = c;
|
||||||
|
}
|
||||||
|
//DrawRectangle(bounds.x + textWidthCursor + textPadding + 2, bounds.y + 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH), 1, bounds.height - 4*GuiGetStyle(VALUEBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(VALUEBOX, BORDER_COLOR_PRESSED)), guiAlpha));
|
||||||
|
DrawRectangle(bounds.x + textWidthCursor + (int)((bounds.width - textWidth - textPadding)/2.0f) + 2, bounds.y + 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH), 1, bounds.height - 4*GuiGetStyle(VALUEBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(VALUEBOX, BORDER_COLOR_PRESSED)), guiAlpha));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (state == GUI_STATE_DISABLED)
|
||||||
|
{
|
||||||
|
DrawRectangle(bounds.x + GuiGetStyle(VALUEBOX, BORDER_WIDTH), bounds.y + GuiGetStyle(VALUEBOX, BORDER_WIDTH), bounds.width - 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH), bounds.height - 2*GuiGetStyle(VALUEBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(VALUEBOX, BASE_COLOR_DISABLED)), guiAlpha));
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiDrawText(textValue, textBounds, GUI_TEXT_ALIGN_CENTER, Fade(GetColor(GuiGetStyle(VALUEBOX, TEXT + (state*3))), guiAlpha));
|
||||||
|
|
||||||
|
value = valueHasChanged ? strtod(textValue, NULL) : value;
|
||||||
|
|
||||||
|
// Make sure value is in range
|
||||||
|
if(maxValue != minValue){
|
||||||
|
if(value < minValue) value = minValue;
|
||||||
|
if(value > maxValue) value = maxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
double GuiDMSpinner(Rectangle bounds, double value, double minValue, double maxValue, double step, int precision, bool editMode) {
|
||||||
|
GuiControlState state = GuiGetState();
|
||||||
|
|
||||||
|
Rectangle spinner = { bounds.x + GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH) + GuiGetStyle(SPINNER, SPIN_BUTTON_PADDING), bounds.y,
|
||||||
|
bounds.width - 2*(GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH) + GuiGetStyle(SPINNER, SPIN_BUTTON_PADDING)), bounds.height };
|
||||||
|
Rectangle leftButtonBound = { (float)bounds.x, (float)bounds.y, (float)GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH), (float)bounds.height };
|
||||||
|
Rectangle rightButtonBound = { (float)bounds.x + bounds.width - GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH), (float)bounds.y, (float)GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH), (float)bounds.height };
|
||||||
|
|
||||||
|
// Update control
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
if ((state != GUI_STATE_DISABLED) && !guiLocked)
|
||||||
|
{
|
||||||
|
Vector2 mousePoint = GetMousePosition();
|
||||||
|
|
||||||
|
// Check spinner state
|
||||||
|
if (CheckCollisionPointRec(mousePoint, bounds))
|
||||||
|
{
|
||||||
|
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = GUI_STATE_PRESSED;
|
||||||
|
else state = GUI_STATE_FOCUSED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// Draw control
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
// Draw value selector custom buttons
|
||||||
|
// NOTE: BORDER_WIDTH and TEXT_ALIGNMENT forced values
|
||||||
|
int tempBorderWidth = GuiGetStyle(BUTTON, BORDER_WIDTH);
|
||||||
|
int tempTextAlign = GuiGetStyle(BUTTON, TEXT_ALIGNMENT);
|
||||||
|
GuiSetStyle(BUTTON, BORDER_WIDTH, GuiGetStyle(SPINNER, BORDER_WIDTH));
|
||||||
|
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER);
|
||||||
|
|
||||||
|
#if defined(RAYGUI_SUPPORT_RICONS)
|
||||||
|
if (GuiButton(leftButtonBound, GuiIconText(RICON_ARROW_LEFT_FILL, NULL))) value -= step;
|
||||||
|
if (GuiButton(rightButtonBound, GuiIconText(RICON_ARROW_RIGHT_FILL, NULL))) value += step;
|
||||||
|
#else
|
||||||
|
if (GuiButton(leftButtonBound, "<")) value -= step;
|
||||||
|
if (GuiButton(rightButtonBound, ">")) value += step;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, tempTextAlign);
|
||||||
|
GuiSetStyle(BUTTON, BORDER_WIDTH, tempBorderWidth);
|
||||||
|
|
||||||
|
value = GuiDMValueBox(spinner, value, minValue, maxValue, precision, editMode);
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void GuiDMPropertyList(Rectangle bounds, GuiDMProperty* props, int count, int* focus, int* scrollIndex) {
|
||||||
|
#ifdef RAYGUI_SUPPORT_RICONS
|
||||||
|
#define PROPERTY_COLLAPSED_ICON "#120#"
|
||||||
|
#define PROPERTY_EXPANDED_ICON "#121#"
|
||||||
|
#else
|
||||||
|
#define PROPERTY_COLLAPSED_ICON "+"
|
||||||
|
#define PROPERTY_EXPANDED_ICON "-"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define PROPERTY_PADDING 6
|
||||||
|
#define PROPERTY_ICON_SIZE 16
|
||||||
|
#define PROPERTY_DECIMAL_DIGITS 3 //how many digits to show (used only for the vector properties)
|
||||||
|
|
||||||
|
// NOTE: Using ListView style for everything !!
|
||||||
|
GuiControlState state = GuiGetState();
|
||||||
|
int propFocused = (focus == NULL)? -1 : *focus;
|
||||||
|
int scroll = *scrollIndex > 0 ? 0 : *scrollIndex; // NOTE: scroll should always be negative or 0
|
||||||
|
|
||||||
|
// Each property occupies a certain number of slots, highly synchronized with the properties enum (GUI_PROP_BOOL ... GUI_PROP_SECTION)
|
||||||
|
// NOTE: If you add a custom property type make sure to add the number of slots it occupies here !!
|
||||||
|
const int propSlots[] = {1,1,1,2,1,3,4,5,5,5,1};
|
||||||
|
|
||||||
|
Rectangle absoluteBounds = {0}; // total bounds for all of the properties (unclipped)
|
||||||
|
// We need to loop over all the properties to get total height so we can see if we need a scrollbar or not
|
||||||
|
for(int p=0; p<count; ++p) {
|
||||||
|
// Calculate height of this property (properties can occupy 1 or more slots)
|
||||||
|
int height = GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT);
|
||||||
|
if(props[p].type < (sizeof(propSlots)/sizeof(propSlots[0]))) {
|
||||||
|
if(!PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED)) height = propSlots[props[p].type]*GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT);
|
||||||
|
if(props[p].type == GUI_PROP_SECTION && (PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED))) p += props[p].value.vsection; // skip slots for collapsed section
|
||||||
|
}
|
||||||
|
absoluteBounds.height += height+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if we need a scrollbar and adjust bounds when necesary
|
||||||
|
bool useScrollBar = absoluteBounds.height > bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) ? true : false;
|
||||||
|
if(!useScrollBar && scroll != 0) scroll = 0; // make sure scroll is 0 when there's no scrollbar
|
||||||
|
|
||||||
|
Rectangle scrollBarBounds = {bounds.x + GuiGetStyle(LISTVIEW, BORDER_WIDTH), bounds.y + GuiGetStyle(LISTVIEW, BORDER_WIDTH),
|
||||||
|
GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH), bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH)};
|
||||||
|
|
||||||
|
absoluteBounds.x = bounds.x + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING) + GuiGetStyle(DEFAULT, BORDER_WIDTH);
|
||||||
|
absoluteBounds.y = bounds.y + GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING) + GuiGetStyle(DEFAULT, BORDER_WIDTH) + scroll;
|
||||||
|
absoluteBounds.width = bounds.width - 2*(GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING) + GuiGetStyle(DEFAULT, BORDER_WIDTH));
|
||||||
|
|
||||||
|
if(useScrollBar) {
|
||||||
|
if(GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)
|
||||||
|
absoluteBounds.x += GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH); // scrollbar is on the LEFT, adjust bounds
|
||||||
|
else
|
||||||
|
scrollBarBounds.x = bounds.x + bounds.width - GuiGetStyle(LISTVIEW, BORDER_WIDTH) - GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH); // scrollbar is on the RIGHT
|
||||||
|
absoluteBounds.width -= GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH); // adjust width to fit the scrollbar
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxScroll = absoluteBounds.height + 2*(GuiGetStyle(LISTVIEW, LIST_ITEMS_PADDING) + GuiGetStyle(DEFAULT, BORDER_WIDTH))-bounds.height;
|
||||||
|
|
||||||
|
// Update control
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
Vector2 mousePos = GetMousePosition();
|
||||||
|
// NOTE: most of the update code is actually done in the draw control section
|
||||||
|
if ((state != GUI_STATE_DISABLED) && !guiLocked) {
|
||||||
|
if(!CheckCollisionPointRec(mousePos, bounds)) {
|
||||||
|
propFocused = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useScrollBar)
|
||||||
|
{
|
||||||
|
int wheelMove = GetMouseWheelMove();
|
||||||
|
scroll += wheelMove*count;
|
||||||
|
if(-scroll > maxScroll) scroll = -maxScroll;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
// Draw control
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
DrawRectangleRec(bounds, Fade(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)), guiAlpha) ); // Draw background
|
||||||
|
DrawRectangleLinesEx(bounds, GuiGetStyle(DEFAULT, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(LISTVIEW, BORDER + state*3)), guiAlpha)); // Draw border
|
||||||
|
|
||||||
|
BeginScissorMode(absoluteBounds.x, bounds.y + GuiGetStyle(DEFAULT, BORDER_WIDTH), absoluteBounds.width, bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH));
|
||||||
|
int currentHeight = 0;
|
||||||
|
for(int p=0; p<count; ++p)
|
||||||
|
{
|
||||||
|
int height = GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT);
|
||||||
|
if(props[p].type < (sizeof(propSlots)/sizeof(propSlots[0])) && !PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED) )
|
||||||
|
height = propSlots[props[p].type]*GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT); // get property height based on how many slots it occupies
|
||||||
|
|
||||||
|
// Even with scissor mode on, draw only properties that we can see (comment out both BeginScissorMode() / EndScissorMode() to see this)
|
||||||
|
if(absoluteBounds.y + currentHeight + height >= bounds.y && absoluteBounds.y + currentHeight <= bounds.y + bounds.height)
|
||||||
|
{
|
||||||
|
Rectangle propBounds = {absoluteBounds.x, absoluteBounds.y + currentHeight, absoluteBounds.width, height};
|
||||||
|
Color textColor = Fade(GetColor(GuiGetStyle(LISTVIEW, TEXT_COLOR_NORMAL)), guiAlpha);
|
||||||
|
int propState = GUI_STATE_NORMAL;
|
||||||
|
|
||||||
|
// Get the state of this property and do some initial drawing
|
||||||
|
if(PROP_CHECK_FLAG(&props[p], GUI_PFLAG_DISABLED)) {
|
||||||
|
propState = GUI_STATE_DISABLED;
|
||||||
|
propBounds.height += 1;
|
||||||
|
DrawRectangleRec(propBounds, Fade(GetColor(GuiGetStyle(LISTVIEW, BASE_COLOR_DISABLED)), guiAlpha));
|
||||||
|
propBounds.height -= 1;
|
||||||
|
textColor = Fade(GetColor(GuiGetStyle(LISTVIEW, TEXT_COLOR_DISABLED)), guiAlpha);
|
||||||
|
} else {
|
||||||
|
if(CheckCollisionPointRec(mousePos, propBounds) && !guiLocked) {
|
||||||
|
if(IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) {
|
||||||
|
propState = GUI_STATE_PRESSED;
|
||||||
|
//DrawRectangleRec(propRect, Fade(GetColor(GuiGetStyle(LISTVIEW, BASE_COLOR_PRESSED)), guiAlpha));
|
||||||
|
textColor = Fade(GetColor(GuiGetStyle(LISTVIEW, TEXT_COLOR_PRESSED)), guiAlpha);
|
||||||
|
} else {
|
||||||
|
propState = GUI_STATE_FOCUSED;
|
||||||
|
propFocused = p;
|
||||||
|
//DrawRectangleRec(propRect, Fade(GetColor(GuiGetStyle(LISTVIEW, BASE_COLOR_FOCUSED)), guiAlpha));
|
||||||
|
textColor = Fade(GetColor(GuiGetStyle(LISTVIEW, TEXT_COLOR_FOCUSED)), guiAlpha);
|
||||||
|
}
|
||||||
|
} else propState = GUI_STATE_NORMAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(propState == GUI_STATE_DISABLED) GuiSetState(propState);
|
||||||
|
switch(props[p].type)
|
||||||
|
{
|
||||||
|
case GUI_PROP_BOOL: {
|
||||||
|
// draw property name
|
||||||
|
GuiDrawText(props[p].name, (Rectangle){propBounds.x + PROPERTY_PADDING, propBounds.y, propBounds.width/2-PROPERTY_PADDING, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)}, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
if(propState == GUI_STATE_PRESSED) props[p].value.vbool = !props[p].value.vbool; // toggle the property value when clicked
|
||||||
|
|
||||||
|
// draw property value
|
||||||
|
const bool locked = guiLocked;
|
||||||
|
GuiLock(); // lock the checkbox since we changed the value manually
|
||||||
|
GuiCheckBox((Rectangle){propBounds.x+propBounds.width/2, propBounds.y + height/4, height/2, height/2}, props[p].value.vbool ? "Yes" : "No", props[p].value.vbool);
|
||||||
|
if(!locked) GuiUnlock(); // only unlock when needed
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case GUI_PROP_INT:
|
||||||
|
// draw property name
|
||||||
|
GuiDrawText(props[p].name, (Rectangle){propBounds.x + PROPERTY_PADDING, propBounds.y, propBounds.width/2-PROPERTY_PADDING, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)}, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
// draw property value
|
||||||
|
props[p].value.vint.val = GuiDMSpinner((Rectangle){propBounds.x+propBounds.width/2, propBounds.y + 1, propBounds.width/2, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) - 2},
|
||||||
|
props[p].value.vint.val, props[p].value.vint.min, props[p].value.vint.max, props[p].value.vint.step, 0, (propState == GUI_STATE_FOCUSED) );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GUI_PROP_FLOAT:
|
||||||
|
// draw property name
|
||||||
|
GuiDrawText(props[p].name, (Rectangle){propBounds.x + PROPERTY_PADDING, propBounds.y, propBounds.width/2-PROPERTY_PADDING, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)}, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
// draw property value
|
||||||
|
props[p].value.vfloat.val = GuiDMSpinner((Rectangle){propBounds.x+propBounds.width/2, propBounds.y + 1, propBounds.width/2, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) - 2},
|
||||||
|
props[p].value.vfloat.val, props[p].value.vfloat.min, props[p].value.vfloat.max, props[p].value.vfloat.step, props[p].value.vfloat.precision, (propState == GUI_STATE_FOCUSED) );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GUI_PROP_TEXT: {
|
||||||
|
Rectangle titleBounds = { propBounds.x, propBounds.y, propBounds.width, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) };
|
||||||
|
// Collapse/Expand property on click
|
||||||
|
if((propState == GUI_STATE_PRESSED) && CheckCollisionPointRec(mousePos, titleBounds))
|
||||||
|
PROP_TOGGLE_FLAG(&props[p], GUI_PFLAG_COLLAPSED);
|
||||||
|
|
||||||
|
// draw property name
|
||||||
|
GuiDrawText(PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED) ? PROPERTY_COLLAPSED_ICON : PROPERTY_EXPANDED_ICON, titleBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
GuiDrawText(props[p].name, (Rectangle){propBounds.x+PROPERTY_ICON_SIZE+PROPERTY_PADDING, propBounds.y, propBounds.width-PROPERTY_ICON_SIZE-PROPERTY_PADDING, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)}, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
GuiDrawText(TextFormat("%i/%i", strlen(props[p].value.vtext.val), props[p].value.vtext.size), (Rectangle){propBounds.x+propBounds.width/2, propBounds.y + 1, propBounds.width/2, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) - 2}, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
|
||||||
|
// draw property value
|
||||||
|
if(!PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED))
|
||||||
|
GuiTextBox((Rectangle){propBounds.x, propBounds.y + GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)+1, propBounds.width, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)-2}, props[p].value.vtext.val, props[p].value.vtext.size, (propState == GUI_STATE_FOCUSED));
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case GUI_PROP_SELECT: {
|
||||||
|
// TODO: Create a custom dropdownbox control instead of using the raygui combobox
|
||||||
|
// draw property name
|
||||||
|
GuiDrawText(props[p].name, (Rectangle){propBounds.x + PROPERTY_PADDING, propBounds.y, propBounds.width/2-PROPERTY_PADDING, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)}, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
// draw property value
|
||||||
|
props[p].value.vselect.active = GuiComboBox((Rectangle){propBounds.x+propBounds.width/2, propBounds.y + 1, propBounds.width/2, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) - 2},
|
||||||
|
props[p].value.vselect.val, props[p].value.vselect.active);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case GUI_PROP_VECTOR2: case GUI_PROP_VECTOR3: case GUI_PROP_VECTOR4: {
|
||||||
|
Rectangle titleBounds = { propBounds.x, propBounds.y, propBounds.width, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) };
|
||||||
|
// Collapse/Expand property on click
|
||||||
|
if((propState == GUI_STATE_PRESSED) && CheckCollisionPointRec(mousePos, titleBounds))
|
||||||
|
PROP_TOGGLE_FLAG(&props[p], GUI_PFLAG_COLLAPSED);
|
||||||
|
|
||||||
|
const char* fmt = "";
|
||||||
|
if(props[p].type == GUI_PROP_VECTOR2) fmt = TextFormat("[%.0f, %.0f]", props[p].value.v2.x, props[p].value.v2.y);
|
||||||
|
else if(props[p].type == GUI_PROP_VECTOR3) fmt = TextFormat("[%.0f, %.0f, %.0f]", props[p].value.v3.x, props[p].value.v3.y, props[p].value.v3.z);
|
||||||
|
else fmt = TextFormat("[%.0f, %.0f, %.0f, %.0f]", props[p].value.v4.x, props[p].value.v4.y, props[p].value.v4.z, props[p].value.v4.w);
|
||||||
|
|
||||||
|
// draw property name
|
||||||
|
GuiDrawText(PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED) ? PROPERTY_COLLAPSED_ICON : PROPERTY_EXPANDED_ICON, titleBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
GuiDrawText(props[p].name, (Rectangle){propBounds.x+PROPERTY_ICON_SIZE+PROPERTY_PADDING, propBounds.y, propBounds.width-PROPERTY_ICON_SIZE-PROPERTY_PADDING, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)}, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
GuiDrawText(fmt, (Rectangle){propBounds.x+propBounds.width/2, propBounds.y + 1, propBounds.width/2, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) - 2}, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
|
||||||
|
// draw X, Y, Z, W values (only when expanded)
|
||||||
|
if(!PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED)) {
|
||||||
|
Rectangle slotBounds = { propBounds.x, propBounds.y+GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)+1, propBounds.width, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)-2};
|
||||||
|
Rectangle lblBounds = { propBounds.x+PROPERTY_PADDING, slotBounds.y, GetTextWidth("A"), slotBounds.height};
|
||||||
|
Rectangle valBounds = { lblBounds.x+lblBounds.width+PROPERTY_PADDING, slotBounds.y, propBounds.width-lblBounds.width-2*PROPERTY_PADDING, slotBounds.height};
|
||||||
|
GuiDrawText("X", lblBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
props[p].value.v2.x = GuiDMSpinner(valBounds, props[p].value.v2.x, 0.0, 0.0, 1.0, PROPERTY_DECIMAL_DIGITS, (propState == GUI_STATE_FOCUSED) && CheckCollisionPointRec(mousePos, slotBounds) );
|
||||||
|
slotBounds.y += GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT);
|
||||||
|
lblBounds.y = valBounds.y = slotBounds.y;
|
||||||
|
GuiDrawText("Y", lblBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
props[p].value.v2.y = GuiDMSpinner(valBounds, props[p].value.v2.y, 0.0, 0.0, 1.0, PROPERTY_DECIMAL_DIGITS, (propState == GUI_STATE_FOCUSED) && CheckCollisionPointRec(mousePos, slotBounds) );
|
||||||
|
slotBounds.y += GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT);
|
||||||
|
lblBounds.y = valBounds.y = slotBounds.y;
|
||||||
|
if(props[p].type >= GUI_PROP_VECTOR3) {
|
||||||
|
GuiDrawText("Z", lblBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
props[p].value.v3.z = GuiDMSpinner(valBounds, props[p].value.v3.z, 0.0, 0.0, 1.0, PROPERTY_DECIMAL_DIGITS, (propState == GUI_STATE_FOCUSED) && CheckCollisionPointRec(mousePos, slotBounds) );
|
||||||
|
slotBounds.y += GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT);
|
||||||
|
lblBounds.y = valBounds.y = slotBounds.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(props[p].type >= GUI_PROP_VECTOR4) {
|
||||||
|
GuiDrawText("W", lblBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
props[p].value.v4.w = GuiDMSpinner(valBounds, props[p].value.v4.w, 0.0, 0.0, 1.0, PROPERTY_DECIMAL_DIGITS, (propState == GUI_STATE_FOCUSED) && CheckCollisionPointRec(mousePos, slotBounds) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case GUI_PROP_RECT:{
|
||||||
|
Rectangle titleBounds = { propBounds.x, propBounds.y, propBounds.width, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) };
|
||||||
|
// Collapse/Expand property on click
|
||||||
|
if((propState == GUI_STATE_PRESSED) && CheckCollisionPointRec(mousePos, titleBounds))
|
||||||
|
PROP_TOGGLE_FLAG(&props[p], GUI_PFLAG_COLLAPSED);
|
||||||
|
|
||||||
|
// draw property name
|
||||||
|
GuiDrawText(PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED) ? PROPERTY_COLLAPSED_ICON : PROPERTY_EXPANDED_ICON, titleBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
GuiDrawText(props[p].name, (Rectangle){propBounds.x+PROPERTY_ICON_SIZE+PROPERTY_PADDING, propBounds.y, propBounds.width-PROPERTY_ICON_SIZE-PROPERTY_PADDING, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)}, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
GuiDrawText(TextFormat("[%.0f, %.0f, %.0f, %.0f]", props[p].value.vrect.x, props[p].value.vrect.y, props[p].value.vrect.width, props[p].value.vrect.height),
|
||||||
|
(Rectangle){propBounds.x+propBounds.width/2, propBounds.y + 1, propBounds.width/2, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) - 2}, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
|
||||||
|
// draw X, Y, Width, Height values (only when expanded)
|
||||||
|
if(!PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED)) {
|
||||||
|
Rectangle slotBounds = { propBounds.x, propBounds.y+GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)+1, propBounds.width, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)-2};
|
||||||
|
Rectangle lblBounds = { propBounds.x+PROPERTY_PADDING, slotBounds.y, GetTextWidth("Height"), slotBounds.height};
|
||||||
|
Rectangle valBounds = { lblBounds.x+lblBounds.width+PROPERTY_PADDING, slotBounds.y, propBounds.width-lblBounds.width-2*PROPERTY_PADDING, slotBounds.height};
|
||||||
|
GuiDrawText("X", lblBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
props[p].value.vrect.x = GuiDMSpinner(valBounds, props[p].value.vrect.x, 0.0, 0.0, 1.0, 0, (propState == GUI_STATE_FOCUSED) && CheckCollisionPointRec(mousePos, slotBounds) );
|
||||||
|
slotBounds.y += GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT);
|
||||||
|
lblBounds.y = valBounds.y = slotBounds.y;
|
||||||
|
GuiDrawText("Y", lblBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
props[p].value.vrect.y = GuiDMSpinner(valBounds, props[p].value.vrect.y, 0.0, 0.0, 1.0, 0, (propState == GUI_STATE_FOCUSED) && CheckCollisionPointRec(mousePos, slotBounds) );
|
||||||
|
slotBounds.y += GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT);
|
||||||
|
lblBounds.y = valBounds.y = slotBounds.y;
|
||||||
|
GuiDrawText("Width", lblBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
props[p].value.vrect.width = GuiDMSpinner(valBounds, props[p].value.vrect.width, 0.0, 0.0, 1.0, 0, (propState == GUI_STATE_FOCUSED) && CheckCollisionPointRec(mousePos, slotBounds) );
|
||||||
|
slotBounds.y += GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT);
|
||||||
|
lblBounds.y = valBounds.y = slotBounds.y;
|
||||||
|
GuiDrawText("Height", lblBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
props[p].value.vrect.height = GuiDMSpinner(valBounds, props[p].value.vrect.height, 0.0, 0.0, 1.0, 0, (propState == GUI_STATE_FOCUSED) && CheckCollisionPointRec(mousePos, slotBounds) );
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
|
||||||
|
case GUI_PROP_COLOR: {
|
||||||
|
Rectangle titleBounds = { propBounds.x, propBounds.y, propBounds.width, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) };
|
||||||
|
// Collapse/Expand property on click
|
||||||
|
if((propState == GUI_STATE_PRESSED) && CheckCollisionPointRec(mousePos, titleBounds))
|
||||||
|
PROP_TOGGLE_FLAG(&props[p], GUI_PFLAG_COLLAPSED);
|
||||||
|
|
||||||
|
// draw property name
|
||||||
|
GuiDrawText(PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED) ? PROPERTY_COLLAPSED_ICON : PROPERTY_EXPANDED_ICON, titleBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
GuiDrawText(props[p].name, (Rectangle){propBounds.x+PROPERTY_ICON_SIZE+PROPERTY_PADDING, propBounds.y+1, propBounds.width-PROPERTY_ICON_SIZE-PROPERTY_PADDING, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)-2}, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
DrawLineEx( (Vector2){propBounds.x+propBounds.width/2, propBounds.y + GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) - 5}, (Vector2){propBounds.x+propBounds.width, propBounds.y + GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) - 5}, 6.0f, props[p].value.vcolor);
|
||||||
|
const char* fmt = TextFormat("#%02X%02X%02X%02X", props[p].value.vcolor.r, props[p].value.vcolor.g, props[p].value.vcolor.b, props[p].value.vcolor.a);
|
||||||
|
char clip[10] = "\0";
|
||||||
|
memcpy(clip, fmt, 10*sizeof(char)); // copy to temporary buffer since we can't be sure when TextFormat() will be called again and our text will be overwritten
|
||||||
|
GuiDrawText(fmt, (Rectangle){propBounds.x+propBounds.width/2, propBounds.y + 1, propBounds.width/2, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) - 2}, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
|
||||||
|
// draw R, G, B, A values (only when expanded)
|
||||||
|
if(!PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED)) {
|
||||||
|
Rectangle slotBounds = { propBounds.x, propBounds.y+GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)+1, propBounds.width, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)-2};
|
||||||
|
Rectangle lblBounds = { propBounds.x+PROPERTY_PADDING, slotBounds.y, GetTextWidth("A"), slotBounds.height};
|
||||||
|
Rectangle valBounds = { lblBounds.x+lblBounds.width+PROPERTY_PADDING, slotBounds.y, GetTextWidth("000000"), slotBounds.height};
|
||||||
|
Rectangle sbarBounds = { valBounds.x + valBounds.width + PROPERTY_PADDING, slotBounds.y, slotBounds.width - 3*PROPERTY_PADDING - lblBounds.width - valBounds.width, slotBounds.height };
|
||||||
|
|
||||||
|
if(sbarBounds.width <= GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)-2) valBounds.width = propBounds.width-lblBounds.width-2*PROPERTY_PADDING; // hide slider when no space
|
||||||
|
// save current scrollbar style
|
||||||
|
int tmpSliderPadding = GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING);
|
||||||
|
int tmpPadding = GuiGetStyle(SCROLLBAR, SCROLL_PADDING);
|
||||||
|
int tmpBorder = GuiGetStyle(SCROLLBAR, BORDER_WIDTH);
|
||||||
|
int tmpSliderSize = GuiGetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE);
|
||||||
|
int tmpArrows = GuiGetStyle(SCROLLBAR, ARROWS_VISIBLE);
|
||||||
|
Color tmpBG1 = GetColor(GuiGetStyle(DEFAULT, BORDER_COLOR_DISABLED));
|
||||||
|
// set a custom scrollbar style
|
||||||
|
GuiSetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING, 3);
|
||||||
|
GuiSetStyle(SCROLLBAR, SCROLL_PADDING, 10);
|
||||||
|
GuiSetStyle(SCROLLBAR, BORDER_WIDTH, 0);
|
||||||
|
GuiSetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE, 6);
|
||||||
|
GuiSetStyle(SCROLLBAR, ARROWS_VISIBLE, 0);
|
||||||
|
GuiSetStyle(DEFAULT, BORDER_COLOR_DISABLED, GuiGetStyle(DEFAULT, BACKGROUND_COLOR)); // disable scrollbar background
|
||||||
|
|
||||||
|
GuiDrawText("R", lblBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
props[p].value.vcolor.r = GuiDMValueBox(valBounds, props[p].value.vcolor.r, 0.0, 255.0, 0, (propState == GUI_STATE_FOCUSED) && CheckCollisionPointRec(mousePos, slotBounds) );
|
||||||
|
if(sbarBounds.width > GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)-2)
|
||||||
|
props[p].value.vcolor.r = GuiScrollBar(sbarBounds, props[p].value.vcolor.r, 0, 255);
|
||||||
|
slotBounds.y += GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT);
|
||||||
|
lblBounds.y = valBounds.y = sbarBounds.y = slotBounds.y;
|
||||||
|
|
||||||
|
GuiDrawText("G", lblBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
props[p].value.vcolor.g = GuiDMValueBox(valBounds, props[p].value.vcolor.g, 0.0, 255.0, 0, (propState == GUI_STATE_FOCUSED) && CheckCollisionPointRec(mousePos, slotBounds) );
|
||||||
|
if(sbarBounds.width > GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)-2)
|
||||||
|
props[p].value.vcolor.g = GuiScrollBar(sbarBounds, props[p].value.vcolor.g, 0, 255);
|
||||||
|
slotBounds.y += GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT);
|
||||||
|
lblBounds.y = valBounds.y = sbarBounds.y = slotBounds.y;
|
||||||
|
|
||||||
|
GuiDrawText("B", lblBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
props[p].value.vcolor.b = GuiDMValueBox(valBounds, props[p].value.vcolor.b, 0.0, 255.0, 0, (propState == GUI_STATE_FOCUSED) && CheckCollisionPointRec(mousePos, slotBounds) );
|
||||||
|
if(sbarBounds.width > GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)-2)
|
||||||
|
props[p].value.vcolor.b = GuiScrollBar(sbarBounds, props[p].value.vcolor.b, 0, 255);
|
||||||
|
slotBounds.y += GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT);
|
||||||
|
lblBounds.y = valBounds.y = sbarBounds.y = slotBounds.y;
|
||||||
|
|
||||||
|
GuiDrawText("A", lblBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
props[p].value.vcolor.a = GuiDMValueBox(valBounds, props[p].value.vcolor.a, 0.0, 255.0, 0, (propState == GUI_STATE_FOCUSED) && CheckCollisionPointRec(mousePos, slotBounds) );
|
||||||
|
if(sbarBounds.width > GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)-2)
|
||||||
|
props[p].value.vcolor.a = GuiScrollBar(sbarBounds, props[p].value.vcolor.a, 0, 255);
|
||||||
|
|
||||||
|
// load saved scrollbar style
|
||||||
|
GuiSetStyle(SCROLLBAR, SCROLL_SLIDER_PADDING, tmpSliderPadding);
|
||||||
|
GuiSetStyle(SCROLLBAR, SCROLL_PADDING, tmpPadding);
|
||||||
|
GuiSetStyle(SCROLLBAR, BORDER_WIDTH, tmpBorder);
|
||||||
|
GuiSetStyle(SCROLLBAR, SCROLL_SLIDER_SIZE, tmpSliderSize);
|
||||||
|
GuiSetStyle(SCROLLBAR, ARROWS_VISIBLE, tmpArrows);
|
||||||
|
GuiSetStyle(DEFAULT, BORDER_COLOR_DISABLED, ColorToInt(tmpBG1));
|
||||||
|
}
|
||||||
|
|
||||||
|
// support COPY/PASTE (need to do this here since GuiDMValueBox() also has COPY/PASTE so we need to overwrite it)
|
||||||
|
if((propState == GUI_STATE_FOCUSED)) {
|
||||||
|
if(IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_C))
|
||||||
|
SetClipboardText(clip);
|
||||||
|
else if(IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_V)){
|
||||||
|
unsigned int a = props[p].value.vcolor.a, r = props[p].value.vcolor.r, g=props[p].value.vcolor.g, b=props[p].value.vcolor.b;
|
||||||
|
sscanf(GetClipboardText(), "#%02X%02X%02X%02X", &r, &g, &b, &a);
|
||||||
|
props[p].value.vcolor.r=r; props[p].value.vcolor.g=g; props[p].value.vcolor.b=b; props[p].value.vcolor.a=a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case GUI_PROP_SECTION: {
|
||||||
|
Rectangle titleBounds = { propBounds.x, propBounds.y, propBounds.width, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) };
|
||||||
|
// Collapse/Expand section on click
|
||||||
|
if( (propState == GUI_STATE_PRESSED) && CheckCollisionPointRec(mousePos, titleBounds) )
|
||||||
|
PROP_TOGGLE_FLAG(&props[p], GUI_PFLAG_COLLAPSED);
|
||||||
|
|
||||||
|
if(!PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED)) {
|
||||||
|
GuiDrawText(PROPERTY_EXPANDED_ICON, titleBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
GuiDrawText(props[p].name, (Rectangle){propBounds.x+PROPERTY_ICON_SIZE+PROPERTY_PADDING, propBounds.y, propBounds.width-PROPERTY_ICON_SIZE-PROPERTY_PADDING, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)}, GUI_TEXT_ALIGN_CENTER, textColor);
|
||||||
|
} else {
|
||||||
|
GuiDrawText(PROPERTY_COLLAPSED_ICON, titleBounds, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
GuiDrawText(TextFormat("%s [%i]", props[p].name, props[p].value.vsection), (Rectangle){propBounds.x+PROPERTY_ICON_SIZE+PROPERTY_PADDING, propBounds.y, propBounds.width-PROPERTY_ICON_SIZE-PROPERTY_PADDING, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)}, GUI_TEXT_ALIGN_CENTER, textColor);
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
|
|
||||||
|
// NOTE: Add your custom property here !!
|
||||||
|
default: {
|
||||||
|
// draw property name
|
||||||
|
GuiDrawText(props[p].name, (Rectangle){propBounds.x + PROPERTY_PADDING, propBounds.y, propBounds.width/2-PROPERTY_PADDING, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)}, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
// draw property type
|
||||||
|
GuiDrawText(TextFormat("TYPE %i", props[p].type), (Rectangle){propBounds.x+propBounds.width/2, propBounds.y + 1, propBounds.width/2, GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT) - 2}, GUI_TEXT_ALIGN_LEFT, textColor);
|
||||||
|
} break;
|
||||||
|
|
||||||
|
} // end of switch()
|
||||||
|
|
||||||
|
GuiSetState(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
currentHeight += height + 1;
|
||||||
|
|
||||||
|
// Skip collapsed section. Don't put this code inside the switch !!
|
||||||
|
if(props[p].type == GUI_PROP_SECTION && (PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED))) p += props[p].value.vsection;
|
||||||
|
} // end for
|
||||||
|
EndScissorMode();
|
||||||
|
|
||||||
|
if(useScrollBar) {
|
||||||
|
scroll = -GuiScrollBar(scrollBarBounds, -scroll, 0, maxScroll);
|
||||||
|
*scrollIndex = scroll;
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
if(focus != NULL) *focus = propFocused;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GuiDMSaveProperties(const char* file, GuiDMProperty* props, int count) {
|
||||||
|
if(file == NULL || props == NULL) return false;
|
||||||
|
if(count == 0) return true;
|
||||||
|
|
||||||
|
FILE* f = fopen(file, "w");
|
||||||
|
if(f == NULL) return false;
|
||||||
|
|
||||||
|
// write header
|
||||||
|
fprintf(f, "#\n# Property types:\n"
|
||||||
|
"# b <name> <flags> <value> // Bool\n"
|
||||||
|
"# i <name> <flags> <value> <min> <max> <step> // Int\n"
|
||||||
|
"# f <name> <flags> <value> <min> <max> <step> <precision> // Float\n"
|
||||||
|
"# t <name> <flags> <value> <edit_length> // Text\n"
|
||||||
|
"# l <name> <flags> <value> <active> // Select\n"
|
||||||
|
"# g <name> <flags> <value> // Section (Group)\n"
|
||||||
|
"# v2 <name> <flags> <x> <y> // Vector 2D\n"
|
||||||
|
"# v3 <name> <flags> <x> <y> <z> // Vector 3D\n"
|
||||||
|
"# v4 <name> <flags> <x> <y> <z> <w> // Vector 4D\n"
|
||||||
|
"# r <name> <flags> <x> <y> <width> <height> // Rectangle\n"
|
||||||
|
"# c <name> <flags> <r> <g> <b> <a> // Color\n"
|
||||||
|
"#\n\n");
|
||||||
|
for(int p=0; p<count; ++p)
|
||||||
|
{
|
||||||
|
switch(props[p].type) {
|
||||||
|
case GUI_PROP_BOOL: fprintf(f, "b %s %i %i\n", props[p].name, (int)props[p].flags, (int)props[p].value.vbool);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GUI_PROP_INT: fprintf(f, "i %s %i %i %i %i %i\n", props[p].name, (int)props[p].flags, props[p].value.vint.val, props[p].value.vint.min,
|
||||||
|
props[p].value.vint.max, props[p].value.vint.step);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GUI_PROP_FLOAT: fprintf(f, "f %s %i %f %f %f %f %i\n", props[p].name, (int)props[p].flags, props[p].value.vfloat.val, props[p].value.vfloat.min,
|
||||||
|
props[p].value.vfloat.max, props[p].value.vfloat.step, props[p].value.vfloat.precision);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GUI_PROP_TEXT: fprintf(f, "t %s %i %s %i\n", props[p].name, (int)props[p].flags, props[p].value.vtext.val, props[p].value.vtext.size);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GUI_PROP_SELECT: fprintf(f, "l %s %i %s %i\n", props[p].name, (int)props[p].flags, props[p].value.vselect.val, props[p].value.vselect.active);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GUI_PROP_SECTION: fprintf(f, "g %s %i %i\n", props[p].name, (int)props[p].flags, props[p].value.vsection);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GUI_PROP_VECTOR2: fprintf(f, "v2 %s %i %f %f\n", props[p].name, (int)props[p].flags, props[p].value.v2.x, props[p].value.v2.y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GUI_PROP_VECTOR3: fprintf(f, "v3 %s %i %f %f %f\n", props[p].name, (int)props[p].flags, props[p].value.v3.x, props[p].value.v3.y, props[p].value.v3.z);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GUI_PROP_VECTOR4: fprintf(f, "v4 %s %i %f %f %f %f\n", props[p].name, (int)props[p].flags, props[p].value.v4.x, props[p].value.v4.y,
|
||||||
|
props[p].value.v4.z, props[p].value.v4.w);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GUI_PROP_RECT: fprintf(f, "r %s %i %i %i %i %i\n", props[p].name, (int)props[p].flags, (int)props[p].value.vrect.x, (int)props[p].value.vrect.y,
|
||||||
|
(int)props[p].value.vrect.width, (int)props[p].value.vrect.height);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GUI_PROP_COLOR: fprintf(f, "c %s %i %i %i %i %i\n", props[p].name, (int)props[p].flags, props[p].value.vcolor.r, props[p].value.vcolor.g,
|
||||||
|
props[p].value.vcolor.b, props[p].value.vcolor.a);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(f);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // GUI_PROPERTY_LIST_IMPLEMENTATION
|
||||||
99
examples/property_list/property_list.c
Normal file
99
examples/property_list/property_list.c
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raygui - custom property list control
|
||||||
|
*
|
||||||
|
* DEPENDENCIES:
|
||||||
|
* raylib 4.0 - Windowing/input management and drawing.
|
||||||
|
* raygui 3.0 - Immediate-mode GUI controls.
|
||||||
|
*
|
||||||
|
* COMPILATION (Windows - MinGW):
|
||||||
|
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
||||||
|
*
|
||||||
|
* LICENSE: zlib/libpng
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020-2021 Vlad Adrian (@Demizdor) and Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
**********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#define RAYGUI_IMPLEMENTATION
|
||||||
|
#include "../../src/raygui.h"
|
||||||
|
|
||||||
|
#undef RAYGUI_IMPLEMENTATION // Avoid including raygui implementation again
|
||||||
|
|
||||||
|
#define GUI_PROPERTY_LIST_IMPLEMENTATION
|
||||||
|
#include "dm_property_list.h"
|
||||||
|
|
||||||
|
#define SIZEOF(A) (sizeof(A)/sizeof(A[0]))
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Program main entry point
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//---------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raygui - property list");
|
||||||
|
|
||||||
|
GuiDMProperty prop[] = {
|
||||||
|
PBOOL("Bool", 0, true),
|
||||||
|
PSECTION("#102#SECTION", 0, 2),
|
||||||
|
PINT("Int", 0, 123),
|
||||||
|
PFLOAT("Float", 0, 0.99f),
|
||||||
|
PTEXT("Text", 0, (char*)&(char[30]){"Hello!"}, 30),
|
||||||
|
PSELECT("Select", 0, "ONE;TWO;THREE;FOUR", 0),
|
||||||
|
PINT_RANGE("Int Range", 0, 32, 1, 0, 100),
|
||||||
|
PRECT("Rect", 0, 0, 0, 100, 200),
|
||||||
|
PVEC2("Vec2", 0, 20, 20),
|
||||||
|
PVEC3("Vec3", 0, 12, 13, 14),
|
||||||
|
PVEC4("Vec4", 0, 12, 13, 14, 15),
|
||||||
|
PCOLOR("Color", 0, 0, 255, 0, 255),
|
||||||
|
};
|
||||||
|
|
||||||
|
int focus = 0, scroll = 0; // Needed by GuiDMPropertyList()
|
||||||
|
|
||||||
|
GuiLoadStyleDefault();
|
||||||
|
|
||||||
|
// Tweak the default raygui style a bit
|
||||||
|
GuiSetStyle(LISTVIEW, LIST_ITEMS_HEIGHT, 24);
|
||||||
|
GuiSetStyle(LISTVIEW, SCROLLBAR_WIDTH, 12);
|
||||||
|
|
||||||
|
SetTargetFPS(60);
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)));
|
||||||
|
|
||||||
|
GuiGrid((Rectangle){0, 0, screenWidth, screenHeight},20.0f, 2); // Draw a fancy grid
|
||||||
|
|
||||||
|
GuiDMPropertyList((Rectangle){(screenWidth - 180)/2, (screenHeight - 280)/2, 180, 280}, prop, SIZEOF(prop), &focus, &scroll);
|
||||||
|
|
||||||
|
if (prop[0].value.vbool >= 1)
|
||||||
|
{
|
||||||
|
DrawText(TextFormat("FOCUS:%i | SCROLL:%i | FPS:%i", focus, scroll, GetFPS()), prop[8].value.v2.x, prop[8].value.v2.y, 20, prop[11].value.vcolor);
|
||||||
|
}
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
GuiDMSaveProperties("test.props", prop, SIZEOF(prop)); // Save properties to `test.props` file at exit
|
||||||
|
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
27
examples/property_list/test.props
Normal file
27
examples/property_list/test.props
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#
|
||||||
|
# Property types:
|
||||||
|
# b <name> <flags> <value> // Bool
|
||||||
|
# i <name> <flags> <value> <min> <max> <step> // Int
|
||||||
|
# f <name> <flags> <value> <min> <max> <step> <precision> // Float
|
||||||
|
# t <name> <flags> <value> <edit_length> // Text
|
||||||
|
# l <name> <flags> <value> <active> // Select
|
||||||
|
# g <name> <flags> <value> // Section (Group)
|
||||||
|
# v2 <name> <flags> <x> <y> // Vector 2D
|
||||||
|
# v3 <name> <flags> <x> <y> <z> // Vector 3D
|
||||||
|
# v4 <name> <flags> <x> <y> <z> <w> // Vector 4D
|
||||||
|
# r <name> <flags> <x> <y> <width> <height> // Rectangle
|
||||||
|
# c <name> <flags> <r> <g> <b> <a> // Color
|
||||||
|
#
|
||||||
|
|
||||||
|
b Bool 0 1
|
||||||
|
g #102#SECTION 0 2
|
||||||
|
i Int 0 123 0 0 1
|
||||||
|
f Float 0 0.990000 0.000000 0.000000 1.000000 3
|
||||||
|
t Text 1 Hello! 30
|
||||||
|
l Select 0 ONE;TWO;THREE;FOUR 3
|
||||||
|
i Int Range 0 32 0 100 1
|
||||||
|
r Rect 1 0 0 100 200
|
||||||
|
v2 Vec2 1 20.000000 20.000000
|
||||||
|
v3 Vec3 1 12.000000 13.000000 14.000000
|
||||||
|
v4 Vec4 1 12.000000 13.000000 14.000000 15.000000
|
||||||
|
c Color 1 94 68 197 160
|
||||||
@ -6,18 +6,18 @@
|
|||||||
* - GuiScrollPanel()
|
* - GuiScrollPanel()
|
||||||
*
|
*
|
||||||
* DEPENDENCIES:
|
* DEPENDENCIES:
|
||||||
* raylib 2.4 - Windowing/input management and drawing.
|
* raylib 4.0 - Windowing/input management and drawing.
|
||||||
* raygui 2.0 - Immediate-mode GUI controls.
|
* raygui 3.0 - Immediate-mode GUI controls.
|
||||||
*
|
*
|
||||||
* COMPILATION (Windows - MinGW):
|
* COMPILATION (Windows - MinGW):
|
||||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
||||||
*
|
*
|
||||||
* COMPILATION (Linux - gcc):
|
* COMPILATION (Linux - gcc):
|
||||||
* gcc -o $(NAME_PART) $(FILE_NAME) -I../../src -lraylib -std=c99
|
* gcc -o $(NAME_PART) $(FILE_NAME) -I../../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -std=c99
|
||||||
*
|
*
|
||||||
* LICENSE: zlib/libpng
|
* LICENSE: zlib/libpng
|
||||||
*
|
*
|
||||||
* Copyright (c) 2019 Vlad Adrian (@Demizdor) and Ramon Santamaria (@raysan5)
|
* Copyright (c) 2019-2021 Vlad Adrian (@Demizdor) and Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
**********************************************************************************************/
|
**********************************************************************************************/
|
||||||
|
|
||||||
@ -78,8 +78,8 @@ int main()
|
|||||||
|
|
||||||
showContentArea = GuiCheckBox((Rectangle){ 565, 80, 20, 20 }, "SHOW CONTENT AREA", showContentArea);
|
showContentArea = GuiCheckBox((Rectangle){ 565, 80, 20, 20 }, "SHOW CONTENT AREA", showContentArea);
|
||||||
|
|
||||||
panelContentRec.width = GuiSliderBar((Rectangle){ 590, 385, 145, 15}, "WIDTH", panelContentRec.width, 1, 600, true);
|
panelContentRec.width = GuiSliderBar((Rectangle){ 590, 385, 145, 15}, "WIDTH", TextFormat("%i", (int)panelContentRec.width), panelContentRec.width, 1, 600);
|
||||||
panelContentRec.height = GuiSliderBar((Rectangle){ 590, 410, 145, 15 }, "HEIGHT", panelContentRec.height, 1, 400, true);
|
panelContentRec.height = GuiSliderBar((Rectangle){ 590, 410, 145, 15 }, "HEIGHT", TextFormat("%i", (int)panelContentRec.height), panelContentRec.height, 1, 400);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
@ -102,31 +102,31 @@ static void DrawStyleEditControls(void)
|
|||||||
|
|
||||||
int style = GuiGetStyle(SCROLLBAR, BORDER_WIDTH);
|
int style = GuiGetStyle(SCROLLBAR, BORDER_WIDTH);
|
||||||
GuiLabel((Rectangle){ 555, 195, 110, 10 }, "BORDER_WIDTH");
|
GuiLabel((Rectangle){ 555, 195, 110, 10 }, "BORDER_WIDTH");
|
||||||
GuiSpinner((Rectangle){ 670, 190, 90, 20 }, &style, 0, 6, false);
|
GuiSpinner((Rectangle){ 670, 190, 90, 20 }, NULL, &style, 0, 6, false);
|
||||||
GuiSetStyle(SCROLLBAR, BORDER_WIDTH, style);
|
GuiSetStyle(SCROLLBAR, BORDER_WIDTH, style);
|
||||||
|
|
||||||
style = GuiGetStyle(SCROLLBAR, ARROWS_SIZE);
|
style = GuiGetStyle(SCROLLBAR, ARROWS_SIZE);
|
||||||
GuiLabel((Rectangle){ 555, 220, 110, 10 }, "ARROWS_SIZE");
|
GuiLabel((Rectangle){ 555, 220, 110, 10 }, "ARROWS_SIZE");
|
||||||
GuiSpinner((Rectangle){ 670, 215, 90, 20 }, &style, 4, 14, false);
|
GuiSpinner((Rectangle){ 670, 215, 90, 20 }, NULL, &style, 4, 14, false);
|
||||||
GuiSetStyle(SCROLLBAR, ARROWS_SIZE, style);
|
GuiSetStyle(SCROLLBAR, ARROWS_SIZE, style);
|
||||||
|
|
||||||
style = GuiGetStyle(SCROLLBAR, INNER_PADDING);
|
style = GuiGetStyle(SCROLLBAR, SLIDER_PADDING);
|
||||||
GuiLabel((Rectangle){ 555, 245, 110, 10 }, "INNER_PADDING");
|
GuiLabel((Rectangle){ 555, 245, 110, 10 }, "SLIDER_PADDING");
|
||||||
GuiSpinner((Rectangle){ 670, 240, 90, 20 }, &style, 0, 14, false);
|
GuiSpinner((Rectangle){ 670, 240, 90, 20 }, NULL, &style, 0, 14, false);
|
||||||
GuiSetStyle(SCROLLBAR, INNER_PADDING, style);
|
GuiSetStyle(SCROLLBAR, SLIDER_PADDING, style);
|
||||||
|
|
||||||
style = GuiCheckBox((Rectangle){ 565, 280, 20, 20 }, "ARROWS_VISIBLE", GuiGetStyle(SCROLLBAR, ARROWS_VISIBLE));
|
style = GuiCheckBox((Rectangle){ 565, 280, 20, 20 }, "ARROWS_VISIBLE", GuiGetStyle(SCROLLBAR, ARROWS_VISIBLE));
|
||||||
GuiSetStyle(SCROLLBAR, ARROWS_VISIBLE, style);
|
GuiSetStyle(SCROLLBAR, ARROWS_VISIBLE, style);
|
||||||
|
|
||||||
style = GuiGetStyle(SCROLLBAR, SLIDER_PADDING);
|
style = GuiGetStyle(SCROLLBAR, SLIDER_PADDING);
|
||||||
GuiLabel((Rectangle){ 555, 325, 110, 10 }, "SLIDER_PADDING");
|
GuiLabel((Rectangle){ 555, 325, 110, 10 }, "SLIDER_PADDING");
|
||||||
GuiSpinner((Rectangle){ 670, 320, 90, 20 }, &style, 0, 14, false);
|
GuiSpinner((Rectangle){ 670, 320, 90, 20 }, NULL, &style, 0, 14, false);
|
||||||
GuiSetStyle(SCROLLBAR, SLIDER_PADDING, style);
|
GuiSetStyle(SCROLLBAR, SLIDER_PADDING, style);
|
||||||
|
|
||||||
style = GuiGetStyle(SCROLLBAR, SLIDER_SIZE);
|
style = GuiGetStyle(SCROLLBAR, SLIDER_WIDTH);
|
||||||
GuiLabel((Rectangle){ 555, 350, 110, 10 }, "SLIDER_SIZE");
|
GuiLabel((Rectangle){ 555, 350, 110, 10 }, "SLIDER_WIDTH");
|
||||||
GuiSpinner((Rectangle){ 670, 345, 90, 20 }, &style, 2, 100, false);
|
GuiSpinner((Rectangle){ 670, 345, 90, 20 }, NULL, &style, 2, 100, false);
|
||||||
GuiSetStyle(SCROLLBAR, SLIDER_SIZE, style);
|
GuiSetStyle(SCROLLBAR, SLIDER_WIDTH, style);
|
||||||
|
|
||||||
const char *text = GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE? "SCROLLBAR: LEFT" : "SCROLLBAR: RIGHT";
|
const char *text = GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE? "SCROLLBAR: LEFT" : "SCROLLBAR: RIGHT";
|
||||||
style = GuiToggle((Rectangle){ 560, 110, 200, 35 }, text, GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE));
|
style = GuiToggle((Rectangle){ 560, 110, 200, 35 }, text, GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE));
|
||||||
@ -139,12 +139,12 @@ static void DrawStyleEditControls(void)
|
|||||||
|
|
||||||
style = GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH);
|
style = GuiGetStyle(LISTVIEW, SCROLLBAR_WIDTH);
|
||||||
GuiLabel((Rectangle){ 555, 35, 110, 10 }, "SCROLLBAR_WIDTH");
|
GuiLabel((Rectangle){ 555, 35, 110, 10 }, "SCROLLBAR_WIDTH");
|
||||||
GuiSpinner((Rectangle){ 670, 30, 90, 20 }, &style, 6, 30, false);
|
GuiSpinner((Rectangle){ 670, 30, 90, 20 }, NULL, &style, 6, 30, false);
|
||||||
GuiSetStyle(LISTVIEW, SCROLLBAR_WIDTH, style);
|
GuiSetStyle(LISTVIEW, SCROLLBAR_WIDTH, style);
|
||||||
|
|
||||||
style = GuiGetStyle(DEFAULT, BORDER_WIDTH);
|
style = GuiGetStyle(DEFAULT, BORDER_WIDTH);
|
||||||
GuiLabel((Rectangle){ 555, 60, 110, 10 }, "BORDER_WIDTH");
|
GuiLabel((Rectangle){ 555, 60, 110, 10 }, "BORDER_WIDTH");
|
||||||
GuiSpinner((Rectangle){ 670, 55, 90, 20 }, &style, 0, 20, false);
|
GuiSpinner((Rectangle){ 670, 55, 90, 20 }, NULL, &style, 0, 20, false);
|
||||||
GuiSetStyle(DEFAULT, BORDER_WIDTH, style);
|
GuiSetStyle(DEFAULT, BORDER_WIDTH, style);
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
}
|
}
|
||||||
193
examples/standalone/raygui_custom_backend.h
Normal file
193
examples/standalone/raygui_custom_backend.h
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raygui - Standalone mode custom backend
|
||||||
|
*
|
||||||
|
* Just edit this file to include your custom implementation to your graphic API
|
||||||
|
*
|
||||||
|
* LICENSE: <your_license>
|
||||||
|
*
|
||||||
|
* Copyright (c) <year> <developer_name>
|
||||||
|
*
|
||||||
|
**********************************************************************************************/
|
||||||
|
|
||||||
|
//#include "my_cool_graphic_api.h"
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Defines and Macros
|
||||||
|
// TODO: Define input keys required by raygui
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
#define KEY_RIGHT 262
|
||||||
|
#define KEY_LEFT 263
|
||||||
|
#define KEY_DOWN 264
|
||||||
|
#define KEY_UP 265
|
||||||
|
#define KEY_BACKSPACE 259
|
||||||
|
#define KEY_ENTER 257
|
||||||
|
#define MOUSE_LEFT_BUTTON 0
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Types and Structures Definition
|
||||||
|
// TODO: Define required structures, maybe Font/Texture2D should be defined here?
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// ...
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Global Variables Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// ...
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Module Functions Definition
|
||||||
|
// TODO: Define all raygui required functions (previously provided by raylib)
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
// Input required functions
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
static Vector2 GetMousePosition(void)
|
||||||
|
{
|
||||||
|
Vector2 position = { 0 };
|
||||||
|
|
||||||
|
// TODO: Mouse position
|
||||||
|
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int GetMouseWheelMove(void)
|
||||||
|
{
|
||||||
|
// TODO: Mouse wheel movement variation, reseted every frame
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool IsMouseButtonDown(int button)
|
||||||
|
{
|
||||||
|
// TODO: Return true while mouse button [0..2] is being down
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool IsMouseButtonPressed(int button)
|
||||||
|
{
|
||||||
|
// TODO: Return true when mouse button [0..2] has been pressed: up->down
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool IsMouseButtonReleased(int button)
|
||||||
|
{
|
||||||
|
// TODO: Return true when mouse button [0..2] has been released: down->up
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool IsKeyDown(int key)
|
||||||
|
{
|
||||||
|
// TODO: Return true while key is being down
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool IsKeyPressed(int key)
|
||||||
|
{
|
||||||
|
// TODO: Return true when key has been pressed: up->down
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// USED IN: GuiTextBox(), GuiTextBoxMulti(), GuiValueBox()
|
||||||
|
static int GetKeyPressed(void)
|
||||||
|
{
|
||||||
|
// TODO: Return last key pressed (up->down) in the frame
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
// Drawing required functions
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
static void DrawRectangle(int x, int y, int width, int height, Color color)
|
||||||
|
{
|
||||||
|
// TODO: Draw rectangle on the screen
|
||||||
|
}
|
||||||
|
|
||||||
|
// USED IN: GuiColorPicker()
|
||||||
|
static void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4)
|
||||||
|
{
|
||||||
|
// TODO: Draw rectangle with gradients (4 vertex colors) on the screen
|
||||||
|
}
|
||||||
|
|
||||||
|
// USED IN: GuiDropdownBox(), GuiScrollBar()
|
||||||
|
static void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color)
|
||||||
|
{
|
||||||
|
// TODO: Draw triangle on the screen, required for arrows
|
||||||
|
}
|
||||||
|
|
||||||
|
// USED IN: GuiImageButtonEx()
|
||||||
|
static void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, Color tint)
|
||||||
|
{
|
||||||
|
// TODO: Draw texture (piece defined by source rectangle) on screen
|
||||||
|
}
|
||||||
|
|
||||||
|
// USED IN: GuiTextBoxMulti()
|
||||||
|
static void DrawTextRec(Font font, const char *text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint)
|
||||||
|
{
|
||||||
|
// TODO: Draw text limited by a rectangle. This advance function wraps the text inside the rectangle
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
// Text required functions
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
// USED IN: GuiLoadStyleDefault()
|
||||||
|
static Font GetFontDefault(void)
|
||||||
|
{
|
||||||
|
Font font = { 0 };
|
||||||
|
|
||||||
|
// TODO: Return default rendering Font for the UI
|
||||||
|
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
// USED IN: GetTextWidth(), GuiTextBoxMulti()
|
||||||
|
static Vector2 MeasureTextEx(Font font, const char *text, float fontSize, float spacing)
|
||||||
|
{
|
||||||
|
Vector2 size = { 0 };
|
||||||
|
|
||||||
|
// TODO: Return text size (width, height) on screen depending on the Font, text, fontSize and spacing
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
// USED IN: GuiDrawText()
|
||||||
|
static void DrawTextEx(Font font, const char *text, Vector2 position, float fontSize, float spacing, Color tint)
|
||||||
|
{
|
||||||
|
// TODO: Draw text on the screen
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
// GuiLoadStyle() required functions
|
||||||
|
//-------------------------------------------------------------------------------
|
||||||
|
static Font LoadFontEx(const char *fileName, int fontSize, int *fontChars, int glyphCount)
|
||||||
|
{
|
||||||
|
Font font = { 0 };
|
||||||
|
|
||||||
|
// TODO: Load a new font from a file
|
||||||
|
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *LoadText(const char *fileName)
|
||||||
|
{
|
||||||
|
// TODO: Load text file data, used by GuiLoadStyle() to load characters list required on Font generation,
|
||||||
|
// this is a .rgs feature, probably this function is not required in most cases
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *GetDirectoryPath(const char *filePath)
|
||||||
|
{
|
||||||
|
// TODO: Get directory path for .rgs file, required to look for a possible .ttf/.otf font file referenced,
|
||||||
|
// this is a .rgs feature, probably this function is not required in most cases
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
36
examples/standalone/raygui_standalone.c
Normal file
36
examples/standalone/raygui_standalone.c
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raygui - Standalone mode usage template
|
||||||
|
*
|
||||||
|
* DEPENDENCIES:
|
||||||
|
* raygui 2.6 - Immediate-mode GUI controls.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* LICENSE: zlib/libpng
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
**********************************************************************************************/
|
||||||
|
|
||||||
|
#define RAYGUI_IMPLEMENTATION
|
||||||
|
#define RAYGUI_STANDALONE
|
||||||
|
#include "../../src/raygui.h"
|
||||||
|
|
||||||
|
#include "custom_backend.h"
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Program main entry point
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// TODO: Initialize your systems (window, graphics, inputs)
|
||||||
|
|
||||||
|
// TODO: Create your game loop
|
||||||
|
{
|
||||||
|
// TODO: Use raygui API
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: De-initialize all resources
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@ -1,314 +0,0 @@
|
|||||||
/*******************************************************************************************
|
|
||||||
*
|
|
||||||
* raygui - Controls test
|
|
||||||
*
|
|
||||||
* TEST CONTROLS:
|
|
||||||
* - GuiScrollPanel()
|
|
||||||
*
|
|
||||||
* DEPENDENCIES:
|
|
||||||
* raylib 2.5 - Windowing/input management and drawing.
|
|
||||||
* raygui 2.0 - Immediate-mode GUI controls.
|
|
||||||
*
|
|
||||||
* COMPILATION (Windows - MinGW):
|
|
||||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
|
||||||
*
|
|
||||||
* COMPILATION (Linux - gcc):
|
|
||||||
* gcc -o $(NAME_PART) $(FILE_NAME) -I../../src -lraylib -std=c99
|
|
||||||
*
|
|
||||||
* LICENSE: zlib/libpng
|
|
||||||
*
|
|
||||||
* Copyright (c) 2019 Vlad Adrian (@Demizdor) and Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
**********************************************************************************************/
|
|
||||||
|
|
||||||
#include "raylib.h"
|
|
||||||
|
|
||||||
#define RAYGUI_IMPLEMENTATION
|
|
||||||
#define RAYGUI_SUPPORT_RICONS
|
|
||||||
#define RAYGUI_TEXTBOX_EXTENDED
|
|
||||||
#include "../../src/raygui.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
// -----------------
|
|
||||||
// DEFINES
|
|
||||||
// -----------------
|
|
||||||
#define SIZEOF(A) (sizeof(A)/sizeof(A[0])) // Get number of elements in array `A`. Total size of `A` should be known at compile time.
|
|
||||||
#define SCREEN_WIDTH 800
|
|
||||||
#define SCREEN_HEIGHT 450
|
|
||||||
#define TEXTBOX_MAX_HEIGHT 55
|
|
||||||
|
|
||||||
// -----------------
|
|
||||||
// GLOBAL VARIABLES
|
|
||||||
// -----------------
|
|
||||||
char text0[92] = "Lorem ipsum dolor sit amet, \xE7\x8C\xBF\xE3\x82\x82\xE6\x9C\xA8\xE3\x81\x8B\xE3\x82\x89\xE8\x90\xBD\xE3\x81\xA1\xE3\x82\x8B consectetur adipiscing elit"; // including some hiragana/kanji
|
|
||||||
char text1[128] = "Here's another, much bigger textbox." "\xf4\xa1\xa1\xff" " TIP: try COPY/PASTE ;)"; // including some invalid UTF8
|
|
||||||
int spinnerValue = 0, boxValue = 0;
|
|
||||||
int textboxActive = 0; // Keeps traks of the active textbox
|
|
||||||
|
|
||||||
struct {
|
|
||||||
Rectangle bounds;
|
|
||||||
int maxWidth;
|
|
||||||
} textbox[] = { // Params for each of the 4 textboxes
|
|
||||||
{ .bounds = (Rectangle){20,60,160,25}, .maxWidth = 160 },
|
|
||||||
{ .bounds = (Rectangle){220,60,300,25}, .maxWidth = 300 },
|
|
||||||
{ .bounds = (Rectangle){565,60,95,25}, .maxWidth = 95 },
|
|
||||||
{ .bounds = (Rectangle){680,60,100,25}, .maxWidth = 100 }
|
|
||||||
};
|
|
||||||
|
|
||||||
int fontSize = 10, fontSpacing = 1, padding = 0, border = 0;
|
|
||||||
Font font = {0};
|
|
||||||
Color colorBG = {0}, colorFG = {0}, *colorSelected = NULL;
|
|
||||||
|
|
||||||
bool showMenu = false;
|
|
||||||
Rectangle menuRect = {0};
|
|
||||||
Texture2D pattern = {0};
|
|
||||||
|
|
||||||
// -----------------
|
|
||||||
// FUNCTIONS
|
|
||||||
// -----------------
|
|
||||||
|
|
||||||
// Draw a color button, if clicked return true.
|
|
||||||
bool ColorButton(Rectangle bounds, Color color)
|
|
||||||
{
|
|
||||||
Rectangle body = {bounds.x + 2, bounds.y + 2, bounds.width - 4, bounds.height - 4};
|
|
||||||
bool pressed = false;
|
|
||||||
|
|
||||||
// Update control
|
|
||||||
Vector2 mouse = GetMousePosition();
|
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && CheckCollisionPointRec(mouse, bounds)) pressed = true;
|
|
||||||
|
|
||||||
// Draw control
|
|
||||||
DrawTexture(pattern, body.x, body.y, WHITE);
|
|
||||||
DrawRectangleRec(body, color);
|
|
||||||
DrawRectangleLinesEx(bounds, 1, BLACK);
|
|
||||||
|
|
||||||
return pressed;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handles GUI logic
|
|
||||||
void UpdateGUI()
|
|
||||||
{
|
|
||||||
// Check all of the 4 textboxes to get the active textbox
|
|
||||||
for (int i = 0; i < SIZEOF(textbox); i++)
|
|
||||||
{
|
|
||||||
if (GuiTextBoxIsActive(textbox[i].bounds))
|
|
||||||
{
|
|
||||||
textboxActive = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show/Hide the textbox menu
|
|
||||||
Vector2 mouse = GetMousePosition();
|
|
||||||
if ((textboxActive < 2) && !showMenu && CheckCollisionPointRec(mouse, textbox[textboxActive].bounds) && IsMouseButtonPressed(MOUSE_RIGHT_BUTTON))
|
|
||||||
{
|
|
||||||
showMenu = true;
|
|
||||||
menuRect = (Rectangle){mouse.x, mouse.y, 80, 110};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Menu hidding logic
|
|
||||||
if (showMenu && IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && !CheckCollisionPointRec(mouse, menuRect)) showMenu = false;
|
|
||||||
|
|
||||||
// Fonts drag & drop logic
|
|
||||||
if (IsFileDropped())
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
char **files = GetDroppedFiles(&count);
|
|
||||||
|
|
||||||
if (IsFileExtension(files[0], ".ttf") ||
|
|
||||||
IsFileExtension(files[0], ".otf") ||
|
|
||||||
IsFileExtension(files[0], ".fnt"))
|
|
||||||
{
|
|
||||||
Font fnt = LoadFont(files[0]);
|
|
||||||
|
|
||||||
if (fnt.texture.id != 0)
|
|
||||||
{
|
|
||||||
// Font was loaded, only change font on success
|
|
||||||
GuiFont(fnt);
|
|
||||||
fontSize = fnt.baseSize;
|
|
||||||
|
|
||||||
// Remove old font
|
|
||||||
if (font.texture.id != 0) UnloadFont(font);
|
|
||||||
font = fnt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ClearDroppedFiles();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handles GUI drawing
|
|
||||||
void DrawGUI()
|
|
||||||
{
|
|
||||||
// DRAW TEXTBOXES TO TEST
|
|
||||||
// Set custom style for textboxes
|
|
||||||
if (font.texture.id != 0) GuiFont(font); // Use our custom font if valid
|
|
||||||
GuiSetStyle(DEFAULT, TEXT_SIZE, fontSize);
|
|
||||||
GuiSetStyle(DEFAULT, TEXT_SPACING, fontSpacing);
|
|
||||||
GuiSetStyle(TEXTBOX, INNER_PADDING, padding);
|
|
||||||
GuiSetStyle(TEXTBOX, BORDER_WIDTH, border);
|
|
||||||
GuiSetStyle(TEXTBOX, COLOR_SELECTED_BG, ColorToInt(colorBG));
|
|
||||||
GuiSetStyle(TEXTBOX, COLOR_SELECTED_FG, ColorToInt(colorFG));
|
|
||||||
|
|
||||||
// Draw textboxes
|
|
||||||
GuiTextBox(textbox[0].bounds, text0, SIZEOF(text0) - 1, true);
|
|
||||||
GuiTextBox(textbox[1].bounds, text1, SIZEOF(text1) - 1, true);
|
|
||||||
GuiSpinner(textbox[2].bounds, &spinnerValue, INT_MIN, INT_MAX, true);
|
|
||||||
GuiValueBox(textbox[3].bounds, &boxValue, INT_MIN, INT_MAX, true);
|
|
||||||
|
|
||||||
// RESET STYLE TO DEFAULT
|
|
||||||
GuiLoadStyleDefault();
|
|
||||||
GuiFont(GetFontDefault());
|
|
||||||
GuiSetStyle(TEXTBOX, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER);
|
|
||||||
|
|
||||||
// DRAW HEX VIEW
|
|
||||||
// Convert text to hex representation and draw it on screen
|
|
||||||
char hex[(((textboxActive == 1) ? SIZEOF(text1) : SIZEOF(text0)) +1)*3 + 1];
|
|
||||||
char* text = (textboxActive == 1) ? text1 : text0;
|
|
||||||
int maxSize = (textboxActive == 1) ? SIZEOF(text1) : SIZEOF(text0);
|
|
||||||
for (int i=0, j=0; i < maxSize; ++i, j+=3)
|
|
||||||
{
|
|
||||||
sprintf(&hex[j], "%02Xh ", (char)text[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
int startIdx = 0, endIdx = 0;
|
|
||||||
if (textboxActive < 2)
|
|
||||||
{
|
|
||||||
Vector2 sel = GuiTextBoxGetSelection();
|
|
||||||
startIdx = GuiTextBoxGetByteIndex(text, 0, 0, sel.x);
|
|
||||||
endIdx = GuiTextBoxGetByteIndex(text, 0, 0, sel.x + sel.y);
|
|
||||||
}
|
|
||||||
int len = endIdx - startIdx;
|
|
||||||
DrawTextRecEx(guiFont, hex, (Rectangle){20,95,760,205}, 20, 1, true, BLACK, startIdx*3, len*3, colorFG, colorBG);
|
|
||||||
|
|
||||||
// DISPLAY A MENU ON RIGHT CLICKING A TEXTBOX
|
|
||||||
// draw the menu and handle clicked item
|
|
||||||
if (showMenu)
|
|
||||||
{
|
|
||||||
GuiSetStyle(LISTVIEW, ELEMENTS_HEIGHT, 24); // make items look a little bigger
|
|
||||||
const char *menuItems[] = { "#17# Cut", "#16# Copy", "#18# Paste", "#101# SelectAll" };
|
|
||||||
int enabledItems[] = { textboxActive < 2 ? 1 : 0, textboxActive < 2 ? 1 : 0, GetClipboardText() != NULL, 1 };
|
|
||||||
int active = -1, focus = 0, scroll = 0;
|
|
||||||
|
|
||||||
GuiSetStyle(DEFAULT, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT); // Fixes visual glitch with other alignments
|
|
||||||
active = GuiListViewEx(menuRect, menuItems, SIZEOF(menuItems), &focus, &scroll, active);
|
|
||||||
|
|
||||||
if (active != -1)
|
|
||||||
{
|
|
||||||
showMenu = false;
|
|
||||||
char *text = (textboxActive == 1) ? text1 : text0;
|
|
||||||
switch(active)
|
|
||||||
{
|
|
||||||
case 0: GuiTextBoxCut(text); break;
|
|
||||||
case 1: GuiTextBoxCopy(text); break;
|
|
||||||
case 2: GuiTextBoxPaste(text, (textboxActive == 1) ? SIZEOF(text1) : SIZEOF(text0)); break;
|
|
||||||
case 3: GuiTextBoxSelectAll(text); break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DRAW THE GUI FOR CHANGING THE TEXTBOXES
|
|
||||||
// UI for changing the font size and spacing of all textboxes
|
|
||||||
GuiLine((Rectangle){25,280,750,10}, NULL);
|
|
||||||
GuiGroupBox((Rectangle){20,320,190,100}, GuiIconText(RICON_GEAR, "FONT"));
|
|
||||||
GuiLabel((Rectangle){30,340,60,20}, "Size");
|
|
||||||
GuiSpinner((Rectangle){95,340,100,20},&fontSize, 10, 40, true);
|
|
||||||
GuiLabel((Rectangle){30,380,60,20}, "Spacing");
|
|
||||||
GuiSpinner((Rectangle){95,380,100,20},&fontSpacing, 1, 10, true);
|
|
||||||
|
|
||||||
// UI for changing the style of all textboxes
|
|
||||||
GuiGroupBox((Rectangle){225,320,190,100}, GuiIconText(RICON_COLOR_BUCKET, "STYLE"));
|
|
||||||
GuiLabel((Rectangle){240,340,60,20}, "Padding");
|
|
||||||
GuiSpinner((Rectangle){305,340,100,20},&padding, 2, 30, true);
|
|
||||||
GuiLabel((Rectangle){240,380,60,20}, "Border");
|
|
||||||
GuiSpinner((Rectangle){305,380,100,20},&border, 0, 8, true);
|
|
||||||
|
|
||||||
// UI for changing the width/height of the active textbox
|
|
||||||
bool changed = false;
|
|
||||||
int width = textbox[textboxActive].bounds.width, height = textbox[textboxActive].bounds.height;
|
|
||||||
GuiGroupBox((Rectangle){430,320,175,100}, GuiIconText(RICON_CURSOR_SCALE, "SCALE"));
|
|
||||||
GuiLabel((Rectangle){435,340,55,20}, "Width");
|
|
||||||
if (GuiSpinner((Rectangle){495,340,100,20}, &width, 30, textbox[textboxActive].maxWidth, true)) changed = true;
|
|
||||||
GuiLabel((Rectangle){435,380,55,20}, "Height");
|
|
||||||
if (GuiSpinner((Rectangle){495,380,100,20}, &height, 12, TEXTBOX_MAX_HEIGHT, true)) changed = true;
|
|
||||||
GuiSetStyle(LABEL, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER);
|
|
||||||
GuiLabel((Rectangle){30,290,740,10}, GuiIconText(RICON_TEXT_T, " DRAG A FONT FILE (*.TTF, *.FNT) ANYWHERE TO CHANGE THE DEFAULT FONT!"));
|
|
||||||
GuiSetStyle(LABEL, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT);
|
|
||||||
textbox[textboxActive].bounds.y = 85 - height;
|
|
||||||
textbox[textboxActive].bounds.height = height;
|
|
||||||
textbox[textboxActive].bounds.width = width;
|
|
||||||
if (changed) GuiTextBoxSetActive(textbox[textboxActive].bounds);
|
|
||||||
|
|
||||||
// UI for selecting the selected text background and foreground color
|
|
||||||
if (ColorButton((Rectangle){625,320,30,30}, colorFG)) colorSelected = &colorFG;
|
|
||||||
if (ColorButton((Rectangle){625,389,30,30}, colorBG)) colorSelected = &colorBG;
|
|
||||||
*colorSelected = GuiColorPicker((Rectangle){660,320,90,85}, *colorSelected);
|
|
||||||
float alpha = colorSelected->a;
|
|
||||||
GuiSetStyle(SLIDER, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT); // Slider for the selected color alpha value
|
|
||||||
colorSelected->a = GuiSlider((Rectangle){664,420,100,20}, GuiIconText(RICON_CROP_ALPHA, "Alpha"), alpha, 0.f, 255.f, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
// Program main entry point
|
|
||||||
//------------------------------------------------------------------------------------
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
// Initialization
|
|
||||||
//---------------------------------------------------------------------------------------
|
|
||||||
const int screenWidth = 800;
|
|
||||||
const int screenHeight = 450;
|
|
||||||
|
|
||||||
InitWindow(screenWidth, screenHeight, "raygui - GuiTextBoxEx()");
|
|
||||||
|
|
||||||
// Generate a checked pattern used by the color buttons
|
|
||||||
Image timg = GenImageChecked(26, 26, 5, 5, RAYWHITE, DARKGRAY);
|
|
||||||
pattern = LoadTextureFromImage(timg);
|
|
||||||
UnloadImage(timg);
|
|
||||||
|
|
||||||
// Load initial style
|
|
||||||
GuiLoadStyleDefault();
|
|
||||||
//font = LoadFont("resources/notoCJK.fnt");
|
|
||||||
//GuiFont(font);
|
|
||||||
|
|
||||||
fontSize = GuiGetStyle(DEFAULT, TEXT_SIZE);
|
|
||||||
fontSpacing = GuiGetStyle(DEFAULT, TEXT_SPACING);
|
|
||||||
padding = GuiGetStyle(TEXTBOX, INNER_PADDING);
|
|
||||||
border = GuiGetStyle(TEXTBOX, BORDER_WIDTH);
|
|
||||||
colorFG = GetColor(GuiGetStyle(TEXTBOX, COLOR_SELECTED_FG));
|
|
||||||
colorBG = GetColor(GuiGetStyle(TEXTBOX, COLOR_SELECTED_BG));
|
|
||||||
colorSelected = &colorFG;
|
|
||||||
|
|
||||||
SetTargetFPS(60);
|
|
||||||
//---------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Main game loop
|
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
||||||
{
|
|
||||||
// Update
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// TODO: Implement required update logic
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Draw
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
BeginDrawing();
|
|
||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
|
||||||
|
|
||||||
UpdateGUI();
|
|
||||||
DrawGUI();
|
|
||||||
|
|
||||||
EndDrawing();
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
// De-Initialization
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
|
||||||
//--------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
300
examples/text_box_selection/textbox_extended_demo.c
Normal file
300
examples/text_box_selection/textbox_extended_demo.c
Normal file
@ -0,0 +1,300 @@
|
|||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raygui - Controls test
|
||||||
|
*
|
||||||
|
* TEST CONTROLS:
|
||||||
|
* - GuiScrollPanel()
|
||||||
|
*
|
||||||
|
* DEPENDENCIES:
|
||||||
|
* raylib 2.5 - Windowing/input management and drawing.
|
||||||
|
* raygui 2.0 - Immediate-mode GUI controls.
|
||||||
|
*
|
||||||
|
* COMPILATION (Windows - MinGW):
|
||||||
|
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
||||||
|
*
|
||||||
|
* COMPILATION (Linux - gcc):
|
||||||
|
* gcc -o $(NAME_PART) $(FILE_NAME) -I../../src -lraylib -std=c99
|
||||||
|
*
|
||||||
|
* LICENSE: zlib/libpng
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Vlad Adrian (@Demizdor) and Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
**********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#define RAYGUI_IMPLEMENTATION
|
||||||
|
#include "../../src/raygui.h"
|
||||||
|
|
||||||
|
#undef RAYGUI_IMPLEMENTATION // Avoid including raygui implementation again
|
||||||
|
|
||||||
|
#define GUI_TEXTBOX_EXTENDED_IMPLEMENTATION
|
||||||
|
#include "../../src/extras/gui_textbox_extended.h"
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Defines and Macros
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
#define SIZEOF(A) (sizeof(A)/sizeof(A[0])) // Get number of elements in array `A`. Total size of `A` should be known at compile time.
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Global Variables Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
static char text01[92] = "Lorem ipsum dolor sit amet, \xE7\x8C\xBF\xE3\x82\x82\xE6\x9C\xA8\xE3\x81\x8B\xE3\x82\x89\xE8\x90\xBD\xE3\x81\xA1\xE3\x82\x8B consectetur adipiscing elit"; // including some hiragana/kanji
|
||||||
|
static char text02[128] = "Here's another, much bigger textboxBounds." "\xf4\xa1\xa1\xff" " TIP: try COPY/PASTE ;)"; // including some invalid UTF8
|
||||||
|
|
||||||
|
static int textboxActive = 0; // Keeps traks of the active textboxBounds
|
||||||
|
|
||||||
|
static Rectangle textboxBounds[4] = {
|
||||||
|
{ 20, 60, 160, 25 },
|
||||||
|
{ 220, 60, 300, 25 },
|
||||||
|
{ 565, 60, 95, 25 },
|
||||||
|
{ 680, 60, 100, 25 },
|
||||||
|
};
|
||||||
|
|
||||||
|
static Texture2D checked = { 0 };
|
||||||
|
|
||||||
|
// Draw a color button, if clicked return true
|
||||||
|
bool ColorButton(Rectangle bounds, Color color)
|
||||||
|
{
|
||||||
|
Rectangle body = {bounds.x + 2, bounds.y + 2, bounds.width - 4, bounds.height - 4};
|
||||||
|
bool pressed = false;
|
||||||
|
|
||||||
|
// Update control
|
||||||
|
Vector2 mouse = GetMousePosition();
|
||||||
|
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && CheckCollisionPointRec(mouse, bounds)) pressed = true;
|
||||||
|
|
||||||
|
// Draw control
|
||||||
|
DrawTexture(checked, body.x, body.y, WHITE);
|
||||||
|
DrawRectangleRec(body, color);
|
||||||
|
DrawRectangleLinesEx(bounds, 1, BLACK);
|
||||||
|
|
||||||
|
return pressed;
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Program main entry point
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//---------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raygui - gui textboxBounds extended demo");
|
||||||
|
|
||||||
|
// Generate a checked checked used by the color buttons
|
||||||
|
Image img = GenImageChecked(26, 26, 5, 5, RAYWHITE, DARKGRAY);
|
||||||
|
checked = LoadTextureFromImage(img);
|
||||||
|
UnloadImage(img);
|
||||||
|
|
||||||
|
Font font = { 0 };
|
||||||
|
int fontSize = GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||||
|
int fontSpacing = GuiGetStyle(DEFAULT, TEXT_SPACING);
|
||||||
|
int padding = GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING);
|
||||||
|
int border = GuiGetStyle(TEXTBOX, BORDER_WIDTH);
|
||||||
|
Color colorFG = GetColor(GuiGetStyle(TEXTBOX, COLOR_SELECTED_FG));
|
||||||
|
Color colorBG = GetColor(GuiGetStyle(TEXTBOX, COLOR_SELECTED_BG));
|
||||||
|
Color *colorSelected = &colorFG;
|
||||||
|
|
||||||
|
bool showMenu = false;
|
||||||
|
Rectangle menuRect = { 0 };
|
||||||
|
|
||||||
|
int spinnerValue = 0;
|
||||||
|
int valueBoxValue = 0;
|
||||||
|
|
||||||
|
bool textBox01EditMode = false;
|
||||||
|
bool textBox02EditMode = false;
|
||||||
|
bool spinnerEditMode = false;
|
||||||
|
bool valueBoxEditMode = false;
|
||||||
|
|
||||||
|
SetTargetFPS(60);
|
||||||
|
//---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
Vector2 mouse = GetMousePosition();
|
||||||
|
|
||||||
|
// Check all textboxes to get the active textboxBounds
|
||||||
|
if (textBox01EditMode) textboxActive = 0;
|
||||||
|
else if (textBox02EditMode) textboxActive = 1;
|
||||||
|
else if (spinnerEditMode) textboxActive = 2;
|
||||||
|
else if (valueBoxEditMode) textboxActive = 3;
|
||||||
|
|
||||||
|
// Show/Hide the textboxBounds menu
|
||||||
|
/*
|
||||||
|
if ((textboxActive < 2) && !showMenu && CheckCollisionPointRec(mouse, textboxBounds[textboxActive]) && IsMouseButtonPressed(MOUSE_RIGHT_BUTTON))
|
||||||
|
{
|
||||||
|
showMenu = true;
|
||||||
|
menuRect = (Rectangle){mouse.x, mouse.y, 80, 110};
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Menu hidding logic
|
||||||
|
if (showMenu && IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && !CheckCollisionPointRec(mouse, menuRect)) showMenu = false;
|
||||||
|
|
||||||
|
// Fonts drag & drop logic
|
||||||
|
if (IsFileDropped())
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
char **files = GetDroppedFiles(&count);
|
||||||
|
|
||||||
|
if (IsFileExtension(files[0], ".ttf") ||
|
||||||
|
IsFileExtension(files[0], ".otf") ||
|
||||||
|
IsFileExtension(files[0], ".fnt"))
|
||||||
|
{
|
||||||
|
Font fnt = LoadFont(files[0]);
|
||||||
|
|
||||||
|
if (fnt.texture.id != 0)
|
||||||
|
{
|
||||||
|
// Font was loaded, only change font on success
|
||||||
|
GuiSetFont(fnt);
|
||||||
|
fontSize = fnt.baseSize;
|
||||||
|
|
||||||
|
// Remove old font
|
||||||
|
if (font.texture.id != 0) UnloadFont(font);
|
||||||
|
font = fnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClearDroppedFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert text to hex representation and draw it on screen
|
||||||
|
char hex[(((textboxActive == 1) ? SIZEOF(text02) : SIZEOF(text01)) + 1)*3 + 1];
|
||||||
|
char *text = (textboxActive == 1) ? text02 : text01;
|
||||||
|
int maxSize = (textboxActive == 1) ? SIZEOF(text02) : SIZEOF(text01);
|
||||||
|
for (int i = 0, j = 0; i < maxSize; ++i, j += 3) sprintf(&hex[j], "%02Xh ", (char)text[i]);
|
||||||
|
|
||||||
|
int startIdx = 0, endIdx = 0;
|
||||||
|
if (textboxActive < 2)
|
||||||
|
{
|
||||||
|
Vector2 sel = GuiTextBoxGetSelection();
|
||||||
|
startIdx = GuiTextBoxGetByteIndex(text, 0, 0, sel.x);
|
||||||
|
endIdx = GuiTextBoxGetByteIndex(text, 0, 0, sel.x + sel.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
int len = endIdx - startIdx;
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
// Draw textboxes extended
|
||||||
|
//---------------------------------------------------------------------------------------
|
||||||
|
// Set custom style
|
||||||
|
GuiSetStyle(DEFAULT, TEXT_SIZE, fontSize);
|
||||||
|
GuiSetStyle(DEFAULT, TEXT_SPACING, fontSpacing);
|
||||||
|
GuiSetStyle(TEXTBOX, TEXT_INNER_PADDING, padding);
|
||||||
|
GuiSetStyle(TEXTBOX, BORDER_WIDTH, border);
|
||||||
|
GuiSetStyle(TEXTBOX, COLOR_SELECTED_BG, ColorToInt(colorBG));
|
||||||
|
GuiSetStyle(TEXTBOX, COLOR_SELECTED_FG, ColorToInt(colorFG));
|
||||||
|
|
||||||
|
// TODO: GuiTextBoxEx() is not following editMode logic like GuiTextBox()
|
||||||
|
if (GuiTextBoxEx(textboxBounds[0], text01, SIZEOF(text01) - 1, textBox01EditMode)) textBox01EditMode = !textBox01EditMode;
|
||||||
|
if (GuiTextBoxEx(textboxBounds[1], text02, SIZEOF(text02) - 1, textBox02EditMode)) textBox02EditMode = !textBox02EditMode;
|
||||||
|
|
||||||
|
if (GuiSpinner(textboxBounds[2], NULL, &spinnerValue, INT_MIN, INT_MAX, spinnerEditMode)) spinnerEditMode = !spinnerEditMode;
|
||||||
|
if (GuiValueBox(textboxBounds[3], NULL, &valueBoxValue, INT_MIN, INT_MAX, valueBoxEditMode)) valueBoxEditMode = !valueBoxEditMode;
|
||||||
|
//---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Reset style to default
|
||||||
|
GuiLoadStyleDefault();
|
||||||
|
GuiSetFont(GetFontDefault());
|
||||||
|
GuiSetStyle(TEXTBOX, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER);
|
||||||
|
|
||||||
|
// Draw hexadecimal values viewer
|
||||||
|
DrawTextBoxedSelectable(guiFont, hex, (Rectangle){ 20, 95, 760, 205 }, 20, 1, true, BLACK, startIdx*3, len*3, colorFG, colorBG);
|
||||||
|
|
||||||
|
// Draw right-mouse-button-click menu and logic
|
||||||
|
//---------------------------------------------------------------------------------------
|
||||||
|
if (showMenu)
|
||||||
|
{
|
||||||
|
GuiSetStyle(LISTVIEW, LIST_ITEMS_HEIGHT, 24); // make items look a little bigger
|
||||||
|
const char *menuItems[] = { "#17# Cut", "#16# Copy", "#18# Paste", "#101# SelectAll" };
|
||||||
|
//int enabledItems[] = { textboxActive < 2 ? 1 : 0, textboxActive < 2 ? 1 : 0, GetClipboardText() != NULL, 1 };
|
||||||
|
int active = -1, focus = 0, scroll = 0;
|
||||||
|
|
||||||
|
GuiSetStyle(DEFAULT, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT); // Fixes visual glitch with other alignments
|
||||||
|
active = GuiListViewEx(menuRect, menuItems, SIZEOF(menuItems), &focus, &scroll, active);
|
||||||
|
|
||||||
|
if (active != -1)
|
||||||
|
{
|
||||||
|
showMenu = false;
|
||||||
|
char *text = (textboxActive == 1) ? text02 : text01;
|
||||||
|
switch(active)
|
||||||
|
{
|
||||||
|
case 0: GuiTextBoxCut(text); break;
|
||||||
|
case 1: GuiTextBoxCopy(text); break;
|
||||||
|
case 2: GuiTextBoxPaste(text, (textboxActive == 1) ? SIZEOF(text02) : SIZEOF(text01)); break;
|
||||||
|
case 3: GuiTextBoxSelectAll(text); break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw GUI to change textboxes parameters
|
||||||
|
//---------------------------------------------------------------------------------------
|
||||||
|
/*
|
||||||
|
// UI for changing the font size and spacing of all textboxes
|
||||||
|
GuiLine((Rectangle){25,280,750,10}, NULL);
|
||||||
|
GuiGroupBox((Rectangle){20,320,190,100}, GuiIconText(RICON_GEAR, "FONT"));
|
||||||
|
GuiLabel((Rectangle){30,340,60,20}, "Size");
|
||||||
|
GuiSpinner((Rectangle){95,340,100,20}, NULL, &fontSize, 10, 40, true);
|
||||||
|
GuiLabel((Rectangle){30,380,60,20}, "Spacing");
|
||||||
|
GuiSpinner((Rectangle){95,380,100,20}, NULL, &fontSpacing, 1, 10, true);
|
||||||
|
|
||||||
|
// UI for changing the style of all textboxes
|
||||||
|
GuiGroupBox((Rectangle){225,320,190,100}, GuiIconText(RICON_COLOR_BUCKET, "STYLE"));
|
||||||
|
GuiLabel((Rectangle){240,340,60,20}, "Padding");
|
||||||
|
GuiSpinner((Rectangle){305,340,100,20}, NULL, &padding, 2, 30, true);
|
||||||
|
GuiLabel((Rectangle){240,380,60,20}, "Border");
|
||||||
|
GuiSpinner((Rectangle){305,380,100,20}, NULL, &border, 0, 8, true);
|
||||||
|
|
||||||
|
// UI for changing the width/height of the active textboxBounds
|
||||||
|
bool changed = false;
|
||||||
|
int width = textboxBounds[textboxActive].width, height = textboxBounds[textboxActive].height;
|
||||||
|
GuiGroupBox((Rectangle){430,320,175,100}, GuiIconText(RICON_CURSOR_SCALE, "SCALE"));
|
||||||
|
GuiLabel((Rectangle){435,340,55,20}, "Width");
|
||||||
|
if (GuiSpinner((Rectangle){495,340,100,20}, NULL, &width, 30, 300, true)) changed = true;
|
||||||
|
GuiLabel((Rectangle){435,380,55,20}, "Height");
|
||||||
|
if (GuiSpinner((Rectangle){495,380,100,20}, NULL, &height, 12, 60, true)) changed = true;
|
||||||
|
GuiSetStyle(LABEL, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER);
|
||||||
|
GuiLabel((Rectangle){30,290,740,10}, GuiIconText(RICON_TEXT_T, " DRAG A FONT FILE (*.TTF, *.FNT) ANYWHERE TO CHANGE THE DEFAULT FONT!"));
|
||||||
|
GuiSetStyle(LABEL, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT);
|
||||||
|
textboxBounds[textboxActive].y = 85 - height;
|
||||||
|
textboxBounds[textboxActive].height = height;
|
||||||
|
textboxBounds[textboxActive].width = width;
|
||||||
|
if (changed) GuiTextBoxSetActive(textboxBounds[textboxActive]);
|
||||||
|
|
||||||
|
// UI for selecting the selected text background and foreground color
|
||||||
|
if (ColorButton((Rectangle){625,320,30,30}, colorFG)) colorSelected = &colorFG;
|
||||||
|
if (ColorButton((Rectangle){625,389,30,30}, colorBG)) colorSelected = &colorBG;
|
||||||
|
*colorSelected = GuiColorPicker((Rectangle){660,320,90,85}, *colorSelected);
|
||||||
|
|
||||||
|
float alpha = colorSelected->a;
|
||||||
|
GuiSetStyle(SLIDER, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT); // Slider for the selected color alpha value
|
||||||
|
colorSelected->a = GuiSlider((Rectangle){664,420,100,20}, GuiIconText(RICON_CROP_ALPHA, "Alpha"), NULL, alpha, 0.0f, 255.0f);
|
||||||
|
*/
|
||||||
|
//---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
295
examples/text_editor/text_editor.c
Normal file
295
examples/text_editor/text_editor.c
Normal file
@ -0,0 +1,295 @@
|
|||||||
|
/*******************************************************************************************
|
||||||
|
*
|
||||||
|
* raygui - Controls test
|
||||||
|
*
|
||||||
|
* TEST CONTROLS:
|
||||||
|
* - GuiTextEditor()
|
||||||
|
*
|
||||||
|
* DEPENDENCIES:
|
||||||
|
* raylib 3.0 - Windowing/input management and drawing.
|
||||||
|
* raygui 2.7 - Immediate-mode GUI controls.
|
||||||
|
*
|
||||||
|
* COMPILATION (Windows - MinGW):
|
||||||
|
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
||||||
|
*
|
||||||
|
* LICENSE: zlib/libpng
|
||||||
|
*
|
||||||
|
* Copyright (c) 2020 Ramon Santamaria (@raysan5)
|
||||||
|
*
|
||||||
|
**********************************************************************************************/
|
||||||
|
|
||||||
|
#include "raylib.h"
|
||||||
|
|
||||||
|
#define RAYGUI_IMPLEMENTATION
|
||||||
|
#include "../../src/raygui.h"
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Defines and Macros
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// ...
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
// Global Variables Definition
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
static char text01[128] = "Lorem ipsum dolor sit amet, \xE7\x8C\xBF\xE3\x82\x82\xE6\x9C\xA8\xE3\x81\x8B\xE3\x82\x89\xE8\x90\xBD\xE3\x81\xA1\xE3\x82\x8B consectetur adipiscing elit...\0"; // including some hiragana/kanji
|
||||||
|
static char text02[128] = "Here's another, much bigger textbox extended.\xf4\xa1\xa1\xff TIP: try COPY/PASTE ;)\0"; // Including some invalid UTF8
|
||||||
|
|
||||||
|
bool GuiTextEditor(Rectangle bounds, char *text, int textLen, bool editMode);
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
// Program main entry point
|
||||||
|
//------------------------------------------------------------------------------------
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
// Initialization
|
||||||
|
//---------------------------------------------------------------------------------------
|
||||||
|
const int screenWidth = 800;
|
||||||
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
InitWindow(screenWidth, screenHeight, "raygui - gui text editor test");
|
||||||
|
|
||||||
|
Font font = { 0 };
|
||||||
|
|
||||||
|
bool textEditor01EditMode = false;
|
||||||
|
bool textEditor02EditMode = false;
|
||||||
|
|
||||||
|
SetTargetFPS(60);
|
||||||
|
//---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Main game loop
|
||||||
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
|
{
|
||||||
|
// Update
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
Vector2 mouse = GetMousePosition();
|
||||||
|
|
||||||
|
// Fonts drag & drop logic
|
||||||
|
if (IsFileDropped())
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
char **files = GetDroppedFiles(&count);
|
||||||
|
|
||||||
|
if (IsFileExtension(files[0], ".ttf") ||
|
||||||
|
IsFileExtension(files[0], ".otf") ||
|
||||||
|
IsFileExtension(files[0], ".fnt"))
|
||||||
|
{
|
||||||
|
Font fnt = LoadFont(files[0]);
|
||||||
|
|
||||||
|
if (fnt.texture.id != 0)
|
||||||
|
{
|
||||||
|
// Font was loaded, only change font on success
|
||||||
|
GuiSetFont(fnt);
|
||||||
|
|
||||||
|
// Remove old font
|
||||||
|
if (font.texture.id != 0) UnloadFont(font);
|
||||||
|
font = fnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClearDroppedFiles();
|
||||||
|
}
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
BeginDrawing();
|
||||||
|
|
||||||
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
|
// Draw textboxes extended
|
||||||
|
//---------------------------------------------------------------------------------------
|
||||||
|
if (GuiTextEditor((Rectangle){ 20, 20, 380, 410 }, text01, strlen(text01), textEditor01EditMode)) textEditor01EditMode = !textEditor01EditMode;
|
||||||
|
if (GuiTextEditor((Rectangle){ 420, 20, 360, 410 }, text02, strlen(text02), textEditor02EditMode)) textEditor02EditMode = !textEditor02EditMode;
|
||||||
|
//---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
}
|
||||||
|
|
||||||
|
// De-Initialization
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Text editor control (Advanced text box)
|
||||||
|
bool GuiTextEditor(Rectangle bounds, char *text, int textSize, bool editMode)
|
||||||
|
{
|
||||||
|
static Rectangle cursor = { 0 }; // Cursor position and size
|
||||||
|
static int framesCounter = 0; // Blinking cursor frames counter
|
||||||
|
static int cursorCodepoint = -1;
|
||||||
|
static int selectStartCp = -1;
|
||||||
|
static int selectLengthCp = 0;
|
||||||
|
|
||||||
|
GuiControlState state = guiState;
|
||||||
|
bool pressed = false;
|
||||||
|
|
||||||
|
bool textWrap = true; // TODO: Word-Wrap vs Char-Wrap -> textWrapMode { NO_WRAP_LOCK, NO_WRAP_OVERFLOW, CHAR_WRAP, WORD_WRAP }
|
||||||
|
|
||||||
|
// WARNING: First string full traversal
|
||||||
|
int codepointCount = GetCodepointCount(text);
|
||||||
|
|
||||||
|
int textLen = strlen(text); // Text length in bytes
|
||||||
|
|
||||||
|
// Update control
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
if ((state != GUI_STATE_DISABLED) && !guiLocked)
|
||||||
|
{
|
||||||
|
Vector2 mousePoint = GetMousePosition();
|
||||||
|
|
||||||
|
if (editMode)
|
||||||
|
{
|
||||||
|
state = GUI_STATE_PRESSED;
|
||||||
|
framesCounter++;
|
||||||
|
|
||||||
|
// TODO: Cursor position logic (mouse and keys)
|
||||||
|
|
||||||
|
// Characters selection logic
|
||||||
|
if (selectStartCp != -1)
|
||||||
|
{
|
||||||
|
if (IsKeyDown(KEY_LEFT_SHIFT) && IsKeyPressed(KEY_RIGHT))
|
||||||
|
{
|
||||||
|
selectLengthCp++;
|
||||||
|
if (selectLengthCp >= (codepointCount - selectStartCp)) selectLengthCp = codepointCount - selectStartCp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsKeyDown(KEY_LEFT_SHIFT) && IsKeyPressed(KEY_LEFT))
|
||||||
|
{
|
||||||
|
selectLengthCp--;
|
||||||
|
if (selectLengthCp < 0) selectLengthCp = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int key = GetCharPressed();
|
||||||
|
|
||||||
|
// TODO: On key pressed, place new character in cursor position
|
||||||
|
|
||||||
|
// Exit edit mode logic
|
||||||
|
if (IsKeyPressed(KEY_ENTER) || (!CheckCollisionPointRec(mousePoint, bounds) && IsMouseButtonPressed(0))) pressed = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (CheckCollisionPointRec(mousePoint, bounds))
|
||||||
|
{
|
||||||
|
state = GUI_STATE_FOCUSED;
|
||||||
|
if (IsMouseButtonPressed(0)) pressed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pressed)
|
||||||
|
{
|
||||||
|
// Exiting edit mode, reset temp variables
|
||||||
|
framesCounter = 0;
|
||||||
|
cursor = (Rectangle){ 0 };
|
||||||
|
|
||||||
|
cursorCodepoint = -1;
|
||||||
|
selectStartCp = -1;
|
||||||
|
selectLengthCp = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Draw control
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
DrawRectangleLinesEx(bounds, GuiGetStyle(TEXTBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER + (state*3))), guiAlpha));
|
||||||
|
|
||||||
|
if (state == GUI_STATE_PRESSED) DrawRectangle(bounds.x + GuiGetStyle(TEXTBOX, BORDER_WIDTH), bounds.y + GuiGetStyle(TEXTBOX, BORDER_WIDTH), bounds.width - 2*GuiGetStyle(TEXTBOX, BORDER_WIDTH), bounds.height - 2*GuiGetStyle(TEXTBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_PRESSED)), guiAlpha));
|
||||||
|
else if (state == GUI_STATE_DISABLED) DrawRectangle(bounds.x + GuiGetStyle(TEXTBOX, BORDER_WIDTH), bounds.y + GuiGetStyle(TEXTBOX, BORDER_WIDTH), bounds.width - 2*GuiGetStyle(TEXTBOX, BORDER_WIDTH), bounds.height - 2*GuiGetStyle(TEXTBOX, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(TEXTBOX, BASE_COLOR_DISABLED)), guiAlpha));
|
||||||
|
|
||||||
|
Font font = GetFontDefault();
|
||||||
|
|
||||||
|
int textOffsetY = 0; // Offset between lines (on line break '\n')
|
||||||
|
float textOffsetX = 0.0f; // Offset X to next character to draw
|
||||||
|
|
||||||
|
float scaleFactor = GuiGetStyle(DEFAULT, TEXT_SIZE)*2/font.baseSize; // Character quad scaling factor
|
||||||
|
|
||||||
|
for (int i = 0, cp = 0; i < textLen; i++)
|
||||||
|
{
|
||||||
|
// Get next codepoint from byte string and glyph index in font
|
||||||
|
int codepointByteCount = 0;
|
||||||
|
int codepoint = GetCodepoint(&text[i], &codepointByteCount);
|
||||||
|
int index = GetGlyphIndex(font, codepoint);
|
||||||
|
|
||||||
|
Rectangle rec = { bounds.x + textOffsetX + font.glyphs[index].offsetX*scaleFactor,
|
||||||
|
bounds.y + textOffsetY + font.glyphs[index].offsetY*scaleFactor,
|
||||||
|
font.recs[index].width*scaleFactor, font.recs[index].height*scaleFactor };
|
||||||
|
|
||||||
|
// Automatic line break to wrap text inside box
|
||||||
|
if (textWrap && ((rec.x + rec.width) >= (bounds.x + bounds.width)))
|
||||||
|
{
|
||||||
|
textOffsetY += (int)((font.baseSize + font.baseSize/2)*scaleFactor);
|
||||||
|
textOffsetX = 0.0f;
|
||||||
|
|
||||||
|
// Recalculate drawing rectangle position
|
||||||
|
rec = (Rectangle){ bounds.x + textOffsetX + font.glyphs[index].offsetX*scaleFactor,
|
||||||
|
bounds.y + textOffsetY + font.glyphs[index].offsetY*scaleFactor,
|
||||||
|
font.recs[index].width*scaleFactor, font.recs[index].height*scaleFactor };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check selected codepoint
|
||||||
|
if (editMode)
|
||||||
|
{
|
||||||
|
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) && CheckCollisionPointRec(GetMousePosition(), rec))
|
||||||
|
{
|
||||||
|
cursor = rec;
|
||||||
|
cursorCodepoint = cp;
|
||||||
|
selectStartCp = cursorCodepoint;
|
||||||
|
selectLengthCp = 0;
|
||||||
|
|
||||||
|
// TODO: Place cursor at the end if pressed out of text
|
||||||
|
}
|
||||||
|
|
||||||
|
// On mouse left button down allow text selection
|
||||||
|
if ((selectStartCp != -1) && IsMouseButtonDown(MOUSE_LEFT_BUTTON) && CheckCollisionPointRec(GetMousePosition(), rec))
|
||||||
|
{
|
||||||
|
if (cp >= selectStartCp) selectLengthCp = cp - selectStartCp;
|
||||||
|
else if (cp < selectStartCp)
|
||||||
|
{
|
||||||
|
//int temp = selectStartCp;
|
||||||
|
//selectStartCp = cp;
|
||||||
|
//selectLengthCp = temp - selectStartCp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (codepoint == '\n') // Line break character
|
||||||
|
{
|
||||||
|
// NOTE: Fixed line spacing of 1.5 line-height
|
||||||
|
// TODO: Support custom line spacing defined by user
|
||||||
|
textOffsetY += (int)((font.baseSize + font.baseSize/2)*scaleFactor);
|
||||||
|
textOffsetX = 0.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Draw codepoint glyph
|
||||||
|
if ((codepoint != ' ') && (codepoint != '\t') && ((rec.x + rec.width) < (bounds.x + bounds.width)))
|
||||||
|
{
|
||||||
|
DrawTexturePro(font.texture, font.recs[index], rec, (Vector2){ 0, 0 }, 0.0f, GetColor(GuiGetStyle(DEFAULT, TEXT_COLOR_NORMAL)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: On text overflow do something... move text to the left?
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw codepoints selection from selectStartCp to selectLengthCp
|
||||||
|
// TODO: Consider spacing when drawing selected characters background
|
||||||
|
if (editMode && (selectStartCp != -1) && ((cp >= selectStartCp) && (cp <= (selectStartCp + selectLengthCp)))) DrawRectangleRec(rec, MAROON);
|
||||||
|
|
||||||
|
if (font.glyphs[index].advanceX == 0) textOffsetX += ((float)font.recs[index].width*scaleFactor + GuiGetStyle(DEFAULT, TEXT_SPACING));
|
||||||
|
else textOffsetX += ((float)font.glyphs[index].advanceX*scaleFactor + GuiGetStyle(DEFAULT, TEXT_SPACING));
|
||||||
|
|
||||||
|
i += (codepointByteCount - 1); // Move text bytes counter to next codepoint
|
||||||
|
cp++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw blinking cursor
|
||||||
|
if (editMode && ((framesCounter/20)%2 == 0)) DrawRectangleRec(cursor, Fade(GetColor(GuiGetStyle(TEXTBOX, BORDER_COLOR_PRESSED)), guiAlpha));
|
||||||
|
|
||||||
|
//GuiDrawText(text, GetTextBounds(TEXTBOX, bounds), GuiGetStyle(TEXTBOX, TEXT_ALIGNMENT), Fade(GetColor(GuiGetStyle(TEXTBOX, TEXT + (state*3))), guiAlpha));
|
||||||
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
|
return pressed;
|
||||||
|
}
|
||||||
BIN
images/rguiicons_v100.png
Normal file
BIN
images/rguiicons_v100.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
BIN
images/rguilayout_v220.png
Normal file
BIN
images/rguilayout_v220.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
70
projects/CMake/CMakeLists.txt
Normal file
70
projects/CMake/CMakeLists.txt
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.11)
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||||
|
|
||||||
|
project(raygui C)
|
||||||
|
|
||||||
|
# Config options
|
||||||
|
option(BUILD_RAYGUI_EXAMPLES "Build the examples." ON)
|
||||||
|
|
||||||
|
# Directory Variables
|
||||||
|
set(RAYGUI_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
|
||||||
|
set(RAYGUI_SRC ${RAYGUI_ROOT}/src)
|
||||||
|
set(RAYGUI_EXAMPLES ${RAYGUI_ROOT}/examples)
|
||||||
|
|
||||||
|
# raygui
|
||||||
|
add_library(raygui INTERFACE)
|
||||||
|
file(GLOB sources ${RAYGUI_SRC}/*.h)
|
||||||
|
set(RAYGUI_HEADERS ${sources})
|
||||||
|
install(FILES
|
||||||
|
${RAYGUI_HEADERS} DESTINATION include
|
||||||
|
)
|
||||||
|
target_include_directories(raygui INTERFACE ${RAYGUI_SRC})
|
||||||
|
|
||||||
|
# Examples
|
||||||
|
if(${BUILD_RAYGUI_EXAMPLES})
|
||||||
|
find_package(Raylib)
|
||||||
|
|
||||||
|
# Get the sources together
|
||||||
|
set(example_dirs
|
||||||
|
custom_file_dialog
|
||||||
|
image_raw_importer
|
||||||
|
portable_window
|
||||||
|
scroll_panel
|
||||||
|
text_box_selection
|
||||||
|
controls_test_suite
|
||||||
|
image_exporter
|
||||||
|
property_list
|
||||||
|
text_editor
|
||||||
|
)
|
||||||
|
|
||||||
|
set(example_sources)
|
||||||
|
set(example_resources)
|
||||||
|
|
||||||
|
foreach(example_dir ${example_dirs})
|
||||||
|
# Get the .c files
|
||||||
|
file(GLOB sources ${RAYGUI_EXAMPLES}/${example_dir}/*.c)
|
||||||
|
list(APPEND example_sources ${sources})
|
||||||
|
|
||||||
|
# Any any resources
|
||||||
|
file(GLOB resources ${RAYGUI_EXAMPLES}/${example_dir}/resources/*)
|
||||||
|
list(APPEND example_resources ${resources})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Do each example
|
||||||
|
foreach(example_source ${example_sources})
|
||||||
|
# Create the basename for the example
|
||||||
|
get_filename_component(example_name ${example_source} NAME)
|
||||||
|
string(REPLACE ".c" "${OUTPUT_EXT}" example_name ${example_name})
|
||||||
|
|
||||||
|
# Setup the example
|
||||||
|
add_executable(${example_name} ${example_source})
|
||||||
|
|
||||||
|
target_link_libraries(${example_name} PUBLIC raylib raygui)
|
||||||
|
|
||||||
|
string(REGEX MATCH ".*/.*/" resources_dir ${example_source})
|
||||||
|
string(APPEND resources_dir "resources")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Copy all of the resource files to the destination
|
||||||
|
file(COPY ${example_resources} DESTINATION "resources/")
|
||||||
|
endif()
|
||||||
13
projects/CMake/README.md
Normal file
13
projects/CMake/README.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# raygui CMake Definitions
|
||||||
|
|
||||||
|
This provides CMake definition files for raygui.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
cd projects/CMake
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake ..
|
||||||
|
make
|
||||||
|
```
|
||||||
17
projects/CMake/cmake/FindRaylib.cmake
Normal file
17
projects/CMake/cmake/FindRaylib.cmake
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
find_package(raylib 3.0.0 QUIET CONFIG)
|
||||||
|
if (NOT raylib_FOUND)
|
||||||
|
include(FetchContent)
|
||||||
|
FetchContent_Declare(
|
||||||
|
raylib
|
||||||
|
GIT_REPOSITORY https://github.com/raysan5/raylib.git
|
||||||
|
GIT_TAG df5c522049ddd82fba048a6bd069338999729d6a
|
||||||
|
)
|
||||||
|
FetchContent_GetProperties(raylib)
|
||||||
|
if (NOT raylib_POPULATED) # Have we downloaded raylib yet?
|
||||||
|
set(FETCHCONTENT_QUIET NO)
|
||||||
|
FetchContent_Populate(raylib)
|
||||||
|
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples
|
||||||
|
set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # or games
|
||||||
|
add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
182
projects/VS2019/examples/controls_test_suite.vcxproj
Normal file
182
projects/VS2019/examples/controls_test_suite.vcxproj
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug.DLL|Win32">
|
||||||
|
<Configuration>Debug.DLL</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release.DLL|Win32">
|
||||||
|
<Configuration>Release.DLL</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{0981CA98-E4A5-4DF1-987F-A41D09131EFC}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>controls_test_suite</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||||
|
<ProjectName>controls_test_suite</ProjectName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<OutDir>$(ProjectDir)$(ProjectName)\$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(ProjectDir)$(ProjectName)\$(Configuration)\temp</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<OutDir>$(ProjectDir)$(ProjectName)\$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(ProjectDir)$(ProjectName)\$(Configuration)\temp</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(ProjectDir)$(ProjectName)\$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(ProjectDir)$(ProjectName)\$(Configuration)\temp</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(ProjectDir)$(ProjectName)\$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(ProjectDir)$(ProjectName)\$(Configuration)\temp</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)..\..\..\raylib\src;$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;PLATFORM_DESKTOP;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
|
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);PLATFORM_DESKTOP</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
|
<RemoveUnreferencedCodeData>true</RemoveUnreferencedCodeData>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winmm.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\..\examples\controls_test_suite\controls_test_suite.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\raylib\raylib.vcxproj">
|
||||||
|
<Project>{e89d61ac-55de-4482-afd4-df7242ebc859}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
55
projects/VS2019/raygui.sln
Normal file
55
projects/VS2019/raygui.sln
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 16
|
||||||
|
VisualStudioVersion = 16.0.29411.108
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "controls_test_suite", "examples\controls_test_suite.vcxproj", "{0981CA98-E4A5-4DF1-987F-A41D09131EFC}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "raylib", "raylib\raylib.vcxproj", "{E89D61AC-55DE-4482-AFD4-DF7242EBC859}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug.DLL|x86 = Debug.DLL|x86
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release.DLL|x86 = Release.DLL|x86
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32
|
||||||
|
{0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32
|
||||||
|
{0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32
|
||||||
|
{0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Release.DLL|x86.Build.0 = Release.DLL|Win32
|
||||||
|
{0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{0981CA98-E4A5-4DF1-987F-A41D09131EFC}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{E89D61AC-55DE-4482-AFD4-DF7242EBC859}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32
|
||||||
|
{E89D61AC-55DE-4482-AFD4-DF7242EBC859}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32
|
||||||
|
{E89D61AC-55DE-4482-AFD4-DF7242EBC859}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{E89D61AC-55DE-4482-AFD4-DF7242EBC859}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{E89D61AC-55DE-4482-AFD4-DF7242EBC859}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32
|
||||||
|
{E89D61AC-55DE-4482-AFD4-DF7242EBC859}.Release.DLL|x86.Build.0 = Release.DLL|Win32
|
||||||
|
{E89D61AC-55DE-4482-AFD4-DF7242EBC859}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{E89D61AC-55DE-4482-AFD4-DF7242EBC859}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{B655E850-3322-42F7-941D-6AC18FD66CA1}.Debug.DLL|x86.ActiveCfg = Debug.DLL|Win32
|
||||||
|
{B655E850-3322-42F7-941D-6AC18FD66CA1}.Debug.DLL|x86.Build.0 = Debug.DLL|Win32
|
||||||
|
{B655E850-3322-42F7-941D-6AC18FD66CA1}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{B655E850-3322-42F7-941D-6AC18FD66CA1}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{B655E850-3322-42F7-941D-6AC18FD66CA1}.Release.DLL|x86.ActiveCfg = Release.DLL|Win32
|
||||||
|
{B655E850-3322-42F7-941D-6AC18FD66CA1}.Release.DLL|x86.Build.0 = Release.DLL|Win32
|
||||||
|
{B655E850-3322-42F7-941D-6AC18FD66CA1}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{B655E850-3322-42F7-941D-6AC18FD66CA1}.Release|x86.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(NestedProjects) = preSolution
|
||||||
|
{0981CA98-E4A5-4DF1-987F-A41D09131EFC} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1}
|
||||||
|
{B655E850-3322-42F7-941D-6AC18FD66CA1} = {8716DC0F-4FDE-4F57-8E25-5F78DFB80FE1}
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {E926C768-6307-4423-A1EC-57E95B1FAB29}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
192
projects/VS2019/raylib/raylib.vcxproj
Normal file
192
projects/VS2019/raylib/raylib.vcxproj
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug.DLL|Win32">
|
||||||
|
<Configuration>Debug.DLL</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release.DLL|Win32">
|
||||||
|
<Configuration>Release.DLL</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{E89D61AC-55DE-4482-AFD4-DF7242EBC859}</ProjectGuid>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<RootNamespace>raylib</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|Win32'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)$(ProjectName)\$(Configuration)\</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)$(ProjectName)\$(Configuration)\</OutDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)$(ProjectName)\$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)$(ProjectName)\$(Configuration)\temp</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)$(ProjectName)\$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)$(ProjectName)\$(Configuration)\temp</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);GRAPHICS_API_OPENGL_33;PLATFORM_DESKTOP</PreprocessorDefinitions>
|
||||||
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)..\..\..\raylib\release\include;$(SolutionDir)..\..\..\raylib\src\external\glfw\include</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
</Link>
|
||||||
|
<Lib>
|
||||||
|
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
</Lib>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug.DLL|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);GRAPHICS_API_OPENGL_33;PLATFORM_DESKTOP;BUILD_LIBTYPE_SHARED</PreprocessorDefinitions>
|
||||||
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)..\..\..\..\raylib\release\include;$(SolutionDir)..\..\..\raylib\src\external\glfw\include</AdditionalIncludeDirectories>
|
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
</Link>
|
||||||
|
<Lib>
|
||||||
|
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
</Lib>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);GRAPHICS_API_OPENGL_33;PLATFORM_DESKTOP</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)..\..\..\raylib\release\include;$(SolutionDir)..\..\..\raylib\src\external\glfw\include</AdditionalIncludeDirectories>
|
||||||
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release.DLL|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<PrecompiledHeader>
|
||||||
|
</PrecompiledHeader>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);GRAPHICS_API_OPENGL_33;PLATFORM_DESKTOP;BUILD_LIBTYPE_SHARED</PreprocessorDefinitions>
|
||||||
|
<AdditionalIncludeDirectories>$(SolutionDir)..\..\..\raylib\release\include;$(SolutionDir)..\..\..\raylib\src\external\glfw\include</AdditionalIncludeDirectories>
|
||||||
|
<CompileAs>CompileAsC</CompileAs>
|
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Text Include="ReadMe.txt" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\..\..\raylib\src\raudio.c" />
|
||||||
|
<ClCompile Include="..\..\..\..\raylib\src\rcore.c" />
|
||||||
|
<ClCompile Include="..\..\..\..\raylib\src\rmodels.c" />
|
||||||
|
<ClCompile Include="..\..\..\..\raylib\src\rglfw.c" />
|
||||||
|
<ClCompile Include="..\..\..\..\raylib\src\rshapes.c" />
|
||||||
|
<ClCompile Include="..\..\..\..\raylib\src\rtext.c" />
|
||||||
|
<ClCompile Include="..\..\..\..\raylib\src\rtextures.c" />
|
||||||
|
<ClCompile Include="..\..\..\..\raylib\src\utils.c" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\..\..\raylib\src\rcamera.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\raylib\src\external\glad.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\raylib\src\external\jar_mod.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\raylib\src\external\jar_xm.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\raylib\src\external\miniaudio.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\raylib\src\external\stb_image.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\raylib\src\external\stb_image_resize.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\raylib\src\external\stb_image_write.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\raylib\src\external\stb_rect_pack.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\raylib\src\external\stb_truetype.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\raylib\src\external\stb_vorbis.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\raylib\src\rgestures.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\raylib\src\raylib.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\raylib\src\raymath.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\raylib\src\rlgl.h" />
|
||||||
|
<ClInclude Include="..\..\..\..\raylib\src\utils.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
||||||
1217
src/extras/gui_textbox_extended.h
Normal file
1217
src/extras/gui_textbox_extended.h
Normal file
File diff suppressed because it is too large
Load Diff
3851
src/raygui.h
3851
src/raygui.h
File diff suppressed because it is too large
Load Diff
493
src/ricons.h
493
src/ricons.h
@ -1,493 +0,0 @@
|
|||||||
/**********************************************************************************************
|
|
||||||
*
|
|
||||||
* rIcons - Icons pack intended for tools development with raygui
|
|
||||||
*
|
|
||||||
* CONFIGURATION:
|
|
||||||
*
|
|
||||||
* #define RICONS_IMPLEMENTATION
|
|
||||||
* Generates the implementation of the library into the included file.
|
|
||||||
* If not defined, the library is in header only mode and can be included in other headers
|
|
||||||
* or source files without problems. But only ONE file should hold the implementation.
|
|
||||||
*
|
|
||||||
* #define RICONS_STANDALONE
|
|
||||||
* Avoid raylib.h header inclusion in this file. Icon drawing function must be provided by
|
|
||||||
* the user (check library implementation for further details).
|
|
||||||
*
|
|
||||||
* LICENSE: zlib/libpng
|
|
||||||
*
|
|
||||||
* Copyright (c) 2019 Ramon Santamaria (@raysan5)
|
|
||||||
*
|
|
||||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
|
||||||
* will the authors be held liable for any damages arising from the use of this software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any purpose, including commercial
|
|
||||||
* applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The origin of this software must not be misrepresented; you must not claim that you
|
|
||||||
* wrote the original software. If you use this software in a product, an acknowledgment
|
|
||||||
* in the product documentation would be appreciated but is not required.
|
|
||||||
*
|
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be misrepresented
|
|
||||||
* as being the original software.
|
|
||||||
*
|
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
|
||||||
*
|
|
||||||
**********************************************************************************************/
|
|
||||||
|
|
||||||
#ifndef RICONS_H
|
|
||||||
#define RICONS_H
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Defines and Macros
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
#define RICONS_COUNT 199 // Number of icons included
|
|
||||||
#define RICONS_SIZE 16 // Size of icons (squared)
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Icons enumeration
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
typedef enum {
|
|
||||||
RICON_NONE = 0,
|
|
||||||
RICON_FOLDER_FILE_OPEN,
|
|
||||||
RICON_FILE_SAVE_CLASSIC,
|
|
||||||
RICON_FOLDER_OPEN,
|
|
||||||
RICON_FOLDER_SAVE,
|
|
||||||
RICON_FILE_OPEN,
|
|
||||||
RICON_FILE_SAVE,
|
|
||||||
RICON_FILE_EXPORT,
|
|
||||||
RICON_FILE_NEW,
|
|
||||||
RICON_FILE_DELETE,
|
|
||||||
RICON_FILETYPE_TEXT,
|
|
||||||
RICON_FILETYPE_AUDIO,
|
|
||||||
RICON_FILETYPE_IMAGE,
|
|
||||||
RICON_FILETYPE_PLAY,
|
|
||||||
RICON_FILETYPE_VIDEO,
|
|
||||||
RICON_FILETYPE_INFO,
|
|
||||||
RICON_FILE_COPY,
|
|
||||||
RICON_FILE_CUT,
|
|
||||||
RICON_FILE_PASTE,
|
|
||||||
RICON_CURSOR_HAND,
|
|
||||||
RICON_CURSOR_POINTER,
|
|
||||||
RICON_CURSOR_CLASSIC,
|
|
||||||
RICON_PENCIL,
|
|
||||||
RICON_PENCIL_BIG,
|
|
||||||
RICON_BRUSH_CLASSIC,
|
|
||||||
RICON_BRUSH_PAINTER,
|
|
||||||
RICON_WATER_DROP,
|
|
||||||
RICON_COLOR_PICKER,
|
|
||||||
RICON_RUBBER,
|
|
||||||
RICON_COLOR_BUCKET,
|
|
||||||
RICON_TEXT_T,
|
|
||||||
RICON_TEXT_A,
|
|
||||||
RICON_SCALE,
|
|
||||||
RICON_RESIZE,
|
|
||||||
RICON_FILTER_POINT,
|
|
||||||
RICON_FILTER_BILINEAR,
|
|
||||||
RICON_CROP,
|
|
||||||
RICON_CROP_ALPHA,
|
|
||||||
RICON_SQUARE_TOGGLE,
|
|
||||||
RICON_SIMMETRY,
|
|
||||||
RICON_SIMMETRY_HORIZONTAL,
|
|
||||||
RICON_SIMMETRY_VERTICAL,
|
|
||||||
RICON_LENS,
|
|
||||||
RICON_LENS_BIG,
|
|
||||||
RICON_EYE_ON,
|
|
||||||
RICON_EYE_OFF,
|
|
||||||
RICON_FILTER_TOP,
|
|
||||||
RICON_FILTER,
|
|
||||||
RICON_TARGET_POINT,
|
|
||||||
RICON_TARGET_SMALL,
|
|
||||||
RICON_TARGET_BIG,
|
|
||||||
RICON_TARGET_MOVE,
|
|
||||||
RICON_CURSOR_MOVE,
|
|
||||||
RICON_CURSOR_SCALE,
|
|
||||||
RICON_CURSOR_SCALE_RIGHT,
|
|
||||||
RICON_CURSOR_SCALE_LEFT,
|
|
||||||
RICON_UNDO,
|
|
||||||
RICON_REDO,
|
|
||||||
RICON_REREDO,
|
|
||||||
RICON_MUTATE,
|
|
||||||
RICON_ROTATE,
|
|
||||||
RICON_REPEAT,
|
|
||||||
RICON_SHUFFLE,
|
|
||||||
RICON_EMPTYBOX,
|
|
||||||
RICON_TARGET,
|
|
||||||
RICON_TARGET_SMALL_FILL,
|
|
||||||
RICON_TARGET_BIG_FILL,
|
|
||||||
RICON_TARGET_MOVE_FILL,
|
|
||||||
RICON_CURSOR_MOVE_FILL,
|
|
||||||
RICON_CURSOR_SCALE_FILL,
|
|
||||||
RICON_CURSOR_SCALE_RIGHT_FILL,
|
|
||||||
RICON_CURSOR_SCALE_LEFT_FILL,
|
|
||||||
RICON_UNDO_FILL,
|
|
||||||
RICON_REDO_FILL,
|
|
||||||
RICON_REREDO_FILL,
|
|
||||||
RICON_MUTATE_FILL,
|
|
||||||
RICON_ROTATE_FILL,
|
|
||||||
RICON_REPEAT_FILL,
|
|
||||||
RICON_SHUFFLE_FILL,
|
|
||||||
RICON_EMPTYBOX_SMALL,
|
|
||||||
RICON_BOX,
|
|
||||||
RICON_BOX_TOP,
|
|
||||||
RICON_BOX_TOP_RIGHT,
|
|
||||||
RICON_BOX_RIGHT,
|
|
||||||
RICON_BOX_BOTTOM_RIGHT,
|
|
||||||
RICON_BOX_BOTTOM,
|
|
||||||
RICON_BOX_BOTTOM_LEFT,
|
|
||||||
RICON_BOX_LEFT,
|
|
||||||
RICON_BOX_TOP_LEFT,
|
|
||||||
RICON_BOX_CENTER,
|
|
||||||
RICON_BOX_CIRCLE_MASK,
|
|
||||||
RICON_POT,
|
|
||||||
RICON_ALPHA_MULTIPLY,
|
|
||||||
RICON_ALPHA_CLEAR,
|
|
||||||
RICON_DITHERING,
|
|
||||||
RICON_MIPMAPS,
|
|
||||||
RICON_BOX_GRID,
|
|
||||||
RICON_GRID,
|
|
||||||
RICON_BOX_CORNERS_SMALL,
|
|
||||||
RICON_BOX_CORNERS_BIG,
|
|
||||||
RICON_FOUR_BOXES,
|
|
||||||
RICON_GRID_FILL,
|
|
||||||
RICON_BOX_MULTISIZE,
|
|
||||||
RICON_ZOOM_SMALL,
|
|
||||||
RICON_ZOOM_MEDIUM,
|
|
||||||
RICON_ZOOM_BIG,
|
|
||||||
RICON_ZOOM_ALL,
|
|
||||||
RICON_ZOOM_CENTER,
|
|
||||||
RICON_BOX_DOTS_SMALL,
|
|
||||||
RICON_BOX_DOTS_BIG,
|
|
||||||
RICON_BOX_CONCENTRIC,
|
|
||||||
RICON_BOX_GRID_BIG,
|
|
||||||
RICON_OK_TICK,
|
|
||||||
RICON_CROSS,
|
|
||||||
RICON_ARROW_LEFT,
|
|
||||||
RICON_ARROW_RIGHT,
|
|
||||||
RICON_ARROW_BOTTOM,
|
|
||||||
RICON_ARROW_TOP,
|
|
||||||
RICON_ARROW_LEFT_FILL,
|
|
||||||
RICON_ARROW_RIGHT_FILL,
|
|
||||||
RICON_ARROW_BOTTOM_FILL,
|
|
||||||
RICON_ARROW_TOP_FILL,
|
|
||||||
RICON_AUDIO,
|
|
||||||
RICON_FX,
|
|
||||||
RICON_WAVE,
|
|
||||||
RICON_WAVE_SINUS,
|
|
||||||
RICON_WAVE_SQUARE,
|
|
||||||
RICON_WAVE_TRIANGULAR,
|
|
||||||
RICON_CROSS_SMALL,
|
|
||||||
RICON_PLAYER_PREVIOUS,
|
|
||||||
RICON_PLAYER_PLAY_BACK,
|
|
||||||
RICON_PLAYER_PLAY,
|
|
||||||
RICON_PLAYER_PAUSE,
|
|
||||||
RICON_PLAYER_STOP,
|
|
||||||
RICON_PLAYER_NEXT,
|
|
||||||
RICON_PLAYER_RECORD,
|
|
||||||
RICON_MAGNET,
|
|
||||||
RICON_LOCK_CLOSE,
|
|
||||||
RICON_LOCK_OPEN,
|
|
||||||
RICON_CLOCK,
|
|
||||||
RICON_TOOLS,
|
|
||||||
RICON_GEAR,
|
|
||||||
RICON_GEAR_BIG,
|
|
||||||
RICON_BIN,
|
|
||||||
RICON_HAND_POINTER,
|
|
||||||
RICON_LASER,
|
|
||||||
RICON_COIN,
|
|
||||||
RICON_EXPLOSION,
|
|
||||||
RICON_1UP,
|
|
||||||
RICON_PLAYER,
|
|
||||||
RICON_PLAYER_JUMP,
|
|
||||||
RICON_KEY,
|
|
||||||
RICON_DEMON,
|
|
||||||
RICON_TEXT_POPUP,
|
|
||||||
RICON_GEAR_EX,
|
|
||||||
RICON_CRACK,
|
|
||||||
RICON_CRACK_POINTS,
|
|
||||||
RICON_STAR,
|
|
||||||
RICON_DOOR,
|
|
||||||
RICON_EXIT,
|
|
||||||
RICON_MODE_2D,
|
|
||||||
RICON_MODE_3D,
|
|
||||||
RICON_CUBE,
|
|
||||||
RICON_CUBE_FACE_TOP,
|
|
||||||
RICON_CUBE_FACE_LEFT,
|
|
||||||
RICON_CUBE_FACE_FRONT,
|
|
||||||
RICON_CUBE_FACE_BOTTOM,
|
|
||||||
RICON_CUBE_FACE_RIGHT,
|
|
||||||
RICON_CUBE_FACE_BACK,
|
|
||||||
RICON_CAMERA,
|
|
||||||
RICON_SPECIAL,
|
|
||||||
RICON_LINK_NET,
|
|
||||||
RICON_LINK_BOXES,
|
|
||||||
RICON_LINK_MULTI,
|
|
||||||
RICON_LINK,
|
|
||||||
RICON_LINK_BROKE,
|
|
||||||
RICON_TEXT_NOTES,
|
|
||||||
RICON_NOTEBOOK,
|
|
||||||
RICON_SUITCASE,
|
|
||||||
RICON_SUITCASE_ZIP,
|
|
||||||
RICON_MAILBOX,
|
|
||||||
RICON_MONITOR,
|
|
||||||
RICON_PRINTER,
|
|
||||||
RICON_PHOTO_CAMERA,
|
|
||||||
RICON_PHOTO_CAMERA_FLASH,
|
|
||||||
RICON_HOUSE,
|
|
||||||
RICON_HEART,
|
|
||||||
RICON_CORNER,
|
|
||||||
RICON_VERTICAL_BARS,
|
|
||||||
RICON_VERTICAL_BARS_FILL,
|
|
||||||
RICON_LIFE_BARS,
|
|
||||||
RICON_INFO,
|
|
||||||
RICON_CROSSLINE,
|
|
||||||
RICON_HELP,
|
|
||||||
RICON_FILETYPE_ALPHA,
|
|
||||||
RICON_FILETYPE_HOME,
|
|
||||||
RICON_LAYERS_VISIBLE,
|
|
||||||
RICON_LAYERS,
|
|
||||||
RICON_WINDOW
|
|
||||||
} rIconDescription;
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
// Module Functions Declaration
|
|
||||||
//----------------------------------------------------------------------------------
|
|
||||||
void DrawIcon(int iconId, Vector2 position, int pixelSize, Color color);
|
|
||||||
|
|
||||||
#endif // RICONS_H
|
|
||||||
|
|
||||||
/***********************************************************************************
|
|
||||||
*
|
|
||||||
* RICONS IMPLEMENTATION
|
|
||||||
*
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#if defined(RICONS_IMPLEMENTATION)
|
|
||||||
|
|
||||||
#if !defined(RICONS_STANDALONE)
|
|
||||||
#include "raylib.h" // Required for: Icons drawing function: DrawRectangle()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static const unsigned int RICONS[RICONS_COUNT*8] = {
|
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // RICON_NONE
|
|
||||||
0x3ff80000, 0x2f082008, 0x2042207e, 0x40027fc2, 0x40024002, 0x40024002, 0x40024002, 0x00007ffe, // RICON_FOLDER_FILE_OPEN
|
|
||||||
0x3ffe0000, 0x44226422, 0x400247e2, 0x5ffa4002, 0x57ea500a, 0x500a500a, 0x40025ffa, 0x00007ffe, // RICON_FILE_SAVE_CLASSIC
|
|
||||||
0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024002, 0x44424282, 0x793e4102, 0x00000100, // RICON_FOLDER_OPEN
|
|
||||||
0x00000000, 0x0042007e, 0x40027fc2, 0x40024002, 0x41024102, 0x44424102, 0x793e4282, 0x00000000, // RICON_FOLDER_SAVE
|
|
||||||
0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x24442284, 0x21042104, 0x20042104, 0x00003ffc, // RICON_FILE_OPEN
|
|
||||||
0x3ff00000, 0x201c2010, 0x20042004, 0x21042004, 0x21042104, 0x22842444, 0x20042104, 0x00003ffc, // RICON_FILE_SAVE
|
|
||||||
0x3ff00000, 0x201c2010, 0x00042004, 0x20041004, 0x20844784, 0x00841384, 0x20042784, 0x00003ffc, // RICON_FILE_EXPORT
|
|
||||||
0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x22042204, 0x22042f84, 0x20042204, 0x00003ffc, // RICON_FILE_NEW
|
|
||||||
0x3ff00000, 0x201c2010, 0x20042004, 0x20042004, 0x25042884, 0x25042204, 0x20042884, 0x00003ffc, // RICON_FILE_DELETE
|
|
||||||
0x3ff00000, 0x201c2010, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc, // RICON_FILETYPE_TEXT
|
|
||||||
0x3ff00000, 0x201c2010, 0x27042004, 0x244424c4, 0x26442444, 0x20642664, 0x20042004, 0x00003ffc, // RICON_FILETYPE_AUDIO
|
|
||||||
0x3ff00000, 0x201c2010, 0x26042604, 0x20042004, 0x35442884, 0x2414222c, 0x20042004, 0x00003ffc, // RICON_FILETYPE_IMAGE
|
|
||||||
0x3ff00000, 0x201c2010, 0x20c42004, 0x22442144, 0x22442444, 0x20c42144, 0x20042004, 0x00003ffc, // RICON_FILETYPE_PLAY
|
|
||||||
0x3ff00000, 0x3ffc2ff0, 0x3f3c2ff4, 0x3dbc2eb4, 0x3dbc2bb4, 0x3f3c2eb4, 0x3ffc2ff4, 0x00002ff4, // RICON_FILETYPE_VIDEO
|
|
||||||
0x3ff00000, 0x201c2010, 0x21842184, 0x21842004, 0x21842184, 0x21842184, 0x20042184, 0x00003ffc, // RICON_FILETYPE_INFO
|
|
||||||
0x0ff00000, 0x381c0810, 0x28042804, 0x28042804, 0x28042804, 0x28042804, 0x20102ffc, 0x00003ff0, // RICON_FILE_COPY
|
|
||||||
0x00000000, 0x701c0000, 0x079c1e14, 0x55a000f0, 0x079c00f0, 0x701c1e14, 0x00000000, 0x00000000, // RICON_FILE_CUT
|
|
||||||
0x01c00000, 0x13e41bec, 0x3f841004, 0x204420c4, 0x20442044, 0x20442044, 0x207c2044, 0x00003fc0, // RICON_FILE_PASTE
|
|
||||||
0x00000000, 0x3aa00fe0, 0x2abc2aa0, 0x2aa42aa4, 0x20042aa4, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_CURSOR_HAND
|
|
||||||
0x00000000, 0x003c000c, 0x030800c8, 0x30100c10, 0x10202020, 0x04400840, 0x01800280, 0x00000000, // RICON_CURSOR_POINTER
|
|
||||||
0x00000000, 0x00180000, 0x01f00078, 0x03e007f0, 0x07c003e0, 0x04000e40, 0x00000000, 0x00000000, // RICON_CURSOR_CLASSIC
|
|
||||||
0x00000000, 0x04000000, 0x11000a00, 0x04400a80, 0x01100220, 0x00580088, 0x00000038, 0x00000000, // RICON_PENCIL
|
|
||||||
0x04000000, 0x15000a00, 0x50402880, 0x14102820, 0x05040a08, 0x015c028c, 0x007c00bc, 0x00000000, // RICON_PENCIL_BIG
|
|
||||||
0x01c00000, 0x01400140, 0x01400140, 0x0ff80140, 0x0ff80808, 0x0aa80808, 0x0aa80aa8, 0x00000ff8, // RICON_BRUSH_CLASSIC
|
|
||||||
0x1ffc0000, 0x5ffc7ffe, 0x40004000, 0x00807f80, 0x01c001c0, 0x01c001c0, 0x01c001c0, 0x00000080, // RICON_BRUSH_PAINTER
|
|
||||||
0x00000000, 0x00800000, 0x01c00080, 0x03e001c0, 0x07f003e0, 0x036006f0, 0x000001c0, 0x00000000, // RICON_WATER_DROP
|
|
||||||
0x00000000, 0x3e003800, 0x1f803f80, 0x0c201e40, 0x02080c10, 0x00840104, 0x00380044, 0x00000000, // RICON_COLOR_PICKER
|
|
||||||
0x00000000, 0x07800300, 0x1fe00fc0, 0x3f883fd0, 0x0e021f04, 0x02040402, 0x00f00108, 0x00000000, // RICON_RUBBER
|
|
||||||
0x00c00000, 0x02800140, 0x08200440, 0x20081010, 0x2ffe3004, 0x03f807fc, 0x00e001f0, 0x00000040, // RICON_COLOR_BUCKET
|
|
||||||
0x00000000, 0x21843ffc, 0x01800180, 0x01800180, 0x01800180, 0x01800180, 0x03c00180, 0x00000000, // RICON_TEXT_T
|
|
||||||
0x00800000, 0x01400180, 0x06200340, 0x0c100620, 0x1ff80c10, 0x380c1808, 0x70067004, 0x0000f80f, // RICON_TEXT_A
|
|
||||||
0x78000000, 0x50004000, 0x00004800, 0x03c003c0, 0x03c003c0, 0x00100000, 0x0002000a, 0x0000000e, // RICON_SCALE
|
|
||||||
0x75560000, 0x5e004002, 0x54001002, 0x41001202, 0x408200fe, 0x40820082, 0x40820082, 0x00006afe, // RICON_RESIZE
|
|
||||||
0x00000000, 0x3f003f00, 0x3f003f00, 0x3f003f00, 0x00400080, 0x001c0020, 0x001c001c, 0x00000000, // RICON_FILTER_POINT
|
|
||||||
0x6d800000, 0x00004080, 0x40804080, 0x40800000, 0x00406d80, 0x001c0020, 0x001c001c, 0x00000000, // RICON_FILTER_BILINEAR
|
|
||||||
0x40080000, 0x1ffe2008, 0x14081008, 0x11081208, 0x10481088, 0x10081028, 0x10047ff8, 0x00001002, // RICON_CROP
|
|
||||||
0x00100000, 0x3ffc0010, 0x2ab03550, 0x22b02550, 0x20b02150, 0x20302050, 0x2000fff0, 0x00002000, // RICON_CROP_ALPHA
|
|
||||||
0x40000000, 0x1ff82000, 0x04082808, 0x01082208, 0x00482088, 0x00182028, 0x35542008, 0x00000002, // RICON_SQUARE_TOGGLE
|
|
||||||
0x00000000, 0x02800280, 0x06c006c0, 0x0ea00ee0, 0x1e901eb0, 0x3e883e98, 0x7efc7e8c, 0x00000000, // RICON_SIMMETRY
|
|
||||||
0x01000000, 0x05600100, 0x1d480d50, 0x7d423d44, 0x3d447d42, 0x0d501d48, 0x01000560, 0x00000100, // RICON_SIMMETRY_HORIZONTAL
|
|
||||||
0x01800000, 0x04200240, 0x10080810, 0x00001ff8, 0x00007ffe, 0x0ff01ff8, 0x03c007e0, 0x00000180, // RICON_SIMMETRY_VERTICAL
|
|
||||||
0x00000000, 0x010800f0, 0x02040204, 0x02040204, 0x07f00308, 0x1c000e00, 0x30003800, 0x00000000, // RICON_LENS
|
|
||||||
0x00000000, 0x061803f0, 0x08240c0c, 0x08040814, 0x0c0c0804, 0x23f01618, 0x18002400, 0x00000000, // RICON_LENS_BIG
|
|
||||||
0x00000000, 0x00000000, 0x1c7007c0, 0x638e3398, 0x1c703398, 0x000007c0, 0x00000000, 0x00000000, // RICON_EYE_ON
|
|
||||||
0x00000000, 0x10002000, 0x04700fc0, 0x610e3218, 0x1c703098, 0x001007a0, 0x00000008, 0x00000000, // RICON_EYE_OFF
|
|
||||||
0x00000000, 0x00007ffc, 0x40047ffc, 0x10102008, 0x04400820, 0x02800280, 0x02800280, 0x00000100, // RICON_FILTER_TOP
|
|
||||||
0x00000000, 0x40027ffe, 0x10082004, 0x04200810, 0x02400240, 0x02400240, 0x01400240, 0x000000c0, // RICON_FILTER
|
|
||||||
0x00800000, 0x00800080, 0x00000080, 0x3c9e0000, 0x00000000, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_POINT
|
|
||||||
0x00800000, 0x00800080, 0x00800080, 0x3f7e01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_SMALL
|
|
||||||
0x00800000, 0x00800080, 0x03e00080, 0x3e3e0220, 0x03e00220, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_BIG
|
|
||||||
0x01000000, 0x04400280, 0x01000100, 0x43842008, 0x43849ab2, 0x01002008, 0x04400100, 0x01000280, // RICON_TARGET_MOVE
|
|
||||||
0x01000000, 0x04400280, 0x01000100, 0x41042108, 0x41049ff2, 0x01002108, 0x04400100, 0x01000280, // RICON_CURSOR_MOVE
|
|
||||||
0x781e0000, 0x500a4002, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x4002500a, 0x0000781e, // RICON_CURSOR_SCALE
|
|
||||||
0x00000000, 0x20003c00, 0x24002800, 0x01000200, 0x00400080, 0x00140024, 0x003c0004, 0x00000000, // RICON_CURSOR_SCALE_RIGHT
|
|
||||||
0x00000000, 0x0004003c, 0x00240014, 0x00800040, 0x02000100, 0x28002400, 0x3c002000, 0x00000000, // RICON_CURSOR_SCALE_LEFT
|
|
||||||
0x00000000, 0x00100020, 0x10101fc8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000, // RICON_UNDO
|
|
||||||
0x00000000, 0x08000400, 0x080813f8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000, // RICON_REDO
|
|
||||||
0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3f902020, 0x00400020, 0x00000000, // RICON_REREDO
|
|
||||||
0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3fc82010, 0x00200010, 0x00000000, // RICON_MUTATE
|
|
||||||
0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18101020, 0x00100fc8, 0x00000020, // RICON_ROTATE
|
|
||||||
0x00000000, 0x04000200, 0x240429fc, 0x20042204, 0x20442004, 0x3f942024, 0x00400020, 0x00000000, // RICON_REPEAT
|
|
||||||
0x00000000, 0x20001000, 0x22104c0e, 0x00801120, 0x11200040, 0x4c0e2210, 0x10002000, 0x00000000, // RICON_SHUFFLE
|
|
||||||
0x7ffe0000, 0x50024002, 0x44024802, 0x41024202, 0x40424082, 0x40124022, 0x4002400a, 0x00007ffe, // RICON_EMPTYBOX
|
|
||||||
0x00800000, 0x03e00080, 0x08080490, 0x3c9e0808, 0x08080808, 0x03e00490, 0x00800080, 0x00000000, // RICON_TARGET
|
|
||||||
0x00800000, 0x00800080, 0x00800080, 0x3ffe01c0, 0x008001c0, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_SMALL_FILL
|
|
||||||
0x00800000, 0x00800080, 0x03e00080, 0x3ffe03e0, 0x03e003e0, 0x00800080, 0x00800080, 0x00000000, // RICON_TARGET_BIG_FILL
|
|
||||||
0x01000000, 0x07c00380, 0x01000100, 0x638c2008, 0x638cfbbe, 0x01002008, 0x07c00100, 0x01000380, // RICON_TARGET_MOVE_FILL
|
|
||||||
0x01000000, 0x07c00380, 0x01000100, 0x610c2108, 0x610cfffe, 0x01002108, 0x07c00100, 0x01000380, // RICON_CURSOR_MOVE_FILL
|
|
||||||
0x781e0000, 0x6006700e, 0x04204812, 0x00000240, 0x02400000, 0x48120420, 0x700e6006, 0x0000781e, // RICON_CURSOR_SCALE_FILL
|
|
||||||
0x00000000, 0x38003c00, 0x24003000, 0x01000200, 0x00400080, 0x000c0024, 0x003c001c, 0x00000000, // RICON_CURSOR_SCALE_RIGHT
|
|
||||||
0x00000000, 0x001c003c, 0x0024000c, 0x00800040, 0x02000100, 0x30002400, 0x3c003800, 0x00000000, // RICON_CURSOR_SCALE_LEFT
|
|
||||||
0x00000000, 0x00300020, 0x10301ff8, 0x10001020, 0x10001000, 0x10001000, 0x00001fc0, 0x00000000, // RICON_UNDO_FILL
|
|
||||||
0x00000000, 0x0c000400, 0x0c081ff8, 0x00080408, 0x00080008, 0x00080008, 0x000003f8, 0x00000000, // RICON_REDO_FILL
|
|
||||||
0x00000000, 0x3ffc0000, 0x20042004, 0x20002000, 0x20402000, 0x3ff02060, 0x00400060, 0x00000000, // RICON_REREDO_FILL
|
|
||||||
0x00000000, 0x3ffc0000, 0x20042004, 0x27fc2004, 0x20202000, 0x3ff82030, 0x00200030, 0x00000000, // RICON_MUTATE_FILL
|
|
||||||
0x00000000, 0x0ff00000, 0x10081818, 0x11801008, 0x10001180, 0x18301020, 0x00300ff8, 0x00000020, // RICON_ROTATE_FILL
|
|
||||||
0x00000000, 0x06000200, 0x26042ffc, 0x20042204, 0x20442004, 0x3ff42064, 0x00400060, 0x00000000, // RICON_REPEAT_FILL
|
|
||||||
0x00000000, 0x30001000, 0x32107c0e, 0x00801120, 0x11200040, 0x7c0e3210, 0x10003000, 0x00000000, // RICON_SHUFFLE_FILL
|
|
||||||
0x00000000, 0x30043ffc, 0x24042804, 0x21042204, 0x20442084, 0x20142024, 0x3ffc200c, 0x00000000, // RICON_EMPTYBOX_SMALL
|
|
||||||
0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX
|
|
||||||
0x00000000, 0x23c43ffc, 0x23c423c4, 0x200423c4, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_TOP
|
|
||||||
0x00000000, 0x3e043ffc, 0x3e043e04, 0x20043e04, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_TOP_RIGHT
|
|
||||||
0x00000000, 0x20043ffc, 0x20042004, 0x3e043e04, 0x3e043e04, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_RIGHT
|
|
||||||
0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x3e042004, 0x3e043e04, 0x3ffc3e04, 0x00000000, // RICON_BOX_BOTTOM_RIGHT
|
|
||||||
0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x23c42004, 0x23c423c4, 0x3ffc23c4, 0x00000000, // RICON_BOX_BOTTOM
|
|
||||||
0x00000000, 0x20043ffc, 0x20042004, 0x20042004, 0x207c2004, 0x207c207c, 0x3ffc207c, 0x00000000, // RICON_BOX_BOTTOM_LEFT
|
|
||||||
0x00000000, 0x20043ffc, 0x20042004, 0x207c207c, 0x207c207c, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_LEFT
|
|
||||||
0x00000000, 0x207c3ffc, 0x207c207c, 0x2004207c, 0x20042004, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_TOP_LEFT
|
|
||||||
0x00000000, 0x20043ffc, 0x20042004, 0x23c423c4, 0x23c423c4, 0x20042004, 0x3ffc2004, 0x00000000, // RICON_BOX_CIRCLE_MASK
|
|
||||||
0x7ffe0000, 0x40024002, 0x47e24182, 0x4ff247e2, 0x47e24ff2, 0x418247e2, 0x40024002, 0x00007ffe, // RICON_BOX_CENTER
|
|
||||||
0x7fff0000, 0x40014001, 0x40014001, 0x49555ddd, 0x4945495d, 0x400149c5, 0x40014001, 0x00007fff, // RICON_POT
|
|
||||||
0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x404e40ce, 0x48125432, 0x4006540e, 0x00007ffe, // RICON_ALPHA_MULTIPLY
|
|
||||||
0x7ffe0000, 0x53327332, 0x44ce4cce, 0x41324332, 0x5c4e40ce, 0x44124432, 0x40065c0e, 0x00007ffe, // RICON_ALPHA_CLEAR
|
|
||||||
0x7ffe0000, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x42fe417e, 0x00007ffe, // RICON_DITHERING
|
|
||||||
0x07fe0000, 0x1ffa0002, 0x7fea000a, 0x402a402a, 0x5b2a512a, 0x5128552a, 0x40205128, 0x00007fe0, // RICON_MIPMAPS
|
|
||||||
0x00000000, 0x1ff80000, 0x12481248, 0x12481ff8, 0x1ff81248, 0x12481248, 0x00001ff8, 0x00000000, // RICON_BOX_GRID
|
|
||||||
0x12480000, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x7ffe1248, 0x12481248, 0x12487ffe, 0x00001248, // RICON_GRID
|
|
||||||
0x00000000, 0x1c380000, 0x1c3817e8, 0x08100810, 0x08100810, 0x17e81c38, 0x00001c38, 0x00000000, // RICON_BOX_CORNERS_SMALL
|
|
||||||
0x700e0000, 0x700e5ffa, 0x20042004, 0x20042004, 0x20042004, 0x20042004, 0x5ffa700e, 0x0000700e, // RICON_BOX_CORNERS_BIG
|
|
||||||
0x3f7e0000, 0x21422142, 0x21422142, 0x00003f7e, 0x21423f7e, 0x21422142, 0x3f7e2142, 0x00000000, // RICON_FOUR_BOXES
|
|
||||||
0x00000000, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x3bb80000, 0x3bb83bb8, 0x00000000, // RICON_GRID_FILL
|
|
||||||
0x7ffe0000, 0x7ffe7ffe, 0x77fe7000, 0x77fe77fe, 0x777e7700, 0x777e777e, 0x777e777e, 0x0000777e, // RICON_BOX_MULTISIZE
|
|
||||||
0x781e0000, 0x40024002, 0x00004002, 0x01800000, 0x00000180, 0x40020000, 0x40024002, 0x0000781e, // RICON_ZOOM_SMALL
|
|
||||||
0x781e0000, 0x40024002, 0x00004002, 0x03c003c0, 0x03c003c0, 0x40020000, 0x40024002, 0x0000781e, // RICON_ZOOM_MEDIUM
|
|
||||||
0x781e0000, 0x40024002, 0x07e04002, 0x07e007e0, 0x07e007e0, 0x400207e0, 0x40024002, 0x0000781e, // RICON_ZOOM_BIG
|
|
||||||
0x781e0000, 0x5ffa4002, 0x1ff85ffa, 0x1ff81ff8, 0x1ff81ff8, 0x5ffa1ff8, 0x40025ffa, 0x0000781e, // RICON_ZOOM_ALL
|
|
||||||
0x00000000, 0x2004381c, 0x00002004, 0x00000000, 0x00000000, 0x20040000, 0x381c2004, 0x00000000, // RICON_ZOOM_CENTER
|
|
||||||
0x00000000, 0x1db80000, 0x10081008, 0x10080000, 0x00001008, 0x10081008, 0x00001db8, 0x00000000, // RICON_BOX_DOTS_SMALL
|
|
||||||
0x35560000, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x00002002, 0x35562002, 0x00000000, // RICON_BOX_DOTS_BIG
|
|
||||||
0x7ffe0000, 0x40024002, 0x48124ff2, 0x49924812, 0x48124992, 0x4ff24812, 0x40024002, 0x00007ffe, // RICON_BOX_CONCENTRIC
|
|
||||||
0x00000000, 0x10841ffc, 0x10841084, 0x1ffc1084, 0x10841084, 0x10841084, 0x00001ffc, 0x00000000, // RICON_BOX_GRID_BIG
|
|
||||||
0x00000000, 0x00000000, 0x10000000, 0x04000800, 0x01040200, 0x00500088, 0x00000020, 0x00000000, // RICON_OK_TICK
|
|
||||||
0x00000000, 0x10080000, 0x04200810, 0x01800240, 0x02400180, 0x08100420, 0x00001008, 0x00000000, // RICON_CROSS
|
|
||||||
0x00000000, 0x02000000, 0x00800100, 0x00200040, 0x00200010, 0x00800040, 0x02000100, 0x00000000, // RICON_ARROW_LEFT
|
|
||||||
0x00000000, 0x00400000, 0x01000080, 0x04000200, 0x04000800, 0x01000200, 0x00400080, 0x00000000, // RICON_ARROW_RIGHT
|
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x08081004, 0x02200410, 0x00800140, 0x00000000, 0x00000000, // RICON_ARROW_BOTTOM
|
|
||||||
0x00000000, 0x00000000, 0x01400080, 0x04100220, 0x10040808, 0x00000000, 0x00000000, 0x00000000, // RICON_ARROW_TOP
|
|
||||||
0x00000000, 0x02000000, 0x03800300, 0x03e003c0, 0x03e003f0, 0x038003c0, 0x02000300, 0x00000000, // RICON_ARROW_LEFT_FILL
|
|
||||||
0x00000000, 0x00400000, 0x01c000c0, 0x07c003c0, 0x07c00fc0, 0x01c003c0, 0x004000c0, 0x00000000, // RICON_ARROW_RIGHT_FILL
|
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x0ff81ffc, 0x03e007f0, 0x008001c0, 0x00000000, 0x00000000, // RICON_ARROW_BOTTOM_FILL
|
|
||||||
0x00000000, 0x00000000, 0x01c00080, 0x07f003e0, 0x1ffc0ff8, 0x00000000, 0x00000000, 0x00000000, // RICON_ARROW_TOP_FILL
|
|
||||||
0x00000000, 0x18a008c0, 0x32881290, 0x24822686, 0x26862482, 0x12903288, 0x08c018a0, 0x00000000, // RICON_AUDIO
|
|
||||||
0x00000000, 0x04800780, 0x004000c0, 0x662000f0, 0x08103c30, 0x130a0e18, 0x0000318e, 0x00000000, // RICON_FX
|
|
||||||
0x00000000, 0x00800000, 0x08880888, 0x2aaa0a8a, 0x0a8a2aaa, 0x08880888, 0x00000080, 0x00000000, // RICON_WAVE
|
|
||||||
0x00000000, 0x00600000, 0x01080090, 0x02040108, 0x42044204, 0x24022402, 0x00001800, 0x00000000, // RICON_WAVE_SINUS
|
|
||||||
0x00000000, 0x07f80000, 0x04080408, 0x04080408, 0x04080408, 0x7c0e0408, 0x00000000, 0x00000000, // RICON_WAVE_SQUARE
|
|
||||||
0x00000000, 0x00000000, 0x00a00040, 0x22084110, 0x08021404, 0x00000000, 0x00000000, 0x00000000, // RICON_WAVE_TRIANGULAR
|
|
||||||
0x00000000, 0x00000000, 0x04200000, 0x01800240, 0x02400180, 0x00000420, 0x00000000, 0x00000000, // RICON_CROSS_SMALL
|
|
||||||
0x00000000, 0x18380000, 0x12281428, 0x10a81128, 0x112810a8, 0x14281228, 0x00001838, 0x00000000, // RICON_PLAYER_PREVIOUS
|
|
||||||
0x00000000, 0x18000000, 0x11801600, 0x10181060, 0x10601018, 0x16001180, 0x00001800, 0x00000000, // RICON_PLAYER_PLAY_BACK
|
|
||||||
0x00000000, 0x00180000, 0x01880068, 0x18080608, 0x06081808, 0x00680188, 0x00000018, 0x00000000, // RICON_PLAYER_PLAY
|
|
||||||
0x00000000, 0x1e780000, 0x12481248, 0x12481248, 0x12481248, 0x12481248, 0x00001e78, 0x00000000, // RICON_PLAYER_PAUSE
|
|
||||||
0x00000000, 0x1ff80000, 0x10081008, 0x10081008, 0x10081008, 0x10081008, 0x00001ff8, 0x00000000, // RICON_PLAYER_STOP
|
|
||||||
0x00000000, 0x1c180000, 0x14481428, 0x15081488, 0x14881508, 0x14281448, 0x00001c18, 0x00000000, // RICON_PLAYER_NEXT
|
|
||||||
0x00000000, 0x03c00000, 0x08100420, 0x10081008, 0x10081008, 0x04200810, 0x000003c0, 0x00000000, // RICON_PLAYER_RECORD
|
|
||||||
0x00000000, 0x0c3007e0, 0x13c81818, 0x14281668, 0x14281428, 0x1c381c38, 0x08102244, 0x00000000, // RICON_MAGNET
|
|
||||||
0x07c00000, 0x08200820, 0x3ff80820, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000, // RICON_LOCK_CLOSE
|
|
||||||
0x07c00000, 0x08000800, 0x3ff80800, 0x23882008, 0x21082388, 0x20082108, 0x1ff02008, 0x00000000, // RICON_LOCK_OPEN
|
|
||||||
0x01c00000, 0x0c180770, 0x3086188c, 0x60832082, 0x60034781, 0x30062002, 0x0c18180c, 0x01c00770, // RICON_CLOCK
|
|
||||||
0x0a200000, 0x1b201b20, 0x04200e20, 0x04200420, 0x04700420, 0x0e700e70, 0x0e700e70, 0x04200e70, // RICON_TOOLS
|
|
||||||
0x01800000, 0x3bdc318c, 0x0ff01ff8, 0x7c3e1e78, 0x1e787c3e, 0x1ff80ff0, 0x318c3bdc, 0x00000180, // RICON_GEAR
|
|
||||||
0x01800000, 0x3ffc318c, 0x1c381ff8, 0x781e1818, 0x1818781e, 0x1ff81c38, 0x318c3ffc, 0x00000180, // RICON_GEAR_BIG
|
|
||||||
0x00000000, 0x08080ff8, 0x08081ffc, 0x0aa80aa8, 0x0aa80aa8, 0x0aa80aa8, 0x08080aa8, 0x00000ff8, // RICON_BIN
|
|
||||||
0x00000000, 0x00000000, 0x20043ffc, 0x08043f84, 0x04040f84, 0x04040784, 0x000007fc, 0x00000000, // RICON_HAND_POINTER
|
|
||||||
0x00000000, 0x24400400, 0x00001480, 0x6efe0e00, 0x00000e00, 0x24401480, 0x00000400, 0x00000000, // RICON_LASER
|
|
||||||
0x00000000, 0x03c00000, 0x08300460, 0x11181118, 0x11181118, 0x04600830, 0x000003c0, 0x00000000, // RICON_COIN
|
|
||||||
0x00000000, 0x10880080, 0x06c00810, 0x366c07e0, 0x07e00240, 0x00001768, 0x04200240, 0x00000000, // RICON_EXPLOSION
|
|
||||||
0x00000000, 0x3d280000, 0x2528252c, 0x3d282528, 0x05280528, 0x05e80528, 0x00000000, 0x00000000, // RICON_1UP
|
|
||||||
0x01800000, 0x03c003c0, 0x018003c0, 0x0ff007e0, 0x0bd00bd0, 0x0a500bd0, 0x02400240, 0x02400240, // RICON_PLAYER
|
|
||||||
0x01800000, 0x03c003c0, 0x118013c0, 0x03c81ff8, 0x07c003c8, 0x04400440, 0x0c080478, 0x00000000, // RICON_PLAYER_JUMP
|
|
||||||
0x3ff80000, 0x30183ff8, 0x30183018, 0x3ff83ff8, 0x03000300, 0x03c003c0, 0x03e00300, 0x000003e0, // RICON_KEY
|
|
||||||
0x3ff80000, 0x3ff83ff8, 0x33983ff8, 0x3ff83398, 0x3ff83ff8, 0x00000540, 0x0fe00aa0, 0x00000fe0, // RICON_DEMON
|
|
||||||
0x00000000, 0x0ff00000, 0x20041008, 0x25442004, 0x10082004, 0x06000bf0, 0x00000300, 0x00000000, // RICON_TEXT_POPUP
|
|
||||||
0x00000000, 0x11440000, 0x07f00be8, 0x1c1c0e38, 0x1c1c0c18, 0x07f00e38, 0x11440be8, 0x00000000, // RICON_GEAR_EX
|
|
||||||
0x00000000, 0x20080000, 0x0c601010, 0x07c00fe0, 0x07c007c0, 0x0c600fe0, 0x20081010, 0x00000000, // RICON_CRACK
|
|
||||||
0x00000000, 0x20080000, 0x0c601010, 0x04400fe0, 0x04405554, 0x0c600fe0, 0x20081010, 0x00000000, // RICON_CRACK_POINTS
|
|
||||||
0x00000000, 0x00800080, 0x01c001c0, 0x1ffc3ffe, 0x03e007f0, 0x07f003e0, 0x0c180770, 0x00000808, // RICON_STAR
|
|
||||||
0x0ff00000, 0x08180810, 0x08100818, 0x0a100810, 0x08180810, 0x08100818, 0x08100810, 0x00001ff8, // RICON_DOOR
|
|
||||||
0x0ff00000, 0x08100810, 0x08100810, 0x10100010, 0x4f902010, 0x10102010, 0x08100010, 0x00000ff0, // RICON_EXIT
|
|
||||||
0x00040000, 0x001f000e, 0x0ef40004, 0x12f41284, 0x0ef41214, 0x10040004, 0x7ffc3004, 0x10003000, // RICON_MODE_2D
|
|
||||||
0x78040000, 0x501f600e, 0x0ef44004, 0x12f41284, 0x0ef41284, 0x10140004, 0x7ffc300c, 0x10003000, // RICON_MODE_3D
|
|
||||||
0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe, // RICON_CUBE
|
|
||||||
0x7fe00000, 0x5ff87ff0, 0x47fe4ffc, 0x44224402, 0x44224422, 0x241275e2, 0x0c06140a, 0x000007fe, // RICON_CUBE_FACE_TOP
|
|
||||||
0x7fe00000, 0x50386030, 0x47fe483c, 0x443e443e, 0x443e443e, 0x241e75fe, 0x0c06140e, 0x000007fe, // RICON_CUBE_FACE_LEFT
|
|
||||||
0x7fe00000, 0x50286030, 0x47fe4804, 0x47fe47fe, 0x47fe47fe, 0x27fe77fe, 0x0ffe17fe, 0x000007fe, // RICON_CUBE_FACE_FRONT
|
|
||||||
0x7fe00000, 0x50286030, 0x47fe4804, 0x44224402, 0x44224422, 0x3ff27fe2, 0x0ffe1ffa, 0x000007fe, // RICON_CUBE_FACE_BOTTOM
|
|
||||||
0x7fe00000, 0x70286030, 0x7ffe7804, 0x7c227c02, 0x7c227c22, 0x3c127de2, 0x0c061c0a, 0x000007fe, // RICON_CUBE_FACE_RIGHT
|
|
||||||
0x7fe00000, 0x7fe87ff0, 0x7ffe7fe4, 0x7fe27fe2, 0x7fe27fe2, 0x24127fe2, 0x0c06140a, 0x000007fe, // RICON_CUBE_FACE_BACK
|
|
||||||
0x00000000, 0x2a0233fe, 0x22022602, 0x22022202, 0x2a022602, 0x00a033fe, 0x02080110, 0x00000000, // RICON_CAMERA
|
|
||||||
0x00000000, 0x200c3ffc, 0x000c000c, 0x3ffc000c, 0x30003000, 0x30003000, 0x3ffc3004, 0x00000000, // RICON_SPECIAL
|
|
||||||
0x00000000, 0x0022003e, 0x012201e2, 0x0100013e, 0x01000100, 0x79000100, 0x4f004900, 0x00007800, // RICON_LINK_NET
|
|
||||||
0x00000000, 0x44007c00, 0x45004600, 0x00627cbe, 0x00620022, 0x45007cbe, 0x44004600, 0x00007c00, // RICON_LINK_BOXES
|
|
||||||
0x00000000, 0x0044007c, 0x0010007c, 0x3f100010, 0x3f1021f0, 0x3f100010, 0x3f0021f0, 0x00000000, // RICON_LINK_MULTI
|
|
||||||
0x00000000, 0x0044007c, 0x00440044, 0x0010007c, 0x00100010, 0x44107c10, 0x440047f0, 0x00007c00, // RICON_LINK
|
|
||||||
0x00000000, 0x0044007c, 0x00440044, 0x0000007c, 0x00000010, 0x44007c10, 0x44004550, 0x00007c00, // RICON_LINK_BROKE
|
|
||||||
0x02a00000, 0x22a43ffc, 0x20042004, 0x20042ff4, 0x20042ff4, 0x20042ff4, 0x20042004, 0x00003ffc, // RICON_TEXT_NOTES
|
|
||||||
0x3ffc0000, 0x20042004, 0x245e27c4, 0x27c42444, 0x2004201e, 0x201e2004, 0x20042004, 0x00003ffc, // RICON_NOTEBOOK
|
|
||||||
0x00000000, 0x07e00000, 0x04200420, 0x24243ffc, 0x24242424, 0x24242424, 0x3ffc2424, 0x00000000, // RICON_SUITCASE
|
|
||||||
0x00000000, 0x0fe00000, 0x08200820, 0x40047ffc, 0x7ffc5554, 0x40045554, 0x7ffc4004, 0x00000000, // RICON_SUITCASE_ZIP
|
|
||||||
0x00000000, 0x20043ffc, 0x3ffc2004, 0x13c81008, 0x100813c8, 0x10081008, 0x1ff81008, 0x00000000, // RICON_MAILBOX
|
|
||||||
0x00000000, 0x40027ffe, 0x5ffa5ffa, 0x5ffa5ffa, 0x40025ffa, 0x03c07ffe, 0x1ff81ff8, 0x00000000, // RICON_MONITOR
|
|
||||||
0x0ff00000, 0x6bfe7ffe, 0x7ffe7ffe, 0x68167ffe, 0x08106816, 0x08100810, 0x0ff00810, 0x00000000, // RICON_PRINTER
|
|
||||||
0x3ff80000, 0xfffe2008, 0x870a8002, 0x904a888a, 0x904a904a, 0x870a888a, 0xfffe8002, 0x00000000, // RICON_PHOTO_CAMERA
|
|
||||||
0x0fc00000, 0xfcfe0cd8, 0x8002fffe, 0x84428382, 0x84428442, 0x80028382, 0xfffe8002, 0x00000000, // RICON_PHOTO_CAMERA_FLASH
|
|
||||||
0x00000000, 0x02400180, 0x08100420, 0x20041008, 0x23c42004, 0x22442244, 0x3ffc2244, 0x00000000, // RICON_HOUSE
|
|
||||||
0x00000000, 0x1c700000, 0x3ff83ef8, 0x3ff83ff8, 0x0fe01ff0, 0x038007c0, 0x00000100, 0x00000000, // RICON_HEART
|
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x80000000, 0xe000c000, // RICON_CORNER
|
|
||||||
0x00000000, 0x14001c00, 0x15c01400, 0x15401540, 0x155c1540, 0x15541554, 0x1ddc1554, 0x00000000, // RICON_VERTICAL_BARS
|
|
||||||
0x00000000, 0x03000300, 0x1b001b00, 0x1b601b60, 0x1b6c1b60, 0x1b6c1b6c, 0x1b6c1b6c, 0x00000000, // RICON_VERTICAL_BARS_FILL
|
|
||||||
0x00000000, 0x00000000, 0x403e7ffe, 0x7ffe403e, 0x7ffe0000, 0x43fe43fe, 0x00007ffe, 0x00000000, // RICON_LIFE_BARS
|
|
||||||
0x7ffc0000, 0x43844004, 0x43844284, 0x43844004, 0x42844284, 0x42844284, 0x40044384, 0x00007ffc, // RICON_INFO
|
|
||||||
0x40008000, 0x10002000, 0x04000800, 0x01000200, 0x00400080, 0x00100020, 0x00040008, 0x00010002, // RICON_CROSSLINE
|
|
||||||
0x00000000, 0x1ff01ff0, 0x18301830, 0x1f001830, 0x03001f00, 0x00000300, 0x03000300, 0x00000000, // RICON_HELP
|
|
||||||
0x3ff00000, 0x2abc3550, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x2aac3554, 0x00003ffc, // RICON_FILETYPE_ALPHA
|
|
||||||
0x3ff00000, 0x201c2010, 0x22442184, 0x28142424, 0x29942814, 0x2ff42994, 0x20042004, 0x00003ffc, // RICON_FILETYPE_HOME
|
|
||||||
0x07fe0000, 0x04020402, 0x7fe20402, 0x44224422, 0x44224422, 0x402047fe, 0x40204020, 0x00007fe0, // RICON_LAYERS_VISIBLE
|
|
||||||
0x07fe0000, 0x04020402, 0x7c020402, 0x44024402, 0x44024402, 0x402047fe, 0x40204020, 0x00007fe0, // RICON_LAYERS
|
|
||||||
0x00000000, 0x40027ffe, 0x7ffe4002, 0x40024002, 0x40024002, 0x40024002, 0x7ffe4002, 0x00000000, // RICON_WINDOW
|
|
||||||
};
|
|
||||||
|
|
||||||
// Draw selected icon using rectangles pixel-by-pixel
|
|
||||||
void DrawIcon(int iconId, Vector2 position, int pixelSize, Color color)
|
|
||||||
{
|
|
||||||
#define BIT_CHECK(a,b) ((a) & (1<<(b)))
|
|
||||||
|
|
||||||
for (int i = 0, y = 0; i < RICONS_SIZE*RICONS_SIZE/32; i++)
|
|
||||||
{
|
|
||||||
for (int k = 0; k < 32; k++)
|
|
||||||
{
|
|
||||||
if (BIT_CHECK(RICONS[8*iconId + i], k))
|
|
||||||
{
|
|
||||||
#if !defined(RICONS_STANDALONE)
|
|
||||||
DrawRectangle(position.x + (k%RICONS_SIZE)*pixelSize, position.y + y*pixelSize, pixelSize, pixelSize, color);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((k == 15) || (k == 31)) y++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // RICONS_IMPLEMENTATION
|
|
||||||
@ -19,6 +19,6 @@ p 00 09 0x94795dff DEFAULT_BORDER_COLOR_DISABLED
|
|||||||
p 00 10 0xc2a37aff DEFAULT_BASE_COLOR_DISABLED
|
p 00 10 0xc2a37aff DEFAULT_BASE_COLOR_DISABLED
|
||||||
p 00 11 0x9c8369ff DEFAULT_TEXT_COLOR_DISABLED
|
p 00 11 0x9c8369ff DEFAULT_TEXT_COLOR_DISABLED
|
||||||
p 00 16 0x0000000f TEXT_SIZE
|
p 00 16 0x0000000f TEXT_SIZE
|
||||||
p 00 17 0x00000000 TEXT_SPACING
|
p 00 17 0x00000001 TEXT_SPACING
|
||||||
p 00 18 0xd77575ff DEFAULT_LINE_COLOR
|
p 00 18 0xd77575ff DEFAULT_LINE_COLOR
|
||||||
p 00 19 0xfff5e1ff DEFAULT_BACKGROUND_COLOR
|
p 00 19 0xfff5e1ff DEFAULT_BACKGROUND_COLOR
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
f 14 0 Kyrou 7 Wide.ttf
|
f 14 0 Kyrou 7 Wide.ttf
|
||||||
p 00 00 0x2f7486ff DEFAULT_BORDER_COLOR_NORMAL
|
p 00 00 0x2f7486ff DEFAULT_BORDER_COLOR_NORMAL
|
||||||
p 00 01 0x024658ff DEFAULT_BASE_COLOR_NORMAL
|
p 00 01 0x024658ff DEFAULT_BASE_COLOR_NORMAL
|
||||||
p 00 02 0x2489a2ff DEFAULT_TEXT_COLOR_NORMAL
|
p 00 02 0x51bfd3ff DEFAULT_TEXT_COLOR_NORMAL
|
||||||
p 00 03 0x82cde0ff DEFAULT_BORDER_COLOR_FOCUSED
|
p 00 03 0x82cde0ff DEFAULT_BORDER_COLOR_FOCUSED
|
||||||
p 00 04 0x3299b4ff DEFAULT_BASE_COLOR_FOCUSED
|
p 00 04 0x3299b4ff DEFAULT_BASE_COLOR_FOCUSED
|
||||||
p 00 05 0xb6e1eaff DEFAULT_TEXT_COLOR_FOCUSED
|
p 00 05 0xb6e1eaff DEFAULT_TEXT_COLOR_FOCUSED
|
||||||
@ -18,7 +18,7 @@ p 00 08 0xd86f36ff DEFAULT_TEXT_COLOR_PRESSED
|
|||||||
p 00 09 0x134b5aff DEFAULT_BORDER_COLOR_DISABLED
|
p 00 09 0x134b5aff DEFAULT_BORDER_COLOR_DISABLED
|
||||||
p 00 10 0x02313dff DEFAULT_BASE_COLOR_DISABLED
|
p 00 10 0x02313dff DEFAULT_BASE_COLOR_DISABLED
|
||||||
p 00 11 0x17505fff DEFAULT_TEXT_COLOR_DISABLED
|
p 00 11 0x17505fff DEFAULT_TEXT_COLOR_DISABLED
|
||||||
p 00 16 0x0000000e TEXT_SIZE
|
p 00 16 0x0000000e DEFAULT_TEXT_SIZE
|
||||||
p 00 17 0x00000000 TEXT_SPACING
|
p 00 17 0x00000000 DEFAULT_TEXT_SPACING
|
||||||
p 00 18 0x81c0d0ff DEFAULT_LINE_COLOR
|
p 00 18 0x81c0d0ff DEFAULT_LINE_COLOR
|
||||||
p 00 19 0x00222bff DEFAULT_BACKGROUND_COLOR
|
p 00 19 0x00222bff DEFAULT_BACKGROUND_COLOR
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 54 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Reference in New Issue
Block a user