Update raygui.h
This commit is contained in:
parent
386bf890a0
commit
fc21a8e552
@ -246,7 +246,7 @@
|
||||
* 0.8 (27-Aug-2015) Initial release. Implemented by Kevin Gato, Daniel Nicolás and Ramon Santamaria.
|
||||
*
|
||||
* DEPENDENCIES:
|
||||
* raylib 4.6-dev Inputs reading (keyboard/mouse), shapes drawing, font loading and text drawing
|
||||
* raylib 5.0 - Inputs reading (keyboard/mouse), shapes drawing, font loading and text drawing
|
||||
*
|
||||
* STANDALONE MODE:
|
||||
* By default raygui depends on raylib mostly for the inputs and the drawing functionality but that dependency can be disabled
|
||||
@ -2625,8 +2625,6 @@ int GuiTextBox(Rectangle bounds, char *text, int bufferSize, bool editMode)
|
||||
if (CheckCollisionPointRec(mousePosition, textBounds)) // Mouse hover text
|
||||
{
|
||||
float scaleFactor = (float)GuiGetStyle(DEFAULT, TEXT_SIZE)/(float)guiFont.baseSize;
|
||||
int codepoint = 0;
|
||||
int codepointSize = 0;
|
||||
int codepointIndex = 0;
|
||||
float glyphWidth = 0.0f;
|
||||
float widthToMouseX = 0;
|
||||
@ -2937,6 +2935,7 @@ int GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, in
|
||||
int GuiSliderPro(Rectangle bounds, const char *textLeft, const char *textRight, float *value, float minValue, float maxValue, int sliderWidth)
|
||||
{
|
||||
int result = 0;
|
||||
float oldValue = *value;
|
||||
GuiState state = guiState;
|
||||
|
||||
float temp = (maxValue - minValue)/2.0f;
|
||||
@ -3006,6 +3005,10 @@ int GuiSliderPro(Rectangle bounds, const char *textLeft, const char *textRight,
|
||||
else if (*value < minValue) *value = minValue;
|
||||
}
|
||||
|
||||
// Control value change check
|
||||
if(oldValue == *value) result = 0;
|
||||
else result = 1;
|
||||
|
||||
// Bar limits check
|
||||
if (sliderWidth > 0) // Slider
|
||||
{
|
||||
@ -3085,7 +3088,7 @@ int GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRight
|
||||
if (*value > maxValue) *value = maxValue;
|
||||
|
||||
// WARNING: Working with floats could lead to rounding issues
|
||||
if ((state != STATE_DISABLED)) progress.width = (float)(*value/(maxValue - minValue))*bounds.width - ((*value >= maxValue) ? (float)(2*GuiGetStyle(PROGRESSBAR, BORDER_WIDTH)) : 0.0f);
|
||||
if ((state != STATE_DISABLED)) progress.width = (float)(*value/(maxValue - minValue))*bounds.width - ((*value >= maxValue)? (float)(2*GuiGetStyle(PROGRESSBAR, BORDER_WIDTH)) : 0.0f);
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
// Draw control
|
||||
@ -3366,8 +3369,7 @@ int GuiColorPanel(Rectangle bounds, const char *text, Color *color)
|
||||
pickerSelector.x = bounds.x + (float)hsv.y*bounds.width; // HSV: Saturation
|
||||
pickerSelector.y = bounds.y + (1.0f - (float)hsv.z)*bounds.height; // HSV: Value
|
||||
|
||||
float hue = -1.0f;
|
||||
Vector3 maxHue = { hue >= 0.0f ? hue : hsv.x, 1.0f, 1.0f };
|
||||
Vector3 maxHue = { hsv.x, 1.0f, 1.0f };
|
||||
Vector3 rgbHue = ConvertHSVtoRGB(maxHue);
|
||||
Color maxHueCol = { (unsigned char)(255.0f*rgbHue.x),
|
||||
(unsigned char)(255.0f*rgbHue.y),
|
||||
@ -3680,8 +3682,7 @@ int GuiColorPanelHSV(Rectangle bounds, const char *text, Vector3 *colorHsv)
|
||||
pickerSelector.x = bounds.x + (float)colorHsv->y*bounds.width; // HSV: Saturation
|
||||
pickerSelector.y = bounds.y + (1.0f - (float)colorHsv->z)*bounds.height; // HSV: Value
|
||||
|
||||
float hue = -1.0f;
|
||||
Vector3 maxHue = { hue >= 0.0f ? hue : colorHsv->x, 1.0f, 1.0f };
|
||||
Vector3 maxHue = { colorHsv->x, 1.0f, 1.0f };
|
||||
Vector3 rgbHue = ConvertHSVtoRGB(maxHue);
|
||||
Color maxHueCol = { (unsigned char)(255.0f*rgbHue.x),
|
||||
(unsigned char)(255.0f*rgbHue.y),
|
||||
@ -3894,12 +3895,14 @@ int GuiGrid(Rectangle bounds, const char *text, float spacing, int subdivs, Vect
|
||||
GuiState state = guiState;
|
||||
|
||||
Vector2 mousePoint = GetMousePosition();
|
||||
Vector2 currentMouseCell = { 0 };
|
||||
Vector2 currentMouseCell = { -1, -1 };
|
||||
|
||||
float spaceWidth = spacing/(float)subdivs;
|
||||
int linesV = (int)(bounds.width/spaceWidth) + 1;
|
||||
int linesH = (int)(bounds.height/spaceWidth) + 1;
|
||||
|
||||
int color = GuiGetStyle(DEFAULT, LINE_COLOR);
|
||||
|
||||
// Update control
|
||||
//--------------------------------------------------------------------
|
||||
if ((state != STATE_DISABLED) && !guiLocked && !guiSliderDragging)
|
||||
@ -3915,29 +3918,24 @@ int GuiGrid(Rectangle bounds, const char *text, float spacing, int subdivs, Vect
|
||||
|
||||
// Draw control
|
||||
//--------------------------------------------------------------------
|
||||
switch (state)
|
||||
{
|
||||
case STATE_NORMAL:
|
||||
{
|
||||
if (state == STATE_DISABLED) color = GuiGetStyle(DEFAULT, BORDER_COLOR_DISABLED);
|
||||
|
||||
if (subdivs > 0)
|
||||
{
|
||||
// Draw vertical grid lines
|
||||
for (int i = 0; i < linesV; i++)
|
||||
{
|
||||
Rectangle lineV = { bounds.x + spacing*i/subdivs, bounds.y, 1, bounds.height };
|
||||
GuiDrawRectangle(lineV, 0, BLANK, ((i%subdivs) == 0)? GuiFade(GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)), RAYGUI_GRID_ALPHA*4) : GuiFade(GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)), RAYGUI_GRID_ALPHA));
|
||||
GuiDrawRectangle(lineV, 0, BLANK, ((i%subdivs) == 0)? GuiFade(GetColor(color), RAYGUI_GRID_ALPHA*4) : GuiFade(GetColor(color), RAYGUI_GRID_ALPHA));
|
||||
}
|
||||
|
||||
// Draw horizontal grid lines
|
||||
for (int i = 0; i < linesH; i++)
|
||||
{
|
||||
Rectangle lineH = { bounds.x, bounds.y + spacing*i/subdivs, bounds.width, 1 };
|
||||
GuiDrawRectangle(lineH, 0, BLANK, ((i%subdivs) == 0)? GuiFade(GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)), RAYGUI_GRID_ALPHA*4) : GuiFade(GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)), RAYGUI_GRID_ALPHA));
|
||||
GuiDrawRectangle(lineH, 0, BLANK, ((i%subdivs) == 0)? GuiFade(GetColor(color), RAYGUI_GRID_ALPHA*4) : GuiFade(GetColor(color), RAYGUI_GRID_ALPHA));
|
||||
}
|
||||
}
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (mouseCell != NULL) *mouseCell = currentMouseCell;
|
||||
return result;
|
||||
@ -4189,7 +4187,7 @@ const char *GuiIconText(int iconId, const char *text)
|
||||
return NULL;
|
||||
#else
|
||||
static char buffer[1024] = { 0 };
|
||||
static char iconBuffer[6] = { 0 };
|
||||
static char iconBuffer[16] = { 0 };
|
||||
|
||||
if (text != NULL)
|
||||
{
|
||||
@ -4206,7 +4204,7 @@ const char *GuiIconText(int iconId, const char *text)
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(iconBuffer, "#%03i#", iconId & 0x1ff);
|
||||
sprintf(iconBuffer, "#%03i#", iconId);
|
||||
|
||||
return iconBuffer;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user