mirror of
https://github.com/raysan5/raygui.git
synced 2025-12-25 10:22:33 -05:00
Compare commits
8 Commits
aed63cedd1
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 0b94b80c92 | |||
| 867ca4bf8d | |||
| 367e169ad3 | |||
| 1a74db2ab3 | |||
| 715baf250d | |||
| 3aea427fc8 | |||
| 773d1ec52b | |||
| ff4dbd0712 |
@ -6,10 +6,10 @@ PRODUCTVERSION 4,0,0,0
|
|||||||
BEGIN
|
BEGIN
|
||||||
BLOCK "StringFileInfo"
|
BLOCK "StringFileInfo"
|
||||||
BEGIN
|
BEGIN
|
||||||
//BLOCK "080904E4" // English UK
|
//BLOCK "080904E4" // English UK
|
||||||
BLOCK "040904E4" // English US
|
BLOCK "040904E4" // English US
|
||||||
BEGIN
|
BEGIN
|
||||||
//VALUE "CompanyName", "raylib technologies"
|
//VALUE "CompanyName", "raylib technologies"
|
||||||
VALUE "FileDescription", "raygui application (www.raylib.com)"
|
VALUE "FileDescription", "raygui application (www.raylib.com)"
|
||||||
VALUE "FileVersion", "4.0.0"
|
VALUE "FileVersion", "4.0.0"
|
||||||
VALUE "InternalName", "raygui app"
|
VALUE "InternalName", "raygui app"
|
||||||
@ -21,7 +21,7 @@ BEGIN
|
|||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
BEGIN
|
BEGIN
|
||||||
//VALUE "Translation", 0x809, 1252 // English UK
|
//VALUE "Translation", 0x809, 1252 // English UK
|
||||||
VALUE "Translation", 0x409, 1252 // English US
|
VALUE "Translation", 0x409, 1252 // English US
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
|||||||
74
src/raygui.h
74
src/raygui.h
@ -141,7 +141,7 @@
|
|||||||
* Draw text bounds rectangles for debug
|
* Draw text bounds rectangles for debug
|
||||||
*
|
*
|
||||||
* VERSIONS HISTORY:
|
* VERSIONS HISTORY:
|
||||||
* 5.0-dev (2025) Current dev version...
|
* 5.0 (xx-Nov-2025) ADDED: Support up to 32 controls (v500)
|
||||||
* ADDED: guiControlExclusiveMode and guiControlExclusiveRec for exclusive modes
|
* ADDED: guiControlExclusiveMode and guiControlExclusiveRec for exclusive modes
|
||||||
* ADDED: GuiValueBoxFloat()
|
* ADDED: GuiValueBoxFloat()
|
||||||
* ADDED: GuiDropdonwBox() properties: DROPDOWN_ARROW_HIDDEN, DROPDOWN_ROLL_UP
|
* ADDED: GuiDropdonwBox() properties: DROPDOWN_ARROW_HIDDEN, DROPDOWN_ROLL_UP
|
||||||
@ -1091,7 +1091,7 @@ typedef enum {
|
|||||||
// Icons data is defined by bit array (every bit represents one pixel)
|
// Icons data is defined by bit array (every bit represents one pixel)
|
||||||
// Those arrays are stored as unsigned int data arrays, so,
|
// Those arrays are stored as unsigned int data arrays, so,
|
||||||
// every array element defines 32 pixels (bits) of information
|
// every array element defines 32 pixels (bits) of information
|
||||||
// One icon is defined by 8 int, (8 int * 32 bit = 256 bit = 16*16 pixels)
|
// One icon is defined by 8 int, (8 int*32 bit = 256 bit = 16*16 pixels)
|
||||||
// NOTE: Number of elemens depend on RAYGUI_ICON_SIZE (by default 16x16 pixels)
|
// NOTE: Number of elemens depend on RAYGUI_ICON_SIZE (by default 16x16 pixels)
|
||||||
#define RAYGUI_ICON_DATA_ELEMENTS (RAYGUI_ICON_SIZE*RAYGUI_ICON_SIZE/32)
|
#define RAYGUI_ICON_DATA_ELEMENTS (RAYGUI_ICON_SIZE*RAYGUI_ICON_SIZE/32)
|
||||||
|
|
||||||
@ -1743,7 +1743,7 @@ int GuiPanel(Rectangle bounds, const char *text)
|
|||||||
// NOTE: Using GuiToggle() for the TABS
|
// NOTE: Using GuiToggle() for the TABS
|
||||||
int GuiTabBar(Rectangle bounds, const char **text, int count, int *active)
|
int GuiTabBar(Rectangle bounds, const char **text, int count, int *active)
|
||||||
{
|
{
|
||||||
#define RAYGUI_TABBAR_ITEM_WIDTH 160
|
#define RAYGUI_TABBAR_ITEM_WIDTH 148
|
||||||
|
|
||||||
int result = -1;
|
int result = -1;
|
||||||
//GuiState state = guiState;
|
//GuiState state = guiState;
|
||||||
@ -1776,12 +1776,12 @@ int GuiTabBar(Rectangle bounds, const char **text, int count, int *active)
|
|||||||
if (i == (*active))
|
if (i == (*active))
|
||||||
{
|
{
|
||||||
toggle = true;
|
toggle = true;
|
||||||
GuiToggle(tabBounds, GuiIconText(12, text[i]), &toggle);
|
GuiToggle(tabBounds, text[i], &toggle);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
toggle = false;
|
toggle = false;
|
||||||
GuiToggle(tabBounds, GuiIconText(12, text[i]), &toggle);
|
GuiToggle(tabBounds, text[i], &toggle);
|
||||||
if (toggle) *active = i;
|
if (toggle) *active = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2506,7 +2506,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
GuiState state = guiState;
|
GuiState state = guiState;
|
||||||
|
|
||||||
bool multiline = false; // TODO: Consider multiline text input
|
bool multiline = false; // TODO: Consider multiline text input
|
||||||
int wrapMode = GuiGetStyle(DEFAULT, TEXT_WRAP_MODE);
|
int wrapMode = GuiGetStyle(DEFAULT, TEXT_WRAP_MODE);
|
||||||
|
|
||||||
Rectangle textBounds = GetTextBounds(TEXTBOX, bounds);
|
Rectangle textBounds = GetTextBounds(TEXTBOX, bounds);
|
||||||
@ -2514,7 +2514,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
int thisCursorIndex = textBoxCursorIndex;
|
int thisCursorIndex = textBoxCursorIndex;
|
||||||
if (thisCursorIndex > textLength) thisCursorIndex = textLength;
|
if (thisCursorIndex > textLength) thisCursorIndex = textLength;
|
||||||
int textWidth = GuiGetTextWidth(text) - GuiGetTextWidth(text + thisCursorIndex);
|
int textWidth = GuiGetTextWidth(text) - GuiGetTextWidth(text + thisCursorIndex);
|
||||||
int textIndexOffset = 0; // Text index offset to start drawing in the box
|
int textIndexOffset = 0; // Text index offset to start drawing in the box
|
||||||
|
|
||||||
// Cursor rectangle
|
// Cursor rectangle
|
||||||
// NOTE: Position X value should be updated
|
// NOTE: Position X value should be updated
|
||||||
@ -2692,8 +2692,8 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
{
|
{
|
||||||
int offset = textBoxCursorIndex;
|
int offset = textBoxCursorIndex;
|
||||||
int accCodepointSize = 0;
|
int accCodepointSize = 0;
|
||||||
int prevCodepointSize;
|
int prevCodepointSize = 0;
|
||||||
int prevCodepoint;
|
int prevCodepoint = 0;
|
||||||
|
|
||||||
// Check whitespace to delete (ASCII only)
|
// Check whitespace to delete (ASCII only)
|
||||||
while (offset > 0)
|
while (offset > 0)
|
||||||
@ -2744,8 +2744,8 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
{
|
{
|
||||||
int offset = textBoxCursorIndex;
|
int offset = textBoxCursorIndex;
|
||||||
//int accCodepointSize = 0;
|
//int accCodepointSize = 0;
|
||||||
int prevCodepointSize;
|
int prevCodepointSize = 0;
|
||||||
int prevCodepoint;
|
int prevCodepoint = 0;
|
||||||
|
|
||||||
// Check whitespace to skip (ASCII only)
|
// Check whitespace to skip (ASCII only)
|
||||||
while (offset > 0)
|
while (offset > 0)
|
||||||
@ -3033,7 +3033,7 @@ int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, in
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
GuiState state = guiState;
|
GuiState state = guiState;
|
||||||
|
|
||||||
char textValue[RAYGUI_VALUEBOX_MAX_CHARS + 1] = "\0";
|
char textValue[RAYGUI_VALUEBOX_MAX_CHARS + 1] = { 0 };
|
||||||
snprintf(textValue, RAYGUI_VALUEBOX_MAX_CHARS + 1, "%i", *value);
|
snprintf(textValue, RAYGUI_VALUEBOX_MAX_CHARS + 1, "%i", *value);
|
||||||
|
|
||||||
Rectangle textBounds = { 0 };
|
Rectangle textBounds = { 0 };
|
||||||
@ -3051,7 +3051,6 @@ int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, in
|
|||||||
if ((state != STATE_DISABLED) && !guiLocked && !guiControlExclusiveMode)
|
if ((state != STATE_DISABLED) && !guiLocked && !guiControlExclusiveMode)
|
||||||
{
|
{
|
||||||
Vector2 mousePoint = GetMousePosition();
|
Vector2 mousePoint = GetMousePosition();
|
||||||
|
|
||||||
bool valueHasChanged = false;
|
bool valueHasChanged = false;
|
||||||
|
|
||||||
if (editMode)
|
if (editMode)
|
||||||
@ -3070,7 +3069,7 @@ int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, in
|
|||||||
keyCount--;
|
keyCount--;
|
||||||
valueHasChanged = true;
|
valueHasChanged = true;
|
||||||
}
|
}
|
||||||
else if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS -1)
|
else if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS)
|
||||||
{
|
{
|
||||||
if (keyCount == 0)
|
if (keyCount == 0)
|
||||||
{
|
{
|
||||||
@ -3087,30 +3086,26 @@ int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only allow keys in range [48..57]
|
// Add new digit to text value
|
||||||
if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS)
|
if ((keyCount >= 0) && (keyCount < RAYGUI_VALUEBOX_MAX_CHARS) && (GuiGetTextWidth(textValue) < bounds.width))
|
||||||
{
|
{
|
||||||
if (GuiGetTextWidth(textValue) < bounds.width)
|
int key = GetCharPressed();
|
||||||
|
|
||||||
|
// Only allow keys in range [48..57]
|
||||||
|
if ((key >= 48) && (key <= 57))
|
||||||
{
|
{
|
||||||
int key = GetCharPressed();
|
textValue[keyCount] = (char)key;
|
||||||
if ((key >= 48) && (key <= 57))
|
keyCount++;
|
||||||
{
|
valueHasChanged = true;
|
||||||
textValue[keyCount] = (char)key;
|
|
||||||
keyCount++;
|
|
||||||
valueHasChanged = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete text
|
// Delete text
|
||||||
if (keyCount > 0)
|
if ((keyCount > 0) && IsKeyPressed(KEY_BACKSPACE))
|
||||||
{
|
{
|
||||||
if (IsKeyPressed(KEY_BACKSPACE))
|
keyCount--;
|
||||||
{
|
textValue[keyCount] = '\0';
|
||||||
keyCount--;
|
valueHasChanged = true;
|
||||||
textValue[keyCount] = '\0';
|
|
||||||
valueHasChanged = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valueHasChanged) *value = TextToInteger(textValue);
|
if (valueHasChanged) *value = TextToInteger(textValue);
|
||||||
@ -4236,7 +4231,7 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co
|
|||||||
// Grid control
|
// Grid control
|
||||||
// NOTE: Returns grid mouse-hover selected cell
|
// NOTE: Returns grid mouse-hover selected cell
|
||||||
// About drawing lines at subpixel spacing, simple put, not easy solution:
|
// About drawing lines at subpixel spacing, simple put, not easy solution:
|
||||||
// https://stackoverflow.com/questions/4435450/2d-opengl-drawing-lines-that-dont-exactly-fit-pixel-raster
|
// REF: https://stackoverflow.com/questions/4435450/2d-opengl-drawing-lines-that-dont-exactly-fit-pixel-raster
|
||||||
int GuiGrid(Rectangle bounds, const char *text, float spacing, int subdivs, Vector2 *mouseCell)
|
int GuiGrid(Rectangle bounds, const char *text, float spacing, int subdivs, Vector2 *mouseCell)
|
||||||
{
|
{
|
||||||
// Grid lines alpha amount
|
// Grid lines alpha amount
|
||||||
@ -5081,28 +5076,21 @@ static const char **GetTextLines(const char *text, int *count)
|
|||||||
static const char *lines[RAYGUI_MAX_TEXT_LINES] = { 0 };
|
static const char *lines[RAYGUI_MAX_TEXT_LINES] = { 0 };
|
||||||
for (int i = 0; i < RAYGUI_MAX_TEXT_LINES; i++) lines[i] = NULL; // Init NULL pointers to substrings
|
for (int i = 0; i < RAYGUI_MAX_TEXT_LINES; i++) lines[i] = NULL; // Init NULL pointers to substrings
|
||||||
|
|
||||||
int textSize = (int)strlen(text);
|
int textLength = (int)strlen(text);
|
||||||
|
|
||||||
lines[0] = text;
|
lines[0] = text;
|
||||||
int len = 0;
|
|
||||||
*count = 1;
|
*count = 1;
|
||||||
//int lineSize = 0; // Stores current line size, not returned
|
|
||||||
|
|
||||||
for (int i = 0, k = 0; (i < textSize) && (*count < RAYGUI_MAX_TEXT_LINES); i++)
|
for (int i = 0, k = 0; (i < textLength) && (*count < RAYGUI_MAX_TEXT_LINES); i++)
|
||||||
{
|
{
|
||||||
if (text[i] == '\n')
|
if (text[i] == '\n')
|
||||||
{
|
{
|
||||||
//lineSize = len;
|
|
||||||
k++;
|
k++;
|
||||||
lines[k] = &text[i + 1]; // WARNING: next value is valid?
|
lines[k] = &text[i + 1]; // WARNING: next value is valid?
|
||||||
len = 0;
|
|
||||||
*count += 1;
|
*count += 1;
|
||||||
}
|
}
|
||||||
else len++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//lines[*count - 1].size = len;
|
|
||||||
|
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5878,7 +5866,7 @@ static int TextToInteger(const char *text)
|
|||||||
text++;
|
text++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; ((text[i] >= '0') && (text[i] <= '9')); ++i) value = value*10 + (int)(text[i] - '0');
|
for (int i = 0; ((text[i] >= '0') && (text[i] <= '9')); i++) value = value*10 + (int)(text[i] - '0');
|
||||||
|
|
||||||
return value*sign;
|
return value*sign;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user