22 Commits

Author SHA1 Message Date
Ray
0b94b80c92 Update raygui.h 2025-12-20 22:09:03 +01:00
Ray
867ca4bf8d Update raygui.h 2025-12-11 21:41:33 +01:00
367e169ad3 initializ some variables to prevent warnings (#515) 2025-12-02 23:31:24 +01:00
Ray
1a74db2ab3 Update raygui.h 2025-11-25 12:15:44 +01:00
Ray
715baf250d Update raygui.rc 2025-11-25 12:15:42 +01:00
Ray
3aea427fc8 REVIEWED: Out of bounds warning 2025-11-18 20:59:05 +01:00
Ray
773d1ec52b Update raygui.h 2025-11-18 16:49:44 +01:00
Ray
ff4dbd0712 Update raygui.h 2025-11-13 22:49:22 +01:00
Ray
aed63cedd1 Update raygui.h 2025-11-12 11:09:02 +01:00
Ray
4436a897f9 ADDED: New icons 2025-11-12 09:41:36 +01:00
Ray
d4ebcdc2be Update raygui.h 2025-11-11 19:38:38 +01:00
Ray
860e46d3f8 Reviewed text cursor 2025-11-09 14:06:53 +01:00
Ray
b9971133b2 Comment unused variable 2025-10-21 12:28:05 +02:00
947ef5799d Lock other controls when GuiTextInputBox is open (#512)
Previously, the color picker would end up eating inputs intended for the
GuiTextInputBox!
2025-10-08 14:46:29 +02:00
Ray
681393a423 Update user links to github 2025-09-22 11:54:08 +02:00
Ray
9cdfec460b Update raygui.h 2025-09-18 15:26:53 +02:00
Ray
546b4bacf4 Using calloc() instead of malloc() 2025-09-10 21:03:27 +02:00
Ray
cf3aab1e9f REVIEWED: Code sections description for consistency 2025-09-02 12:35:58 +02:00
9193f38424 Fixed examples (#505) 2025-08-28 22:49:47 +02:00
Ray
6530ee136b Fix #501 2025-08-15 12:21:17 +02:00
Ray
1b2612cf75 Minor format tweaks to align with new raylib conventions 2025-08-08 21:49:33 +02:00
Ray
54ee53e7d7 Update raygui.h 2025-08-04 23:36:27 +02:00
9 changed files with 178 additions and 176 deletions

View File

@ -203,11 +203,12 @@ int main()
BeginDrawing();
ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)));
// raygui: controls drawing
//----------------------------------------------------------------------------------
// Check all possible events that require GuiLock
if (dropDown000EditMode || dropDown001EditMode) GuiLock();
if (showTextInputBox) GuiLock();
// First GUI column
//GuiSetStyle(CHECKBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
@ -236,7 +237,9 @@ int main()
GuiComboBox((Rectangle){ 25, 480, 125, 30 }, "default;Jungle;Lavanda;Dark;Bluish;Cyber;Terminal;Candy;Cherry;Ashes;Enefete;Sunny;Amber", &visualStyleActive);
// NOTE: GuiDropdownBox must draw after any other control that can be covered on unfolding
GuiUnlock();
if (dropDown000EditMode || dropDown001EditMode) GuiUnlock();
if (showTextInputBox) GuiLock(); // Stay locked
GuiSetStyle(DROPDOWNBOX, TEXT_PADDING, 4);
GuiSetStyle(DROPDOWNBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
if (GuiDropdownBox((Rectangle){ 25, 65, 125, 30 }, "#01#ONE;#02#TWO;#03#THREE;#04#FOUR", &dropdownBox001Active, dropDown001EditMode)) dropDown001EditMode = !dropDown001EditMode;
@ -300,6 +303,8 @@ int main()
if (showTextInputBox)
{
GuiUnlock();
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, 0.8f));
int result = GuiTextInputBox((Rectangle){ (float)GetScreenWidth()/2 - 120, (float)GetScreenHeight()/2 - 60, 240, 140 }, GuiIconText(ICON_FILE_SAVE, "Save file as..."), "Introduce output file name:", "Ok;Cancel", textInput, 255, NULL);

View File

@ -97,7 +97,7 @@ int GuiFloatBox(Rectangle bounds, const char* text, float* value, int minValue,
Rectangle textBounds = { 0 };
if (text != NULL)
{
textBounds.width = (float)GetTextWidth(text) + 2;
textBounds.width = (float)GuiGetTextWidth(text) + 2;
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
textBounds.x = bounds.x + bounds.width + GuiGetStyle(VALUEBOX, TEXT_PADDING);
textBounds.y = bounds.y + bounds.height / 2.0f - GuiGetStyle(DEFAULT, TEXT_SIZE) / 2.0f;
@ -124,7 +124,7 @@ int GuiFloatBox(Rectangle bounds, const char* text, float* value, int minValue,
// Only allow keys in range [48..57]
if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS)
{
if (GetTextWidth(textValue) < bounds.width)
if (GuiGetTextWidth(textValue) < bounds.width)
{
int key = GetCharPressed();
if ((key >= 48) && (key <= 57) && guiFloatingPointIndex)
@ -211,7 +211,7 @@ int GuiFloatBox(Rectangle bounds, const char* text, float* value, int minValue,
if (editMode)
{
// NOTE: ValueBox internal text is always centered
Rectangle cursor = { bounds.x + GetTextWidth(textValue) / 2.0f + bounds.width / 2.0f + 1, bounds.y + 2.0f * GuiGetStyle(VALUEBOX, BORDER_WIDTH), 4, bounds.height - 4 * GuiGetStyle(VALUEBOX, BORDER_WIDTH) };
Rectangle cursor = { bounds.x + GuiGetTextWidth(textValue) / 2.0f + bounds.width / 2.0f + 1, bounds.y + 2.0f * GuiGetStyle(VALUEBOX, BORDER_WIDTH), 4, bounds.height - 4 * GuiGetStyle(VALUEBOX, BORDER_WIDTH) };
GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(VALUEBOX, BORDER_COLOR_PRESSED)), guiAlpha));
}

View File

@ -182,7 +182,7 @@ float GuiVerticalSliderPro(Rectangle bounds, const char *textTop, const char *te
if (textTop != NULL)
{
Rectangle textBounds = { 0 };
textBounds.width = (float)GetTextWidth(textTop);
textBounds.width = (float)GuiGetTextWidth(textTop);
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
textBounds.x = bounds.x + bounds.width/2 - textBounds.width/2;
textBounds.y = bounds.y - textBounds.height - GuiGetStyle(SLIDER, TEXT_PADDING);
@ -193,7 +193,7 @@ float GuiVerticalSliderPro(Rectangle bounds, const char *textTop, const char *te
if (textBottom != NULL)
{
Rectangle textBounds = { 0 };
textBounds.width = (float)GetTextWidth(textBottom);
textBounds.width = (float)GuiGetTextWidth(textBottom);
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
textBounds.x = bounds.x + bounds.width/2 - textBounds.width/2;
textBounds.y = bounds.y + bounds.height + GuiGetStyle(SLIDER, TEXT_PADDING);
@ -304,7 +304,7 @@ bool GuiSliderProOwning(Rectangle bounds, const char *textLeft, const char *text
if (textLeft != NULL)
{
Rectangle textBounds = { 0 };
textBounds.width = (float)GetTextWidth(textLeft);
textBounds.width = (float)GuiGetTextWidth(textLeft);
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
textBounds.x = bounds.x - textBounds.width - GuiGetStyle(SLIDER, TEXT_PADDING);
textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
@ -315,7 +315,7 @@ bool GuiSliderProOwning(Rectangle bounds, const char *textLeft, const char *text
if (textRight != NULL)
{
Rectangle textBounds = { 0 };
textBounds.width = (float)GetTextWidth(textRight);
textBounds.width = (float)GuiGetTextWidth(textRight);
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
textBounds.x = bounds.x + bounds.width + GuiGetStyle(SLIDER, TEXT_PADDING);
textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
@ -435,7 +435,7 @@ bool GuiVerticalSliderProOwning(Rectangle bounds, const char *textTop, const cha
if (textTop != NULL)
{
Rectangle textBounds = { 0 };
textBounds.width = (float)GetTextWidth(textTop);
textBounds.width = (float)GuiGetTextWidth(textTop);
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
textBounds.x = bounds.x + bounds.width/2 - textBounds.width/2;
textBounds.y = bounds.y - textBounds.height - GuiGetStyle(SLIDER, TEXT_PADDING);
@ -446,7 +446,7 @@ bool GuiVerticalSliderProOwning(Rectangle bounds, const char *textTop, const cha
if (textBottom != NULL)
{
Rectangle textBounds = { 0 };
textBounds.width = (float)GetTextWidth(textBottom);
textBounds.width = (float)GuiGetTextWidth(textBottom);
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
textBounds.x = bounds.x + bounds.width/2 - textBounds.width/2;
textBounds.y = bounds.y + bounds.height + GuiGetStyle(SLIDER, TEXT_PADDING);

View File

@ -38,10 +38,10 @@ int main(int argc, char *argv[])
bool windowBoxActive = false;
int fileFormatActive = 0;
char *fileFormatTextList[3] = { "IMAGE (.png)", "DATA (.raw)", "CODE (.h)" };
const char *fileFormatTextList[3] = { "IMAGE (.png)", "DATA (.raw)", "CODE (.h)" };
int pixelFormatActive = 0;
char *pixelFormatTextList[7] = { "GRAYSCALE", "GRAY ALPHA", "R5G6B5", "R8G8B8", "R5G5B5A1", "R4G4B4A4", "R8G8B8A8" };
const char *pixelFormatTextList[7] = { "GRAYSCALE", "GRAY ALPHA", "R5G6B5", "R8G8B8", "R5G5B5A1", "R4G4B4A4", "R8G8B8A8" };
bool textBoxEditMode = false;
char fileName[64] = "untitled";

View File

@ -50,12 +50,12 @@ int main()
bool heightEditMode = false;
int pixelFormatActive = 0;
char *pixelFormatTextList[8] = { "CUSTOM", "GRAYSCALE", "GRAY ALPHA", "R5G6B5", "R8G8B8", "R5G5B5A1", "R4G4B4A4", "R8G8B8A8" };
const char *pixelFormatTextList[8] = { "CUSTOM", "GRAYSCALE", "GRAY ALPHA", "R5G6B5", "R8G8B8", "R5G5B5A1", "R4G4B4A4", "R8G8B8A8" };
int channelsActive = 3;
char *channelsTextList[4] = { "1", "2", "3", "4" };
const char *channelsTextList[4] = { "1", "2", "3", "4" };
int bitDepthActive = 0;
char *bitDepthTextList[3] = { "8", "16", "32" };
const char *bitDepthTextList[3] = { "8", "16", "32" };
int headerSizeValue = 0;
bool headerSizeEditMode = false;

View File

@ -323,7 +323,7 @@ double GuiDMValueBox(Rectangle bounds, double value, double minValue, double max
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);
int textWidth = GuiGetTextWidth(textValue);
if(textWidth > textBounds.width) textBounds.width = textWidth;
if (state == STATE_PRESSED)
@ -338,7 +338,7 @@ double GuiDMValueBox(Rectangle bounds, double value, double minValue, double max
if(cursor > 0) {
char c = textValue[cursor];
textValue[cursor] = '\0';
textWidthCursor = GetTextWidth(textValue);
textWidthCursor = GuiGetTextWidth(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));
@ -608,7 +608,7 @@ void GuiDMPropertyList(Rectangle bounds, GuiDMProperty* props, int count, int* f
// 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 lblBounds = { propBounds.x+PROPERTY_PADDING, slotBounds.y, GuiGetTextWidth("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, 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 == STATE_FOCUSED) && CheckCollisionPointRec(mousePos, slotBounds) );
@ -647,7 +647,7 @@ void GuiDMPropertyList(Rectangle bounds, GuiDMProperty* props, int count, int* f
// 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 lblBounds = { propBounds.x+PROPERTY_PADDING, slotBounds.y, GuiGetTextWidth("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, TEXT_ALIGN_LEFT, textColor);
props[p].value.vrect.x = GuiDMSpinner(valBounds, props[p].value.vrect.x, 0.0, 0.0, 1.0, 0, (propState == STATE_FOCUSED) && CheckCollisionPointRec(mousePos, slotBounds) );
@ -685,8 +685,8 @@ void GuiDMPropertyList(Rectangle bounds, GuiDMProperty* props, int count, int* f
// 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 lblBounds = { propBounds.x+PROPERTY_PADDING, slotBounds.y, GuiGetTextWidth("A"), slotBounds.height};
Rectangle valBounds = { lblBounds.x+lblBounds.width+PROPERTY_PADDING, slotBounds.y, GuiGetTextWidth("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
@ -865,4 +865,4 @@ bool GuiDMSaveProperties(const char* file, GuiDMProperty* props, int count) {
return true;
}
#endif // GUI_PROPERTY_LIST_IMPLEMENTATION
#endif // GUI_PROPERTY_LIST_IMPLEMENTATION

View File

@ -6,10 +6,10 @@ PRODUCTVERSION 4,0,0,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
//BLOCK "080904E4" // English UK
BLOCK "040904E4" // English US
//BLOCK "080904E4" // English UK
BLOCK "040904E4" // English US
BEGIN
//VALUE "CompanyName", "raylib technologies"
//VALUE "CompanyName", "raylib technologies"
VALUE "FileDescription", "raygui application (www.raylib.com)"
VALUE "FileVersion", "4.0.0"
VALUE "InternalName", "raygui app"
@ -21,7 +21,7 @@ BEGIN
END
BLOCK "VarFileInfo"
BEGIN
//VALUE "Translation", 0x809, 1252 // English UK
VALUE "Translation", 0x409, 1252 // English US
//VALUE "Translation", 0x809, 1252 // English UK
VALUE "Translation", 0x409, 1252 // English US
END
END

View File

@ -4,7 +4,7 @@
*
* DESCRIPTION:
* raygui is a tools-dev-focused immediate-mode-gui library based on raylib but also
* available as a standalone library, as long as input and drawing functions are provided.
* available as a standalone library, as long as input and drawing functions are provided
*
* FEATURES:
* - Immediate-mode gui, minimal retained data
@ -27,7 +27,7 @@
* - WARNING: GuiLoadStyle() and GuiLoadStyle{Custom}() functions, allocate memory for
* font atlas recs and glyphs, freeing that memory is (usually) up to the user,
* no unload function is explicitly provided... but note that GuiLoadStyleDefault() unloads
* by default any previously loaded font (texture, recs, glyphs).
* by default any previously loaded font (texture, recs, glyphs)
* - Global UI alpha (guiAlpha) is applied inside GuiDrawRectangle() and GuiDrawText() functions
*
* CONTROLS PROVIDED:
@ -65,7 +65,7 @@
* - MessageBox --> Window, Label, Button
* - TextInputBox --> Window, Label, TextBox, Button
*
* It also provides a set of functions for styling the controls based on its properties (size, color).
* It also provides a set of functions for styling the controls based on its properties (size, color)
*
*
* RAYGUI STYLE (guiStyle):
@ -77,11 +77,11 @@
*
* static unsigned int guiStyle[RAYGUI_MAX_CONTROLS*(RAYGUI_MAX_PROPS_BASE + RAYGUI_MAX_PROPS_EXTENDED)];
*
* guiStyle size is by default: 16*(16 + 8) = 384*4 = 1536 bytes = 1.5 KB
* guiStyle size is by default: 16*(16 + 8) = 384 int = 384*4 bytes = 1536 bytes = 1.5 KB
*
* Note that the first set of BASE properties (by default guiStyle[0..15]) belong to the generic style
* used for all controls, when any of those base values is set, it is automatically populated to all
* controls, so, specific control values overwriting generic style should be set after base values.
* controls, so, specific control values overwriting generic style should be set after base values
*
* After the first BASE set we have the EXTENDED properties (by default guiStyle[16..23]), those
* properties are actually common to all controls and can not be overwritten individually (like BASE ones)
@ -100,7 +100,7 @@
* Every icon is codified in binary form, using 1 bit per pixel, so, every 16x16 icon
* requires 8 integers (16*16/32) to be stored in memory.
*
* When the icon is draw, actually one quad per pixel is drawn if the bit for that pixel is set.
* When the icon is draw, actually one quad per pixel is drawn if the bit for that pixel is set
*
* The global icons array size is fixed and depends on the number of icons and size:
*
@ -112,20 +112,20 @@
*
* RAYGUI LAYOUT:
* raygui currently does not provide an auto-layout mechanism like other libraries,
* layouts must be defined manually on controls drawing, providing the right bounds Rectangle for it.
* layouts must be defined manually on controls drawing, providing the right bounds Rectangle for it
*
* TOOL: rGuiLayout is a visual tool to create raygui layouts: github.com/raysan5/rguilayout
*
* CONFIGURATION:
* #define RAYGUI_IMPLEMENTATION
* Generates the implementation of the library into the included file.
* 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.
* or source files without problems. But only ONE file should hold the implementation
*
* #define RAYGUI_STANDALONE
* Avoid raylib.h header inclusion in this file. Data types defined on raylib are defined
* internally in the library and input management and drawing functions must be provided by
* the user (check library implementation for further details).
* the user (check library implementation for further details)
*
* #define RAYGUI_NO_ICONS
* Avoid including embedded ricons data (256 icons, 16x16 pixels, 1-bit per pixel, 2KB)
@ -141,7 +141,7 @@
* Draw text bounds rectangles for debug
*
* 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: GuiValueBoxFloat()
* ADDED: GuiDropdonwBox() properties: DROPDOWN_ARROW_HIDDEN, DROPDOWN_ROLL_UP
@ -266,16 +266,16 @@
* 1.4 (15-Jun-2017) Rewritten all GUI functions (removed useless ones)
* 1.3 (12-Jun-2017) Complete redesign of style system
* 1.1 (01-Jun-2017) Complete review of the library
* 1.0 (07-Jun-2016) Converted to header-only by Ramon Santamaria.
* 0.9 (07-Mar-2016) Reviewed and tested by Albert Martos, Ian Eito, Sergio Martinez and Ramon Santamaria.
* 0.8 (27-Aug-2015) Initial release. Implemented by Kevin Gato, Daniel Nicolás and Ramon Santamaria.
* 1.0 (07-Jun-2016) Converted to header-only by Ramon Santamaria
* 0.9 (07-Mar-2016) Reviewed and tested by Albert Martos, Ian Eito, Sergio Martinez and Ramon Santamaria
* 0.8 (27-Aug-2015) Initial release. Implemented by Kevin Gato, Daniel Nicolás and Ramon Santamaria
*
* DEPENDENCIES:
* raylib 5.0 - Inputs reading (keyboard/mouse), shapes drawing, font loading and text drawing
* raylib 5.6-dev - Inputs reading (keyboard/mouse), shapes drawing, font loading and text drawing
*
* STANDALONE MODE:
* By default raygui depends on raylib mostly for the inputs and the drawing functionality but that dependency can be disabled
* with the config flag RAYGUI_STANDALONE. In that case is up to the user to provide another backend to cover library needs.
* with the config flag RAYGUI_STANDALONE. In that case is up to the user to provide another backend to cover library needs
*
* The following functions should be redefined for a custom backend:
*
@ -417,13 +417,16 @@
// TODO: Texture2D type is very coupled to raylib, required by Font type
// It should be redesigned to be provided by user
typedef struct Texture2D {
typedef struct Texture {
unsigned int id; // OpenGL texture id
int width; // Texture base width
int height; // Texture base height
int mipmaps; // Mipmap levels, 1 by default
int format; // Data format (PixelFormat type)
} Texture2D;
} Texture;
// Texture2D, same as Texture
typedef Texture Texture2D;
// Image, pixel data stored in CPU memory (RAM)
typedef struct Image {
@ -1007,28 +1010,28 @@ typedef enum {
ICON_SLICING = 231,
ICON_MANUAL_CONTROL = 232,
ICON_COLLISION = 233,
ICON_234 = 234,
ICON_235 = 235,
ICON_236 = 236,
ICON_237 = 237,
ICON_238 = 238,
ICON_239 = 239,
ICON_240 = 240,
ICON_241 = 241,
ICON_242 = 242,
ICON_243 = 243,
ICON_244 = 244,
ICON_245 = 245,
ICON_246 = 246,
ICON_247 = 247,
ICON_248 = 248,
ICON_249 = 249,
ICON_CIRCLE_ADD = 234,
ICON_CIRCLE_ADD_FILL = 235,
ICON_CIRCLE_WARNING = 236,
ICON_CIRCLE_WARNING_FILL = 237,
ICON_BOX_MORE = 238,
ICON_BOX_MORE_FILL = 239,
ICON_BOX_MINUS = 240,
ICON_BOX_MINUS_FILL = 241,
ICON_UNION = 242,
ICON_INTERSECTION = 243,
ICON_DIFFERENCE = 244,
ICON_SPHERE = 245,
ICON_CYLINDER = 246,
ICON_CONE = 247,
ICON_ELLIPSOID = 248,
ICON_CAPSULE = 249,
ICON_250 = 250,
ICON_251 = 251,
ICON_252 = 252,
ICON_253 = 253,
ICON_254 = 254,
ICON_255 = 255,
ICON_255 = 255
} GuiIconName;
#endif
@ -1075,7 +1078,7 @@ typedef enum {
// Check if two rectangles are equal, used to validate a slider bounds as an id
#ifndef CHECK_BOUNDS_ID
#define CHECK_BOUNDS_ID(src, dst) ((src.x == dst.x) && (src.y == dst.y) && (src.width == dst.width) && (src.height == dst.height))
#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))
#endif
#if !defined(RAYGUI_NO_ICONS) && !defined(RAYGUI_CUSTOM_ICONS)
@ -1088,7 +1091,7 @@ typedef enum {
// Icons data is defined by bit array (every bit represents one pixel)
// Those arrays are stored as unsigned int data arrays, so,
// 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)
#define RAYGUI_ICON_DATA_ELEMENTS (RAYGUI_ICON_SIZE*RAYGUI_ICON_SIZE/32)
@ -1338,22 +1341,22 @@ static unsigned int guiIcons[RAYGUI_ICON_MAX_ICONS*RAYGUI_ICON_DATA_ELEMENTS] =
0x7fe00000, 0x402e4020, 0x43ce5e0a, 0x40504078, 0x438e4078, 0x402e5e0a, 0x7fe04020, 0x00000000, // ICON_SLICING
0x00000000, 0x40027ffe, 0x47c24002, 0x55425d42, 0x55725542, 0x50125552, 0x10105016, 0x00001ff0, // ICON_MANUAL_CONTROL
0x7ffe0000, 0x43c24002, 0x48124422, 0x500a500a, 0x500a500a, 0x44224812, 0x400243c2, 0x00007ffe, // ICON_COLLISION
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_234
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_235
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_236
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_237
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_238
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_239
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_240
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_241
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_242
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_243
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_244
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_245
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_246
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_247
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_248
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_249
0x03c00000, 0x10080c30, 0x21842184, 0x4ff24182, 0x41824ff2, 0x21842184, 0x0c301008, 0x000003c0, // ICON_CIRCLE_ADD
0x03c00000, 0x1ff80ff0, 0x3e7c3e7c, 0x700e7e7e, 0x7e7e700e, 0x3e7c3e7c, 0x0ff01ff8, 0x000003c0, // ICON_CIRCLE_ADD_FILL
0x03c00000, 0x10080c30, 0x21842184, 0x41824182, 0x40024182, 0x21842184, 0x0c301008, 0x000003c0, // ICON_CIRCLE_WARNING
0x03c00000, 0x1ff80ff0, 0x3e7c3e7c, 0x7e7e7e7e, 0x7ffe7e7e, 0x3e7c3e7c, 0x0ff01ff8, 0x000003c0, // ICON_CIRCLE_WARNING_FILL
0x00000000, 0x10041ffc, 0x10841004, 0x13e41084, 0x10841084, 0x10041004, 0x00001ffc, 0x00000000, // ICON_BOX_MORE
0x00000000, 0x1ffc1ffc, 0x1f7c1ffc, 0x1c1c1f7c, 0x1f7c1f7c, 0x1ffc1ffc, 0x00001ffc, 0x00000000, // ICON_BOX_MORE_FILL
0x00000000, 0x1ffc1ffc, 0x1ffc1ffc, 0x1c1c1ffc, 0x1ffc1ffc, 0x1ffc1ffc, 0x00001ffc, 0x00000000, // ICON_BOX_MINUS
0x00000000, 0x10041ffc, 0x10041004, 0x13e41004, 0x10041004, 0x10041004, 0x00001ffc, 0x00000000, // ICON_BOX_MINUS_FILL
0x07fe0000, 0x055606aa, 0x7ff606aa, 0x55766eba, 0x55766eaa, 0x55606ffe, 0x55606aa0, 0x00007fe0, // ICON_UNION
0x07fe0000, 0x04020402, 0x7fe20402, 0x456246a2, 0x456246a2, 0x402047fe, 0x40204020, 0x00007fe0, // ICON_INTERSECTION
0x07fe0000, 0x055606aa, 0x7ff606aa, 0x4436442a, 0x4436442a, 0x402047fe, 0x40204020, 0x00007fe0, // ICON_DIFFERENCE
0x03c00000, 0x10080c30, 0x20042004, 0x60064002, 0x47e2581a, 0x20042004, 0x0c301008, 0x000003c0, // ICON_SPHERE
0x03e00000, 0x08080410, 0x0c180808, 0x08080be8, 0x08080808, 0x08080808, 0x04100808, 0x000003e0, // ICON_CYLINDER
0x00800000, 0x01400140, 0x02200220, 0x04100410, 0x08080808, 0x1c1c13e4, 0x08081004, 0x000007f0, // ICON_CONE
0x00000000, 0x07e00000, 0x20841918, 0x40824082, 0x40824082, 0x19182084, 0x000007e0, 0x00000000, // ICON_ELLIPSOID
0x00000000, 0x00000000, 0x20041ff8, 0x40024002, 0x40024002, 0x1ff82004, 0x00000000, 0x00000000, // ICON_CAPSULE
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_250
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_251
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_252
@ -1378,7 +1381,7 @@ static unsigned int *guiIconsPtr = guiIcons;
#define RAYGUI_MAX_PROPS_EXTENDED 8 // Maximum number of extended properties
//----------------------------------------------------------------------------------
// Types and Structures Definition
// Module Types and Structures Definition
//----------------------------------------------------------------------------------
// Gui control property style color element
typedef enum { BORDER = 0, BASE, TEXT, OTHER } GuiPropertyElement;
@ -1494,7 +1497,7 @@ static void DrawRectangleGradientV(int posX, int posY, int width, int height, Co
#endif // RAYGUI_STANDALONE
//----------------------------------------------------------------------------------
// Module specific Functions Declaration
// Module Internal Functions Declaration
//----------------------------------------------------------------------------------
static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize); // Load style from memory (binary only)
@ -1740,7 +1743,7 @@ int GuiPanel(Rectangle bounds, const char *text)
// NOTE: Using GuiToggle() for the TABS
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;
//GuiState state = guiState;
@ -1773,12 +1776,12 @@ int GuiTabBar(Rectangle bounds, const char **text, int count, int *active)
if (i == (*active))
{
toggle = true;
GuiToggle(tabBounds, GuiIconText(12, text[i]), &toggle);
GuiToggle(tabBounds, text[i], &toggle);
}
else
{
toggle = false;
GuiToggle(tabBounds, GuiIconText(12, text[i]), &toggle);
GuiToggle(tabBounds, text[i], &toggle);
if (toggle) *active = i;
}
@ -2494,16 +2497,16 @@ int GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMod
int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
{
#if !defined(RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN)
#define RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN 30 // Frames to wait for autocursor movement
#define RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN 20 // Frames to wait for autocursor movement
#endif
#if !defined(RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY)
#define RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY 2 // Frames delay for autocursor movement
#define RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY 1 // Frames delay for autocursor movement
#endif
int result = 0;
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);
Rectangle textBounds = GetTextBounds(TEXTBOX, bounds);
@ -2511,7 +2514,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
int thisCursorIndex = textBoxCursorIndex;
if (thisCursorIndex > textLength) thisCursorIndex = textLength;
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
// NOTE: Position X value should be updated
@ -2578,7 +2581,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
int codepointSize = 0;
const char *charEncoded = CodepointToUTF8(codepoint, &codepointSize);
// Handle Paste action
// Handle text paste action
if (IsKeyPressed(KEY_V) && (IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_RIGHT_CONTROL)))
{
const char *pasteText = GetClipboardText();
@ -2587,7 +2590,8 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
int pasteLength = 0;
int pasteCodepoint;
int pasteCodepointSize;
// count how many codepoints to copy, stopping at the first unwanted control character
// Count how many codepoints to copy, stopping at the first unwanted control character
while (true)
{
pasteCodepoint = GetCodepointNext(pasteText + pasteLength, &pasteCodepointSize);
@ -2595,6 +2599,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
if (!(multiline && (pasteCodepoint == (int)'\n')) && !(pasteCodepoint >= 32)) break;
pasteLength += pasteCodepointSize;
}
if (pasteLength > 0)
{
// Move forward data from cursor position
@ -2609,10 +2614,10 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
}
}
}
// Add codepoint to text, at current cursor position
// NOTE: Make sure we do not overflow buffer size
else if (((multiline && (codepoint == (int)'\n')) || (codepoint >= 32)) && ((textLength + codepointSize) < textSize))
{
// Adding codepoint to text, at current cursor position
// Move forward data from cursor position
for (int i = (textLength + codepointSize); i > textBoxCursorIndex; i--) text[i] = text[i - codepointSize];
@ -2639,6 +2644,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
int accCodepointSize = 0;
int nextCodepointSize;
int nextCodepoint;
// Check characters of the same type to delete (either ASCII punctuation or anything non-whitespace)
// Not using isalnum() since it only works on ASCII characters
nextCodepoint = GetCodepointNext(text + offset, &nextCodepointSize);
@ -2651,11 +2657,12 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
accCodepointSize += nextCodepointSize;
nextCodepoint = GetCodepointNext(text + offset, &nextCodepointSize);
}
// Check whitespace to delete (ASCII only)
while (offset < textLength)
{
if (!isspace(nextCodepoint & 0xff))
break;
if (!isspace(nextCodepoint & 0xff)) break;
offset += nextCodepointSize;
accCodepointSize += nextCodepointSize;
nextCodepoint = GetCodepointNext(text + offset, &nextCodepointSize);
@ -2666,9 +2673,11 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
textLength -= accCodepointSize;
}
// Delete single codepoint from text, after current cursor position
else if ((textLength > textBoxCursorIndex) && (IsKeyPressed(KEY_DELETE) || (IsKeyDown(KEY_DELETE) && autoCursorShouldTrigger)))
{
// Delete single codepoint from text, after current cursor position
int nextCodepointSize = 0;
GetCodepointNext(text + textBoxCursorIndex, &nextCodepointSize);
@ -2683,8 +2692,8 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
{
int offset = textBoxCursorIndex;
int accCodepointSize = 0;
int prevCodepointSize;
int prevCodepoint;
int prevCodepointSize = 0;
int prevCodepoint = 0;
// Check whitespace to delete (ASCII only)
while (offset > 0)
@ -2695,6 +2704,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
offset -= prevCodepointSize;
accCodepointSize += prevCodepointSize;
}
// Check characters of the same type to delete (either ASCII punctuation or anything non-whitespace)
// Not using isalnum() since it only works on ASCII characters
bool puctuation = ispunct(prevCodepoint & 0xff);
@ -2713,9 +2723,11 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
textLength -= accCodepointSize;
textBoxCursorIndex -= accCodepointSize;
}
// Delete single codepoint from text, before current cursor position
else if ((textBoxCursorIndex > 0) && (IsKeyPressed(KEY_BACKSPACE) || (IsKeyDown(KEY_BACKSPACE) && autoCursorShouldTrigger)))
{
// Delete single codepoint from text, before current cursor position
int prevCodepointSize = 0;
GetCodepointPrevious(text + textBoxCursorIndex, &prevCodepointSize);
@ -2731,9 +2743,9 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
if ((textBoxCursorIndex > 0) && IsKeyPressed(KEY_LEFT) && (IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_RIGHT_CONTROL)))
{
int offset = textBoxCursorIndex;
int accCodepointSize = 0;
int prevCodepointSize;
int prevCodepoint;
//int accCodepointSize = 0;
int prevCodepointSize = 0;
int prevCodepoint = 0;
// Check whitespace to skip (ASCII only)
while (offset > 0)
@ -2742,7 +2754,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
if (!isspace(prevCodepoint & 0xff)) break;
offset -= prevCodepointSize;
accCodepointSize += prevCodepointSize;
//accCodepointSize += prevCodepointSize;
}
// Check characters of the same type to skip (either ASCII punctuation or anything non-whitespace)
@ -2754,7 +2766,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
if ((puctuation && !ispunct(prevCodepoint & 0xff)) || (!puctuation && (isspace(prevCodepoint & 0xff) || ispunct(prevCodepoint & 0xff)))) break;
offset -= prevCodepointSize;
accCodepointSize += prevCodepointSize;
//accCodepointSize += prevCodepointSize;
}
textBoxCursorIndex = offset;
@ -2769,7 +2781,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
else if ((textLength > textBoxCursorIndex) && IsKeyPressed(KEY_RIGHT) && (IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_RIGHT_CONTROL)))
{
int offset = textBoxCursorIndex;
int accCodepointSize = 0;
//int accCodepointSize = 0;
int nextCodepointSize;
int nextCodepoint;
@ -2782,7 +2794,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
if ((puctuation && !ispunct(nextCodepoint & 0xff)) || (!puctuation && (isspace(nextCodepoint & 0xff) || ispunct(nextCodepoint & 0xff)))) break;
offset += nextCodepointSize;
accCodepointSize += nextCodepointSize;
//accCodepointSize += nextCodepointSize;
nextCodepoint = GetCodepointNext(text + offset, &nextCodepointSize);
}
@ -2792,7 +2804,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
if (!isspace(nextCodepoint & 0xff)) break;
offset += nextCodepointSize;
accCodepointSize += nextCodepointSize;
//accCodepointSize += nextCodepointSize;
nextCodepoint = GetCodepointNext(text + offset, &nextCodepointSize);
}
@ -3021,7 +3033,7 @@ int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, in
int result = 0;
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);
Rectangle textBounds = { 0 };
@ -3039,7 +3051,6 @@ int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, in
if ((state != STATE_DISABLED) && !guiLocked && !guiControlExclusiveMode)
{
Vector2 mousePoint = GetMousePosition();
bool valueHasChanged = false;
if (editMode)
@ -3053,14 +3064,12 @@ int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, in
{
if (textValue[0] == '-')
{
for (int i = 0 ; i < keyCount; i++)
{
textValue[i] = textValue[i + 1];
}
for (int i = 0 ; i < keyCount; i++) textValue[i] = textValue[i + 1];
keyCount--;
valueHasChanged = true;
}
else if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS -1)
else if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS)
{
if (keyCount == 0)
{
@ -3077,30 +3086,26 @@ int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, in
}
}
// Only allow keys in range [48..57]
if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS)
// Add new digit to text value
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();
if ((key >= 48) && (key <= 57))
{
textValue[keyCount] = (char)key;
keyCount++;
valueHasChanged = true;
}
textValue[keyCount] = (char)key;
keyCount++;
valueHasChanged = true;
}
}
// Delete text
if (keyCount > 0)
if ((keyCount > 0) && IsKeyPressed(KEY_BACKSPACE))
{
if (IsKeyPressed(KEY_BACKSPACE))
{
keyCount--;
textValue[keyCount] = '\0';
valueHasChanged = true;
}
keyCount--;
textValue[keyCount] = '\0';
valueHasChanged = true;
}
if (valueHasChanged) *value = TextToInteger(textValue);
@ -3172,7 +3177,7 @@ int GuiValueBoxFloat(Rectangle bounds, const char *text, char *textValue, float
//char textValue[RAYGUI_VALUEBOX_MAX_CHARS + 1] = "\0";
//snprintf(textValue, sizeof(textValue), "%2.2f", *value);
Rectangle textBounds = {0};
Rectangle textBounds = { 0 };
if (text != NULL)
{
textBounds.width = (float)GuiGetTextWidth(text) + 2;
@ -3201,26 +3206,25 @@ int GuiValueBoxFloat(Rectangle bounds, const char *text, char *textValue, float
{
if (textValue[0] == '-')
{
for (int i = 0; i < keyCount; i++)
for (int i = 0; i < keyCount; i++) textValue[i] = textValue[i + 1];
keyCount--;
valueHasChanged = true;
}
else if (keyCount < (RAYGUI_VALUEBOX_MAX_CHARS - 1))
{
textValue[i] = textValue[i + 1];
}
keyCount--;
valueHasChanged = true;
}
else if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS - 1) {
if (keyCount == 0) {
textValue[0] = '0';
textValue[1] = '\0';
if (keyCount == 0)
{
textValue[0] = '0';
textValue[1] = '\0';
keyCount++;
}
for (int i = keyCount; i > -1; i--) textValue[i + 1] = textValue[i];
textValue[0] = '-';
keyCount++;
}
for (int i = keyCount; i > -1; i--)
{
textValue[i + 1] = textValue[i];
}
textValue[0] = '-';
keyCount++;
valueHasChanged = true;
valueHasChanged = true;
}
}
@ -4227,7 +4231,7 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co
// Grid control
// NOTE: Returns grid mouse-hover selected cell
// 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)
{
// Grid lines alpha amount
@ -4405,7 +4409,7 @@ void GuiLoadStyle(const char *fileName)
if (fileDataSize > 0)
{
unsigned char *fileData = (unsigned char *)RAYGUI_MALLOC(fileDataSize*sizeof(unsigned char));
unsigned char *fileData = (unsigned char *)RAYGUI_CALLOC(fileDataSize, sizeof(unsigned char));
fread(fileData, sizeof(unsigned char), fileDataSize, rgsFile);
GuiLoadStyleFromMemory(fileData, fileDataSize);
@ -4613,10 +4617,10 @@ char **GuiLoadIcons(const char *fileName, bool loadIconsName)
{
if (loadIconsName)
{
guiIconsName = (char **)RAYGUI_MALLOC(iconCount*sizeof(char **));
guiIconsName = (char **)RAYGUI_CALLOC(iconCount, sizeof(char *));
for (int i = 0; i < iconCount; i++)
{
guiIconsName[i] = (char *)RAYGUI_MALLOC(RAYGUI_ICON_MAX_NAME_LENGTH);
guiIconsName[i] = (char *)RAYGUI_CALLOC(RAYGUI_ICON_MAX_NAME_LENGTH, sizeof(char));
fread(guiIconsName[i], 1, RAYGUI_ICON_MAX_NAME_LENGTH, rgiFile);
}
}
@ -4659,10 +4663,10 @@ char **GuiLoadIconsFromMemory(const unsigned char *fileData, int dataSize, bool
{
if (loadIconsName)
{
guiIconsName = (char **)RAYGUI_MALLOC(iconCount*sizeof(char *));
guiIconsName = (char **)RAYGUI_CALLOC(iconCount, sizeof(char *));
for (int i = 0; i < iconCount; i++)
{
guiIconsName[i] = (char *)RAYGUI_MALLOC(RAYGUI_ICON_MAX_NAME_LENGTH);
guiIconsName[i] = (char *)RAYGUI_CALLOC(RAYGUI_ICON_MAX_NAME_LENGTH, sizeof(char));
memcpy(guiIconsName[i], fileDataPtr, RAYGUI_ICON_MAX_NAME_LENGTH);
fileDataPtr += RAYGUI_ICON_MAX_NAME_LENGTH;
}
@ -4674,7 +4678,7 @@ char **GuiLoadIconsFromMemory(const unsigned char *fileData, int dataSize, bool
}
int iconDataSize = iconCount*((int)iconSize*(int)iconSize/32)*(int)sizeof(unsigned int);
guiIconsPtr = (unsigned int *)RAYGUI_MALLOC(iconDataSize);
guiIconsPtr = (unsigned int *)RAYGUI_CALLOC(iconDataSize, 1);
memcpy(guiIconsPtr, fileDataPtr, iconDataSize);
}
@ -4774,9 +4778,8 @@ int GuiGetTextWidth(const char *text)
#endif // !RAYGUI_NO_ICONS
//----------------------------------------------------------------------------------
// Module specific Functions Definition
// Module Internal Functions Definition
//----------------------------------------------------------------------------------
// Load style from memory
// WARNING: Binary files only
static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
@ -4862,7 +4865,7 @@ static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
{
// Compressed font atlas image data (DEFLATE), it requires DecompressData()
int dataUncompSize = 0;
unsigned char *compData = (unsigned char *)RAYGUI_MALLOC(fontImageCompSize);
unsigned char *compData = (unsigned char *)RAYGUI_CALLOC(fontImageCompSize, sizeof(unsigned char));
memcpy(compData, fileDataPtr, fontImageCompSize);
fileDataPtr += fontImageCompSize;
@ -4876,7 +4879,7 @@ static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
else
{
// Font atlas image data is not compressed
imFont.data = (unsigned char *)RAYGUI_MALLOC(fontImageUncompSize);
imFont.data = (unsigned char *)RAYGUI_CALLOC(fontImageUncompSize, sizeof(unsigned char));
memcpy(imFont.data, fileDataPtr, fontImageUncompSize);
fileDataPtr += fontImageUncompSize;
}
@ -4904,7 +4907,7 @@ static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
if ((recsDataCompressedSize > 0) && (recsDataCompressedSize != recsDataSize))
{
// Recs data is compressed, uncompress it
unsigned char *recsDataCompressed = (unsigned char *)RAYGUI_MALLOC(recsDataCompressedSize);
unsigned char *recsDataCompressed = (unsigned char *)RAYGUI_CALLOC(recsDataCompressedSize, sizeof(unsigned char));
memcpy(recsDataCompressed, fileDataPtr, recsDataCompressedSize);
fileDataPtr += recsDataCompressedSize;
@ -4946,7 +4949,7 @@ static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
if ((glyphsDataCompressedSize > 0) && (glyphsDataCompressedSize != glyphsDataSize))
{
// Glyphs data is compressed, uncompress it
unsigned char *glypsDataCompressed = (unsigned char *)RAYGUI_MALLOC(glyphsDataCompressedSize);
unsigned char *glypsDataCompressed = (unsigned char *)RAYGUI_CALLOC(glyphsDataCompressedSize, sizeof(unsigned char));
memcpy(glypsDataCompressed, fileDataPtr, glyphsDataCompressedSize);
fileDataPtr += glyphsDataCompressedSize;
@ -5065,6 +5068,7 @@ static const char *GetTextIcon(const char *text, int *iconId)
}
// Get text divided into lines (by line-breaks '\n')
// WARNING: It returns pointers to new lines but it does not add NULL ('\0') terminator!
static const char **GetTextLines(const char *text, int *count)
{
#define RAYGUI_MAX_TEXT_LINES 128
@ -5072,28 +5076,21 @@ static const char **GetTextLines(const char *text, int *count)
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
int textSize = (int)strlen(text);
int textLength = (int)strlen(text);
lines[0] = text;
int len = 0;
*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')
{
//lineSize = len;
k++;
lines[k] = &text[i + 1]; // WARNING: next value is valid?
len = 0;
lines[k] = &text[i + 1]; // WARNING: next value is valid?
*count += 1;
}
else len++;
}
//lines[*count - 1].size = len;
return lines;
}
@ -5869,7 +5866,7 @@ static int TextToInteger(const char *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;
}

View File

@ -19,4 +19,4 @@ Several options are provided to add the style to a `raygui` application, choose
## about font
raylib font by Ramon Santamaria ([@raysan5](https://twitter.com/raysan5)).
raylib font by Ramon Santamaria ([@raysan5](https://github.com/raysan5)).