Revert "Corrected bugs and reviewed some functions"
This reverts commit 949e93f9fe
.
This commit is contained in:
parent
949e93f9fe
commit
625e4e2fb3
151
src/raygui.c
151
src/raygui.c
@ -169,14 +169,11 @@ void GuiLabel(Rectangle bounds, const char *text)
|
||||
// Label element extended, configurable colors
|
||||
void GuiLabelEx(Rectangle bounds, const char *text, Color textColor, Color border, Color inner)
|
||||
{
|
||||
// Update control
|
||||
//--------------------------------------------------------------------
|
||||
int textWidth = MeasureText(text, style[GLOBAL_TEXT_FONTSIZE]);
|
||||
int textHeight = GetDefaultFont().size;
|
||||
int textHeight = GetFontBaseSize(GetDefaultFont());
|
||||
|
||||
if (bounds.width < textWidth) bounds.width = textWidth + style[LABEL_TEXT_PADDING];
|
||||
if (bounds.height < textHeight) bounds.height = textHeight + style[LABEL_TEXT_PADDING]/2;
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
// Draw control
|
||||
//--------------------------------------------------------------------
|
||||
@ -190,23 +187,22 @@ void GuiLabelEx(Rectangle bounds, const char *text, Color textColor, Color borde
|
||||
bool GuiButton(Rectangle bounds, const char *text)
|
||||
{
|
||||
ButtonState buttonState = BUTTON_DEFAULT;
|
||||
|
||||
Rectangle button = bounds;
|
||||
Vector2 mousePoint = GetMousePosition();
|
||||
|
||||
int textWidth = MeasureText(text, style[GLOBAL_TEXT_FONTSIZE]);
|
||||
int textHeight = GetDefaultFont().size;
|
||||
int textHeight = GetFontBaseSize(GetDefaultFont());
|
||||
|
||||
// Update control
|
||||
//--------------------------------------------------------------------
|
||||
if (bounds.width < textWidth) bounds.width = textWidth + style[BUTTON_TEXT_PADDING];
|
||||
if (bounds.height < textHeight) bounds.height = textHeight + style[BUTTON_TEXT_PADDING]/2;
|
||||
if (button.width < textWidth) button.width = textWidth + style[BUTTON_TEXT_PADDING];
|
||||
if (button.height < textHeight) button.height = textHeight + style[BUTTON_TEXT_PADDING]/2;
|
||||
|
||||
if (CheckCollisionPointRec(mousePoint, bounds))
|
||||
if (CheckCollisionPointRec(mousePoint, button))
|
||||
{
|
||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) buttonState = BUTTON_PRESSED;
|
||||
else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) buttonState = BUTTON_CLICKED;
|
||||
else buttonState = BUTTON_HOVER;
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
// Draw control
|
||||
//--------------------------------------------------------------------
|
||||
@ -214,26 +210,26 @@ bool GuiButton(Rectangle bounds, const char *text)
|
||||
{
|
||||
case BUTTON_DEFAULT:
|
||||
{
|
||||
DrawRectangleRec(bounds, GetColor(style[BUTTON_DEFAULT_BORDER_COLOR]));
|
||||
DrawRectangle((int)(bounds.x + style[BUTTON_BORDER_WIDTH]), (int)(bounds.y + style[BUTTON_BORDER_WIDTH]) , (int)(bounds.width - (2 * style[BUTTON_BORDER_WIDTH])), (int)(bounds.height - (2 * style[BUTTON_BORDER_WIDTH])), GetColor(style[BUTTON_DEFAULT_INSIDE_COLOR]));
|
||||
DrawText(text, bounds.x + ((bounds.width/2) - (MeasureText(text, style[GLOBAL_TEXT_FONTSIZE])/2)), bounds.y + ((bounds.height/2) - (style[GLOBAL_TEXT_FONTSIZE]/2)), style[GLOBAL_TEXT_FONTSIZE], GetColor(style[BUTTON_DEFAULT_TEXT_COLOR]));
|
||||
DrawRectangleRec(button, GetColor(style[BUTTON_DEFAULT_BORDER_COLOR]));
|
||||
DrawRectangle((int)(button.x + style[BUTTON_BORDER_WIDTH]), (int)(button.y + style[BUTTON_BORDER_WIDTH]) , (int)(button.width - (2 * style[BUTTON_BORDER_WIDTH])), (int)(button.height - (2 * style[BUTTON_BORDER_WIDTH])), GetColor(style[BUTTON_DEFAULT_INSIDE_COLOR]));
|
||||
DrawText(text, button.x + ((button.width/2) - (MeasureText(text, style[GLOBAL_TEXT_FONTSIZE])/2)), button.y + ((button.height/2) - (style[GLOBAL_TEXT_FONTSIZE]/2)), style[GLOBAL_TEXT_FONTSIZE], GetColor(style[BUTTON_DEFAULT_TEXT_COLOR]));
|
||||
} break;
|
||||
case BUTTON_HOVER:
|
||||
{
|
||||
DrawRectangleRec(bounds, GetColor(style[BUTTON_HOVER_BORDER_COLOR]));
|
||||
DrawRectangle((int)(bounds.x + style[BUTTON_BORDER_WIDTH]), (int)(bounds.y + style[BUTTON_BORDER_WIDTH]) , (int)(bounds.width - (2 * style[BUTTON_BORDER_WIDTH])), (int)(bounds.height - (2 * style[BUTTON_BORDER_WIDTH])), GetColor(style[BUTTON_HOVER_INSIDE_COLOR]));
|
||||
DrawText(text, bounds.x + ((bounds.width/2) - (MeasureText(text, style[GLOBAL_TEXT_FONTSIZE])/2)), bounds.y + ((bounds.height/2) - (style[GLOBAL_TEXT_FONTSIZE]/2)), style[GLOBAL_TEXT_FONTSIZE], GetColor(style[BUTTON_HOVER_TEXT_COLOR]));
|
||||
DrawRectangleRec(button, GetColor(style[BUTTON_HOVER_BORDER_COLOR]));
|
||||
DrawRectangle((int)(button.x + style[BUTTON_BORDER_WIDTH]), (int)(button.y + style[BUTTON_BORDER_WIDTH]) , (int)(button.width - (2 * style[BUTTON_BORDER_WIDTH])), (int)(button.height - (2 * style[BUTTON_BORDER_WIDTH])), GetColor(style[BUTTON_HOVER_INSIDE_COLOR]));
|
||||
DrawText(text, button.x + ((button.width/2) - (MeasureText(text, style[GLOBAL_TEXT_FONTSIZE])/2)), button.y + ((button.height/2) - (style[GLOBAL_TEXT_FONTSIZE]/2)), style[GLOBAL_TEXT_FONTSIZE], GetColor(style[BUTTON_HOVER_TEXT_COLOR]));
|
||||
} break;
|
||||
case BUTTON_PRESSED:
|
||||
{
|
||||
DrawRectangleRec(bounds, GetColor(style[BUTTON_PRESSED_BORDER_COLOR]));
|
||||
DrawRectangle((int)(bounds.x + style[BUTTON_BORDER_WIDTH]), (int)(bounds.y + style[BUTTON_BORDER_WIDTH]) , (int)(bounds.width - (2 * style[BUTTON_BORDER_WIDTH])), (int)(bounds.height - (2 * style[BUTTON_BORDER_WIDTH])), GetColor(style[BUTTON_PRESSED_INSIDE_COLOR]));
|
||||
DrawText(text, bounds.x + ((bounds.width/2) - (MeasureText(text, style[GLOBAL_TEXT_FONTSIZE])/2)), bounds.y + ((bounds.height/2) - (style[GLOBAL_TEXT_FONTSIZE]/2)), style[GLOBAL_TEXT_FONTSIZE], GetColor(style[BUTTON_PRESSED_TEXT_COLOR]));
|
||||
DrawRectangleRec(button, GetColor(style[BUTTON_PRESSED_BORDER_COLOR]));
|
||||
DrawRectangle((int)(button.x + style[BUTTON_BORDER_WIDTH]), (int)(button.y + style[BUTTON_BORDER_WIDTH]) , (int)(button.width - (2 * style[BUTTON_BORDER_WIDTH])), (int)(button.height - (2 * style[BUTTON_BORDER_WIDTH])), GetColor(style[BUTTON_PRESSED_INSIDE_COLOR]));
|
||||
DrawText(text, button.x + ((button.width/2) - (MeasureText(text, style[GLOBAL_TEXT_FONTSIZE])/2)), button.y + ((button.height/2) - (style[GLOBAL_TEXT_FONTSIZE]/2)), style[GLOBAL_TEXT_FONTSIZE], GetColor(style[BUTTON_PRESSED_TEXT_COLOR]));
|
||||
} break;
|
||||
case BUTTON_CLICKED:
|
||||
{
|
||||
DrawRectangleRec(bounds, GetColor(style[BUTTON_PRESSED_BORDER_COLOR]));
|
||||
DrawRectangle((int)(bounds.x + style[BUTTON_BORDER_WIDTH]), (int)(bounds.y + style[BUTTON_BORDER_WIDTH]) , (int)(bounds.width - (2 * style[BUTTON_BORDER_WIDTH])), (int)(bounds.height - (2 * style[BUTTON_BORDER_WIDTH])), GetColor(style[BUTTON_PRESSED_INSIDE_COLOR]));
|
||||
DrawRectangleRec(button, GetColor(style[BUTTON_PRESSED_BORDER_COLOR]));
|
||||
DrawRectangle((int)(button.x + style[BUTTON_BORDER_WIDTH]), (int)(button.y + style[BUTTON_BORDER_WIDTH]) , (int)(button.width - (2 * style[BUTTON_BORDER_WIDTH])), (int)(button.height - (2 * style[BUTTON_BORDER_WIDTH])), GetColor(style[BUTTON_PRESSED_INSIDE_COLOR]));
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
@ -251,11 +247,9 @@ bool GuiToggleButton(Rectangle bounds, const char *text, bool toggle)
|
||||
Vector2 mousePoint = GetMousePosition();
|
||||
|
||||
int textWidth = MeasureText(text, style[GLOBAL_TEXT_FONTSIZE]);
|
||||
int textHeight = GetDefaultFont().size;
|
||||
int textHeight = GetFontBaseSize(GetDefaultFont());
|
||||
|
||||
// Update control
|
||||
//--------------------------------------------------------------------
|
||||
if (toggleButton.width < textWidth) toggleButton.width = textWidth + style[TOGGLE_TEXT_PADDING];
|
||||
if (toggleButton.width < textWidth) toggleButton.width = textWidth + style[TOGGLE_TEXT_PADDING];
|
||||
if (toggleButton.height < textHeight) toggleButton.height = textHeight + style[TOGGLE_TEXT_PADDING]/2;
|
||||
if (CheckCollisionPointRec(mousePoint, toggleButton))
|
||||
{
|
||||
@ -266,7 +260,6 @@ bool GuiToggleButton(Rectangle bounds, const char *text, bool toggle)
|
||||
|
||||
if (toggleState == TOGGLE_ACTIVE && !toggle) toggle = true;
|
||||
if (toggle) toggleState = TOGGLE_ACTIVE;
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
// Draw control
|
||||
//--------------------------------------------------------------------
|
||||
@ -323,14 +316,12 @@ int GuiComboBox(Rectangle bounds, int comboNum, char **comboText, int comboActiv
|
||||
Rectangle click = { bounds.x + bounds.width + style[COMBOBOX_PADDING], bounds.y, style[COMBOBOX_BUTTON_WIDTH], bounds.height };
|
||||
Vector2 mousePoint = GetMousePosition();
|
||||
|
||||
int textHeight = GetDefaultFont().size;
|
||||
|
||||
int textHeight = GetFontBaseSize(GetDefaultFont());
|
||||
|
||||
for (int i = 0; i < comboNum; i++)
|
||||
{
|
||||
if (i == comboActive)
|
||||
{
|
||||
// Update control
|
||||
//--------------------------------------------------------------------
|
||||
int textWidth = MeasureText(comboText[i], style[GLOBAL_TEXT_FONTSIZE]);
|
||||
|
||||
if (comboBoxButton.width < textWidth) comboBoxButton.width = textWidth + style[TOGGLE_TEXT_PADDING];
|
||||
@ -342,7 +333,6 @@ int GuiComboBox(Rectangle bounds, int comboNum, char **comboText, int comboActiv
|
||||
else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) comboBoxState = COMBOBOX_ACTIVE;
|
||||
else comboBoxState = COMBOBOX_HOVER;
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
// Draw control
|
||||
//--------------------------------------------------------------------
|
||||
@ -412,11 +402,10 @@ int GuiComboBox(Rectangle bounds, int comboNum, char **comboText, int comboActiv
|
||||
bool GuiCheckBox(Rectangle checkBoxBounds, const char *text, bool checked)
|
||||
{
|
||||
CheckBoxState checkBoxState = CHECKBOX_STATUS;
|
||||
Rectangle checkBoxRec = checkBoxBounds;
|
||||
Vector2 mousePoint = GetMousePosition();
|
||||
|
||||
// Update control
|
||||
//--------------------------------------------------------------------
|
||||
if (CheckCollisionPointRec(mousePoint, checkBoxBounds))
|
||||
if (CheckCollisionPointRec(mousePoint, checkBoxRec))
|
||||
{
|
||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) checkBoxState = CHECKBOX_PRESSED;
|
||||
else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
|
||||
@ -426,7 +415,6 @@ bool GuiCheckBox(Rectangle checkBoxBounds, const char *text, bool checked)
|
||||
}
|
||||
else checkBoxState = CHECKBOX_HOVER;
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
// Draw control
|
||||
//--------------------------------------------------------------------
|
||||
@ -434,27 +422,25 @@ bool GuiCheckBox(Rectangle checkBoxBounds, const char *text, bool checked)
|
||||
{
|
||||
case CHECKBOX_HOVER:
|
||||
{
|
||||
DrawRectangleRec(checkBoxBounds, GetColor(style[CHECKBOX_HOVER_BORDER_COLOR]));
|
||||
DrawRectangle((int)(checkBoxBounds.x + style[TOGGLE_BORDER_WIDTH]), (int)(checkBoxBounds.y + style[TOGGLE_BORDER_WIDTH]), (int)(checkBoxBounds.width - (2*style[TOGGLE_BORDER_WIDTH])), (int)(checkBoxBounds.height - (2*style[TOGGLE_BORDER_WIDTH])), GetColor(style[CHECKBOX_HOVER_INSIDE_COLOR]));
|
||||
DrawRectangleRec(checkBoxRec, GetColor(style[CHECKBOX_HOVER_BORDER_COLOR]));
|
||||
DrawRectangle((int)(checkBoxRec.x + style[TOGGLE_BORDER_WIDTH]), (int)(checkBoxRec.y + style[TOGGLE_BORDER_WIDTH]), (int)(checkBoxRec.width - (2*style[TOGGLE_BORDER_WIDTH])), (int)(checkBoxRec.height - (2*style[TOGGLE_BORDER_WIDTH])), GetColor(style[CHECKBOX_HOVER_INSIDE_COLOR]));
|
||||
} break;
|
||||
case CHECKBOX_STATUS:
|
||||
{
|
||||
DrawRectangleRec(checkBoxBounds, GetColor(style[CHECKBOX_DEFAULT_BORDER_COLOR]));
|
||||
DrawRectangle((int)(checkBoxBounds.x + style[TOGGLE_BORDER_WIDTH]), (int)(checkBoxBounds.y + style[TOGGLE_BORDER_WIDTH]), (int)(checkBoxBounds.width - (2*style[TOGGLE_BORDER_WIDTH])), (int)(checkBoxBounds.height - (2*style[TOGGLE_BORDER_WIDTH])), GetColor(style[CHECKBOX_DEFAULT_INSIDE_COLOR]));
|
||||
DrawRectangleRec(checkBoxRec, GetColor(style[CHECKBOX_DEFAULT_BORDER_COLOR]));
|
||||
DrawRectangle((int)(checkBoxRec.x + style[TOGGLE_BORDER_WIDTH]), (int)(checkBoxRec.y + style[TOGGLE_BORDER_WIDTH]), (int)(checkBoxRec.width - (2*style[TOGGLE_BORDER_WIDTH])), (int)(checkBoxRec.height - (2*style[TOGGLE_BORDER_WIDTH])), GetColor(style[CHECKBOX_DEFAULT_INSIDE_COLOR]));
|
||||
} break;
|
||||
case CHECKBOX_PRESSED:
|
||||
{
|
||||
DrawRectangleRec(checkBoxBounds, GetColor(style[CHECKBOX_CLICK_BORDER_COLOR]));
|
||||
DrawRectangle((int)(checkBoxBounds.x + style[TOGGLE_BORDER_WIDTH]), (int)(checkBoxBounds.y + style[TOGGLE_BORDER_WIDTH]), (int)(checkBoxBounds.width - (2*style[TOGGLE_BORDER_WIDTH])), (int)(checkBoxBounds.height - (2*style[TOGGLE_BORDER_WIDTH])), GetColor(style[CHECKBOX_CLICK_INSIDE_COLOR]));
|
||||
DrawRectangleRec(checkBoxRec, GetColor(style[CHECKBOX_CLICK_BORDER_COLOR]));
|
||||
DrawRectangle((int)(checkBoxRec.x + style[TOGGLE_BORDER_WIDTH]), (int)(checkBoxRec.y + style[TOGGLE_BORDER_WIDTH]), (int)(checkBoxRec.width - (2*style[TOGGLE_BORDER_WIDTH])), (int)(checkBoxRec.height - (2*style[TOGGLE_BORDER_WIDTH])), GetColor(style[CHECKBOX_CLICK_INSIDE_COLOR]));
|
||||
} break;
|
||||
default: break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (text != NULL) DrawText(text, checkBoxBounds.x + checkBoxBounds.width + 2, checkBoxBounds.y + ((checkBoxBounds.height/2) - (style[GLOBAL_TEXT_FONTSIZE]/2) + 1), style[GLOBAL_TEXT_FONTSIZE], GetColor(style[LABEL_TEXT_COLOR]));
|
||||
|
||||
if (checked)
|
||||
{
|
||||
DrawRectangle((int)(checkBoxBounds.x + style[CHECKBOX_INSIDE_WIDTH]), (int)(checkBoxBounds.y + style[CHECKBOX_INSIDE_WIDTH]), (int)(checkBoxBounds.width - (2*style[CHECKBOX_INSIDE_WIDTH])), (int)(checkBoxBounds.height - (2*style[CHECKBOX_INSIDE_WIDTH])), GetColor(style[CHECKBOX_STATUS_ACTIVE_COLOR]));
|
||||
DrawRectangle((int)(checkBoxRec.x + style[CHECKBOX_INSIDE_WIDTH]), (int)(checkBoxRec.y + style[CHECKBOX_INSIDE_WIDTH]), (int)(checkBoxRec.width - (2*style[CHECKBOX_INSIDE_WIDTH])), (int)(checkBoxRec.height - (2*style[CHECKBOX_INSIDE_WIDTH])), GetColor(style[CHECKBOX_STATUS_ACTIVE_COLOR]));
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
@ -469,8 +455,6 @@ float GuiSlider(Rectangle bounds, float value, float minValue, float maxValue)
|
||||
float sliderPos = 0;
|
||||
Vector2 mousePoint = GetMousePosition();
|
||||
|
||||
// Update control
|
||||
//--------------------------------------------------------------------
|
||||
if (value < minValue) value = minValue;
|
||||
else if (value >= maxValue) value = maxValue;
|
||||
|
||||
@ -505,7 +489,6 @@ float GuiSlider(Rectangle bounds, float value, float minValue, float maxValue)
|
||||
}
|
||||
}
|
||||
else sliderState = SLIDER_DEFAULT;
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
// Draw control
|
||||
//--------------------------------------------------------------------
|
||||
@ -536,8 +519,6 @@ float GuiSliderBar(Rectangle bounds, float value, float minValue, float maxValue
|
||||
maxValue = maxValue - minValue;
|
||||
fixedMinValue = 0;
|
||||
|
||||
// Update control
|
||||
//--------------------------------------------------------------------
|
||||
if (fixedValue <= fixedMinValue) fixedValue = fixedMinValue;
|
||||
else if (fixedValue >= maxValue) fixedValue = maxValue;
|
||||
|
||||
@ -565,7 +546,6 @@ float GuiSliderBar(Rectangle bounds, float value, float minValue, float maxValue
|
||||
else sliderState = SLIDER_DEFAULT;
|
||||
|
||||
fixedValue = ((float)sliderBar.width*(maxValue - fixedMinValue))/((float)bounds.width - 2*style[SLIDER_BORDER_WIDTH]);
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
// Draw control
|
||||
//--------------------------------------------------------------------
|
||||
@ -613,7 +593,7 @@ int GuiSpinner(Rectangle bounds, int value, int minValue, int maxValue)
|
||||
Rectangle rightButtonBound = { bounds.x + bounds.width - bounds.width/4 + 1, bounds.y, bounds.width/4, bounds.height };
|
||||
Vector2 mousePoint = GetMousePosition();
|
||||
|
||||
int textHeight = GetDefaultFont().size;
|
||||
int textHeight = GetFontBaseSize(GetDefaultFont());
|
||||
|
||||
int textWidth = MeasureText(FormatText("%i", value), style[GLOBAL_TEXT_FONTSIZE]);
|
||||
|
||||
@ -625,8 +605,6 @@ int GuiSpinner(Rectangle bounds, int value, int minValue, int maxValue)
|
||||
//if (comboBoxButton.width < textWidth) comboBoxButton.width = textWidth + style[TOGGLE_TEXT_PADDING];
|
||||
//if (comboBoxButton.height < textHeight) comboBoxButton.height = textHeight + style[TOGGLE_TEXT_PADDING]/2;
|
||||
|
||||
// Update control
|
||||
//--------------------------------------------------------------------
|
||||
if (CheckCollisionPointRec(mousePoint, leftButtonBound) || CheckCollisionPointRec(mousePoint, rightButtonBound) || CheckCollisionPointRec(mousePoint, labelBoxBound))
|
||||
{
|
||||
if (IsKeyDown(KEY_LEFT))
|
||||
@ -696,7 +674,6 @@ int GuiSpinner(Rectangle bounds, int value, int minValue, int maxValue)
|
||||
valueSpeed = false;
|
||||
framesCounter = 0;
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
// Draw control
|
||||
//--------------------------------------------------------------------
|
||||
@ -783,72 +760,60 @@ int GuiSpinner(Rectangle bounds, int value, int minValue, int maxValue)
|
||||
}
|
||||
|
||||
// Text Box element, returns input text
|
||||
// NOTE: Requires static variables: framesCounter - ERROR!
|
||||
// NOTE: Requires static variables: framesCounter, maxChars - ERROR!
|
||||
char *GuiTextBox(Rectangle bounds, char *text)
|
||||
{
|
||||
#define MAX_CHARS_LENGTH 20
|
||||
#define KEY_BACKSPACE_TEXT 3
|
||||
|
||||
static int maxChars = 20;
|
||||
int initPos = bounds.x + 4;
|
||||
char letter = -1;
|
||||
static int framesCounter = 0;
|
||||
Vector2 mousePoint = GetMousePosition();
|
||||
|
||||
// Update control
|
||||
//--------------------------------------------------------------------
|
||||
framesCounter++;
|
||||
|
||||
letter = GetKeyPressed();
|
||||
|
||||
if (CheckCollisionPointRec(mousePoint, bounds))
|
||||
{
|
||||
if (letter != -1)
|
||||
|
||||
if (letter != -1)
|
||||
{
|
||||
if (letter == 3)
|
||||
{
|
||||
if (letter == KEY_BACKSPACE_TEXT)
|
||||
for (int i = 0; i < maxChars; i++)
|
||||
{
|
||||
for (int i = 0; i < MAX_CHARS_LENGTH; i++)
|
||||
if ((text[i] == '\0') && (i > 0))
|
||||
{
|
||||
if ((text[i] == '\0') && (i > 0))
|
||||
{
|
||||
text[i - 1] = '\0';
|
||||
break;
|
||||
}
|
||||
text[i - 1] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
text[MAX_CHARS_LENGTH - 1] = '\0';
|
||||
}
|
||||
else
|
||||
|
||||
text[19] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < maxChars; i++)
|
||||
{
|
||||
for (int i = 0; i < MAX_CHARS_LENGTH; i++)
|
||||
if (text[i] == '\0')
|
||||
{
|
||||
if (text[i] == '\0')
|
||||
{
|
||||
text[i] = letter;
|
||||
break;
|
||||
}
|
||||
text[i] = letter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
// Draw control
|
||||
//--------------------------------------------------------------------
|
||||
if (CheckCollisionPointRec(mousePoint, bounds)) DrawRectangleRec(bounds, GetColor(style[TOGGLE_ACTIVE_BORDER_COLOR]));
|
||||
else DrawRectangleRec(bounds, GetColor(style[TEXTBOX_BORDER_COLOR]));
|
||||
|
||||
DrawRectangleRec(bounds, GetColor(style[TEXTBOX_BORDER_COLOR]));
|
||||
DrawRectangle(bounds.x + style[TEXTBOX_BORDER_WIDTH], bounds.y + style[TEXTBOX_BORDER_WIDTH], bounds.width - (style[TEXTBOX_BORDER_WIDTH] * 2), bounds.height - (style[TEXTBOX_BORDER_WIDTH] * 2), GetColor(style[TEXTBOX_INSIDE_COLOR]));
|
||||
|
||||
for (int i = 0; i < MAX_CHARS_LENGTH; i++)
|
||||
|
||||
for (int i = 0; i < maxChars; i++)
|
||||
{
|
||||
if (text[i] == '\0') break;
|
||||
|
||||
DrawText(FormatText("%c", text[i]), initPos, bounds.y + 5, style[TEXTBOX_TEXT_FONTSIZE], GetColor(style[TEXTBOX_TEXT_COLOR]));
|
||||
|
||||
initPos += ((GetDefaultFont().charRecs[(int)text[i] - 32].width + 2));
|
||||
DrawText(FormatText("%c", text[i]), initPos, bounds.y + 10, style[TEXTBOX_TEXT_FONTSIZE], GetColor(style[TEXTBOX_TEXT_COLOR]));
|
||||
initPos += ((GetDefaultFont().charSet[(int)text[i] - 32].w + 2));
|
||||
}
|
||||
|
||||
if ((framesCounter/20)%2 && CheckCollisionPointRec(mousePoint, bounds)) DrawLine(initPos + 2, bounds.y, initPos + 2, bounds.y + 10 + 10, GetColor(style[TEXTBOX_LINE_COLOR]));
|
||||
if ((framesCounter/20)%2) DrawLine(initPos + 2, bounds.y + 10, initPos + 2, bounds.y + 10 + 10, GetColor(style[TEXTBOX_LINE_COLOR]));
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
return text;
|
||||
|
Loading…
Reference in New Issue
Block a user