mirror of
https://github.com/raysan5/raygui.git
synced 2026-02-05 21:59:18 -05:00
Compare commits
29 Commits
b4eb06657b
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| fd8d0f1b17 | |||
| 1c2365a20c | |||
| 7f842d85ba | |||
| 0f5f0f7d00 | |||
| 9a1c183d85 | |||
| 51e6bcb393 | |||
| 04282d1763 | |||
| 0b94b80c92 | |||
| 867ca4bf8d | |||
| 367e169ad3 | |||
| 1a74db2ab3 | |||
| 715baf250d | |||
| 3aea427fc8 | |||
| 773d1ec52b | |||
| ff4dbd0712 | |||
| aed63cedd1 | |||
| 4436a897f9 | |||
| d4ebcdc2be | |||
| 860e46d3f8 | |||
| b9971133b2 | |||
| 947ef5799d | |||
| 681393a423 | |||
| 9cdfec460b | |||
| 546b4bacf4 | |||
| cf3aab1e9f | |||
| 9193f38424 | |||
| 6530ee136b | |||
| 1b2612cf75 | |||
| 54ee53e7d7 |
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
|||||||
zlib License
|
zlib License
|
||||||
|
|
||||||
Copyright (c) 2014-2025 Ramon Santamaria (@raysan5)
|
Copyright (c) 2014-2026 Ramon Santamaria (@raysan5)
|
||||||
|
|
||||||
This software is provided "as-is", without any express or implied warranty. In no event
|
This software is provided "as-is", without any express or implied warranty. In no event
|
||||||
will the authors be held liable for any damages arising from the use of this software.
|
will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
|||||||
@ -208,6 +208,7 @@ int main()
|
|||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Check all possible events that require GuiLock
|
// Check all possible events that require GuiLock
|
||||||
if (dropDown000EditMode || dropDown001EditMode) GuiLock();
|
if (dropDown000EditMode || dropDown001EditMode) GuiLock();
|
||||||
|
if (showTextInputBox) GuiLock();
|
||||||
|
|
||||||
// First GUI column
|
// First GUI column
|
||||||
//GuiSetStyle(CHECKBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
|
//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);
|
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
|
// 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_PADDING, 4);
|
||||||
GuiSetStyle(DROPDOWNBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
|
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;
|
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)
|
if (showTextInputBox)
|
||||||
{
|
{
|
||||||
|
GuiUnlock();
|
||||||
|
|
||||||
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, 0.8f));
|
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);
|
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);
|
||||||
|
|
||||||
|
|||||||
@ -97,7 +97,7 @@ int GuiFloatBox(Rectangle bounds, const char* text, float* value, int minValue,
|
|||||||
Rectangle textBounds = { 0 };
|
Rectangle textBounds = { 0 };
|
||||||
if (text != NULL)
|
if (text != NULL)
|
||||||
{
|
{
|
||||||
textBounds.width = (float)GetTextWidth(text) + 2;
|
textBounds.width = (float)GuiGetTextWidth(text) + 2;
|
||||||
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||||
textBounds.x = bounds.x + bounds.width + GuiGetStyle(VALUEBOX, TEXT_PADDING);
|
textBounds.x = bounds.x + bounds.width + GuiGetStyle(VALUEBOX, TEXT_PADDING);
|
||||||
textBounds.y = bounds.y + bounds.height / 2.0f - GuiGetStyle(DEFAULT, TEXT_SIZE) / 2.0f;
|
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]
|
// Only allow keys in range [48..57]
|
||||||
if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS)
|
if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS)
|
||||||
{
|
{
|
||||||
if (GetTextWidth(textValue) < bounds.width)
|
if (GuiGetTextWidth(textValue) < bounds.width)
|
||||||
{
|
{
|
||||||
int key = GetCharPressed();
|
int key = GetCharPressed();
|
||||||
if ((key >= 48) && (key <= 57) && guiFloatingPointIndex)
|
if ((key >= 48) && (key <= 57) && guiFloatingPointIndex)
|
||||||
@ -211,7 +211,7 @@ int GuiFloatBox(Rectangle bounds, const char* text, float* value, int minValue,
|
|||||||
if (editMode)
|
if (editMode)
|
||||||
{
|
{
|
||||||
// NOTE: ValueBox internal text is always centered
|
// 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));
|
GuiDrawRectangle(cursor, 0, BLANK, Fade(GetColor(GuiGetStyle(VALUEBOX, BORDER_COLOR_PRESSED)), guiAlpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -182,7 +182,7 @@ float GuiVerticalSliderPro(Rectangle bounds, const char *textTop, const char *te
|
|||||||
if (textTop != NULL)
|
if (textTop != NULL)
|
||||||
{
|
{
|
||||||
Rectangle textBounds = { 0 };
|
Rectangle textBounds = { 0 };
|
||||||
textBounds.width = (float)GetTextWidth(textTop);
|
textBounds.width = (float)GuiGetTextWidth(textTop);
|
||||||
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||||
textBounds.x = bounds.x + bounds.width/2 - textBounds.width/2;
|
textBounds.x = bounds.x + bounds.width/2 - textBounds.width/2;
|
||||||
textBounds.y = bounds.y - textBounds.height - GuiGetStyle(SLIDER, TEXT_PADDING);
|
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)
|
if (textBottom != NULL)
|
||||||
{
|
{
|
||||||
Rectangle textBounds = { 0 };
|
Rectangle textBounds = { 0 };
|
||||||
textBounds.width = (float)GetTextWidth(textBottom);
|
textBounds.width = (float)GuiGetTextWidth(textBottom);
|
||||||
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||||
textBounds.x = bounds.x + bounds.width/2 - textBounds.width/2;
|
textBounds.x = bounds.x + bounds.width/2 - textBounds.width/2;
|
||||||
textBounds.y = bounds.y + bounds.height + GuiGetStyle(SLIDER, TEXT_PADDING);
|
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)
|
if (textLeft != NULL)
|
||||||
{
|
{
|
||||||
Rectangle textBounds = { 0 };
|
Rectangle textBounds = { 0 };
|
||||||
textBounds.width = (float)GetTextWidth(textLeft);
|
textBounds.width = (float)GuiGetTextWidth(textLeft);
|
||||||
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||||
textBounds.x = bounds.x - textBounds.width - GuiGetStyle(SLIDER, TEXT_PADDING);
|
textBounds.x = bounds.x - textBounds.width - GuiGetStyle(SLIDER, TEXT_PADDING);
|
||||||
textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
|
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)
|
if (textRight != NULL)
|
||||||
{
|
{
|
||||||
Rectangle textBounds = { 0 };
|
Rectangle textBounds = { 0 };
|
||||||
textBounds.width = (float)GetTextWidth(textRight);
|
textBounds.width = (float)GuiGetTextWidth(textRight);
|
||||||
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||||
textBounds.x = bounds.x + bounds.width + GuiGetStyle(SLIDER, TEXT_PADDING);
|
textBounds.x = bounds.x + bounds.width + GuiGetStyle(SLIDER, TEXT_PADDING);
|
||||||
textBounds.y = bounds.y + bounds.height/2 - GuiGetStyle(DEFAULT, TEXT_SIZE)/2;
|
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)
|
if (textTop != NULL)
|
||||||
{
|
{
|
||||||
Rectangle textBounds = { 0 };
|
Rectangle textBounds = { 0 };
|
||||||
textBounds.width = (float)GetTextWidth(textTop);
|
textBounds.width = (float)GuiGetTextWidth(textTop);
|
||||||
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||||
textBounds.x = bounds.x + bounds.width/2 - textBounds.width/2;
|
textBounds.x = bounds.x + bounds.width/2 - textBounds.width/2;
|
||||||
textBounds.y = bounds.y - textBounds.height - GuiGetStyle(SLIDER, TEXT_PADDING);
|
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)
|
if (textBottom != NULL)
|
||||||
{
|
{
|
||||||
Rectangle textBounds = { 0 };
|
Rectangle textBounds = { 0 };
|
||||||
textBounds.width = (float)GetTextWidth(textBottom);
|
textBounds.width = (float)GuiGetTextWidth(textBottom);
|
||||||
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
textBounds.height = (float)GuiGetStyle(DEFAULT, TEXT_SIZE);
|
||||||
textBounds.x = bounds.x + bounds.width/2 - textBounds.width/2;
|
textBounds.x = bounds.x + bounds.width/2 - textBounds.width/2;
|
||||||
textBounds.y = bounds.y + bounds.height + GuiGetStyle(SLIDER, TEXT_PADDING);
|
textBounds.y = bounds.y + bounds.height + GuiGetStyle(SLIDER, TEXT_PADDING);
|
||||||
|
|||||||
@ -38,10 +38,10 @@ int main(int argc, char *argv[])
|
|||||||
bool windowBoxActive = false;
|
bool windowBoxActive = false;
|
||||||
|
|
||||||
int fileFormatActive = 0;
|
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;
|
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;
|
bool textBoxEditMode = false;
|
||||||
char fileName[64] = "untitled";
|
char fileName[64] = "untitled";
|
||||||
|
|||||||
@ -50,12 +50,12 @@ int main()
|
|||||||
bool heightEditMode = false;
|
bool heightEditMode = false;
|
||||||
|
|
||||||
int pixelFormatActive = 0;
|
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;
|
int channelsActive = 3;
|
||||||
char *channelsTextList[4] = { "1", "2", "3", "4" };
|
const char *channelsTextList[4] = { "1", "2", "3", "4" };
|
||||||
int bitDepthActive = 0;
|
int bitDepthActive = 0;
|
||||||
char *bitDepthTextList[3] = { "8", "16", "32" };
|
const char *bitDepthTextList[3] = { "8", "16", "32" };
|
||||||
|
|
||||||
int headerSizeValue = 0;
|
int headerSizeValue = 0;
|
||||||
bool headerSizeEditMode = false;
|
bool headerSizeEditMode = false;
|
||||||
|
|||||||
@ -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),
|
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)};
|
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(textWidth > textBounds.width) textBounds.width = textWidth;
|
||||||
|
|
||||||
if (state == STATE_PRESSED)
|
if (state == STATE_PRESSED)
|
||||||
@ -338,7 +338,7 @@ double GuiDMValueBox(Rectangle bounds, double value, double minValue, double max
|
|||||||
if(cursor > 0) {
|
if(cursor > 0) {
|
||||||
char c = textValue[cursor];
|
char c = textValue[cursor];
|
||||||
textValue[cursor] = '\0';
|
textValue[cursor] = '\0';
|
||||||
textWidthCursor = GetTextWidth(textValue);
|
textWidthCursor = GuiGetTextWidth(textValue);
|
||||||
textValue[cursor] = c;
|
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));
|
//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)
|
// draw X, Y, Z, W values (only when expanded)
|
||||||
if(!PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED)) {
|
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 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};
|
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);
|
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) );
|
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)
|
// draw X, Y, Width, Height values (only when expanded)
|
||||||
if(!PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED)) {
|
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 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};
|
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);
|
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) );
|
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)
|
// draw R, G, B, A values (only when expanded)
|
||||||
if(!PROP_CHECK_FLAG(&props[p], GUI_PFLAG_COLLAPSED)) {
|
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 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, GetTextWidth("000000"), 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 };
|
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
|
if(sbarBounds.width <= GuiGetStyle(LISTVIEW, LIST_ITEMS_HEIGHT)-2) valBounds.width = propBounds.width-lblBounds.width-2*PROPERTY_PADDING; // hide slider when no space
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -311,7 +311,6 @@
|
|||||||
<ClCompile Include="$(ProjectDir)..\..\..\..\raylib\src\rshapes.c" />
|
<ClCompile Include="$(ProjectDir)..\..\..\..\raylib\src\rshapes.c" />
|
||||||
<ClCompile Include="$(ProjectDir)..\..\..\..\raylib\src\rtext.c" />
|
<ClCompile Include="$(ProjectDir)..\..\..\..\raylib\src\rtext.c" />
|
||||||
<ClCompile Include="$(ProjectDir)..\..\..\..\raylib\src\rtextures.c" />
|
<ClCompile Include="$(ProjectDir)..\..\..\..\raylib\src\rtextures.c" />
|
||||||
<ClCompile Include="$(ProjectDir)..\..\..\..\raylib\src\utils.c" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="$(ProjectDir)..\..\..\..\raylib\src\external\cgltf.h" />
|
<ClInclude Include="$(ProjectDir)..\..\..\..\raylib\src\external\cgltf.h" />
|
||||||
@ -331,7 +330,6 @@
|
|||||||
<ClInclude Include="$(ProjectDir)..\..\..\..\raylib\src\raylib.h" />
|
<ClInclude Include="$(ProjectDir)..\..\..\..\raylib\src\raylib.h" />
|
||||||
<ClInclude Include="$(ProjectDir)..\..\..\..\raylib\src\raymath.h" />
|
<ClInclude Include="$(ProjectDir)..\..\..\..\raylib\src\raymath.h" />
|
||||||
<ClInclude Include="$(ProjectDir)..\..\..\..\raylib\src\rlgl.h" />
|
<ClInclude Include="$(ProjectDir)..\..\..\..\raylib\src\rlgl.h" />
|
||||||
<ClInclude Include="$(ProjectDir)..\..\..\..\raylib\src\utils.h" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="..\..\..\..\raylib\src\raylib.dll.rc" />
|
<ResourceCompile Include="..\..\..\..\raylib\src\raylib.dll.rc" />
|
||||||
|
|||||||
307
src/raygui.h
307
src/raygui.h
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* DESCRIPTION:
|
* DESCRIPTION:
|
||||||
* raygui is a tools-dev-focused immediate-mode-gui library based on raylib but also
|
* 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:
|
* FEATURES:
|
||||||
* - Immediate-mode gui, minimal retained data
|
* - Immediate-mode gui, minimal retained data
|
||||||
@ -27,7 +27,7 @@
|
|||||||
* - WARNING: GuiLoadStyle() and GuiLoadStyle{Custom}() functions, allocate memory for
|
* - WARNING: GuiLoadStyle() and GuiLoadStyle{Custom}() functions, allocate memory for
|
||||||
* font atlas recs and glyphs, freeing that memory is (usually) up to the user,
|
* 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
|
* 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
|
* - Global UI alpha (guiAlpha) is applied inside GuiDrawRectangle() and GuiDrawText() functions
|
||||||
*
|
*
|
||||||
* CONTROLS PROVIDED:
|
* CONTROLS PROVIDED:
|
||||||
@ -65,7 +65,7 @@
|
|||||||
* - MessageBox --> Window, Label, Button
|
* - MessageBox --> Window, Label, Button
|
||||||
* - TextInputBox --> Window, Label, TextBox, 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):
|
* RAYGUI STYLE (guiStyle):
|
||||||
@ -77,11 +77,11 @@
|
|||||||
*
|
*
|
||||||
* static unsigned int guiStyle[RAYGUI_MAX_CONTROLS*(RAYGUI_MAX_PROPS_BASE + RAYGUI_MAX_PROPS_EXTENDED)];
|
* 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
|
* 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
|
* 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
|
* 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)
|
* 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
|
* 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.
|
* 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:
|
* The global icons array size is fixed and depends on the number of icons and size:
|
||||||
*
|
*
|
||||||
@ -112,20 +112,20 @@
|
|||||||
*
|
*
|
||||||
* RAYGUI LAYOUT:
|
* RAYGUI LAYOUT:
|
||||||
* raygui currently does not provide an auto-layout mechanism like other libraries,
|
* 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
|
* TOOL: rGuiLayout is a visual tool to create raygui layouts: github.com/raysan5/rguilayout
|
||||||
*
|
*
|
||||||
* CONFIGURATION:
|
* CONFIGURATION:
|
||||||
* #define RAYGUI_IMPLEMENTATION
|
* #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
|
* 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
|
* #define RAYGUI_STANDALONE
|
||||||
* Avoid raylib.h header inclusion in this file. Data types defined on raylib are defined
|
* 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
|
* 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
|
* #define RAYGUI_NO_ICONS
|
||||||
* Avoid including embedded ricons data (256 icons, 16x16 pixels, 1-bit per pixel, 2KB)
|
* Avoid including embedded ricons data (256 icons, 16x16 pixels, 1-bit per pixel, 2KB)
|
||||||
@ -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
|
||||||
@ -266,16 +266,16 @@
|
|||||||
* 1.4 (15-Jun-2017) Rewritten all GUI functions (removed useless ones)
|
* 1.4 (15-Jun-2017) Rewritten all GUI functions (removed useless ones)
|
||||||
* 1.3 (12-Jun-2017) Complete redesign of style system
|
* 1.3 (12-Jun-2017) Complete redesign of style system
|
||||||
* 1.1 (01-Jun-2017) Complete review of the library
|
* 1.1 (01-Jun-2017) Complete review of the library
|
||||||
* 1.0 (07-Jun-2016) Converted to header-only by 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.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.
|
* 0.8 (27-Aug-2015) Initial release. Implemented by Kevin Gato, Daniel Nicolás and Ramon Santamaria
|
||||||
*
|
*
|
||||||
* DEPENDENCIES:
|
* 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:
|
* STANDALONE MODE:
|
||||||
* By default raygui depends on raylib mostly for the inputs and the drawing functionality but that dependency can be disabled
|
* 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:
|
* The following functions should be redefined for a custom backend:
|
||||||
*
|
*
|
||||||
@ -316,7 +316,7 @@
|
|||||||
*
|
*
|
||||||
* LICENSE: zlib/libpng
|
* LICENSE: zlib/libpng
|
||||||
*
|
*
|
||||||
* Copyright (c) 2014-2025 Ramon Santamaria (@raysan5)
|
* Copyright (c) 2014-2026 Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||||
* will the authors be held liable for any damages arising from the use of this software.
|
* will the authors be held liable for any damages arising from the use of this software.
|
||||||
@ -351,10 +351,11 @@
|
|||||||
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
|
// NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#if defined(BUILD_LIBTYPE_SHARED)
|
#if defined(BUILD_LIBTYPE_SHARED)
|
||||||
#define RAYGUIAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll)
|
#define RAYGUIAPI __declspec(dllexport) // Building the library as a Win32 shared library (.dll)
|
||||||
#elif defined(USE_LIBTYPE_SHARED)
|
#elif defined(USE_LIBTYPE_SHARED)
|
||||||
#define RAYGUIAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll)
|
#define RAYGUIAPI __declspec(dllimport) // Using the library as a Win32 shared library (.dll)
|
||||||
#endif
|
#endif
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS // disable unsafe warnings on scanf functions in MSVC
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Function specifiers definition
|
// Function specifiers definition
|
||||||
@ -369,9 +370,9 @@
|
|||||||
// NOTE: Avoiding those calls, also avoids const strings memory usage
|
// NOTE: Avoiding those calls, also avoids const strings memory usage
|
||||||
#define RAYGUI_SUPPORT_LOG_INFO
|
#define RAYGUI_SUPPORT_LOG_INFO
|
||||||
#if defined(RAYGUI_SUPPORT_LOG_INFO)
|
#if defined(RAYGUI_SUPPORT_LOG_INFO)
|
||||||
#define RAYGUI_LOG(...) printf(__VA_ARGS__)
|
#define RAYGUI_LOG(...) printf(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define RAYGUI_LOG(...)
|
#define RAYGUI_LOG(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
@ -417,13 +418,16 @@
|
|||||||
|
|
||||||
// TODO: Texture2D type is very coupled to raylib, required by Font type
|
// TODO: Texture2D type is very coupled to raylib, required by Font type
|
||||||
// It should be redesigned to be provided by user
|
// It should be redesigned to be provided by user
|
||||||
typedef struct Texture2D {
|
typedef struct Texture {
|
||||||
unsigned int id; // OpenGL texture id
|
unsigned int id; // OpenGL texture id
|
||||||
int width; // Texture base width
|
int width; // Texture base width
|
||||||
int height; // Texture base height
|
int height; // Texture base height
|
||||||
int mipmaps; // Mipmap levels, 1 by default
|
int mipmaps; // Mipmap levels, 1 by default
|
||||||
int format; // Data format (PixelFormat type)
|
int format; // Data format (PixelFormat type)
|
||||||
} Texture2D;
|
} Texture;
|
||||||
|
|
||||||
|
// Texture2D, same as Texture
|
||||||
|
typedef Texture Texture2D;
|
||||||
|
|
||||||
// Image, pixel data stored in CPU memory (RAM)
|
// Image, pixel data stored in CPU memory (RAM)
|
||||||
typedef struct Image {
|
typedef struct Image {
|
||||||
@ -1007,28 +1011,28 @@ typedef enum {
|
|||||||
ICON_SLICING = 231,
|
ICON_SLICING = 231,
|
||||||
ICON_MANUAL_CONTROL = 232,
|
ICON_MANUAL_CONTROL = 232,
|
||||||
ICON_COLLISION = 233,
|
ICON_COLLISION = 233,
|
||||||
ICON_234 = 234,
|
ICON_CIRCLE_ADD = 234,
|
||||||
ICON_235 = 235,
|
ICON_CIRCLE_ADD_FILL = 235,
|
||||||
ICON_236 = 236,
|
ICON_CIRCLE_WARNING = 236,
|
||||||
ICON_237 = 237,
|
ICON_CIRCLE_WARNING_FILL = 237,
|
||||||
ICON_238 = 238,
|
ICON_BOX_MORE = 238,
|
||||||
ICON_239 = 239,
|
ICON_BOX_MORE_FILL = 239,
|
||||||
ICON_240 = 240,
|
ICON_BOX_MINUS = 240,
|
||||||
ICON_241 = 241,
|
ICON_BOX_MINUS_FILL = 241,
|
||||||
ICON_242 = 242,
|
ICON_UNION = 242,
|
||||||
ICON_243 = 243,
|
ICON_INTERSECTION = 243,
|
||||||
ICON_244 = 244,
|
ICON_DIFFERENCE = 244,
|
||||||
ICON_245 = 245,
|
ICON_SPHERE = 245,
|
||||||
ICON_246 = 246,
|
ICON_CYLINDER = 246,
|
||||||
ICON_247 = 247,
|
ICON_CONE = 247,
|
||||||
ICON_248 = 248,
|
ICON_ELLIPSOID = 248,
|
||||||
ICON_249 = 249,
|
ICON_CAPSULE = 249,
|
||||||
ICON_250 = 250,
|
ICON_250 = 250,
|
||||||
ICON_251 = 251,
|
ICON_251 = 251,
|
||||||
ICON_252 = 252,
|
ICON_252 = 252,
|
||||||
ICON_253 = 253,
|
ICON_253 = 253,
|
||||||
ICON_254 = 254,
|
ICON_254 = 254,
|
||||||
ICON_255 = 255,
|
ICON_255 = 255
|
||||||
} GuiIconName;
|
} GuiIconName;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1075,7 +1079,7 @@ typedef enum {
|
|||||||
|
|
||||||
// Check if two rectangles are equal, used to validate a slider bounds as an id
|
// Check if two rectangles are equal, used to validate a slider bounds as an id
|
||||||
#ifndef CHECK_BOUNDS_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
|
#endif
|
||||||
|
|
||||||
#if !defined(RAYGUI_NO_ICONS) && !defined(RAYGUI_CUSTOM_ICONS)
|
#if !defined(RAYGUI_NO_ICONS) && !defined(RAYGUI_CUSTOM_ICONS)
|
||||||
@ -1088,7 +1092,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)
|
||||||
|
|
||||||
@ -1338,22 +1342,22 @@ static unsigned int guiIcons[RAYGUI_ICON_MAX_ICONS*RAYGUI_ICON_DATA_ELEMENTS] =
|
|||||||
0x7fe00000, 0x402e4020, 0x43ce5e0a, 0x40504078, 0x438e4078, 0x402e5e0a, 0x7fe04020, 0x00000000, // ICON_SLICING
|
0x7fe00000, 0x402e4020, 0x43ce5e0a, 0x40504078, 0x438e4078, 0x402e5e0a, 0x7fe04020, 0x00000000, // ICON_SLICING
|
||||||
0x00000000, 0x40027ffe, 0x47c24002, 0x55425d42, 0x55725542, 0x50125552, 0x10105016, 0x00001ff0, // ICON_MANUAL_CONTROL
|
0x00000000, 0x40027ffe, 0x47c24002, 0x55425d42, 0x55725542, 0x50125552, 0x10105016, 0x00001ff0, // ICON_MANUAL_CONTROL
|
||||||
0x7ffe0000, 0x43c24002, 0x48124422, 0x500a500a, 0x500a500a, 0x44224812, 0x400243c2, 0x00007ffe, // ICON_COLLISION
|
0x7ffe0000, 0x43c24002, 0x48124422, 0x500a500a, 0x500a500a, 0x44224812, 0x400243c2, 0x00007ffe, // ICON_COLLISION
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_234
|
0x03c00000, 0x10080c30, 0x21842184, 0x4ff24182, 0x41824ff2, 0x21842184, 0x0c301008, 0x000003c0, // ICON_CIRCLE_ADD
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_235
|
0x03c00000, 0x1ff80ff0, 0x3e7c3e7c, 0x700e7e7e, 0x7e7e700e, 0x3e7c3e7c, 0x0ff01ff8, 0x000003c0, // ICON_CIRCLE_ADD_FILL
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_236
|
0x03c00000, 0x10080c30, 0x21842184, 0x41824182, 0x40024182, 0x21842184, 0x0c301008, 0x000003c0, // ICON_CIRCLE_WARNING
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_237
|
0x03c00000, 0x1ff80ff0, 0x3e7c3e7c, 0x7e7e7e7e, 0x7ffe7e7e, 0x3e7c3e7c, 0x0ff01ff8, 0x000003c0, // ICON_CIRCLE_WARNING_FILL
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_238
|
0x00000000, 0x10041ffc, 0x10841004, 0x13e41084, 0x10841084, 0x10041004, 0x00001ffc, 0x00000000, // ICON_BOX_MORE
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_239
|
0x00000000, 0x1ffc1ffc, 0x1f7c1ffc, 0x1c1c1f7c, 0x1f7c1f7c, 0x1ffc1ffc, 0x00001ffc, 0x00000000, // ICON_BOX_MORE_FILL
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_240
|
0x00000000, 0x1ffc1ffc, 0x1ffc1ffc, 0x1c1c1ffc, 0x1ffc1ffc, 0x1ffc1ffc, 0x00001ffc, 0x00000000, // ICON_BOX_MINUS
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_241
|
0x00000000, 0x10041ffc, 0x10041004, 0x13e41004, 0x10041004, 0x10041004, 0x00001ffc, 0x00000000, // ICON_BOX_MINUS_FILL
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_242
|
0x07fe0000, 0x055606aa, 0x7ff606aa, 0x55766eba, 0x55766eaa, 0x55606ffe, 0x55606aa0, 0x00007fe0, // ICON_UNION
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_243
|
0x07fe0000, 0x04020402, 0x7fe20402, 0x456246a2, 0x456246a2, 0x402047fe, 0x40204020, 0x00007fe0, // ICON_INTERSECTION
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_244
|
0x07fe0000, 0x055606aa, 0x7ff606aa, 0x4436442a, 0x4436442a, 0x402047fe, 0x40204020, 0x00007fe0, // ICON_DIFFERENCE
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_245
|
0x03c00000, 0x10080c30, 0x20042004, 0x60064002, 0x47e2581a, 0x20042004, 0x0c301008, 0x000003c0, // ICON_SPHERE
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_246
|
0x03e00000, 0x08080410, 0x0c180808, 0x08080be8, 0x08080808, 0x08080808, 0x04100808, 0x000003e0, // ICON_CYLINDER
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_247
|
0x00800000, 0x01400140, 0x02200220, 0x04100410, 0x08080808, 0x1c1c13e4, 0x08081004, 0x000007f0, // ICON_CONE
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_248
|
0x00000000, 0x07e00000, 0x20841918, 0x40824082, 0x40824082, 0x19182084, 0x000007e0, 0x00000000, // ICON_ELLIPSOID
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_249
|
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_250
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_251
|
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_251
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_252
|
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_252
|
||||||
@ -1378,7 +1382,7 @@ static unsigned int *guiIconsPtr = guiIcons;
|
|||||||
#define RAYGUI_MAX_PROPS_EXTENDED 8 // Maximum number of extended properties
|
#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
|
// Gui control property style color element
|
||||||
typedef enum { BORDER = 0, BASE, TEXT, OTHER } GuiPropertyElement;
|
typedef enum { BORDER = 0, BASE, TEXT, OTHER } GuiPropertyElement;
|
||||||
@ -1494,7 +1498,7 @@ static void DrawRectangleGradientV(int posX, int posY, int width, int height, Co
|
|||||||
#endif // RAYGUI_STANDALONE
|
#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)
|
static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize); // Load style from memory (binary only)
|
||||||
|
|
||||||
@ -1740,7 +1744,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;
|
||||||
@ -1773,12 +1777,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2494,16 +2498,16 @@ int GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMod
|
|||||||
int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
||||||
{
|
{
|
||||||
#if !defined(RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN)
|
#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
|
#endif
|
||||||
#if !defined(RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY)
|
#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
|
#endif
|
||||||
|
|
||||||
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);
|
||||||
@ -2511,7 +2515,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
|
||||||
@ -2578,7 +2582,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
int codepointSize = 0;
|
int codepointSize = 0;
|
||||||
const char *charEncoded = CodepointToUTF8(codepoint, &codepointSize);
|
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)))
|
if (IsKeyPressed(KEY_V) && (IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_RIGHT_CONTROL)))
|
||||||
{
|
{
|
||||||
const char *pasteText = GetClipboardText();
|
const char *pasteText = GetClipboardText();
|
||||||
@ -2587,7 +2591,8 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
int pasteLength = 0;
|
int pasteLength = 0;
|
||||||
int pasteCodepoint;
|
int pasteCodepoint;
|
||||||
int pasteCodepointSize;
|
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)
|
while (true)
|
||||||
{
|
{
|
||||||
pasteCodepoint = GetCodepointNext(pasteText + pasteLength, &pasteCodepointSize);
|
pasteCodepoint = GetCodepointNext(pasteText + pasteLength, &pasteCodepointSize);
|
||||||
@ -2595,6 +2600,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
if (!(multiline && (pasteCodepoint == (int)'\n')) && !(pasteCodepoint >= 32)) break;
|
if (!(multiline && (pasteCodepoint == (int)'\n')) && !(pasteCodepoint >= 32)) break;
|
||||||
pasteLength += pasteCodepointSize;
|
pasteLength += pasteCodepointSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pasteLength > 0)
|
if (pasteLength > 0)
|
||||||
{
|
{
|
||||||
// Move forward data from cursor position
|
// Move forward data from cursor position
|
||||||
@ -2609,10 +2615,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))
|
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
|
// Move forward data from cursor position
|
||||||
for (int i = (textLength + codepointSize); i > textBoxCursorIndex; i--) text[i] = text[i - codepointSize];
|
for (int i = (textLength + codepointSize); i > textBoxCursorIndex; i--) text[i] = text[i - codepointSize];
|
||||||
|
|
||||||
@ -2639,6 +2645,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
int accCodepointSize = 0;
|
int accCodepointSize = 0;
|
||||||
int nextCodepointSize;
|
int nextCodepointSize;
|
||||||
int nextCodepoint;
|
int nextCodepoint;
|
||||||
|
|
||||||
// Check characters of the same type to delete (either ASCII punctuation or anything non-whitespace)
|
// 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
|
// Not using isalnum() since it only works on ASCII characters
|
||||||
nextCodepoint = GetCodepointNext(text + offset, &nextCodepointSize);
|
nextCodepoint = GetCodepointNext(text + offset, &nextCodepointSize);
|
||||||
@ -2651,11 +2658,12 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
accCodepointSize += nextCodepointSize;
|
accCodepointSize += nextCodepointSize;
|
||||||
nextCodepoint = GetCodepointNext(text + offset, &nextCodepointSize);
|
nextCodepoint = GetCodepointNext(text + offset, &nextCodepointSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whitespace to delete (ASCII only)
|
// Check whitespace to delete (ASCII only)
|
||||||
while (offset < textLength)
|
while (offset < textLength)
|
||||||
{
|
{
|
||||||
if (!isspace(nextCodepoint & 0xff))
|
if (!isspace(nextCodepoint & 0xff)) break;
|
||||||
break;
|
|
||||||
offset += nextCodepointSize;
|
offset += nextCodepointSize;
|
||||||
accCodepointSize += nextCodepointSize;
|
accCodepointSize += nextCodepointSize;
|
||||||
nextCodepoint = GetCodepointNext(text + offset, &nextCodepointSize);
|
nextCodepoint = GetCodepointNext(text + offset, &nextCodepointSize);
|
||||||
@ -2666,9 +2674,11 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
|
|
||||||
textLength -= accCodepointSize;
|
textLength -= accCodepointSize;
|
||||||
}
|
}
|
||||||
// Delete single codepoint from text, after current cursor position
|
|
||||||
else if ((textLength > textBoxCursorIndex) && (IsKeyPressed(KEY_DELETE) || (IsKeyDown(KEY_DELETE) && autoCursorShouldTrigger)))
|
else if ((textLength > textBoxCursorIndex) && (IsKeyPressed(KEY_DELETE) || (IsKeyDown(KEY_DELETE) && autoCursorShouldTrigger)))
|
||||||
{
|
{
|
||||||
|
// Delete single codepoint from text, after current cursor position
|
||||||
|
|
||||||
int nextCodepointSize = 0;
|
int nextCodepointSize = 0;
|
||||||
GetCodepointNext(text + textBoxCursorIndex, &nextCodepointSize);
|
GetCodepointNext(text + textBoxCursorIndex, &nextCodepointSize);
|
||||||
|
|
||||||
@ -2683,8 +2693,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)
|
||||||
@ -2695,6 +2705,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
offset -= prevCodepointSize;
|
offset -= prevCodepointSize;
|
||||||
accCodepointSize += prevCodepointSize;
|
accCodepointSize += prevCodepointSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check characters of the same type to delete (either ASCII punctuation or anything non-whitespace)
|
// 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
|
// Not using isalnum() since it only works on ASCII characters
|
||||||
bool puctuation = ispunct(prevCodepoint & 0xff);
|
bool puctuation = ispunct(prevCodepoint & 0xff);
|
||||||
@ -2713,9 +2724,11 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
textLength -= accCodepointSize;
|
textLength -= accCodepointSize;
|
||||||
textBoxCursorIndex -= accCodepointSize;
|
textBoxCursorIndex -= accCodepointSize;
|
||||||
}
|
}
|
||||||
// Delete single codepoint from text, before current cursor position
|
|
||||||
else if ((textBoxCursorIndex > 0) && (IsKeyPressed(KEY_BACKSPACE) || (IsKeyDown(KEY_BACKSPACE) && autoCursorShouldTrigger)))
|
else if ((textBoxCursorIndex > 0) && (IsKeyPressed(KEY_BACKSPACE) || (IsKeyDown(KEY_BACKSPACE) && autoCursorShouldTrigger)))
|
||||||
{
|
{
|
||||||
|
// Delete single codepoint from text, before current cursor position
|
||||||
|
|
||||||
int prevCodepointSize = 0;
|
int prevCodepointSize = 0;
|
||||||
|
|
||||||
GetCodepointPrevious(text + textBoxCursorIndex, &prevCodepointSize);
|
GetCodepointPrevious(text + textBoxCursorIndex, &prevCodepointSize);
|
||||||
@ -2731,9 +2744,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)))
|
if ((textBoxCursorIndex > 0) && IsKeyPressed(KEY_LEFT) && (IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_RIGHT_CONTROL)))
|
||||||
{
|
{
|
||||||
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)
|
||||||
@ -2742,7 +2755,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
if (!isspace(prevCodepoint & 0xff)) break;
|
if (!isspace(prevCodepoint & 0xff)) break;
|
||||||
|
|
||||||
offset -= prevCodepointSize;
|
offset -= prevCodepointSize;
|
||||||
accCodepointSize += prevCodepointSize;
|
//accCodepointSize += prevCodepointSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check characters of the same type to skip (either ASCII punctuation or anything non-whitespace)
|
// Check characters of the same type to skip (either ASCII punctuation or anything non-whitespace)
|
||||||
@ -2754,7 +2767,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
if ((puctuation && !ispunct(prevCodepoint & 0xff)) || (!puctuation && (isspace(prevCodepoint & 0xff) || ispunct(prevCodepoint & 0xff)))) break;
|
if ((puctuation && !ispunct(prevCodepoint & 0xff)) || (!puctuation && (isspace(prevCodepoint & 0xff) || ispunct(prevCodepoint & 0xff)))) break;
|
||||||
|
|
||||||
offset -= prevCodepointSize;
|
offset -= prevCodepointSize;
|
||||||
accCodepointSize += prevCodepointSize;
|
//accCodepointSize += prevCodepointSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
textBoxCursorIndex = offset;
|
textBoxCursorIndex = offset;
|
||||||
@ -2769,7 +2782,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)))
|
else if ((textLength > textBoxCursorIndex) && IsKeyPressed(KEY_RIGHT) && (IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_RIGHT_CONTROL)))
|
||||||
{
|
{
|
||||||
int offset = textBoxCursorIndex;
|
int offset = textBoxCursorIndex;
|
||||||
int accCodepointSize = 0;
|
//int accCodepointSize = 0;
|
||||||
int nextCodepointSize;
|
int nextCodepointSize;
|
||||||
int nextCodepoint;
|
int nextCodepoint;
|
||||||
|
|
||||||
@ -2782,7 +2795,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
if ((puctuation && !ispunct(nextCodepoint & 0xff)) || (!puctuation && (isspace(nextCodepoint & 0xff) || ispunct(nextCodepoint & 0xff)))) break;
|
if ((puctuation && !ispunct(nextCodepoint & 0xff)) || (!puctuation && (isspace(nextCodepoint & 0xff) || ispunct(nextCodepoint & 0xff)))) break;
|
||||||
|
|
||||||
offset += nextCodepointSize;
|
offset += nextCodepointSize;
|
||||||
accCodepointSize += nextCodepointSize;
|
//accCodepointSize += nextCodepointSize;
|
||||||
nextCodepoint = GetCodepointNext(text + offset, &nextCodepointSize);
|
nextCodepoint = GetCodepointNext(text + offset, &nextCodepointSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2792,7 +2805,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
if (!isspace(nextCodepoint & 0xff)) break;
|
if (!isspace(nextCodepoint & 0xff)) break;
|
||||||
|
|
||||||
offset += nextCodepointSize;
|
offset += nextCodepointSize;
|
||||||
accCodepointSize += nextCodepointSize;
|
//accCodepointSize += nextCodepointSize;
|
||||||
nextCodepoint = GetCodepointNext(text + offset, &nextCodepointSize);
|
nextCodepoint = GetCodepointNext(text + offset, &nextCodepointSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3021,7 +3034,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 };
|
||||||
@ -3039,7 +3052,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)
|
||||||
@ -3053,14 +3065,12 @@ int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, in
|
|||||||
{
|
{
|
||||||
if (textValue[0] == '-')
|
if (textValue[0] == '-')
|
||||||
{
|
{
|
||||||
for (int i = 0 ; i < keyCount; i++)
|
for (int i = 0 ; i < keyCount; i++) textValue[i] = textValue[i + 1];
|
||||||
{
|
|
||||||
textValue[i] = textValue[i + 1];
|
|
||||||
}
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
@ -3077,30 +3087,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);
|
||||||
@ -3172,7 +3178,7 @@ int GuiValueBoxFloat(Rectangle bounds, const char *text, char *textValue, float
|
|||||||
//char textValue[RAYGUI_VALUEBOX_MAX_CHARS + 1] = "\0";
|
//char textValue[RAYGUI_VALUEBOX_MAX_CHARS + 1] = "\0";
|
||||||
//snprintf(textValue, sizeof(textValue), "%2.2f", *value);
|
//snprintf(textValue, sizeof(textValue), "%2.2f", *value);
|
||||||
|
|
||||||
Rectangle textBounds = {0};
|
Rectangle textBounds = { 0 };
|
||||||
if (text != NULL)
|
if (text != NULL)
|
||||||
{
|
{
|
||||||
textBounds.width = (float)GuiGetTextWidth(text) + 2;
|
textBounds.width = (float)GuiGetTextWidth(text) + 2;
|
||||||
@ -3201,26 +3207,25 @@ int GuiValueBoxFloat(Rectangle bounds, const char *text, char *textValue, float
|
|||||||
{
|
{
|
||||||
if (textValue[0] == '-')
|
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];
|
if (keyCount == 0)
|
||||||
}
|
{
|
||||||
keyCount--;
|
textValue[0] = '0';
|
||||||
valueHasChanged = true;
|
textValue[1] = '\0';
|
||||||
}
|
keyCount++;
|
||||||
else if (keyCount < RAYGUI_VALUEBOX_MAX_CHARS - 1) {
|
}
|
||||||
if (keyCount == 0) {
|
|
||||||
textValue[0] = '0';
|
for (int i = keyCount; i > -1; i--) textValue[i + 1] = textValue[i];
|
||||||
textValue[1] = '\0';
|
|
||||||
|
textValue[0] = '-';
|
||||||
keyCount++;
|
keyCount++;
|
||||||
}
|
valueHasChanged = true;
|
||||||
for (int i = keyCount; i > -1; i--)
|
|
||||||
{
|
|
||||||
textValue[i + 1] = textValue[i];
|
|
||||||
}
|
|
||||||
textValue[0] = '-';
|
|
||||||
keyCount++;
|
|
||||||
valueHasChanged = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4194,6 +4199,9 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co
|
|||||||
GuiSetStyle(LABEL, TEXT_ALIGNMENT, prevTextAlignment);
|
GuiSetStyle(LABEL, TEXT_ALIGNMENT, prevTextAlignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int prevTextBoxAlignment = GuiGetStyle(TEXTBOX, TEXT_ALIGNMENT);
|
||||||
|
GuiSetStyle(TEXTBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
|
||||||
|
|
||||||
if (secretViewActive != NULL)
|
if (secretViewActive != NULL)
|
||||||
{
|
{
|
||||||
static char stars[] = "****************";
|
static char stars[] = "****************";
|
||||||
@ -4207,6 +4215,8 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co
|
|||||||
if (GuiTextBox(textBoxBounds, text, textMaxSize, textEditMode)) textEditMode = !textEditMode;
|
if (GuiTextBox(textBoxBounds, text, textMaxSize, textEditMode)) textEditMode = !textEditMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GuiSetStyle(TEXTBOX, TEXT_ALIGNMENT, prevTextBoxAlignment);
|
||||||
|
|
||||||
int prevBtnTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT);
|
int prevBtnTextAlignment = GuiGetStyle(BUTTON, TEXT_ALIGNMENT);
|
||||||
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
|
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
|
||||||
|
|
||||||
@ -4227,7 +4237,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
|
||||||
@ -4405,7 +4415,7 @@ void GuiLoadStyle(const char *fileName)
|
|||||||
|
|
||||||
if (fileDataSize > 0)
|
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);
|
fread(fileData, sizeof(unsigned char), fileDataSize, rgsFile);
|
||||||
|
|
||||||
GuiLoadStyleFromMemory(fileData, fileDataSize);
|
GuiLoadStyleFromMemory(fileData, fileDataSize);
|
||||||
@ -4613,10 +4623,10 @@ char **GuiLoadIcons(const char *fileName, bool loadIconsName)
|
|||||||
{
|
{
|
||||||
if (loadIconsName)
|
if (loadIconsName)
|
||||||
{
|
{
|
||||||
guiIconsName = (char **)RAYGUI_MALLOC(iconCount*sizeof(char **));
|
guiIconsName = (char **)RAYGUI_CALLOC(iconCount, sizeof(char *));
|
||||||
for (int i = 0; i < iconCount; i++)
|
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);
|
fread(guiIconsName[i], 1, RAYGUI_ICON_MAX_NAME_LENGTH, rgiFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4659,10 +4669,10 @@ char **GuiLoadIconsFromMemory(const unsigned char *fileData, int dataSize, bool
|
|||||||
{
|
{
|
||||||
if (loadIconsName)
|
if (loadIconsName)
|
||||||
{
|
{
|
||||||
guiIconsName = (char **)RAYGUI_MALLOC(iconCount*sizeof(char *));
|
guiIconsName = (char **)RAYGUI_CALLOC(iconCount, sizeof(char *));
|
||||||
for (int i = 0; i < iconCount; i++)
|
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);
|
memcpy(guiIconsName[i], fileDataPtr, RAYGUI_ICON_MAX_NAME_LENGTH);
|
||||||
fileDataPtr += RAYGUI_ICON_MAX_NAME_LENGTH;
|
fileDataPtr += RAYGUI_ICON_MAX_NAME_LENGTH;
|
||||||
}
|
}
|
||||||
@ -4674,7 +4684,7 @@ char **GuiLoadIconsFromMemory(const unsigned char *fileData, int dataSize, bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
int iconDataSize = iconCount*((int)iconSize*(int)iconSize/32)*(int)sizeof(unsigned int);
|
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);
|
memcpy(guiIconsPtr, fileDataPtr, iconDataSize);
|
||||||
}
|
}
|
||||||
@ -4774,9 +4784,8 @@ int GuiGetTextWidth(const char *text)
|
|||||||
#endif // !RAYGUI_NO_ICONS
|
#endif // !RAYGUI_NO_ICONS
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module specific Functions Definition
|
// Module Internal Functions Definition
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Load style from memory
|
// Load style from memory
|
||||||
// WARNING: Binary files only
|
// WARNING: Binary files only
|
||||||
static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
|
static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
|
||||||
@ -4862,7 +4871,7 @@ static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
|
|||||||
{
|
{
|
||||||
// Compressed font atlas image data (DEFLATE), it requires DecompressData()
|
// Compressed font atlas image data (DEFLATE), it requires DecompressData()
|
||||||
int dataUncompSize = 0;
|
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);
|
memcpy(compData, fileDataPtr, fontImageCompSize);
|
||||||
fileDataPtr += fontImageCompSize;
|
fileDataPtr += fontImageCompSize;
|
||||||
|
|
||||||
@ -4876,7 +4885,7 @@ static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Font atlas image data is not compressed
|
// 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);
|
memcpy(imFont.data, fileDataPtr, fontImageUncompSize);
|
||||||
fileDataPtr += fontImageUncompSize;
|
fileDataPtr += fontImageUncompSize;
|
||||||
}
|
}
|
||||||
@ -4904,7 +4913,7 @@ static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
|
|||||||
if ((recsDataCompressedSize > 0) && (recsDataCompressedSize != recsDataSize))
|
if ((recsDataCompressedSize > 0) && (recsDataCompressedSize != recsDataSize))
|
||||||
{
|
{
|
||||||
// Recs data is compressed, uncompress it
|
// 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);
|
memcpy(recsDataCompressed, fileDataPtr, recsDataCompressedSize);
|
||||||
fileDataPtr += recsDataCompressedSize;
|
fileDataPtr += recsDataCompressedSize;
|
||||||
@ -4946,7 +4955,7 @@ static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
|
|||||||
if ((glyphsDataCompressedSize > 0) && (glyphsDataCompressedSize != glyphsDataSize))
|
if ((glyphsDataCompressedSize > 0) && (glyphsDataCompressedSize != glyphsDataSize))
|
||||||
{
|
{
|
||||||
// Glyphs data is compressed, uncompress it
|
// 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);
|
memcpy(glypsDataCompressed, fileDataPtr, glyphsDataCompressedSize);
|
||||||
fileDataPtr += glyphsDataCompressedSize;
|
fileDataPtr += glyphsDataCompressedSize;
|
||||||
@ -5065,6 +5074,7 @@ static const char *GetTextIcon(const char *text, int *iconId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get text divided into lines (by line-breaks '\n')
|
// 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)
|
static const char **GetTextLines(const char *text, int *count)
|
||||||
{
|
{
|
||||||
#define RAYGUI_MAX_TEXT_LINES 128
|
#define RAYGUI_MAX_TEXT_LINES 128
|
||||||
@ -5072,28 +5082,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5869,7 +5872,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;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,7 +30,7 @@ static const GuiStyleProp amberStyleProps[AMBER_STYLE_PROPS_COUNT] = {
|
|||||||
{ 0, 16, (int)0x00000010 }, // DEFAULT_TEXT_SIZE
|
{ 0, 16, (int)0x00000010 }, // DEFAULT_TEXT_SIZE
|
||||||
{ 0, 18, (int)0xef922aff }, // DEFAULT_LINE_COLOR
|
{ 0, 18, (int)0xef922aff }, // DEFAULT_LINE_COLOR
|
||||||
{ 0, 19, (int)0x333333ff }, // DEFAULT_BACKGROUND_COLOR
|
{ 0, 19, (int)0x333333ff }, // DEFAULT_BACKGROUND_COLOR
|
||||||
{ 0, 20, (int)0x00000018 }, // DEFAULT_TEXT_LINE_SPACING
|
{ 0, 20, (int)0x00000008 }, // DEFAULT_TEXT_LINE_SPACING
|
||||||
{ 1, 8, (int)0xe7e0d4ff }, // LABEL_TEXT_COLOR_PRESSED
|
{ 1, 8, (int)0xe7e0d4ff }, // LABEL_TEXT_COLOR_PRESSED
|
||||||
{ 4, 8, (int)0xf1cf9dff }, // SLIDER_TEXT_COLOR_PRESSED
|
{ 4, 8, (int)0xf1cf9dff }, // SLIDER_TEXT_COLOR_PRESSED
|
||||||
};
|
};
|
||||||
|
|||||||
@ -30,7 +30,7 @@ static const GuiStyleProp ashesStyleProps[ASHES_STYLE_PROPS_COUNT] = {
|
|||||||
{ 0, 16, (int)0x00000010 }, // DEFAULT_TEXT_SIZE
|
{ 0, 16, (int)0x00000010 }, // DEFAULT_TEXT_SIZE
|
||||||
{ 0, 18, (int)0x9dadb1ff }, // DEFAULT_LINE_COLOR
|
{ 0, 18, (int)0x9dadb1ff }, // DEFAULT_LINE_COLOR
|
||||||
{ 0, 19, (int)0x6b6b6bff }, // DEFAULT_BACKGROUND_COLOR
|
{ 0, 19, (int)0x6b6b6bff }, // DEFAULT_BACKGROUND_COLOR
|
||||||
{ 0, 20, (int)0x00000018 }, // DEFAULT_TEXT_LINE_SPACING
|
{ 0, 20, (int)0x00000008 }, // DEFAULT_TEXT_LINE_SPACING
|
||||||
};
|
};
|
||||||
|
|
||||||
// WARNING: This style uses a custom font: "v5loxical.ttf" (size: 16, spacing: 1)
|
// WARNING: This style uses a custom font: "v5loxical.ttf" (size: 16, spacing: 1)
|
||||||
|
|||||||
@ -31,7 +31,7 @@ static const GuiStyleProp candyStyleProps[CANDY_STYLE_PROPS_COUNT] = {
|
|||||||
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
||||||
{ 0, 18, (int)0xd77575ff }, // DEFAULT_LINE_COLOR
|
{ 0, 18, (int)0xd77575ff }, // DEFAULT_LINE_COLOR
|
||||||
{ 0, 19, (int)0xfff5e1ff }, // DEFAULT_BACKGROUND_COLOR
|
{ 0, 19, (int)0xfff5e1ff }, // DEFAULT_BACKGROUND_COLOR
|
||||||
{ 0, 20, (int)0x00000016 }, // DEFAULT_TEXT_LINE_SPACING
|
{ 0, 20, (int)0x00000007 }, // DEFAULT_TEXT_LINE_SPACING
|
||||||
};
|
};
|
||||||
|
|
||||||
// WARNING: This style uses a custom font: "v5easter.ttf" (size: 15, spacing: 0)
|
// WARNING: This style uses a custom font: "v5easter.ttf" (size: 15, spacing: 0)
|
||||||
|
|||||||
@ -31,7 +31,7 @@ static const GuiStyleProp cherryStyleProps[CHERRY_STYLE_PROPS_COUNT] = {
|
|||||||
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
||||||
{ 0, 18, (int)0xfb8170ff }, // DEFAULT_LINE_COLOR
|
{ 0, 18, (int)0xfb8170ff }, // DEFAULT_LINE_COLOR
|
||||||
{ 0, 19, (int)0x3a1720ff }, // DEFAULT_BACKGROUND_COLOR
|
{ 0, 19, (int)0x3a1720ff }, // DEFAULT_BACKGROUND_COLOR
|
||||||
{ 0, 20, (int)0x00000016 }, // DEFAULT_TEXT_LINE_SPACING
|
{ 0, 20, (int)0x00000007 }, // DEFAULT_TEXT_LINE_SPACING
|
||||||
};
|
};
|
||||||
|
|
||||||
// WARNING: This style uses a custom font: "Westington.ttf" (size: 15, spacing: 0)
|
// WARNING: This style uses a custom font: "Westington.ttf" (size: 15, spacing: 0)
|
||||||
|
|||||||
@ -31,7 +31,7 @@ static const GuiStyleProp cyberStyleProps[CYBER_STYLE_PROPS_COUNT] = {
|
|||||||
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
||||||
{ 0, 18, (int)0x81c0d0ff }, // DEFAULT_LINE_COLOR
|
{ 0, 18, (int)0x81c0d0ff }, // DEFAULT_LINE_COLOR
|
||||||
{ 0, 19, (int)0x00222bff }, // DEFAULT_BACKGROUND_COLOR
|
{ 0, 19, (int)0x00222bff }, // DEFAULT_BACKGROUND_COLOR
|
||||||
{ 0, 20, (int)0x00000015 }, // DEFAULT_TEXT_LINE_SPACING
|
{ 0, 20, (int)0x00000007 }, // DEFAULT_TEXT_LINE_SPACING
|
||||||
};
|
};
|
||||||
|
|
||||||
// WARNING: This style uses a custom font: "Kyrou7Wide.ttf" (size: 14, spacing: 0)
|
// WARNING: This style uses a custom font: "Kyrou7Wide.ttf" (size: 14, spacing: 0)
|
||||||
|
|||||||
@ -31,7 +31,7 @@ static const GuiStyleProp darkStyleProps[DARK_STYLE_PROPS_COUNT] = {
|
|||||||
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
||||||
{ 0, 18, (int)0x9d9d9dff }, // DEFAULT_LINE_COLOR
|
{ 0, 18, (int)0x9d9d9dff }, // DEFAULT_LINE_COLOR
|
||||||
{ 0, 19, (int)0x3c3c3cff }, // DEFAULT_BACKGROUND_COLOR
|
{ 0, 19, (int)0x3c3c3cff }, // DEFAULT_BACKGROUND_COLOR
|
||||||
{ 0, 20, (int)0x00000018 }, // DEFAULT_TEXT_LINE_SPACING
|
{ 0, 20, (int)0x00000008 }, // DEFAULT_TEXT_LINE_SPACING
|
||||||
{ 1, 5, (int)0xf7f7f7ff }, // LABEL_TEXT_COLOR_FOCUSED
|
{ 1, 5, (int)0xf7f7f7ff }, // LABEL_TEXT_COLOR_FOCUSED
|
||||||
{ 1, 8, (int)0x898989ff }, // LABEL_TEXT_COLOR_PRESSED
|
{ 1, 8, (int)0x898989ff }, // LABEL_TEXT_COLOR_PRESSED
|
||||||
{ 4, 5, (int)0xb0b0b0ff }, // SLIDER_TEXT_COLOR_FOCUSED
|
{ 4, 5, (int)0xb0b0b0ff }, // SLIDER_TEXT_COLOR_FOCUSED
|
||||||
|
|||||||
@ -19,4 +19,4 @@ Several options are provided to add the style to a `raygui` application, choose
|
|||||||
|
|
||||||
## about font
|
## about font
|
||||||
|
|
||||||
raylib font by Ramon Santamaria ([@raysan5](https://twitter.com/raysan5)).
|
raylib font by Ramon Santamaria ([@raysan5](https://github.com/raysan5)).
|
||||||
|
|||||||
@ -31,7 +31,7 @@ static const GuiStyleProp enefeteStyleProps[ENEFETE_STYLE_PROPS_COUNT] = {
|
|||||||
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
||||||
{ 0, 18, (int)0x1d3f6cff }, // DEFAULT_LINE_COLOR
|
{ 0, 18, (int)0x1d3f6cff }, // DEFAULT_LINE_COLOR
|
||||||
{ 0, 19, (int)0x29c9e5ff }, // DEFAULT_BACKGROUND_COLOR
|
{ 0, 19, (int)0x29c9e5ff }, // DEFAULT_BACKGROUND_COLOR
|
||||||
{ 0, 20, (int)0x00000018 }, // DEFAULT_TEXT_LINE_SPACING
|
{ 0, 20, (int)0x00000008 }, // DEFAULT_TEXT_LINE_SPACING
|
||||||
};
|
};
|
||||||
|
|
||||||
// WARNING: This style uses a custom font: "GMSN.ttf" (size: 16, spacing: 0)
|
// WARNING: This style uses a custom font: "GMSN.ttf" (size: 16, spacing: 0)
|
||||||
|
|||||||
@ -31,7 +31,7 @@ static const GuiStyleProp genesisStyleProps[GENESIS_STYLE_PROPS_COUNT] = {
|
|||||||
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
||||||
{ 0, 18, (int)0x96a3b4ff }, // DEFAULT_LINE_COLOR
|
{ 0, 18, (int)0x96a3b4ff }, // DEFAULT_LINE_COLOR
|
||||||
{ 0, 19, (int)0x292c33ff }, // DEFAULT_BACKGROUND_COLOR
|
{ 0, 19, (int)0x292c33ff }, // DEFAULT_BACKGROUND_COLOR
|
||||||
{ 0, 20, (int)0x00000018 }, // DEFAULT_TEXT_LINE_SPACING
|
{ 0, 20, (int)0x00000008 }, // DEFAULT_TEXT_LINE_SPACING
|
||||||
{ 1, 5, (int)0x97a9aeff }, // LABEL_TEXT_COLOR_FOCUSED
|
{ 1, 5, (int)0x97a9aeff }, // LABEL_TEXT_COLOR_FOCUSED
|
||||||
{ 4, 5, (int)0xa69a9aff }, // SLIDER_TEXT_COLOR_FOCUSED
|
{ 4, 5, (int)0xa69a9aff }, // SLIDER_TEXT_COLOR_FOCUSED
|
||||||
{ 4, 6, (int)0xc3ccd5ff }, // SLIDER_BORDER_COLOR_PRESSED
|
{ 4, 6, (int)0xc3ccd5ff }, // SLIDER_BORDER_COLOR_PRESSED
|
||||||
|
|||||||
@ -31,7 +31,7 @@ static const GuiStyleProp jungleStyleProps[JUNGLE_STYLE_PROPS_COUNT] = {
|
|||||||
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
||||||
{ 0, 18, (int)0x638465ff }, // DEFAULT_LINE_COLOR
|
{ 0, 18, (int)0x638465ff }, // DEFAULT_LINE_COLOR
|
||||||
{ 0, 19, (int)0x2b3a3aff }, // DEFAULT_BACKGROUND_COLOR
|
{ 0, 19, (int)0x2b3a3aff }, // DEFAULT_BACKGROUND_COLOR
|
||||||
{ 0, 20, (int)0x00000012 }, // DEFAULT_TEXT_LINE_SPACING
|
{ 0, 20, (int)0x00000006 }, // DEFAULT_TEXT_LINE_SPACING
|
||||||
};
|
};
|
||||||
|
|
||||||
// WARNING: This style uses a custom font: "PixelIntv.otf" (size: 12, spacing: 0)
|
// WARNING: This style uses a custom font: "PixelIntv.otf" (size: 12, spacing: 0)
|
||||||
|
|||||||
@ -30,7 +30,7 @@ static const GuiStyleProp lavandaStyleProps[LAVANDA_STYLE_PROPS_COUNT] = {
|
|||||||
{ 0, 16, (int)0x00000010 }, // DEFAULT_TEXT_SIZE
|
{ 0, 16, (int)0x00000010 }, // DEFAULT_TEXT_SIZE
|
||||||
{ 0, 18, (int)0x84adb7ff }, // DEFAULT_LINE_COLOR
|
{ 0, 18, (int)0x84adb7ff }, // DEFAULT_LINE_COLOR
|
||||||
{ 0, 19, (int)0x5b5b81ff }, // DEFAULT_BACKGROUND_COLOR
|
{ 0, 19, (int)0x5b5b81ff }, // DEFAULT_BACKGROUND_COLOR
|
||||||
{ 0, 20, (int)0x00000018 }, // DEFAULT_TEXT_LINE_SPACING
|
{ 0, 20, (int)0x00000008 }, // DEFAULT_TEXT_LINE_SPACING
|
||||||
};
|
};
|
||||||
|
|
||||||
// WARNING: This style uses a custom font: "Cartridge.ttf" (size: 16, spacing: 1)
|
// WARNING: This style uses a custom font: "Cartridge.ttf" (size: 16, spacing: 1)
|
||||||
|
|||||||
@ -29,7 +29,7 @@ static const GuiStyleProp rltechStyleProps[RLTECH_STYLE_PROPS_COUNT] = {
|
|||||||
{ 0, 11, (int)0xb3b3b3ff }, // DEFAULT_TEXT_COLOR_DISABLED
|
{ 0, 11, (int)0xb3b3b3ff }, // DEFAULT_TEXT_COLOR_DISABLED
|
||||||
{ 0, 16, (int)0x00000010 }, // DEFAULT_TEXT_SIZE
|
{ 0, 16, (int)0x00000010 }, // DEFAULT_TEXT_SIZE
|
||||||
{ 0, 18, (int)0x352c2cff }, // DEFAULT_LINE_COLOR
|
{ 0, 18, (int)0x352c2cff }, // DEFAULT_LINE_COLOR
|
||||||
{ 0, 20, (int)0x00000018 }, // DEFAULT_TEXT_LINE_SPACING
|
{ 0, 20, (int)0x00000008 }, // DEFAULT_TEXT_LINE_SPACING
|
||||||
};
|
};
|
||||||
|
|
||||||
// WARNING: This style uses a custom font: "2a03.ttf" (size: 16, spacing: 1)
|
// WARNING: This style uses a custom font: "2a03.ttf" (size: 16, spacing: 1)
|
||||||
|
|||||||
@ -31,7 +31,7 @@ static const GuiStyleProp sunnyStyleProps[SUNNY_STYLE_PROPS_COUNT] = {
|
|||||||
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
||||||
{ 0, 18, (int)0x725706ff }, // DEFAULT_LINE_COLOR
|
{ 0, 18, (int)0x725706ff }, // DEFAULT_LINE_COLOR
|
||||||
{ 0, 19, (int)0xf0be4bff }, // DEFAULT_BACKGROUND_COLOR
|
{ 0, 19, (int)0xf0be4bff }, // DEFAULT_BACKGROUND_COLOR
|
||||||
{ 0, 20, (int)0x00000018 }, // DEFAULT_TEXT_LINE_SPACING
|
{ 0, 20, (int)0x00000008 }, // DEFAULT_TEXT_LINE_SPACING
|
||||||
{ 1, 2, (int)0x504506ff }, // LABEL_TEXT_COLOR_NORMAL
|
{ 1, 2, (int)0x504506ff }, // LABEL_TEXT_COLOR_NORMAL
|
||||||
{ 1, 5, (int)0xfdeb9bff }, // LABEL_TEXT_COLOR_FOCUSED
|
{ 1, 5, (int)0xfdeb9bff }, // LABEL_TEXT_COLOR_FOCUSED
|
||||||
{ 1, 8, (int)0xf5e8a4ff }, // LABEL_TEXT_COLOR_PRESSED
|
{ 1, 8, (int)0xf5e8a4ff }, // LABEL_TEXT_COLOR_PRESSED
|
||||||
|
|||||||
@ -31,7 +31,7 @@ static const GuiStyleProp terminalStyleProps[TERMINAL_STYLE_PROPS_COUNT] = {
|
|||||||
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
{ 0, 17, (int)0x00000000 }, // DEFAULT_TEXT_SPACING
|
||||||
{ 0, 18, (int)0xe6fce3ff }, // DEFAULT_LINE_COLOR
|
{ 0, 18, (int)0xe6fce3ff }, // DEFAULT_LINE_COLOR
|
||||||
{ 0, 19, (int)0x0c1505ff }, // DEFAULT_BACKGROUND_COLOR
|
{ 0, 19, (int)0x0c1505ff }, // DEFAULT_BACKGROUND_COLOR
|
||||||
{ 0, 20, (int)0x00000018 }, // DEFAULT_TEXT_LINE_SPACING
|
{ 0, 20, (int)0x00000008 }, // DEFAULT_TEXT_LINE_SPACING
|
||||||
};
|
};
|
||||||
|
|
||||||
// WARNING: This style uses a custom font: "Mecha.ttf" (size: 16, spacing: 0)
|
// WARNING: This style uses a custom font: "Mecha.ttf" (size: 16, spacing: 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user