mirror of
https://github.com/raysan5/raygui.git
synced 2025-12-25 10:22:33 -05:00
Minor tweaks
This commit is contained in:
@ -144,7 +144,7 @@ int main()
|
|||||||
// raygui: controls drawing
|
// raygui: controls drawing
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Check all possible events that require GuiLock
|
// Check all possible events that require GuiLock
|
||||||
if (dropDown000EditMode ||
|
if (dropDown000EditMode ||
|
||||||
dropDown001EditMode) GuiLock();
|
dropDown001EditMode) GuiLock();
|
||||||
|
|
||||||
// First GUI column
|
// First GUI column
|
||||||
|
|||||||
@ -67,7 +67,7 @@ int main()
|
|||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|
||||||
ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)));
|
ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)));
|
||||||
|
|
||||||
if (vSliderEditMode || vSliderBarEditMode) GuiLock();
|
if (vSliderEditMode || vSliderBarEditMode) GuiLock();
|
||||||
else GuiUnlock();
|
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)));
|
int sliderValue = (int)(((value - minValue)/(maxValue - minValue)) * (bounds.height - 2 * GuiGetStyle(SLIDER, BORDER_WIDTH)));
|
||||||
|
|
||||||
Rectangle slider = {
|
Rectangle slider = {
|
||||||
bounds.x + GuiGetStyle(SLIDER, BORDER_WIDTH) + GuiGetStyle(SLIDER, SLIDER_PADDING),
|
bounds.x + GuiGetStyle(SLIDER, BORDER_WIDTH) + GuiGetStyle(SLIDER, SLIDER_PADDING),
|
||||||
bounds.y + bounds.height - sliderValue,
|
bounds.y + bounds.height - sliderValue,
|
||||||
bounds.width - 2*GuiGetStyle(SLIDER, BORDER_WIDTH) - 2*GuiGetStyle(SLIDER, SLIDER_PADDING),
|
bounds.width - 2*GuiGetStyle(SLIDER, BORDER_WIDTH) - 2*GuiGetStyle(SLIDER, SLIDER_PADDING),
|
||||||
0.0f,
|
0.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (sliderHeight > 0) // Slider
|
if (sliderHeight > 0) // Slider
|
||||||
{
|
{
|
||||||
slider.y -= sliderHeight/2;
|
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
|
if (sliderHeight > 0) slider.y = mousePoint.y - slider.height / 2; // Slider
|
||||||
else if (sliderHeight == 0) // SliderBar
|
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);
|
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
|
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.y = bounds.y + GuiGetStyle(SLIDER, BORDER_WIDTH);
|
||||||
slider.height = bounds.height - 2*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)));
|
int sliderValue = (int)(((tempValue - minValue)/(maxValue - minValue))*(bounds.width - 2*GuiGetStyle(SLIDER, BORDER_WIDTH)));
|
||||||
|
|
||||||
Rectangle slider = {
|
Rectangle slider = {
|
||||||
bounds.x,
|
bounds.x,
|
||||||
bounds.y + GuiGetStyle(SLIDER, BORDER_WIDTH) + GuiGetStyle(SLIDER, SLIDER_PADDING),
|
bounds.y + GuiGetStyle(SLIDER, BORDER_WIDTH) + GuiGetStyle(SLIDER, SLIDER_PADDING),
|
||||||
0,
|
0,
|
||||||
bounds.height - 2*GuiGetStyle(SLIDER, BORDER_WIDTH) - 2*GuiGetStyle(SLIDER, SLIDER_PADDING)
|
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))
|
if ((state != STATE_DISABLED) && (editMode || !guiLocked))
|
||||||
{
|
{
|
||||||
Vector2 mousePoint = GetMousePosition();
|
Vector2 mousePoint = GetMousePosition();
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||||
{
|
{
|
||||||
if (CheckCollisionPointRec(mousePoint, bounds))
|
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
|
if (sliderWidth > 0) slider.x = mousePoint.x - slider.width/2; // Slider
|
||||||
else if (sliderWidth == 0) slider.width = (float)sliderValue; // SliderBar
|
else if (sliderWidth == 0) slider.width = (float)sliderValue; // SliderBar
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (CheckCollisionPointRec(mousePoint, bounds))
|
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));
|
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)
|
// 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));
|
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));
|
GuiDrawRectangle(slider, 0, BLANK, Fade(GetColor(GuiGetStyle(SLIDER, TEXT_COLOR_FOCUSED)), guiAlpha));
|
||||||
|
|
||||||
// Draw left/right text if provided
|
// 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));
|
GuiDrawText(textRight, textBounds, TEXT_ALIGN_LEFT, Fade(GetColor(GuiGetStyle(SLIDER, TEXT + (state*3))), guiAlpha));
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
*value = tempValue;
|
*value = tempValue;
|
||||||
return pressed;
|
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)));
|
int sliderValue = (int)(((tempValue - minValue)/(maxValue - minValue)) * (bounds.height - 2 * GuiGetStyle(SLIDER, BORDER_WIDTH)));
|
||||||
|
|
||||||
Rectangle slider = {
|
Rectangle slider = {
|
||||||
bounds.x + GuiGetStyle(SLIDER, BORDER_WIDTH) + GuiGetStyle(SLIDER, SLIDER_PADDING),
|
bounds.x + GuiGetStyle(SLIDER, BORDER_WIDTH) + GuiGetStyle(SLIDER, SLIDER_PADDING),
|
||||||
bounds.y + bounds.height - sliderValue,
|
bounds.y + bounds.height - sliderValue,
|
||||||
bounds.width - 2*GuiGetStyle(SLIDER, BORDER_WIDTH) - 2*GuiGetStyle(SLIDER, SLIDER_PADDING),
|
bounds.width - 2*GuiGetStyle(SLIDER, BORDER_WIDTH) - 2*GuiGetStyle(SLIDER, SLIDER_PADDING),
|
||||||
0.0f,
|
0.0f,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (sliderHeight > 0) // Slider
|
if (sliderHeight > 0) // Slider
|
||||||
{
|
{
|
||||||
slider.y -= sliderHeight/2;
|
slider.y -= sliderHeight/2;
|
||||||
@ -369,7 +369,7 @@ bool GuiVerticalSliderProOwning(Rectangle bounds, const char *textTop, const cha
|
|||||||
if ((state != STATE_DISABLED) && (editMode || !guiLocked))
|
if ((state != STATE_DISABLED) && (editMode || !guiLocked))
|
||||||
{
|
{
|
||||||
Vector2 mousePoint = GetMousePosition();
|
Vector2 mousePoint = GetMousePosition();
|
||||||
|
|
||||||
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
|
||||||
{
|
{
|
||||||
if (CheckCollisionPointRec(mousePoint, bounds))
|
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);
|
float normalizedValue = (bounds.y + bounds.height - mousePoint.y - (float)(sliderHeight / 2)) / (bounds.height - (float)sliderHeight);
|
||||||
tempValue = (maxValue - minValue) * normalizedValue + minValue;
|
tempValue = (maxValue - minValue) * normalizedValue + minValue;
|
||||||
|
|
||||||
if (sliderHeight > 0) slider.y = mousePoint.y - slider.height / 2; // Slider
|
if (sliderHeight > 0) slider.y = mousePoint.y - slider.height / 2; // Slider
|
||||||
else if (sliderHeight == 0) // SliderBar
|
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);
|
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
|
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.y = bounds.y + GuiGetStyle(SLIDER, BORDER_WIDTH);
|
||||||
slider.height = bounds.height - 2*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));
|
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)
|
// 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));
|
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));
|
GuiDrawRectangle(slider, 0, BLANK, Fade(GetColor(GuiGetStyle(SLIDER, TEXT_COLOR_FOCUSED)), guiAlpha));
|
||||||
|
|
||||||
// Draw top/bottom text if provided
|
// 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));
|
GuiDrawText(textBottom, textBounds, TEXT_ALIGN_LEFT, Fade(GetColor(GuiGetStyle(SLIDER, TEXT + (state*3))), guiAlpha));
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
*value = tempValue;
|
*value = tempValue;
|
||||||
return pressed;
|
return pressed;
|
||||||
}
|
}
|
||||||
|
|||||||
15
src/raygui.h
15
src/raygui.h
@ -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:
|
* 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
|
||||||
@ -128,6 +128,13 @@
|
|||||||
* Draw text bounds rectangles for debug
|
* Draw text bounds rectangles for debug
|
||||||
*
|
*
|
||||||
* VERSIONS HISTORY:
|
* 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()
|
* 3.5 (20-Apr-2023) ADDED: GuiTabBar(), based on GuiToggle()
|
||||||
* ADDED: Helper functions to split text in separate lines
|
* ADDED: Helper functions to split text in separate lines
|
||||||
* ADDED: Multiple new icons, useful for code editing tools
|
* 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));
|
unsigned char *fileData = (unsigned char *)RL_MALLOC(fileDataSize*sizeof(unsigned char));
|
||||||
fread(fileData, sizeof(unsigned char), fileDataSize, rgsFile);
|
fread(fileData, sizeof(unsigned char), fileDataSize, rgsFile);
|
||||||
|
|
||||||
GuiLoadStyleFromMemory(fileData, fileDataSize);
|
GuiLoadStyleFromMemory(fileData, fileDataSize);
|
||||||
|
|
||||||
RL_FREE(fileData);
|
RL_FREE(fileData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3695,7 +3702,7 @@ void GuiSetIconScale(int scale)
|
|||||||
static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
|
static void GuiLoadStyleFromMemory(const unsigned char *fileData, int dataSize)
|
||||||
{
|
{
|
||||||
unsigned char *fileDataPtr = (unsigned char *)fileData;
|
unsigned char *fileDataPtr = (unsigned char *)fileData;
|
||||||
|
|
||||||
char signature[5] = { 0 };
|
char signature[5] = { 0 };
|
||||||
short version = 0;
|
short version = 0;
|
||||||
short reserved = 0;
|
short reserved = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user