Minor tweaks

This commit is contained in:
Ray 2023-05-08 18:57:19 +02:00
parent 7da92d224d
commit b54733ec12
3 changed files with 37 additions and 30 deletions

View File

@ -144,7 +144,7 @@ int main()
// raygui: controls drawing
//----------------------------------------------------------------------------------
// Check all possible events that require GuiLock
if (dropDown000EditMode ||
if (dropDown000EditMode ||
dropDown001EditMode) GuiLock();
// First GUI column

View File

@ -67,7 +67,7 @@ int main()
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)));
ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)));
if (vSliderEditMode || vSliderBarEditMode) GuiLock();
else GuiUnlock();
@ -106,13 +106,13 @@ float GuiVerticalSliderPro(Rectangle bounds, const char *textTop, const char *te
int sliderValue = (int)(((value - minValue)/(maxValue - minValue)) * (bounds.height - 2 * GuiGetStyle(SLIDER, BORDER_WIDTH)));
Rectangle slider = {
bounds.x + GuiGetStyle(SLIDER, BORDER_WIDTH) + GuiGetStyle(SLIDER, SLIDER_PADDING),
Rectangle slider = {
bounds.x + GuiGetStyle(SLIDER, BORDER_WIDTH) + GuiGetStyle(SLIDER, SLIDER_PADDING),
bounds.y + bounds.height - sliderValue,
bounds.width - 2*GuiGetStyle(SLIDER, BORDER_WIDTH) - 2*GuiGetStyle(SLIDER, SLIDER_PADDING),
0.0f,
};
if (sliderHeight > 0) // Slider
{
slider.y -= sliderHeight/2;
@ -142,7 +142,7 @@ float GuiVerticalSliderPro(Rectangle bounds, const char *textTop, const char *te
if (sliderHeight > 0) slider.y = mousePoint.y - slider.height / 2; // Slider
else if (sliderHeight == 0) // SliderBar
{
slider.y = mousePoint.y;
slider.y = mousePoint.y;
slider.height = bounds.y + bounds.height - slider.y - GuiGetStyle(SLIDER, BORDER_WIDTH);
}
}
@ -162,7 +162,7 @@ float GuiVerticalSliderPro(Rectangle bounds, const char *textTop, const char *te
}
else if (sliderHeight == 0) // SliderBar
{
if (slider.y < (bounds.y + GuiGetStyle(SLIDER, BORDER_WIDTH)))
if (slider.y < (bounds.y + GuiGetStyle(SLIDER, BORDER_WIDTH)))
{
slider.y = bounds.y + GuiGetStyle(SLIDER, BORDER_WIDTH);
slider.height = bounds.height - 2*GuiGetStyle(SLIDER, BORDER_WIDTH);
@ -224,10 +224,10 @@ bool GuiSliderProOwning(Rectangle bounds, const char *textLeft, const char *text
int sliderValue = (int)(((tempValue - minValue)/(maxValue - minValue))*(bounds.width - 2*GuiGetStyle(SLIDER, BORDER_WIDTH)));
Rectangle slider = {
bounds.x,
bounds.y + GuiGetStyle(SLIDER, BORDER_WIDTH) + GuiGetStyle(SLIDER, SLIDER_PADDING),
0,
Rectangle slider = {
bounds.x,
bounds.y + GuiGetStyle(SLIDER, BORDER_WIDTH) + GuiGetStyle(SLIDER, SLIDER_PADDING),
0,
bounds.height - 2*GuiGetStyle(SLIDER, BORDER_WIDTH) - 2*GuiGetStyle(SLIDER, SLIDER_PADDING)
};
@ -247,7 +247,7 @@ bool GuiSliderProOwning(Rectangle bounds, const char *textLeft, const char *text
if ((state != STATE_DISABLED) && (editMode || !guiLocked))
{
Vector2 mousePoint = GetMousePosition();
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{
if (CheckCollisionPointRec(mousePoint, bounds))
@ -266,7 +266,7 @@ bool GuiSliderProOwning(Rectangle bounds, const char *textLeft, const char *text
if (sliderWidth > 0) slider.x = mousePoint.x - slider.width/2; // Slider
else if (sliderWidth == 0) slider.width = (float)sliderValue; // SliderBar
}
else if (CheckCollisionPointRec(mousePoint, bounds))
{
@ -295,9 +295,9 @@ bool GuiSliderProOwning(Rectangle bounds, const char *textLeft, const char *text
GuiDrawRectangle(bounds, GuiGetStyle(SLIDER, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(SLIDER, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(SLIDER, (state != STATE_DISABLED)? BASE_COLOR_NORMAL : BASE_COLOR_DISABLED)), guiAlpha));
// Draw slider internal bar (depends on state)
if ((state == STATE_NORMAL) || (state == STATE_PRESSED))
if ((state == STATE_NORMAL) || (state == STATE_PRESSED))
GuiDrawRectangle(slider, 0, BLANK, Fade(GetColor(GuiGetStyle(SLIDER, BASE_COLOR_PRESSED)), guiAlpha));
else if (state == STATE_FOCUSED)
else if (state == STATE_FOCUSED)
GuiDrawRectangle(slider, 0, BLANK, Fade(GetColor(GuiGetStyle(SLIDER, TEXT_COLOR_FOCUSED)), guiAlpha));
// Draw left/right text if provided
@ -323,7 +323,7 @@ bool GuiSliderProOwning(Rectangle bounds, const char *textLeft, const char *text
GuiDrawText(textRight, textBounds, TEXT_ALIGN_LEFT, Fade(GetColor(GuiGetStyle(SLIDER, TEXT + (state*3))), guiAlpha));
}
//--------------------------------------------------------------------
*value = tempValue;
return pressed;
}
@ -347,13 +347,13 @@ bool GuiVerticalSliderProOwning(Rectangle bounds, const char *textTop, const cha
int sliderValue = (int)(((tempValue - minValue)/(maxValue - minValue)) * (bounds.height - 2 * GuiGetStyle(SLIDER, BORDER_WIDTH)));
Rectangle slider = {
bounds.x + GuiGetStyle(SLIDER, BORDER_WIDTH) + GuiGetStyle(SLIDER, SLIDER_PADDING),
Rectangle slider = {
bounds.x + GuiGetStyle(SLIDER, BORDER_WIDTH) + GuiGetStyle(SLIDER, SLIDER_PADDING),
bounds.y + bounds.height - sliderValue,
bounds.width - 2*GuiGetStyle(SLIDER, BORDER_WIDTH) - 2*GuiGetStyle(SLIDER, SLIDER_PADDING),
0.0f,
};
if (sliderHeight > 0) // Slider
{
slider.y -= sliderHeight/2;
@ -369,7 +369,7 @@ bool GuiVerticalSliderProOwning(Rectangle bounds, const char *textTop, const cha
if ((state != STATE_DISABLED) && (editMode || !guiLocked))
{
Vector2 mousePoint = GetMousePosition();
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{
if (CheckCollisionPointRec(mousePoint, bounds))
@ -387,11 +387,11 @@ bool GuiVerticalSliderProOwning(Rectangle bounds, const char *textTop, const cha
float normalizedValue = (bounds.y + bounds.height - mousePoint.y - (float)(sliderHeight / 2)) / (bounds.height - (float)sliderHeight);
tempValue = (maxValue - minValue) * normalizedValue + minValue;
if (sliderHeight > 0) slider.y = mousePoint.y - slider.height / 2; // Slider
else if (sliderHeight == 0) // SliderBar
{
slider.y = mousePoint.y;
slider.y = mousePoint.y;
slider.height = bounds.y + bounds.height - slider.y - GuiGetStyle(SLIDER, BORDER_WIDTH);
}
}
@ -413,7 +413,7 @@ bool GuiVerticalSliderProOwning(Rectangle bounds, const char *textTop, const cha
}
else if (sliderHeight == 0) // SliderBar
{
if (slider.y < (bounds.y + GuiGetStyle(SLIDER, BORDER_WIDTH)))
if (slider.y < (bounds.y + GuiGetStyle(SLIDER, BORDER_WIDTH)))
{
slider.y = bounds.y + GuiGetStyle(SLIDER, BORDER_WIDTH);
slider.height = bounds.height - 2*GuiGetStyle(SLIDER, BORDER_WIDTH);
@ -426,9 +426,9 @@ bool GuiVerticalSliderProOwning(Rectangle bounds, const char *textTop, const cha
GuiDrawRectangle(bounds, GuiGetStyle(SLIDER, BORDER_WIDTH), Fade(GetColor(GuiGetStyle(SLIDER, BORDER + (state*3))), guiAlpha), Fade(GetColor(GuiGetStyle(SLIDER, (state != STATE_DISABLED)? BASE_COLOR_NORMAL : BASE_COLOR_DISABLED)), guiAlpha));
// Draw slider internal bar (depends on state)
if ((state == STATE_NORMAL) || (state == STATE_PRESSED))
if ((state == STATE_NORMAL) || (state == STATE_PRESSED))
GuiDrawRectangle(slider, 0, BLANK, Fade(GetColor(GuiGetStyle(SLIDER, BASE_COLOR_PRESSED)), guiAlpha));
else if (state == STATE_FOCUSED)
else if (state == STATE_FOCUSED)
GuiDrawRectangle(slider, 0, BLANK, Fade(GetColor(GuiGetStyle(SLIDER, TEXT_COLOR_FOCUSED)), guiAlpha));
// Draw top/bottom text if provided
@ -454,7 +454,7 @@ bool GuiVerticalSliderProOwning(Rectangle bounds, const char *textTop, const cha
GuiDrawText(textBottom, textBounds, TEXT_ALIGN_LEFT, Fade(GetColor(GuiGetStyle(SLIDER, TEXT + (state*3))), guiAlpha));
}
//--------------------------------------------------------------------
*value = tempValue;
return pressed;
}

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raygui v3.5 - A simple and easy-to-use immediate-mode gui library
* raygui v3.6-dev - A simple and easy-to-use immediate-mode gui library
*
* DESCRIPTION:
* raygui is a tools-dev-focused immediate-mode-gui library based on raylib but also
@ -128,6 +128,13 @@
* Draw text bounds rectangles for debug
*
* VERSIONS HISTORY:
* 3.6 (xx-Jun-2023) ADDED: New icon: SAND_TIMER
* ADDED: GuiLoadStyleFromMemory() (binary only)
* REVIEWED: GuiScrollBar() horizontal movement key
* REVIEWED: GuiTextBox() crash on cursor movement
* REVIEWED: GuiLabelButton(), avoid text cut
* REVIEWED: GuiTextInputBox(), password input
* REVIEWED: Local GetCodepointNext(), aligned with raylib
* 3.5 (20-Apr-2023) ADDED: GuiTabBar(), based on GuiToggle()
* ADDED: Helper functions to split text in separate lines
* ADDED: Multiple new icons, useful for code editing tools
@ -3445,9 +3452,9 @@ void GuiLoadStyle(const char *fileName)
{
unsigned char *fileData = (unsigned char *)RL_MALLOC(fileDataSize*sizeof(unsigned char));
fread(fileData, sizeof(unsigned char), fileDataSize, rgsFile);
GuiLoadStyleFromMemory(fileData, fileDataSize);
RL_FREE(fileData);
}
@ -3695,7 +3702,7 @@ void GuiSetIconScale(int scale)
static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
{
unsigned char *fileDataPtr = (unsigned char *)fileData;
char signature[5] = { 0 };
short version = 0;
short reserved = 0;