113
113
* VERSIONS HISTORY:
114
114
* 3.5 (xx-xxx-2022) ADDED: Multiple new icons, useful for code editing tools
115
115
* ADDED: GuiTabBar(), based on GuiToggle()
116
- * REMOVED: Unneeded icon editing functions
116
+ * REMOVED: Unneeded icon editing functions
117
117
* REDESIGNED: GuiDrawText() to divide drawing by lines
118
118
* REMOVED: MeasureTextEx() dependency, logic directly implemented
119
119
* REMOVED: DrawTextEx() dependency, logic directly implemented
@@ -1726,7 +1726,7 @@ bool GuiButton(Rectangle bounds, const char *text)
1726
1726
//--------------------------------------------------------------------
1727
1727
GuiDrawRectangle (bounds , GuiGetStyle (BUTTON , BORDER_WIDTH ), Fade (GetColor (GuiGetStyle (BUTTON , BORDER + (state * 3 ))), guiAlpha ), Fade (GetColor (GuiGetStyle (BUTTON , BASE + (state * 3 ))), guiAlpha ));
1728
1728
GuiDrawText (text , GetTextBounds (BUTTON , bounds ), GuiGetStyle (BUTTON , TEXT_ALIGNMENT ), Fade (GetColor (GuiGetStyle (BUTTON , TEXT + (state * 3 ))), guiAlpha ));
1729
-
1729
+
1730
1730
if (state == STATE_FOCUSED ) GuiTooltip (bounds );
1731
1731
//------------------------------------------------------------------
1732
1732
@@ -2166,7 +2166,7 @@ bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
2166
2166
{
2167
2167
GuiDrawRectangle (bounds , GuiGetStyle (TEXTBOX , BORDER_WIDTH ), Fade (GetColor (GuiGetStyle (TEXTBOX , BORDER + (state * 3 ))), guiAlpha ), Fade (GetColor (GuiGetStyle (TEXTBOX , BASE_COLOR_DISABLED )), guiAlpha ));
2168
2168
}
2169
- else GuiDrawRectangle (bounds , 1 , Fade (GetColor (GuiGetStyle (TEXTBOX , BORDER + (state * 3 ))), guiAlpha ), BLANK );
2169
+ else GuiDrawRectangle (bounds , GuiGetStyle ( TEXTBOX , BORDER_WIDTH ) , Fade (GetColor (GuiGetStyle (TEXTBOX , BORDER + (state * 3 ))), guiAlpha ), BLANK );
2170
2170
2171
2171
if (editMode )
2172
2172
{
@@ -2477,7 +2477,7 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
2477
2477
{
2478
2478
GuiDrawRectangle (bounds , GuiGetStyle (TEXTBOX , BORDER_WIDTH ), Fade (GetColor (GuiGetStyle (TEXTBOX , BORDER + (state * 3 ))), guiAlpha ), Fade (GetColor (GuiGetStyle (TEXTBOX , BASE_COLOR_DISABLED )), guiAlpha ));
2479
2479
}
2480
- else GuiDrawRectangle (bounds , 1 , Fade (GetColor (GuiGetStyle (TEXTBOX , BORDER + (state * 3 ))), guiAlpha ), BLANK );
2480
+ else GuiDrawRectangle (bounds , GuiGetStyle ( TEXTBOX , BORDER_WIDTH ) , Fade (GetColor (GuiGetStyle (TEXTBOX , BORDER + (state * 3 ))), guiAlpha ), BLANK );
2481
2481
2482
2482
int wrapMode = 1 ; // 0-No wrap, 1-Char wrap, 2-Word wrap
2483
2483
Vector2 cursorPos = { textAreaBounds .x , textAreaBounds .y };
@@ -2486,7 +2486,7 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
2486
2486
//int lastSpaceWidth = 0;
2487
2487
//int lastSpaceCursorPos = 0;
2488
2488
2489
- for (int i = 0 , codepointSize = 0 ; text [i ] != '\0' ; i += codepointSize )
2489
+ for (int i = 0 , codepointSize = 0 ; ( text != NULL ) && ( text [i ] != '\0' ) ; i += codepointSize )
2490
2490
{
2491
2491
int codepoint = GetCodepointNext (text + i , & codepointSize );
2492
2492
int index = GetGlyphIndex (guiFont , codepoint ); // If requested codepoint is not found, we get '?' (0x3f)
@@ -3462,9 +3462,9 @@ void GuiLoadStyle(const char *fileName)
3462
3462
int propertyCount = 0 ;
3463
3463
3464
3464
fread (signature , 1 , 4 , rgsFile );
3465
- fread (& version , 1 , sizeof (short ), rgsFile );
3466
- fread (& reserved , 1 , sizeof (short ), rgsFile );
3467
- fread (& propertyCount , 1 , sizeof (int ), rgsFile );
3465
+ fread (& version , sizeof (short ), 1 , rgsFile );
3466
+ fread (& reserved , sizeof (short ), 1 , rgsFile );
3467
+ fread (& propertyCount , sizeof (int ), 1 , rgsFile );
3468
3468
3469
3469
if ((signature [0 ] == 'r' ) &&
3470
3470
(signature [1 ] == 'G' ) &&
@@ -3477,9 +3477,9 @@ void GuiLoadStyle(const char *fileName)
3477
3477
3478
3478
for (int i = 0 ; i < propertyCount ; i ++ )
3479
3479
{
3480
- fread (& controlId , 1 , sizeof (short ), rgsFile );
3481
- fread (& propertyId , 1 , sizeof (short ), rgsFile );
3482
- fread (& propertyValue , 1 , sizeof (unsigned int ), rgsFile );
3480
+ fread (& controlId , sizeof (short ), 1 , rgsFile );
3481
+ fread (& propertyId , sizeof (short ), 1 , rgsFile );
3482
+ fread (& propertyValue , sizeof (unsigned int ), 1 , rgsFile );
3483
3483
3484
3484
if (controlId == 0 ) // DEFAULT control
3485
3485
{
@@ -3496,32 +3496,32 @@ void GuiLoadStyle(const char *fileName)
3496
3496
#if !defined(RAYGUI_STANDALONE )
3497
3497
// Load custom font if available
3498
3498
int fontDataSize = 0 ;
3499
- fread (& fontDataSize , 1 , sizeof (int ), rgsFile );
3499
+ fread (& fontDataSize , sizeof (int ), 1 , rgsFile );
3500
3500
3501
3501
if (fontDataSize > 0 )
3502
3502
{
3503
3503
Font font = { 0 };
3504
3504
int fontType = 0 ; // 0-Normal, 1-SDF
3505
3505
Rectangle whiteRec = { 0 };
3506
3506
3507
- fread (& font .baseSize , 1 , sizeof (int ), rgsFile );
3508
- fread (& font .glyphCount , 1 , sizeof (int ), rgsFile );
3509
- fread (& fontType , 1 , sizeof (int ), rgsFile );
3507
+ fread (& font .baseSize , sizeof (int ), 1 , rgsFile );
3508
+ fread (& font .glyphCount , sizeof (int ), 1 , rgsFile );
3509
+ fread (& fontType , sizeof (int ), 1 , rgsFile );
3510
3510
3511
3511
// Load font white rectangle
3512
- fread (& whiteRec , 1 , sizeof (Rectangle ), rgsFile );
3512
+ fread (& whiteRec , sizeof (Rectangle ), 1 , rgsFile );
3513
3513
3514
3514
// Load font image parameters
3515
3515
int fontImageUncompSize = 0 ;
3516
3516
int fontImageCompSize = 0 ;
3517
- fread (& fontImageUncompSize , 1 , sizeof (int ), rgsFile );
3518
- fread (& fontImageCompSize , 1 , sizeof (int ), rgsFile );
3517
+ fread (& fontImageUncompSize , sizeof (int ), 1 , rgsFile );
3518
+ fread (& fontImageCompSize , sizeof (int ), 1 , rgsFile );
3519
3519
3520
3520
Image imFont = { 0 };
3521
3521
imFont .mipmaps = 1 ;
3522
- fread (& imFont .width , 1 , sizeof (int ), rgsFile );
3523
- fread (& imFont .height , 1 , sizeof (int ), rgsFile );
3524
- fread (& imFont .format , 1 , sizeof (int ), rgsFile );
3522
+ fread (& imFont .width , sizeof (int ), 1 , rgsFile );
3523
+ fread (& imFont .height , sizeof (int ), 1 , rgsFile );
3524
+ fread (& imFont .format , sizeof (int ), 1 , rgsFile );
3525
3525
3526
3526
if (fontImageCompSize < fontImageUncompSize )
3527
3527
{
@@ -3551,16 +3551,16 @@ void GuiLoadStyle(const char *fileName)
3551
3551
3552
3552
// Load font recs data
3553
3553
font .recs = (Rectangle * )RAYGUI_CALLOC (font .glyphCount , sizeof (Rectangle ));
3554
- for (int i = 0 ; i < font .glyphCount ; i ++ ) fread (& font .recs [i ], 1 , sizeof (Rectangle ), rgsFile );
3554
+ for (int i = 0 ; i < font .glyphCount ; i ++ ) fread (& font .recs [i ], sizeof (Rectangle ), 1 , rgsFile );
3555
3555
3556
3556
// Load font chars info data
3557
3557
font .glyphs = (GlyphInfo * )RAYGUI_CALLOC (font .glyphCount , sizeof (GlyphInfo ));
3558
3558
for (int i = 0 ; i < font .glyphCount ; i ++ )
3559
3559
{
3560
- fread (& font .glyphs [i ].value , 1 , sizeof (int ), rgsFile );
3561
- fread (& font .glyphs [i ].offsetX , 1 , sizeof (int ), rgsFile );
3562
- fread (& font .glyphs [i ].offsetY , 1 , sizeof (int ), rgsFile );
3563
- fread (& font .glyphs [i ].advanceX , 1 , sizeof (int ), rgsFile );
3560
+ fread (& font .glyphs [i ].value , sizeof (int ), 1 , rgsFile );
3561
+ fread (& font .glyphs [i ].offsetX , sizeof (int ), 1 , rgsFile );
3562
+ fread (& font .glyphs [i ].offsetY , sizeof (int ), 1 , rgsFile );
3563
+ fread (& font .glyphs [i ].advanceX , sizeof (int ), 1 , rgsFile );
3564
3564
}
3565
3565
3566
3566
GuiSetFont (font );
@@ -3746,10 +3746,10 @@ char **GuiLoadIcons(const char *fileName, bool loadIconsName)
3746
3746
short iconSize = 0 ;
3747
3747
3748
3748
fread (signature , 1 , 4 , rgiFile );
3749
- fread (& version , 1 , sizeof (short ), rgiFile );
3750
- fread (& reserved , 1 , sizeof (short ), rgiFile );
3751
- fread (& iconCount , 1 , sizeof (short ), rgiFile );
3752
- fread (& iconSize , 1 , sizeof (short ), rgiFile );
3749
+ fread (& version , sizeof (short ), 1 , rgiFile );
3750
+ fread (& reserved , sizeof (short ), 1 , rgiFile );
3751
+ fread (& iconCount , sizeof (short ), 1 , rgiFile );
3752
+ fread (& iconSize , sizeof (short ), 1 , rgiFile );
3753
3753
3754
3754
if ((signature [0 ] == 'r' ) &&
3755
3755
(signature [1 ] == 'G' ) &&
@@ -3762,13 +3762,13 @@ char **GuiLoadIcons(const char *fileName, bool loadIconsName)
3762
3762
for (int i = 0 ; i < iconCount ; i ++ )
3763
3763
{
3764
3764
guiIconsName [i ] = (char * )RAYGUI_MALLOC (RAYGUI_ICON_MAX_NAME_LENGTH );
3765
- fread (guiIconsName [i ], RAYGUI_ICON_MAX_NAME_LENGTH , 1 , rgiFile );
3765
+ fread (guiIconsName [i ], 1 , RAYGUI_ICON_MAX_NAME_LENGTH , rgiFile );
3766
3766
}
3767
3767
}
3768
3768
else fseek (rgiFile , iconCount * RAYGUI_ICON_MAX_NAME_LENGTH , SEEK_CUR );
3769
3769
3770
3770
// Read icons data directly over internal icons array
3771
- fread (guiIconsPtr , iconCount * (iconSize * iconSize /32 ), sizeof ( unsigned int ), rgiFile );
3771
+ fread (guiIconsPtr , sizeof ( unsigned int ), iconCount * (iconSize * iconSize /32 ), rgiFile );
3772
3772
}
3773
3773
3774
3774
fclose (rgiFile );
@@ -4048,7 +4048,7 @@ static void GuiDrawText(const char *text, Rectangle bounds, int alignment, Color
4048
4048
#endif
4049
4049
//DrawTextEx(guiFont, text, position, (float)GuiGetStyle(DEFAULT, TEXT_SIZE), (float)GuiGetStyle(DEFAULT, TEXT_SPACING), tint);
4050
4050
4051
- // Get size in bytes of text,
4051
+ // Get size in bytes of text,
4052
4052
// considering end of line and line break
4053
4053
int size = 0 ;
4054
4054
for (int c = 0 ; (lines [i ][c ] != '\0' ) && (lines [i ][c ] != '\n' ); c ++ , size ++ ){ }
@@ -4116,13 +4116,13 @@ static void GuiTooltip(Rectangle controlRec)
4116
4116
4117
4117
if ((controlRec .x + textSize .x + 16 ) > GetScreenWidth ()) controlRec .x -= (textSize .x + 16 - controlRec .width );
4118
4118
4119
- GuiPanel ((Rectangle ){ controlRec .x , controlRec .y + controlRec .height + 4 , textSize .x + 16 , GuiGetStyle (DEFAULT , TEXT_SIZE ) + 8.f }, NULL );
4119
+ GuiPanel (RAYGUI_CLITERAL (Rectangle ){ controlRec .x , controlRec .y + controlRec .height + 4 , textSize .x + 16 , GuiGetStyle (DEFAULT , TEXT_SIZE ) + 8.f }, NULL );
4120
4120
4121
4121
int textPadding = GuiGetStyle (LABEL , TEXT_PADDING );
4122
4122
int textAlignment = GuiGetStyle (LABEL , TEXT_ALIGNMENT );
4123
4123
GuiSetStyle (LABEL , TEXT_PADDING , 0 );
4124
4124
GuiSetStyle (LABEL , TEXT_ALIGNMENT , TEXT_ALIGN_CENTER );
4125
- GuiLabel ((Rectangle ){ controlRec .x , controlRec .y + controlRec .height + 4 , textSize .x + 16 , GuiGetStyle (DEFAULT , TEXT_SIZE ) + 8.f }, guiTooltipPtr );
4125
+ GuiLabel (RAYGUI_CLITERAL (Rectangle ){ controlRec .x , controlRec .y + controlRec .height + 4 , textSize .x + 16 , GuiGetStyle (DEFAULT , TEXT_SIZE ) + 8.f }, guiTooltipPtr );
4126
4126
GuiSetStyle (LABEL , TEXT_ALIGNMENT , textAlignment );
4127
4127
GuiSetStyle (LABEL , TEXT_PADDING , textPadding );
4128
4128
}
@@ -4318,8 +4318,8 @@ static int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue)
4318
4318
bool isVertical = (bounds .width > bounds .height )? false : true;
4319
4319
4320
4320
// The size (width or height depending on scrollbar type) of the spinner buttons
4321
- const int spinnerSize = GuiGetStyle (SCROLLBAR , ARROWS_VISIBLE )?
4322
- (isVertical ? (int )bounds .width - 2 * GuiGetStyle (SCROLLBAR , BORDER_WIDTH ) :
4321
+ const int spinnerSize = GuiGetStyle (SCROLLBAR , ARROWS_VISIBLE )?
4322
+ (isVertical ? (int )bounds .width - 2 * GuiGetStyle (SCROLLBAR , BORDER_WIDTH ) :
4323
4323
(int )bounds .height - 2 * GuiGetStyle (SCROLLBAR , BORDER_WIDTH )) : 0 ;
4324
4324
4325
4325
// Arrow buttons [<] [>] [∧] [∨]
@@ -4340,9 +4340,9 @@ static int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue)
4340
4340
int sliderSize = GuiGetStyle (SCROLLBAR , SCROLL_SLIDER_SIZE );
4341
4341
4342
4342
// Calculate rectangles for all of the components
4343
- arrowUpLeft = RAYGUI_CLITERAL (Rectangle ){
4344
- (float )bounds .x + GuiGetStyle (SCROLLBAR , BORDER_WIDTH ),
4345
- (float )bounds .y + GuiGetStyle (SCROLLBAR , BORDER_WIDTH ),
4343
+ arrowUpLeft = RAYGUI_CLITERAL (Rectangle ){
4344
+ (float )bounds .x + GuiGetStyle (SCROLLBAR , BORDER_WIDTH ),
4345
+ (float )bounds .y + GuiGetStyle (SCROLLBAR , BORDER_WIDTH ),
4346
4346
(float )spinnerSize , (float )spinnerSize };
4347
4347
4348
4348
if (isVertical )
@@ -4413,17 +4413,17 @@ static int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue)
4413
4413
if (GuiGetStyle (SCROLLBAR , ARROWS_VISIBLE ))
4414
4414
{
4415
4415
#if defined(RAYGUI_NO_ICONS )
4416
- GuiDrawText (isVertical ? "^" : "<" ,
4416
+ GuiDrawText (isVertical ? "^" : "<" ,
4417
4417
RAYGUI_CLITERAL (Rectangle ){ arrowUpLeft .x , arrowUpLeft .y , isVertical ? bounds .width : bounds .height , isVertical ? bounds .width : bounds .height },
4418
4418
TEXT_ALIGN_CENTER , Fade (GetColor (GuiGetStyle (DROPDOWNBOX , TEXT + (state * 3 ))), guiAlpha ));
4419
- GuiDrawText (isVertical ? "v" : ">" ,
4419
+ GuiDrawText (isVertical ? "v" : ">" ,
4420
4420
RAYGUI_CLITERAL (Rectangle ){ arrowDownRight .x , arrowDownRight .y , isVertical ? bounds .width : bounds .height , isVertical ? bounds .width : bounds .height },
4421
4421
TEXT_ALIGN_CENTER , Fade (GetColor (GuiGetStyle (DROPDOWNBOX , TEXT + (state * 3 ))), guiAlpha ));
4422
4422
#else
4423
- GuiDrawText (isVertical ? "#121#" : "#118#" ,
4423
+ GuiDrawText (isVertical ? "#121#" : "#118#" ,
4424
4424
RAYGUI_CLITERAL (Rectangle ){ arrowUpLeft .x , arrowUpLeft .y , isVertical ? bounds .width : bounds .height , isVertical ? bounds .width : bounds .height },
4425
4425
TEXT_ALIGN_CENTER , Fade (GetColor (GuiGetStyle (SCROLLBAR , TEXT + state * 3 )), guiAlpha )); // ICON_ARROW_UP_FILL / ICON_ARROW_LEFT_FILL
4426
- GuiDrawText (isVertical ? "#120#" : "#119#" ,
4426
+ GuiDrawText (isVertical ? "#120#" : "#119#" ,
4427
4427
RAYGUI_CLITERAL (Rectangle ){ arrowDownRight .x , arrowDownRight .y , isVertical ? bounds .width : bounds .height , isVertical ? bounds .width : bounds .height },
4428
4428
TEXT_ALIGN_CENTER , Fade (GetColor (GuiGetStyle (SCROLLBAR , TEXT + state * 3 )), guiAlpha )); // ICON_ARROW_DOWN_FILL / ICON_ARROW_RIGHT_FILL
4429
4429
#endif
0 commit comments