Update raygui.h
This commit is contained in:
parent
700e2c5e5d
commit
14d3bbbb86
@ -998,7 +998,7 @@ typedef enum {
|
|||||||
ICON_LAYERS2 = 225,
|
ICON_LAYERS2 = 225,
|
||||||
ICON_MLAYERS = 226,
|
ICON_MLAYERS = 226,
|
||||||
ICON_MAPS = 227,
|
ICON_MAPS = 227,
|
||||||
ICON_228 = 228,
|
ICON_HOT = 228,
|
||||||
ICON_229 = 229,
|
ICON_229 = 229,
|
||||||
ICON_230 = 230,
|
ICON_230 = 230,
|
||||||
ICON_231 = 231,
|
ICON_231 = 231,
|
||||||
@ -1045,6 +1045,7 @@ typedef enum {
|
|||||||
|
|
||||||
#if defined(RAYGUI_IMPLEMENTATION)
|
#if defined(RAYGUI_IMPLEMENTATION)
|
||||||
|
|
||||||
|
#include <ctype.h> // required for: isspace() [GuiTextBox()]
|
||||||
#include <stdio.h> // Required for: FILE, fopen(), fclose(), fprintf(), feof(), fscanf(), vsprintf() [GuiLoadStyle(), GuiLoadIcons()]
|
#include <stdio.h> // Required for: FILE, fopen(), fclose(), fprintf(), feof(), fscanf(), vsprintf() [GuiLoadStyle(), GuiLoadIcons()]
|
||||||
#include <stdlib.h> // Required for: malloc(), calloc(), free() [GuiLoadStyle(), GuiLoadIcons()]
|
#include <stdlib.h> // Required for: malloc(), calloc(), free() [GuiLoadStyle(), GuiLoadIcons()]
|
||||||
#include <string.h> // Required for: strlen() [GuiTextBox(), GuiValueBox()], memset(), memcpy()
|
#include <string.h> // Required for: strlen() [GuiTextBox(), GuiValueBox()], memset(), memcpy()
|
||||||
@ -1316,7 +1317,7 @@ static unsigned int guiIcons[RAYGUI_ICON_MAX_ICONS*RAYGUI_ICON_DATA_ELEMENTS] =
|
|||||||
0x07fe0000, 0x1c020402, 0x74021402, 0x54025402, 0x54025402, 0x500857fe, 0x40205ff8, 0x00007fe0, // ICON_LAYERS2
|
0x07fe0000, 0x1c020402, 0x74021402, 0x54025402, 0x54025402, 0x500857fe, 0x40205ff8, 0x00007fe0, // ICON_LAYERS2
|
||||||
0x0ffe0000, 0x3ffa0802, 0x7fea200a, 0x402a402a, 0x422a422a, 0x422e422a, 0x40384e28, 0x00007fe0, // ICON_MLAYERS
|
0x0ffe0000, 0x3ffa0802, 0x7fea200a, 0x402a402a, 0x422a422a, 0x422e422a, 0x40384e28, 0x00007fe0, // ICON_MLAYERS
|
||||||
0x0ffe0000, 0x3ffa0802, 0x7fea200a, 0x402a402a, 0x5b2a512a, 0x512e552a, 0x40385128, 0x00007fe0, // ICON_MAPS
|
0x0ffe0000, 0x3ffa0802, 0x7fea200a, 0x402a402a, 0x5b2a512a, 0x512e552a, 0x40385128, 0x00007fe0, // ICON_MAPS
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_228
|
0x04200000, 0x1cf00c60, 0x11f019f0, 0x0f3807b8, 0x1e3c0f3c, 0x1c1c1e1c, 0x1e3c1c1c, 0x00000f70, // ICON_HOT
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_229
|
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_229
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_230
|
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_230
|
||||||
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_231
|
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, // ICON_231
|
||||||
@ -1639,9 +1640,9 @@ int GuiGroupBox(Rectangle bounds, const char *text)
|
|||||||
|
|
||||||
// Draw control
|
// Draw control
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y, RAYGUI_GROUPBOX_LINE_THICK, bounds.height }, 0, BLANK, GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)));
|
GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y, RAYGUI_GROUPBOX_LINE_THICK, bounds.height }, 0, BLANK, GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? (int)BORDER_COLOR_DISABLED : (int)LINE_COLOR)));
|
||||||
GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y + bounds.height - 1, bounds.width, RAYGUI_GROUPBOX_LINE_THICK }, 0, BLANK, GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)));
|
GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y + bounds.height - 1, bounds.width, RAYGUI_GROUPBOX_LINE_THICK }, 0, BLANK, GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? (int)BORDER_COLOR_DISABLED : (int)LINE_COLOR)));
|
||||||
GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x + bounds.width - 1, bounds.y, RAYGUI_GROUPBOX_LINE_THICK, bounds.height }, 0, BLANK, GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR)));
|
GuiDrawRectangle(RAYGUI_CLITERAL(Rectangle){ bounds.x + bounds.width - 1, bounds.y, RAYGUI_GROUPBOX_LINE_THICK, bounds.height }, 0, BLANK, GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? (int)BORDER_COLOR_DISABLED : (int)LINE_COLOR)));
|
||||||
|
|
||||||
GuiLine(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y - GuiGetStyle(DEFAULT, TEXT_SIZE)/2, bounds.width, (float)GuiGetStyle(DEFAULT, TEXT_SIZE) }, text);
|
GuiLine(RAYGUI_CLITERAL(Rectangle){ bounds.x, bounds.y - GuiGetStyle(DEFAULT, TEXT_SIZE)/2, bounds.width, (float)GuiGetStyle(DEFAULT, TEXT_SIZE) }, text);
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
@ -1662,7 +1663,7 @@ int GuiLine(Rectangle bounds, const char *text)
|
|||||||
int result = 0;
|
int result = 0;
|
||||||
GuiState state = guiState;
|
GuiState state = guiState;
|
||||||
|
|
||||||
Color color = GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED : LINE_COLOR));
|
Color color = GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? (int)BORDER_COLOR_DISABLED : (int)LINE_COLOR));
|
||||||
|
|
||||||
// Draw control
|
// Draw control
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
@ -1710,7 +1711,7 @@ int GuiPanel(Rectangle bounds, const char *text)
|
|||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
if (text != NULL) GuiStatusBar(statusBar, text); // Draw panel header as status bar
|
if (text != NULL) GuiStatusBar(statusBar, text); // Draw panel header as status bar
|
||||||
|
|
||||||
GuiDrawRectangle(bounds, RAYGUI_PANEL_BORDER_WIDTH, GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BORDER_COLOR_DISABLED: LINE_COLOR)),
|
GuiDrawRectangle(bounds, RAYGUI_PANEL_BORDER_WIDTH, GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? (int)BORDER_COLOR_DISABLED: (int)LINE_COLOR)),
|
||||||
GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BASE_COLOR_DISABLED : BACKGROUND_COLOR)));
|
GetColor(GuiGetStyle(DEFAULT, (state == STATE_DISABLED)? BASE_COLOR_DISABLED : BACKGROUND_COLOR)));
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
@ -2603,24 +2604,59 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete codepoint from text, before current cursor position
|
// Delete related codepoints from text, before current cursor position
|
||||||
if ((textLength > 0) && (IsKeyPressed(KEY_BACKSPACE) || (IsKeyDown(KEY_BACKSPACE) && (autoCursorCooldownCounter >= RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN))))
|
if ((textLength > 0) && IsKeyPressed(KEY_BACKSPACE) && (IsKeyDown(KEY_LEFT_CONTROL) || IsKeyDown(KEY_RIGHT_CONTROL)))
|
||||||
|
{
|
||||||
|
int i = textBoxCursorIndex - 1;
|
||||||
|
int accCodepointSize = 0;
|
||||||
|
|
||||||
|
// Move cursor to the end of word if on space already
|
||||||
|
while ((i > 0) && isspace(text[i]))
|
||||||
|
{
|
||||||
|
int prevCodepointSize = 0;
|
||||||
|
GetCodepointPrevious(text + i, &prevCodepointSize);
|
||||||
|
i -= prevCodepointSize;
|
||||||
|
accCodepointSize += prevCodepointSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move cursor to the start of the word
|
||||||
|
while ((i > 0) && !isspace(text[i]))
|
||||||
|
{
|
||||||
|
int prevCodepointSize = 0;
|
||||||
|
GetCodepointPrevious(text + i, &prevCodepointSize);
|
||||||
|
i -= prevCodepointSize;
|
||||||
|
accCodepointSize += prevCodepointSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move forward text from cursor position
|
||||||
|
for (int j = (textBoxCursorIndex - accCodepointSize); j < textLength; j++) text[j] = text[j + accCodepointSize];
|
||||||
|
|
||||||
|
// Prevent cursor index from decrementing past 0
|
||||||
|
if (textBoxCursorIndex > 0)
|
||||||
|
{
|
||||||
|
textBoxCursorIndex -= accCodepointSize;
|
||||||
|
textLength -= accCodepointSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure text last character is EOL
|
||||||
|
text[textLength] = '\0';
|
||||||
|
}
|
||||||
|
else if ((textLength > 0) && (IsKeyPressed(KEY_BACKSPACE) || (IsKeyDown(KEY_BACKSPACE) && (autoCursorCooldownCounter >= RAYGUI_TEXTBOX_AUTO_CURSOR_COOLDOWN))))
|
||||||
{
|
{
|
||||||
autoCursorDelayCounter++;
|
autoCursorDelayCounter++;
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_BACKSPACE) || (autoCursorDelayCounter%RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY) == 0) // Delay every movement some frames
|
if (IsKeyPressed(KEY_BACKSPACE) || (autoCursorDelayCounter%RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY) == 0) // Delay every movement some frames
|
||||||
{
|
{
|
||||||
int prevCodepointSize = 0;
|
int prevCodepointSize = 0;
|
||||||
GetCodepointPrevious(text + textBoxCursorIndex, &prevCodepointSize);
|
|
||||||
|
|
||||||
// Move backward text from cursor position
|
|
||||||
for (int i = (textBoxCursorIndex - prevCodepointSize); i < textLength; i++) text[i] = text[i + prevCodepointSize];
|
|
||||||
|
|
||||||
// TODO Check: >= cursor+codepointsize and <= length-codepointsize
|
|
||||||
|
|
||||||
// Prevent cursor index from decrementing past 0
|
// Prevent cursor index from decrementing past 0
|
||||||
if (textBoxCursorIndex > 0)
|
if (textBoxCursorIndex > 0)
|
||||||
{
|
{
|
||||||
|
GetCodepointPrevious(text + textBoxCursorIndex, &prevCodepointSize);
|
||||||
|
|
||||||
|
// Move backward text from cursor position
|
||||||
|
for (int i = (textBoxCursorIndex - prevCodepointSize); i < textLength; i++) text[i] = text[i + prevCodepointSize];
|
||||||
|
|
||||||
textBoxCursorIndex -= codepointSize;
|
textBoxCursorIndex -= codepointSize;
|
||||||
textLength -= codepointSize;
|
textLength -= codepointSize;
|
||||||
}
|
}
|
||||||
@ -2638,7 +2674,7 @@ int GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode)
|
|||||||
if (IsKeyPressed(KEY_LEFT) || (autoCursorDelayCounter%RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY) == 0) // Delay every movement some frames
|
if (IsKeyPressed(KEY_LEFT) || (autoCursorDelayCounter%RAYGUI_TEXTBOX_AUTO_CURSOR_DELAY) == 0) // Delay every movement some frames
|
||||||
{
|
{
|
||||||
int prevCodepointSize = 0;
|
int prevCodepointSize = 0;
|
||||||
GetCodepointPrevious(text + textBoxCursorIndex, &prevCodepointSize);
|
if (textBoxCursorIndex > 0) GetCodepointPrevious(text + textBoxCursorIndex, &prevCodepointSize);
|
||||||
|
|
||||||
if (textBoxCursorIndex >= prevCodepointSize) textBoxCursorIndex -= prevCodepointSize;
|
if (textBoxCursorIndex >= prevCodepointSize) textBoxCursorIndex -= prevCodepointSize;
|
||||||
}
|
}
|
||||||
@ -3426,7 +3462,7 @@ int GuiListViewEx(Rectangle bounds, const char **text, int count, int *scrollInd
|
|||||||
|
|
||||||
// Draw control
|
// Draw control
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
GuiDrawRectangle(bounds, GuiGetStyle(DEFAULT, BORDER_WIDTH), GetColor(GuiGetStyle(LISTVIEW, BORDER + state*3)), GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR))); // Draw background
|
GuiDrawRectangle(bounds, GuiGetStyle(LISTVIEW, BORDER_WIDTH), GetColor(GuiGetStyle(LISTVIEW, BORDER + state*3)), GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR))); // Draw background
|
||||||
|
|
||||||
// Draw visible items
|
// Draw visible items
|
||||||
for (int i = 0; ((i < visibleItems) && (text != NULL)); i++)
|
for (int i = 0; ((i < visibleItems) && (text != NULL)); i++)
|
||||||
@ -3881,7 +3917,7 @@ int GuiMessageBox(Rectangle bounds, const char *title, const char *message, cons
|
|||||||
buttonBounds.width = (bounds.width - RAYGUI_MESSAGEBOX_BUTTON_PADDING*(buttonCount + 1))/buttonCount;
|
buttonBounds.width = (bounds.width - RAYGUI_MESSAGEBOX_BUTTON_PADDING*(buttonCount + 1))/buttonCount;
|
||||||
buttonBounds.height = RAYGUI_MESSAGEBOX_BUTTON_HEIGHT;
|
buttonBounds.height = RAYGUI_MESSAGEBOX_BUTTON_HEIGHT;
|
||||||
|
|
||||||
int textWidth = GetTextWidth(message) + 2;
|
//int textWidth = GetTextWidth(message) + 2;
|
||||||
|
|
||||||
Rectangle textBounds = { 0 };
|
Rectangle textBounds = { 0 };
|
||||||
textBounds.x = bounds.x + RAYGUI_MESSAGEBOX_BUTTON_PADDING;
|
textBounds.x = bounds.x + RAYGUI_MESSAGEBOX_BUTTON_PADDING;
|
||||||
@ -4485,7 +4521,7 @@ static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
|
|||||||
// NOTE: All DEFAULT properties should be defined first in the file
|
// NOTE: All DEFAULT properties should be defined first in the file
|
||||||
GuiSetStyle(0, (int)propertyId, propertyValue);
|
GuiSetStyle(0, (int)propertyId, propertyValue);
|
||||||
|
|
||||||
if (propertyId < RAYGUI_MAX_PROPS_BASE) for (int i = 1; i < RAYGUI_MAX_CONTROLS; i++) GuiSetStyle(i, (int)propertyId, propertyValue);
|
if (propertyId < RAYGUI_MAX_PROPS_BASE) for (int j = 1; j < RAYGUI_MAX_CONTROLS; j++) GuiSetStyle(j, (int)propertyId, propertyValue);
|
||||||
}
|
}
|
||||||
else GuiSetStyle((int)controlId, (int)propertyId, propertyValue);
|
else GuiSetStyle((int)controlId, (int)propertyId, propertyValue);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user