Skip to content

Commit a235cd6

Browse files
committed
Update raygui.h
1 parent ab463ac commit a235cd6

File tree

1 file changed

+67
-72
lines changed

1 file changed

+67
-72
lines changed

examples/core/raygui.h

Lines changed: 67 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
*
7878
* static unsigned int guiStyle[RAYGUI_MAX_CONTROLS*(RAYGUI_MAX_PROPS_BASE + RAYGUI_MAX_PROPS_EXTENDED)];
7979
*
80-
* guiStyle size is by default: 16*(16 + 8) = 384*4 = 1536 bytes = 1.5 KB
80+
* guiStyle size is by default: 16*(16 + 8) = 384 int = 384*4 bytes = 1536 bytes = 1.5 KB
8181
*
8282
* Note that the first set of BASE properties (by default guiStyle[0..15]) belong to the generic style
8383
* used for all controls, when any of those base values is set, it is automatically populated to all
@@ -141,7 +141,7 @@
141141
* Draw text bounds rectangles for debug
142142
*
143143
* VERSIONS HISTORY:
144-
* 5.0-dev (2025) Current dev version...
144+
* 5.0 (xx-Nov-2025) ADDED: Support up to 32 controls (v500)
145145
* ADDED: guiControlExclusiveMode and guiControlExclusiveRec for exclusive modes
146146
* ADDED: GuiValueBoxFloat()
147147
* ADDED: GuiDropdonwBox() properties: DROPDOWN_ARROW_HIDDEN, DROPDOWN_ROLL_UP
@@ -271,7 +271,7 @@
271271
* 0.8 (27-Aug-2015) Initial release. Implemented by Kevin Gato, Daniel Nicolás and Ramon Santamaria
272272
*
273273
* DEPENDENCIES:
274-
* raylib 5.0 - Inputs reading (keyboard/mouse), shapes drawing, font loading and text drawing
274+
* raylib 5.6-dev - Inputs reading (keyboard/mouse), shapes drawing, font loading and text drawing
275275
*
276276
* STANDALONE MODE:
277277
* By default raygui depends on raylib mostly for the inputs and the drawing functionality but that dependency can be disabled
@@ -1010,28 +1010,28 @@ typedef enum {
10101010
ICON_SLICING = 231,
10111011
ICON_MANUAL_CONTROL = 232,
10121012
ICON_COLLISION = 233,
1013-
ICON_234 = 234,
1014-
ICON_235 = 235,
1015-
ICON_236 = 236,
1016-
ICON_237 = 237,
1017-
ICON_238 = 238,
1018-
ICON_239 = 239,
1019-
ICON_240 = 240,
1020-
ICON_241 = 241,
1021-
ICON_242 = 242,
1022-
ICON_243 = 243,
1023-
ICON_244 = 244,
1024-
ICON_245 = 245,
1025-
ICON_246 = 246,
1026-
ICON_247 = 247,
1027-
ICON_248 = 248,
1028-
ICON_249 = 249,
1013+
ICON_CIRCLE_ADD = 234,
1014+
ICON_CIRCLE_ADD_FILL = 235,
1015+
ICON_CIRCLE_WARNING = 236,
1016+
ICON_CIRCLE_WARNING_FILL = 237,
1017+
ICON_BOX_MORE = 238,
1018+
ICON_BOX_MORE_FILL = 239,
1019+
ICON_BOX_MINUS = 240,
1020+
ICON_BOX_MINUS_FILL = 241,
1021+
ICON_UNION = 242,
1022+
ICON_INTERSECTION = 243,
1023+
ICON_DIFFERENCE = 244,
1024+
ICON_SPHERE = 245,
1025+
ICON_CYLINDER = 246,
1026+
ICON_CONE = 247,
1027+
ICON_ELLIPSOID = 248,
1028+
ICON_CAPSULE = 249,
10291029
ICON_250 = 250,
10301030
ICON_251 = 251,
10311031
ICON_252 = 252,
10321032
ICON_253 = 253,
10331033
ICON_254 = 254,
1034-
ICON_255 = 255,
1034+
ICON_255 = 255
10351035
} GuiIconName;
10361036
#endif
10371037

@@ -1078,7 +1078,7 @@ typedef enum {
10781078

10791079
// Check if two rectangles are equal, used to validate a slider bounds as an id
10801080
#ifndef CHECK_BOUNDS_ID
1081-
#define CHECK_BOUNDS_ID(src, dst) ((src.x == dst.x) && (src.y == dst.y) && (src.width == dst.width) && (src.height == dst.height))
1081+
#define CHECK_BOUNDS_ID(src, dst) (((int)src.x == (int)dst.x) && ((int)src.y == (int)dst.y) && ((int)src.width == (int)dst.width) && ((int)src.height == (int)dst.height))
10821082
#endif
10831083

10841084
#if !defined(RAYGUI_NO_ICONS) && !defined(RAYGUI_CUSTOM_ICONS)
@@ -1341,22 +1341,22 @@ static unsigned int guiIcons[RAYGUI_ICON_MAX_ICONS*RAYGUI_ICON_DATA_ELEMENTS] =
13411341
0x7fe00000, 0x402e4020, 0x43ce5e0a, 0x40504078, 0x438e4078, 0x402e5e0a, 0x7fe04020, 0x00000000, // ICON_SLICING
13421342
0x00000000, 0x40027ffe, 0x47c24002, 0x55425d42, 0x55725542, 0x50125552, 0x10105016, 0x00001ff0, // ICON_MANUAL_CONTROL
13431343
0x7ffe0000, 0x43c24002, 0x48124422, 0x500a500a, 0x500a500a, 0x44224812, 0x400243c2, 0x00007ffe, // ICON_COLLISION
1344-
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_234
1345-
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_235
1346-
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_236
1347-
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_237
1348-
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_238
1349-
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_239
1350-
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_240
1351-
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_241
1352-
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_242
1353-
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_243
1354-
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_244
1355-
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_245
1356-
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_246
1357-
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_247
1358-
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_248
1359-
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_249
1344+
0x03c00000, 0x10080c30, 0x21842184, 0x4ff24182, 0x41824ff2, 0x21842184, 0x0c301008, 0x000003c0, // ICON_CIRCLE_ADD
1345+
0x03c00000, 0x1ff80ff0, 0x3e7c3e7c, 0x700e7e7e, 0x7e7e700e, 0x3e7c3e7c, 0x0ff01ff8, 0x000003c0, // ICON_CIRCLE_ADD_FILL
1346+
0x03c00000, 0x10080c30, 0x21842184, 0x41824182, 0x40024182, 0x21842184, 0x0c301008, 0x000003c0, // ICON_CIRCLE_WARNING
1347+
0x03c00000, 0x1ff80ff0, 0x3e7c3e7c, 0x7e7e7e7e, 0x7ffe7e7e, 0x3e7c3e7c, 0x0ff01ff8, 0x000003c0, // ICON_CIRCLE_WARNING_FILL
1348+
0x00000000, 0x10041ffc, 0x10841004, 0x13e41084, 0x10841084, 0x10041004, 0x00001ffc, 0x00000000, // ICON_BOX_MORE
1349+
0x00000000, 0x1ffc1ffc, 0x1f7c1ffc, 0x1c1c1f7c, 0x1f7c1f7c, 0x1ffc1ffc, 0x00001ffc, 0x00000000, // ICON_BOX_MORE_FILL
1350+
0x00000000, 0x1ffc1ffc, 0x1ffc1ffc, 0x1c1c1ffc, 0x1ffc1ffc, 0x1ffc1ffc, 0x00001ffc, 0x00000000, // ICON_BOX_MINUS
1351+
0x00000000, 0x10041ffc, 0x10041004, 0x13e41004, 0x10041004, 0x10041004, 0x00001ffc, 0x00000000, // ICON_BOX_MINUS_FILL
1352+
0x07fe0000, 0x055606aa, 0x7ff606aa, 0x55766eba, 0x55766eaa, 0x55606ffe, 0x55606aa0, 0x00007fe0, // ICON_UNION
1353+
0x07fe0000, 0x04020402, 0x7fe20402, 0x456246a2, 0x456246a2, 0x402047fe, 0x40204020, 0x00007fe0, // ICON_INTERSECTION
1354+
0x07fe0000, 0x055606aa, 0x7ff606aa, 0x4436442a, 0x4436442a, 0x402047fe, 0x40204020, 0x00007fe0, // ICON_DIFFERENCE
1355+
0x03c00000, 0x10080c30, 0x20042004, 0x60064002, 0x47e2581a, 0x20042004, 0x0c301008, 0x000003c0, // ICON_SPHERE
1356+
0x03e00000, 0x08080410, 0x0c180808, 0x08080be8, 0x08080808, 0x08080808, 0x04100808, 0x000003e0, // ICON_CYLINDER
1357+
0x00800000, 0x01400140, 0x02200220, 0x04100410, 0x08080808, 0x1c1c13e4, 0x08081004, 0x000007f0, // ICON_CONE
1358+
0x00000000, 0x07e00000, 0x20841918, 0x40824082, 0x40824082, 0x19182084, 0x000007e0, 0x00000000, // ICON_ELLIPSOID
1359+
0x00000000, 0x00000000, 0x20041ff8, 0x40024002, 0x40024002, 0x1ff82004, 0x00000000, 0x00000000, // ICON_CAPSULE
13601360
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_250
13611361
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_251
13621362
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_252
@@ -1743,7 +1743,7 @@ int GuiPanel(Rectangle bounds, const char *text)
17431743
// NOTE: Using GuiToggle() for the TABS
17441744
int GuiTabBar(Rectangle bounds, const char **text, int count, int *active)
17451745
{
1746-
#define RAYGUI_TABBAR_ITEM_WIDTH 160
1746+
#define RAYGUI_TABBAR_ITEM_WIDTH 148
17471747

17481748
int result = -1;
17491749
//GuiState state = guiState;
@@ -1776,12 +1776,12 @@ int GuiTabBar(Rectangle bounds, const char **text, int count, int *active)
17761776
if (i == (*active))
17771777
{
17781778
toggle = true;
1779-
GuiToggle(tabBounds, GuiIconText(12, text[i]), &toggle);
1779+
GuiToggle(tabBounds, text[i], &toggle);
17801780
}
17811781
else
17821782
{
17831783
toggle = false;
1784-
GuiToggle(tabBounds, GuiIconText(12, text[i]), &toggle);
1784+
GuiToggle(tabBounds, text[i], &toggle);
17851785
if (toggle) *active = i;
17861786
}
17871787

@@ -2590,7 +2590,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
25902590
int pasteLength = 0;
25912591
int pasteCodepoint;
25922592
int pasteCodepointSize;
2593-
2593+
25942594
// Count how many codepoints to copy, stopping at the first unwanted control character
25952595
while (true)
25962596
{
@@ -2599,7 +2599,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
25992599
if (!(multiline && (pasteCodepoint == (int)'\n')) && !(pasteCodepoint >= 32)) break;
26002600
pasteLength += pasteCodepointSize;
26012601
}
2602-
2602+
26032603
if (pasteLength > 0)
26042604
{
26052605
// Move forward data from cursor position
@@ -2662,7 +2662,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
26622662
while (offset < textLength)
26632663
{
26642664
if (!isspace(nextCodepoint & 0xff)) break;
2665-
2665+
26662666
offset += nextCodepointSize;
26672667
accCodepointSize += nextCodepointSize;
26682668
nextCodepoint = GetCodepointNext(text + offset, &nextCodepointSize);
@@ -2673,11 +2673,11 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
26732673

26742674
textLength -= accCodepointSize;
26752675
}
2676-
2676+
26772677
else if ((textLength > textBoxCursorIndex) && (IsKeyPressed(KEY_DELETE) || (IsKeyDown(KEY_DELETE) && autoCursorShouldTrigger)))
26782678
{
26792679
// Delete single codepoint from text, after current cursor position
2680-
2680+
26812681
int nextCodepointSize = 0;
26822682
GetCodepointNext(text + textBoxCursorIndex, &nextCodepointSize);
26832683

@@ -2704,7 +2704,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
27042704
offset -= prevCodepointSize;
27052705
accCodepointSize += prevCodepointSize;
27062706
}
2707-
2707+
27082708
// Check characters of the same type to delete (either ASCII punctuation or anything non-whitespace)
27092709
// Not using isalnum() since it only works on ASCII characters
27102710
bool puctuation = ispunct(prevCodepoint & 0xff);
@@ -2723,11 +2723,11 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
27232723
textLength -= accCodepointSize;
27242724
textBoxCursorIndex -= accCodepointSize;
27252725
}
2726-
2726+
27272727
else if ((textBoxCursorIndex > 0) && (IsKeyPressed(KEY_BACKSPACE) || (IsKeyDown(KEY_BACKSPACE) && autoCursorShouldTrigger)))
27282728
{
27292729
// Delete single codepoint from text, before current cursor position
2730-
2730+
27312731
int prevCodepointSize = 0;
27322732

27332733
GetCodepointPrevious(text + textBoxCursorIndex, &prevCodepointSize);
@@ -3026,14 +3026,14 @@ int GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, int
30263026
// NOTE: Requires static variables: frameCounter
30273027
int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode)
30283028
{
3029-
#if !defined(RAYGUI_VALUEBOX_MAX_CHARS)
3029+
//#if !defined(RAYGUI_VALUEBOX_MAX_CHARS)
30303030
#define RAYGUI_VALUEBOX_MAX_CHARS 32
3031-
#endif
3031+
//#endif
30323032

30333033
int result = 0;
30343034
GuiState state = guiState;
30353035

3036-
char textValue[RAYGUI_VALUEBOX_MAX_CHARS + 1] = "\0";
3036+
char textValue[RAYGUI_VALUEBOX_MAX_CHARS + 1] = { 0 };
30373037
snprintf(textValue, RAYGUI_VALUEBOX_MAX_CHARS + 1, "%i", *value);
30383038

30393039
Rectangle textBounds = { 0 };
@@ -3051,7 +3051,6 @@ int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, in
30513051
if ((state != STATE_DISABLED) && !guiLocked && !guiControlExclusiveMode)
30523052
{
30533053
Vector2 mousePoint = GetMousePosition();
3054-
30553054
bool valueHasChanged = false;
30563055

30573056
if (editMode)
@@ -3070,7 +3069,7 @@ int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, in
30703069
keyCount--;
30713070
valueHasChanged = true;
30723071
}
3073-
else if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS -1)
3072+
else if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS)
30743073
{
30753074
if (keyCount == 0)
30763075
{
@@ -3087,30 +3086,26 @@ int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, in
30873086
}
30883087
}
30893088

3090-
// Only allow keys in range [48..57]
3091-
if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS)
3089+
// Add new digit to text value
3090+
if ((keyCount < RAYGUI_VALUEBOX_MAX_CHARS) && (GuiGetTextWidth(textValue) < bounds.width))
30923091
{
3093-
if (GuiGetTextWidth(textValue) < bounds.width)
3092+
int key = GetCharPressed();
3093+
3094+
// Only allow keys in range [48..57]
3095+
if ((key >= 48) && (key <= 57))
30943096
{
3095-
int key = GetCharPressed();
3096-
if ((key >= 48) && (key <= 57))
3097-
{
3098-
textValue[keyCount] = (char)key;
3099-
keyCount++;
3100-
valueHasChanged = true;
3101-
}
3097+
textValue[keyCount] = (char)key;
3098+
keyCount++;
3099+
valueHasChanged = true;
31023100
}
31033101
}
31043102

31053103
// Delete text
3106-
if (keyCount > 0)
3104+
if ((keyCount > 0) && IsKeyPressed(KEY_BACKSPACE))
31073105
{
3108-
if (IsKeyPressed(KEY_BACKSPACE))
3109-
{
3110-
keyCount--;
3111-
textValue[keyCount] = '\0';
3112-
valueHasChanged = true;
3113-
}
3106+
keyCount--;
3107+
textValue[keyCount] = '\0';
3108+
valueHasChanged = true;
31143109
}
31153110

31163111
if (valueHasChanged) *value = TextToInteger(textValue);
@@ -3224,9 +3219,9 @@ int GuiValueBoxFloat(Rectangle bounds, const char *text, char *textValue, float
32243219
textValue[1] = '\0';
32253220
keyCount++;
32263221
}
3227-
3222+
32283223
for (int i = keyCount; i > -1; i--) textValue[i + 1] = textValue[i];
3229-
3224+
32303225
textValue[0] = '-';
32313226
keyCount++;
32323227
valueHasChanged = true;

0 commit comments

Comments
 (0)