3 Commits

Author SHA1 Message Date
Ray
96f2970cf6 Update raygui.h 2026-07-11 17:01:48 +02:00
697cb10936 Fix MSVC compiling on cpp (#565) 2026-07-11 12:57:03 +02:00
Ray
5cc802fd9e Update raygui.h 2026-07-03 11:34:08 +02:00

View File

@ -133,7 +133,7 @@
* #define RAYGUI_CUSTOM_ICONS
* Includes custom ricons.h header defining a set of custom icons,
* this file can be generated using rGuiIcons tool
*
*
* #define RAYGUI_FONT_ICONS_BAKING
* On gui font loading from style file, append the icons to font atlas image, so,
* icons can be drawn along the text as a texture, instead of using shapes to draw them
@ -3231,9 +3231,6 @@ int GuiValueBoxFloat(Rectangle bounds, const char *text, char *textValue, float
int result = 0;
GuiState state = guiState;
//char textValue[RAYGUI_VALUEBOX_MAX_CHARS + 1] = "\0";
//snprintf(textValue, sizeof(textValue), "%2.2f", *value);
Rectangle textBounds = { 0 };
if (text != NULL)
{
@ -4513,7 +4510,7 @@ void GuiLoadStyle(const char *fileName)
sscanf(buffer, "f %d %s %[^\r\n]s", &fontSize, charmapFileName, fontFileName);
// GLOBAL: Copy font file name into guiFontName
strncpy(guiFontName, fontFileName, 31);
snprintf(guiFontName, 32, "%s", fontFileName);
Font font = { 0 };
int *codepoints = NULL;
@ -5002,7 +4999,7 @@ void GuiLoadStyleDefault(void)
// NOTE: Setting up a 1px padding on char rectangle to avoid pixel bleeding on MSAA filtering
SetShapesTexture(guiFont.texture, RAYGUI_CLITERAL(Rectangle){ whiteChar.x + 1, whiteChar.y + 1, whiteChar.width - 2, whiteChar.height - 2 });
// Reset baked icons offset in font
guiIconFontOffsetY = 0;
}
@ -5159,14 +5156,14 @@ void GuiDrawIcon(int iconId, int posX, int posY, int pixelSize, Color color)
{
int maxIconsPerLine = guiFont.texture.width/(RAYGUI_ICON_SIZE + 2*RAYGUI_ICON_FONT_ATLAS_PADDING);
int x = iconId%maxIconsPerLine;
int y = iconId/maxIconsPerLine;
int y = iconId/maxIconsPerLine;
Rectangle srcRec = { (float)x*(RAYGUI_ICON_SIZE + 2*RAYGUI_ICON_FONT_ATLAS_PADDING) + RAYGUI_ICON_FONT_ATLAS_PADDING,
guiIconFontOffsetY + (float)y*(RAYGUI_ICON_SIZE + 2*RAYGUI_ICON_FONT_ATLAS_PADDING) + RAYGUI_ICON_FONT_ATLAS_PADDING,
Rectangle srcRec = { (float)x*(RAYGUI_ICON_SIZE + 2*RAYGUI_ICON_FONT_ATLAS_PADDING) + RAYGUI_ICON_FONT_ATLAS_PADDING,
guiIconFontOffsetY + (float)y*(RAYGUI_ICON_SIZE + 2*RAYGUI_ICON_FONT_ATLAS_PADDING) + RAYGUI_ICON_FONT_ATLAS_PADDING,
RAYGUI_ICON_SIZE, RAYGUI_ICON_SIZE };
Rectangle dstRec = { posX, posY, RAYGUI_ICON_SIZE*pixelSize, RAYGUI_ICON_SIZE*pixelSize };
Rectangle dstRec = { (float)posX, (float)posY, (float)pixelSize*RAYGUI_ICON_SIZE, (float)pixelSize*RAYGUI_ICON_SIZE };
DrawTexturePro(guiFont.texture, srcRec, dstRec, (Vector2){ 0, 0 }, 0.0f, color);
DrawTexturePro(guiFont.texture, srcRec, dstRec, RAYGUI_CLITERAL(Vector2){ 0, 0 }, 0.0f, color);
}
else
{
@ -5178,7 +5175,7 @@ void GuiDrawIcon(int iconId, int posX, int posY, int pixelSize, Color color)
{
if (BIT_CHECK(guiIconsPtr[iconId*RAYGUI_ICON_DATA_ELEMENTS + i], k))
{
GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ (float)posX + (k%RAYGUI_ICON_SIZE)*pixelSize,
GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ (float)posX + (k%RAYGUI_ICON_SIZE)*pixelSize,
(float)posY + y*pixelSize, (float)pixelSize, (float)pixelSize }, 0, BLANK, color);
}
@ -5656,7 +5653,7 @@ static void GuiTooltip(Rectangle controlRec)
{
if (!guiLocked && guiTooltip && (guiTooltipPtr != NULL) && !guiControlExclusiveMode)
{
Vector2 textSize = MeasureTextEx(guiFont, guiTooltipPtr, (float)GuiGetStyle(DEFAULT, TEXT_SIZE),
Vector2 textSize = MeasureTextEx(guiFont, guiTooltipPtr, (float)GuiGetStyle(DEFAULT, TEXT_SIZE),
(float)GuiGetStyle(DEFAULT, TEXT_SPACING));
if ((controlRec.x + textSize.x + 16) > GetScreenWidth()) controlRec.x -= (textSize.x + 16 - controlRec.width);
@ -5860,13 +5857,13 @@ static int GuiFontIconBaking(Image *imFont, Font font, Rectangle *whiteRec)
int maxGlyphRecY = 0;
for (int i = 0; i < font.glyphCount; i++)
{
if ((font.recs[i].y + font.recs[i].height) > maxGlyphRecY)
if ((font.recs[i].y + font.recs[i].height) > maxGlyphRecY)
maxGlyphRecY = (int)font.recs[i].y + (int)font.recs[i].height;
}
int maxIconsPerLine = imFont->width/(RAYGUI_ICON_SIZE + 2*RAYGUI_ICON_FONT_ATLAS_PADDING);
int reqIconLines = RAYGUI_ICON_MAX_FONT_BACKED/maxIconsPerLine + RAYGUI_ICON_MAX_FONT_BACKED%maxIconsPerLine + 1; // One extra line
int reqHeight = reqIconLines*(RAYGUI_ICON_SIZE + 2*RAYGUI_ICON_FONT_ATLAS_PADDING);
int reqHeight = reqIconLines*(RAYGUI_ICON_SIZE + 2*RAYGUI_ICON_FONT_ATLAS_PADDING);
// Check if image requires scaling and how much
if ((maxGlyphRecY + reqHeight) > imFont->height)
@ -5891,7 +5888,7 @@ static int GuiFontIconBaking(Image *imFont, Font font, Rectangle *whiteRec)
for (int x = 0; x < 3; x++)
((unsigned short *)newImData)[(imFont->height - y - 1)*imFont->width + imFont->width - x - 1] = 0xffff;
*whiteRec = (Rectangle){ imFont->width - 2, imFont->height - 2, 1, 1 };
*whiteRec = RAYGUI_CLITERAL(Rectangle){ (float)imFont->width - 2, (float)imFont->height - 2, 1, 1 };
}
// Calculate image offset positions to start drawing
@ -6166,7 +6163,8 @@ static const char *TextFormat(const char *text, ...)
#define RAYGUI_TEXTFORMAT_MAX_SIZE 256
#endif
static char buffer[RAYGUI_TEXTFORMAT_MAX_SIZE];
static char buffer[RAYGUI_TEXTFORMAT_MAX_SIZE] = { 0 };
memset(buffer, 0, RAYGUI_TEXTFORMAT_MAX_SIZE);
va_list args;
va_start(args, text);