Working on DISABLE gui state addition

This commit is contained in:
raysan5
2017-12-31 23:48:57 +01:00
parent 45f1f17f14
commit e67a2f2bbc
3 changed files with 317 additions and 239 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

@ -70,7 +70,7 @@
* *
* LICENSE: zlib/libpng * LICENSE: zlib/libpng
* *
* Copyright (c) 2015-2017 Ramon Santamaria (@raysan5) * Copyright (c) 2015-2018 Ramon Santamaria (@raysan5)
* *
* This software is provided "as-is", without any express or implied warranty. In no event * This software is provided "as-is", without any express or implied warranty. In no event
* will the authors be held liable for any damages arising from the use of this software. * will the authors be held liable for any damages arising from the use of this software.
@ -284,25 +284,28 @@ typedef enum GuiProperty {
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Module Functions Declaration // Module Functions Declaration
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
RAYGUIDEF Color GuiBackgroundColor(void); // Get background color RAYGUIDEF Color GuiBackgroundColor(void); // Get background color
RAYGUIDEF Color GuiLinesColor(void); // Get lines color RAYGUIDEF Color GuiLinesColor(void); // Get lines color
RAYGUIDEF Color GuiTextColor(void); // Get text color for normal state RAYGUIDEF Color GuiTextColor(void); // Get text color for normal state
RAYGUIDEF void GuiLabel(Rectangle bounds, const char *text); // Label control, show text RAYGUIDEF void GuiLabel(Rectangle bounds, const char *text); // Label control, show text
RAYGUIDEF bool GuiButton(Rectangle bounds, const char *text); // Button control, returns true when clicked RAYGUIDEF bool GuiButton(Rectangle bounds, const char *text); // Button control, returns true when clicked
RAYGUIDEF bool GuiToggleButton(Rectangle bounds, const char *text, bool toggle); // Toggle Button control, returns true when active RAYGUIDEF bool GuiToggleButton(Rectangle bounds, const char *text, bool toggle); // Toggle Button control, returns true when active
RAYGUIDEF int GuiToggleGroup(Rectangle bounds, int toggleNum, char **toggleText, int toggleActive); // Toggle Group control, returns toggled button index RAYGUIDEF int GuiToggleGroup(Rectangle bounds, int toggleNum, char **toggleText, int toggleActive); // Toggle Group control, returns toggled button index
RAYGUIDEF bool GuiCheckBox(Rectangle bounds, bool checked); // Check Box control, returns true when active RAYGUIDEF bool GuiCheckBox(Rectangle bounds, bool checked); // Check Box control, returns true when active
RAYGUIDEF int GuiComboBox(Rectangle bounds, int comboNum, char **comboText, int comboActive); // Combo Box control, returns selected item index RAYGUIDEF int GuiComboBox(Rectangle bounds, int comboNum, char **comboText, int comboActive); // Combo Box control, returns selected item index
RAYGUIDEF void GuiGroupBox(Rectangle bounds, const char *text); // Group Box control with title name RAYGUIDEF void GuiGroupBox(Rectangle bounds, const char *text); // Group Box control with title name
RAYGUIDEF void GuiTextBox(Rectangle bounds, char *text, int textSize); // Text Box control, updates input text RAYGUIDEF void GuiTextBox(Rectangle bounds, char *text, int textSize); // Text Box control, updates input text
RAYGUIDEF float GuiSlider(Rectangle bounds, float value, float minValue, float maxValue); // Slider control, returns selected value RAYGUIDEF float GuiSlider(Rectangle bounds, float value, float minValue, float maxValue); // Slider control, returns selected value
RAYGUIDEF float GuiSliderBar(Rectangle bounds, float value, float minValue, float maxValue); // Slider Bar control, returns selected value RAYGUIDEF float GuiSliderBar(Rectangle bounds, float value, float minValue, float maxValue); // Slider Bar control, returns selected value
RAYGUIDEF float GuiProgressBar(Rectangle bounds, float value, float minValue, float maxValue); // Progress Bar control, shows current progress value RAYGUIDEF float GuiProgressBar(Rectangle bounds, float value, float minValue, float maxValue); // Progress Bar control, shows current progress value
RAYGUIDEF int GuiSpinner(Rectangle bounds, int value, int minValue, int maxValue); // Spinner control, returns selected value RAYGUIDEF int GuiSpinner(Rectangle bounds, int value, int minValue, int maxValue); // Spinner control, returns selected value
RAYGUIDEF bool GuiTexture(Rectangle bounds, Texture2D texture); // Texture button control, returns true when clicked RAYGUIDEF bool GuiTexture(Rectangle bounds, Texture2D texture); // Texture button control, returns true when clicked
RAYGUIDEF Color GuiColorPicker(Rectangle bounds, Color color); // Color Picker control RAYGUIDEF Color GuiColorPicker(Rectangle bounds, Color color); // Color Picker control
RAYGUIDEF void GuiEnable(void); // Enable gui global state
RAYGUIDEF void GuiDisable(void); // Disable gui global state
#if defined(RAYGUI_STYLE_SAVE_LOAD) #if defined(RAYGUI_STYLE_SAVE_LOAD)
RAYGUIDEF void LoadGuiStyleImage(const char *fileName); // Load GUI style from a text file RAYGUIDEF void LoadGuiStyleImage(const char *fileName); // Load GUI style from a text file
@ -350,11 +353,18 @@ RAYGUIDEF int GetStyleProperty(int guiProperty); // Get o
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// GUI controls state // GUI controls state
typedef enum { DISABLED, NORMAL, FOCUSED, PRESSED } ControlState; typedef enum GuiControlState {
DISABLED = 0,
NORMAL,
FOCUSED,
PRESSED
} GuiControlState;
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Global Variables Definition // Global Variables Definition
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
static int guiState = NORMAL;
static int styleGeneric[18] = { static int styleGeneric[18] = {
#if defined(RAYGUI_STYLE_DEFAULT_LIGHT) #if defined(RAYGUI_STYLE_DEFAULT_LIGHT)
0xf5f5f5ff, // DEFAULT_BACKGROUND_COLOR 0xf5f5f5ff, // DEFAULT_BACKGROUND_COLOR
@ -532,17 +542,18 @@ static int GetKeyPressed(void); // -- GuiTextBox(
static bool IsKeyDown(int key); // -- GuiColorPicker() static bool IsKeyDown(int key); // -- GuiColorPicker()
// Control specific functions // Control specific functions
static void DrawRectangleLines(int x, int y, int width, int height, Color color) { /* TODO */ } // -- GuiColorPicker() static void DrawRectangleLines(int x, int y, int width, int height, Color color) { /* TODO */ } // -- GuiColorPicker() *
static void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2);// -- GuiColorPicker() static void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2);// -- GuiColorPicker() *
static void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2);// -- GuiColorPicker() static void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2);// -- GuiColorPicker() *
static void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // -- GuiColorPicker() static void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); // -- GuiColorPicker()
static void DrawCircleV(Vector2 center, float radius, Color color); // -- GuiColorPicker() static void DrawCircleV(Vector2 center, float radius, Color color); // -- GuiColorPicker() *
static bool IsCursorHidden(void) { return false; } // -- GuiColorPicker() static bool IsCursorHidden(void) { return false; } // -- GuiColorPicker() *
static void HideCursor(void) { } // -- GuiColorPicker() static void HideCursor(void) { } // -- GuiColorPicker() *
static void ShowCursor(void) { } // -- GuiColorPicker() static void ShowCursor(void) { } // -- GuiColorPicker() *
static Color Fade(Color color, float alpha) { return WHITE; } // -- GuiColorPicker() static Color Fade(Color color, float alpha) { return WHITE; } // -- GuiColorPicker()
static void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // -- GuiTexture() static void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // -- GuiTexture()
static void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); // -- GuiGroupBox() static void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); // -- GuiGroupBox() *
#if defined(RAYGUI_STYLE_SAVE_LOAD) #if defined(RAYGUI_STYLE_SAVE_LOAD)
static Image LoadImage(const char *fileName); // -- LoadGuiStyleImage() static Image LoadImage(const char *fileName); // -- LoadGuiStyleImage()
@ -574,23 +585,26 @@ RAYGUIDEF Color GuiTextColor(void) { return GetColor(styleGeneric[DEFAULT_TEXT_C
// Label control // Label control
RAYGUIDEF void GuiLabel(Rectangle bounds, const char *text) RAYGUIDEF void GuiLabel(Rectangle bounds, const char *text)
{ {
ControlState state = NORMAL; GuiControlState state = guiState;
Vector2 mousePoint = GetMousePosition();
// Update control
//--------------------------------------------------------------------
int textWidth = MeasureText(text, styleGeneric[DEFAULT_TEXT_SIZE]); int textWidth = MeasureText(text, styleGeneric[DEFAULT_TEXT_SIZE]);
int textHeight = styleGeneric[DEFAULT_TEXT_SIZE]; int textHeight = styleGeneric[DEFAULT_TEXT_SIZE];
if (bounds.width < textWidth) bounds.width = textWidth; if (bounds.width < textWidth) bounds.width = textWidth;
if (bounds.height < textHeight) bounds.height = textHeight; if (bounds.height < textHeight) bounds.height = textHeight;
// Check label state // Update control
if (CheckCollisionPointRec(mousePoint, bounds)) //--------------------------------------------------------------------
if (state != DISABLED)
{ {
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = PRESSED; Vector2 mousePoint = GetMousePosition();
else state = FOCUSED;
// Check label state
if (CheckCollisionPointRec(mousePoint, bounds))
{
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = PRESSED;
else state = FOCUSED;
}
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -601,6 +615,7 @@ RAYGUIDEF void GuiLabel(Rectangle bounds, const char *text)
case NORMAL: DrawText(text, bounds.x + bounds.width/2 - textWidth/2, bounds.y + bounds.height/2 - textHeight/2, styleGeneric[DEFAULT_TEXT_SIZE], GetColor(style[LABEL_TEXT_COLOR_NORMAL])); break; case NORMAL: DrawText(text, bounds.x + bounds.width/2 - textWidth/2, bounds.y + bounds.height/2 - textHeight/2, styleGeneric[DEFAULT_TEXT_SIZE], GetColor(style[LABEL_TEXT_COLOR_NORMAL])); break;
case FOCUSED: DrawText(text, bounds.x + bounds.width/2 - textWidth/2, bounds.y + bounds.height/2 - textHeight/2, styleGeneric[DEFAULT_TEXT_SIZE], GetColor(style[LABEL_TEXT_COLOR_FOCUSED])); break; case FOCUSED: DrawText(text, bounds.x + bounds.width/2 - textWidth/2, bounds.y + bounds.height/2 - textHeight/2, styleGeneric[DEFAULT_TEXT_SIZE], GetColor(style[LABEL_TEXT_COLOR_FOCUSED])); break;
case PRESSED: DrawText(text, bounds.x + bounds.width/2 - textWidth/2, bounds.y + bounds.height/2 - textHeight/2, styleGeneric[DEFAULT_TEXT_SIZE], GetColor(style[LABEL_TEXT_COLOR_PRESSED])); break; case PRESSED: DrawText(text, bounds.x + bounds.width/2 - textWidth/2, bounds.y + bounds.height/2 - textHeight/2, styleGeneric[DEFAULT_TEXT_SIZE], GetColor(style[LABEL_TEXT_COLOR_PRESSED])); break;
case DISABLED: //DrawText(text, bounds.x + bounds.width/2 - textWidth/2, bounds.y + bounds.height/2 - textHeight/2, styleGeneric[DEFAULT_TEXT_SIZE], GetColor(style[LABEL_TEXT_COLOR_DISABLED])); break;
default: break; default: break;
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -609,25 +624,29 @@ RAYGUIDEF void GuiLabel(Rectangle bounds, const char *text)
// Button control, returns true when clicked // Button control, returns true when clicked
RAYGUIDEF bool GuiButton(Rectangle bounds, const char *text) RAYGUIDEF bool GuiButton(Rectangle bounds, const char *text)
{ {
ControlState state = NORMAL; GuiControlState state = guiState;
Vector2 mousePoint = GetMousePosition();
bool clicked = false; bool clicked = false;
// Update control
//--------------------------------------------------------------------
int textWidth = MeasureText(text, styleGeneric[DEFAULT_TEXT_SIZE]); int textWidth = MeasureText(text, styleGeneric[DEFAULT_TEXT_SIZE]);
int textHeight = styleGeneric[DEFAULT_TEXT_SIZE]; int textHeight = styleGeneric[DEFAULT_TEXT_SIZE];
if (bounds.width < textWidth) bounds.width = textWidth; if (bounds.width < textWidth) bounds.width = textWidth;
if (bounds.height < textHeight) bounds.height = textHeight; if (bounds.height < textHeight) bounds.height = textHeight;
// Check button state // Update control
if (CheckCollisionPointRec(mousePoint, bounds)) //--------------------------------------------------------------------
if (state != DISABLED)
{ {
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = PRESSED; Vector2 mousePoint = GetMousePosition();
else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) clicked = true;
else state = FOCUSED;
// Check button state
if (CheckCollisionPointRec(mousePoint, bounds))
{
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = PRESSED;
else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) clicked = true;
else state = FOCUSED;
}
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -652,41 +671,48 @@ RAYGUIDEF bool GuiButton(Rectangle bounds, const char *text)
DrawRectangleRecT(bounds, GetColor(style[BUTTON_BORDER_COLOR_PRESSED])); DrawRectangleRecT(bounds, GetColor(style[BUTTON_BORDER_COLOR_PRESSED]));
DrawRectangleT(bounds.x + style[BUTTON_BORDER_WIDTH], bounds.y + style[BUTTON_BORDER_WIDTH], bounds.width - 2*style[BUTTON_BORDER_WIDTH], bounds.height - 2*style[BUTTON_BORDER_WIDTH], GetColor(style[BUTTON_BASE_COLOR_PRESSED])); DrawRectangleT(bounds.x + style[BUTTON_BORDER_WIDTH], bounds.y + style[BUTTON_BORDER_WIDTH], bounds.width - 2*style[BUTTON_BORDER_WIDTH], bounds.height - 2*style[BUTTON_BORDER_WIDTH], GetColor(style[BUTTON_BASE_COLOR_PRESSED]));
DrawText(text, bounds.x + bounds.width/2 - textWidth/2, bounds.y + bounds.height/2 - textHeight/2, styleGeneric[DEFAULT_TEXT_SIZE], GetColor(style[BUTTON_TEXT_COLOR_PRESSED])); DrawText(text, bounds.x + bounds.width/2 - textWidth/2, bounds.y + bounds.height/2 - textHeight/2, styleGeneric[DEFAULT_TEXT_SIZE], GetColor(style[BUTTON_TEXT_COLOR_PRESSED]));
} break;
case DISABLED:
{
} break; } break;
default: break; default: break;
} }
//------------------------------------------------------------------ //------------------------------------------------------------------
if (clicked) return true; return clicked;
else return false;
} }
// Toggle Button control, returns true when active // Toggle Button control, returns true when active
RAYGUIDEF bool GuiToggleButton(Rectangle bounds, const char *text, bool active) RAYGUIDEF bool GuiToggleButton(Rectangle bounds, const char *text, bool active)
{ {
ControlState state = NORMAL; GuiControlState state = guiState;
Vector2 mousePoint = GetMousePosition();
// Update control
//--------------------------------------------------------------------
int textWidth = MeasureText(text, styleGeneric[DEFAULT_TEXT_SIZE]); int textWidth = MeasureText(text, styleGeneric[DEFAULT_TEXT_SIZE]);
int textHeight = styleGeneric[DEFAULT_TEXT_SIZE]; int textHeight = styleGeneric[DEFAULT_TEXT_SIZE];
if (bounds.width < textWidth) bounds.width = textWidth; if (bounds.width < textWidth) bounds.width = textWidth;
if (bounds.height < textHeight) bounds.height = textHeight; if (bounds.height < textHeight) bounds.height = textHeight;
// Check toggle button state // Update control
if (CheckCollisionPointRec(mousePoint, bounds)) //--------------------------------------------------------------------
if (state != DISABLED)
{ {
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = PRESSED; Vector2 mousePoint = GetMousePosition();
else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
// Check toggle button state
if (CheckCollisionPointRec(mousePoint, bounds))
{ {
state = NORMAL; if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = PRESSED;
active = !active; else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
{
state = NORMAL;
active = !active;
}
else state = FOCUSED;
} }
else state = FOCUSED;
} }
else active = false;
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// Draw control // Draw control
@ -719,6 +745,11 @@ RAYGUIDEF bool GuiToggleButton(Rectangle bounds, const char *text, bool active)
DrawRectangleRecT(bounds, GetColor(style[TOGGLE_BORDER_COLOR_PRESSED])); DrawRectangleRecT(bounds, GetColor(style[TOGGLE_BORDER_COLOR_PRESSED]));
DrawRectangleT(bounds.x + style[TOGGLE_BORDER_WIDTH], bounds.y + style[TOGGLE_BORDER_WIDTH], bounds.width - 2*style[TOGGLE_BORDER_WIDTH], bounds.height - 2*style[TOGGLE_BORDER_WIDTH], GetColor(style[TOGGLE_BASE_COLOR_PRESSED])); DrawRectangleT(bounds.x + style[TOGGLE_BORDER_WIDTH], bounds.y + style[TOGGLE_BORDER_WIDTH], bounds.width - 2*style[TOGGLE_BORDER_WIDTH], bounds.height - 2*style[TOGGLE_BORDER_WIDTH], GetColor(style[TOGGLE_BASE_COLOR_PRESSED]));
DrawText(text, bounds.x + bounds.width/2 - textWidth/2, bounds.y + bounds.height/2 - textHeight/2, styleGeneric[DEFAULT_TEXT_SIZE], GetColor(style[TOGGLE_TEXT_COLOR_PRESSED])); DrawText(text, bounds.x + bounds.width/2 - textWidth/2, bounds.y + bounds.height/2 - textHeight/2, styleGeneric[DEFAULT_TEXT_SIZE], GetColor(style[TOGGLE_TEXT_COLOR_PRESSED]));
} break;
case DISABLED:
{
} break; } break;
default: break; default: break;
} }
@ -742,19 +773,21 @@ RAYGUIDEF int GuiToggleGroup(Rectangle bounds, int toggleCount, char **toggleTex
// Check Box control, returns true when active // Check Box control, returns true when active
RAYGUIDEF bool GuiCheckBox(Rectangle bounds, bool checked) RAYGUIDEF bool GuiCheckBox(Rectangle bounds, bool checked)
{ {
ControlState state = NORMAL; GuiControlState state = guiState;
Vector2 mousePoint = GetMousePosition();
// Update control // Update control
//-------------------------------------------------------------------- //--------------------------------------------------------------------
if (state != DISABLED)
// Check checkbox state
if (CheckCollisionPointRec(mousePoint, bounds))
{ {
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = PRESSED; Vector2 mousePoint = GetMousePosition();
else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) checked = !checked;
else state = FOCUSED; // Check checkbox state
if (CheckCollisionPointRec(mousePoint, bounds))
{
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = PRESSED;
else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) checked = !checked;
else state = FOCUSED;
}
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -788,6 +821,11 @@ RAYGUIDEF bool GuiCheckBox(Rectangle bounds, bool checked)
bounds.y + style[CHECKBOX_BORDER_WIDTH] + style[CHECKBOX_INNER_PADDING], bounds.y + style[CHECKBOX_BORDER_WIDTH] + style[CHECKBOX_INNER_PADDING],
bounds.width - 2*(style[CHECKBOX_BORDER_WIDTH] + style[CHECKBOX_INNER_PADDING]), bounds.width - 2*(style[CHECKBOX_BORDER_WIDTH] + style[CHECKBOX_INNER_PADDING]),
bounds.height - 2*(style[CHECKBOX_BORDER_WIDTH] + style[CHECKBOX_INNER_PADDING]), GetColor(style[CHECKBOX_BASE_COLOR_PRESSED])); bounds.height - 2*(style[CHECKBOX_BORDER_WIDTH] + style[CHECKBOX_INNER_PADDING]), GetColor(style[CHECKBOX_BASE_COLOR_PRESSED]));
} break;
case DISABLED:
{
} break; } break;
default: break; default: break;
} }
@ -799,38 +837,41 @@ RAYGUIDEF bool GuiCheckBox(Rectangle bounds, bool checked)
// Combo Box control, returns selected item index // Combo Box control, returns selected item index
RAYGUIDEF int GuiComboBox(Rectangle bounds, int comboCount, char **comboText, int active) RAYGUIDEF int GuiComboBox(Rectangle bounds, int comboCount, char **comboText, int active)
{ {
ControlState state = NORMAL;
Vector2 mousePoint = GetMousePosition();
#define COMBOBOX_SELECTOR_WIDTH 35 #define COMBOBOX_SELECTOR_WIDTH 35
GuiControlState state = guiState;
bounds.width -= (COMBOBOX_SELECTOR_WIDTH + style[COMBOBOX_BUTTON_PADDING]); bounds.width -= (COMBOBOX_SELECTOR_WIDTH + style[COMBOBOX_BUTTON_PADDING]);
Rectangle selector = { bounds.x + bounds.width + style[COMBOBOX_BUTTON_PADDING], Rectangle selector = { bounds.x + bounds.width + style[COMBOBOX_BUTTON_PADDING],
bounds.y, COMBOBOX_SELECTOR_WIDTH, bounds.height }; bounds.y, COMBOBOX_SELECTOR_WIDTH, bounds.height };
// Update control
//--------------------------------------------------------------------
if (active < 0) active = 0; if (active < 0) active = 0;
else if (active > comboCount - 1) active = comboCount - 1; else if (active > comboCount - 1) active = comboCount - 1;
int textWidth = MeasureText(comboText[active], styleGeneric[DEFAULT_TEXT_SIZE]); int textWidth = MeasureText(comboText[active], styleGeneric[DEFAULT_TEXT_SIZE]);
int textHeight = styleGeneric[DEFAULT_TEXT_SIZE]; int textHeight = styleGeneric[DEFAULT_TEXT_SIZE];
if (bounds.width < textWidth) bounds.width = textWidth; if (bounds.width < textWidth) bounds.width = textWidth;
if (bounds.height < textHeight) bounds.height = textHeight; if (bounds.height < textHeight) bounds.height = textHeight;
if (CheckCollisionPointRec(mousePoint, bounds) || // Update control
CheckCollisionPointRec(mousePoint, selector)) //--------------------------------------------------------------------
if (state != DISABLED)
{ {
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = PRESSED; Vector2 mousePoint = GetMousePosition();
else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
if (CheckCollisionPointRec(mousePoint, bounds) ||
CheckCollisionPointRec(mousePoint, selector))
{ {
active += 1; if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = PRESSED;
if (active >= comboCount) active = 0; else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON))
{
active += 1;
if (active >= comboCount) active = 0;
}
else state = FOCUSED;
} }
else state = FOCUSED;
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -879,6 +920,10 @@ RAYGUIDEF int GuiComboBox(Rectangle bounds, int comboCount, char **comboText, in
selector.x + selector.width/2 - (MeasureText(FormatText("%i/%i", active + 1, comboCount), selector.x + selector.width/2 - (MeasureText(FormatText("%i/%i", active + 1, comboCount),
styleGeneric[DEFAULT_TEXT_SIZE])/2), selector.y + selector.height/2 - styleGeneric[DEFAULT_TEXT_SIZE]/2, styleGeneric[DEFAULT_TEXT_SIZE])/2), selector.y + selector.height/2 - styleGeneric[DEFAULT_TEXT_SIZE]/2,
styleGeneric[DEFAULT_TEXT_SIZE], GetColor(style[BUTTON_TEXT_COLOR_PRESSED])); styleGeneric[DEFAULT_TEXT_SIZE], GetColor(style[BUTTON_TEXT_COLOR_PRESSED]));
} break;
case DISABLED:
{
} break; } break;
default: break; default: break;
} }
@ -903,52 +948,54 @@ RAYGUIDEF void GuiGroupBox(Rectangle bounds, const char *text)
// NOTE: Requires static variables: framesCounter // NOTE: Requires static variables: framesCounter
RAYGUIDEF void GuiTextBox(Rectangle bounds, char *text, int textSize) RAYGUIDEF void GuiTextBox(Rectangle bounds, char *text, int textSize)
{ {
GuiControlState state = guiState;
static int framesCounter = 0; // Required for blinking cursor static int framesCounter = 0; // Required for blinking cursor
#define KEY_BACKSPACE_TEXT 259 // GLFW BACKSPACE: 3 + 256
ControlState state = NORMAL;
Vector2 mousePoint = GetMousePosition();
// Update control // Update control
//-------------------------------------------------------------------- //--------------------------------------------------------------------
if (CheckCollisionPointRec(mousePoint, bounds)) if (state != DISABLED)
{ {
state = FOCUSED; // NOTE: PRESSED state is not used on this control Vector2 mousePoint = GetMousePosition();
framesCounter++;
int letter = -1;
letter = GetKeyPressed();
if (letter != -1)
{
if (letter == KEY_BACKSPACE_TEXT)
{
for (int i = 0; i < textSize; i++)
{
if ((text[i] == '\0') && (i > 0))
{
text[i - 1] = '\0';
break;
}
}
text[textSize - 1] = '\0'; #define KEY_BACKSPACE_TEXT 259 // GLFW BACKSPACE: 3 + 256
}
else if (CheckCollisionPointRec(mousePoint, bounds))
{
state = FOCUSED; // NOTE: PRESSED state is not used on this control
framesCounter++;
int letter = -1;
letter = GetKeyPressed();
if (letter != -1)
{ {
if ((letter >= 32) && (letter < 127)) if (letter == KEY_BACKSPACE_TEXT)
{ {
for (int i = 0; i < textSize; i++) for (int i = 0; i < textSize; i++)
{ {
if (text[i] == '\0') if ((text[i] == '\0') && (i > 0))
{ {
text[i] = (char)letter; text[i - 1] = '\0';
break; break;
} }
} }
text[textSize - 1] = '\0';
}
else
{
if ((letter >= 32) && (letter < 127))
{
for (int i = 0; i < textSize; i++)
{
if (text[i] == '\0')
{
text[i] = (char)letter;
break;
}
}
}
} }
} }
} }
@ -976,6 +1023,10 @@ RAYGUIDEF void GuiTextBox(Rectangle bounds, char *text, int textSize)
} break; } break;
case PRESSED: break; // NOTE: PRESSED state is not used on this control case PRESSED: break; // NOTE: PRESSED state is not used on this control
case DISABLED:
{
} break;
default: break; default: break;
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -984,35 +1035,33 @@ RAYGUIDEF void GuiTextBox(Rectangle bounds, char *text, int textSize)
// Slider control, returns selected value // Slider control, returns selected value
RAYGUIDEF float GuiSlider(Rectangle bounds, float value, float minValue, float maxValue) RAYGUIDEF float GuiSlider(Rectangle bounds, float value, float minValue, float maxValue)
{ {
ControlState state = NORMAL; GuiControlState state = guiState;
Vector2 mousePoint = GetMousePosition();
Rectangle slider = { bounds.x + (int)((value/(maxValue - minValue))*(bounds.width - 2*style[SLIDER_BORDER_WIDTH])) - 10, Rectangle slider = { bounds.x + (int)((value/(maxValue - minValue))*(bounds.width - 2*style[SLIDER_BORDER_WIDTH])) - 10,
bounds.y + style[SLIDER_BORDER_WIDTH], bounds.y + style[SLIDER_BORDER_WIDTH], 20, bounds.height - 2*style[SLIDER_BORDER_WIDTH] };
20, bounds.height - 2*style[SLIDER_BORDER_WIDTH] };
// Update control // Update control
//-------------------------------------------------------------------- //--------------------------------------------------------------------
if (CheckCollisionPointRec(mousePoint, bounds)) if (state != DISABLED)
{ {
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) Vector2 mousePoint = GetMousePosition();
{
state = PRESSED;
// Get equivalent value from mousePoint.x
value = (((maxValue - minValue)*(mousePoint.x - (float)bounds.x))/(float)bounds.width) + minValue;
if (value > maxValue) value = maxValue;
else if (value < minValue) value = minValue;
slider.x = bounds.x + (int)(((value - minValue)/(maxValue - minValue))*(bounds.width - 2*style[SLIDER_BORDER_WIDTH])) - slider.width/2; if (CheckCollisionPointRec(mousePoint, bounds))
{
// Snap to limits if mouse down moved outside limits if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
//if (slider.x < (bounds.x + style[SLIDER_BORDER_WIDTH])) slider.x = bounds.x + style[SLIDER_BORDER_WIDTH]; {
//else if ((slider.x + slider.width) > (bounds.x + bounds.width - 2*style[SLIDER_BORDER_WIDTH])) slider.x = (bounds.x + bounds.width - 2*style[SLIDER_BORDER_WIDTH]) - slider.width; state = PRESSED;
// Get equivalent value and slider position from mousePoint.x
value = (((maxValue - minValue)*(mousePoint.x - (float)bounds.x))/(float)bounds.width) + minValue;
slider.x = bounds.x + (int)(((value - minValue)/(maxValue - minValue))*(bounds.width - 2*style[SLIDER_BORDER_WIDTH])) - slider.width/2;
// Snap to limits if mouse down moved outside limits
//if (slider.x < (bounds.x + style[SLIDER_BORDER_WIDTH])) slider.x = bounds.x + style[SLIDER_BORDER_WIDTH];
//else if ((slider.x + slider.width) > (bounds.x + bounds.width - 2*style[SLIDER_BORDER_WIDTH])) slider.x = (bounds.x + bounds.width - 2*style[SLIDER_BORDER_WIDTH]) - slider.width;
}
else state = FOCUSED;
} }
else state = FOCUSED;
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -1043,6 +1092,11 @@ RAYGUIDEF float GuiSlider(Rectangle bounds, float value, float minValue, float m
DrawRectangleRecT(slider, GetColor(style[SLIDER_BASE_COLOR_PRESSED])); DrawRectangleRecT(slider, GetColor(style[SLIDER_BASE_COLOR_PRESSED]));
DrawRectangleT(slider.x + slider.width/2, slider.y, 1, slider.height, GetColor(style[SLIDER_BORDER_COLOR_PRESSED])); DrawRectangleT(slider.x + slider.width/2, slider.y, 1, slider.height, GetColor(style[SLIDER_BORDER_COLOR_PRESSED]));
} break;
case DISABLED:
{
} break; } break;
default: break; default: break;
} }
@ -1054,32 +1108,30 @@ RAYGUIDEF float GuiSlider(Rectangle bounds, float value, float minValue, float m
// Slider Bar control, returns selected value // Slider Bar control, returns selected value
RAYGUIDEF float GuiSliderBar(Rectangle bounds, float value, float minValue, float maxValue) RAYGUIDEF float GuiSliderBar(Rectangle bounds, float value, float minValue, float maxValue)
{ {
ControlState state = NORMAL; GuiControlState state = guiState;
Vector2 mousePoint = GetMousePosition(); Rectangle slider = { bounds.x + style[SLIDERBAR_BORDER_WIDTH], bounds.y + style[SLIDERBAR_BORDER_WIDTH] + style[SLIDERBAR_INNER_PADDING],
Rectangle slider = { bounds.x + style[SLIDERBAR_BORDER_WIDTH],
bounds.y + style[SLIDERBAR_BORDER_WIDTH] + style[SLIDERBAR_INNER_PADDING],
(int)(((value - minValue)/(maxValue - minValue))*(bounds.width - 2*style[SLIDERBAR_BORDER_WIDTH])), (int)(((value - minValue)/(maxValue - minValue))*(bounds.width - 2*style[SLIDERBAR_BORDER_WIDTH])),
bounds.height - 2*style[SLIDERBAR_BORDER_WIDTH] - 2*style[SLIDERBAR_INNER_PADDING] }; bounds.height - 2*style[SLIDERBAR_BORDER_WIDTH] - 2*style[SLIDERBAR_INNER_PADDING] };
// Update control // Update control
//-------------------------------------------------------------------- //--------------------------------------------------------------------
if (CheckCollisionPointRec(mousePoint, bounds)) if (state != DISABLED)
{ {
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) Vector2 mousePoint = GetMousePosition();
{
state = PRESSED;
// Get equivalent value from mousePoint.x
value = (maxValue - minValue)*((mousePoint.x - (float)bounds.x)/(float)bounds.width) + minValue;
if (value > maxValue) value = maxValue;
else if (value < minValue) value = minValue;
slider.width = (int)(((value - minValue)/(maxValue - minValue))*(bounds.width - 2*style[SLIDERBAR_BORDER_WIDTH])); if (CheckCollisionPointRec(mousePoint, bounds))
{
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
{
state = PRESSED;
// Get equivalent value and slider width from mousePoint.x
value = (maxValue - minValue)*((mousePoint.x - (float)bounds.x)/(float)bounds.width) + minValue;
slider.width = (int)(((value - minValue)/(maxValue - minValue))*(bounds.width - 2*style[SLIDERBAR_BORDER_WIDTH]));
}
else state = FOCUSED;
} }
else state = FOCUSED;
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -1104,6 +1156,10 @@ RAYGUIDEF float GuiSliderBar(Rectangle bounds, float value, float minValue, floa
DrawRectangleRecT(bounds, GetColor(style[SLIDERBAR_BORDER_COLOR_PRESSED])); DrawRectangleRecT(bounds, GetColor(style[SLIDERBAR_BORDER_COLOR_PRESSED]));
DrawRectangleT(bounds.x + style[SLIDERBAR_BORDER_WIDTH], bounds.y + style[SLIDERBAR_BORDER_WIDTH], bounds.width - 2*style[SLIDERBAR_BORDER_WIDTH], bounds.height - 2*style[SLIDERBAR_BORDER_WIDTH], GetColor(style[SLIDERBAR_BASE_COLOR_NORMAL])); DrawRectangleT(bounds.x + style[SLIDERBAR_BORDER_WIDTH], bounds.y + style[SLIDERBAR_BORDER_WIDTH], bounds.width - 2*style[SLIDERBAR_BORDER_WIDTH], bounds.height - 2*style[SLIDERBAR_BORDER_WIDTH], GetColor(style[SLIDERBAR_BASE_COLOR_NORMAL]));
DrawRectangleRecT(slider, GetColor(style[SLIDERBAR_BASE_COLOR_PRESSED])); DrawRectangleRecT(slider, GetColor(style[SLIDERBAR_BASE_COLOR_PRESSED]));
} break;
case DISABLED:
{
} break; } break;
default: break; default: break;
} }
@ -1115,9 +1171,7 @@ RAYGUIDEF float GuiSliderBar(Rectangle bounds, float value, float minValue, floa
// Progress Bar control, shows current progress value // Progress Bar control, shows current progress value
RAYGUIDEF float GuiProgressBar(Rectangle bounds, float value, float minValue, float maxValue) RAYGUIDEF float GuiProgressBar(Rectangle bounds, float value, float minValue, float maxValue)
{ {
ControlState state = NORMAL; GuiControlState state = guiState;
Vector2 mousePoint = GetMousePosition();
Rectangle progress = { bounds.x + style[PROGRESSBAR_BORDER_WIDTH], Rectangle progress = { bounds.x + style[PROGRESSBAR_BORDER_WIDTH],
bounds.y + style[PROGRESSBAR_BORDER_WIDTH] + style[PROGRESSBAR_INNER_PADDING], bounds.y + style[PROGRESSBAR_BORDER_WIDTH] + style[PROGRESSBAR_INNER_PADDING],
@ -1126,12 +1180,14 @@ RAYGUIDEF float GuiProgressBar(Rectangle bounds, float value, float minValue, fl
// Update control // Update control
//-------------------------------------------------------------------- //--------------------------------------------------------------------
if (value > maxValue) value = maxValue; if (state != DISABLED)
else if (value < minValue) value = minValue; {
Vector2 mousePoint = GetMousePosition();
progress.width = (int)(value/(maxValue - minValue)*(float)(bounds.width - 2*style[PROGRESSBAR_BORDER_WIDTH]));
//if (CheckCollisionPointRec(mousePoint, bounds)) state = FOCUSED; // State not required on ProgressBar progress.width = (int)(value/(maxValue - minValue)*(float)(bounds.width - 2*style[PROGRESSBAR_BORDER_WIDTH]));
//if (CheckCollisionPointRec(mousePoint, bounds)) state = FOCUSED; // State not required on ProgressBar
}
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// Draw control // Draw control
@ -1153,6 +1209,11 @@ RAYGUIDEF float GuiProgressBar(Rectangle bounds, float value, float minValue, fl
//DrawRectangleRecT(progress, GetColor(style[PROGRESSBAR_BASE_COLOR_FOCUSED])); //DrawRectangleRecT(progress, GetColor(style[PROGRESSBAR_BASE_COLOR_FOCUSED]));
} break; } break;
case PRESSED: break; case PRESSED: break;
case DISABLED:
{
} break;
default: break; default: break;
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -1163,15 +1224,12 @@ RAYGUIDEF float GuiProgressBar(Rectangle bounds, float value, float minValue, fl
// Spinner control, returns selected value // Spinner control, returns selected value
// NOTE: Requires static variables: framesCounter, valueSpeed - ERROR! // NOTE: Requires static variables: framesCounter, valueSpeed - ERROR!
RAYGUIDEF int GuiSpinner(Rectangle bounds, int value, int minValue, int maxValue) RAYGUIDEF int GuiSpinner(Rectangle bounds, int value, int minValue, int maxValue)
{ {
ControlState state = NORMAL;
#define SPINNER_LEFT_BUTTON 1 #define SPINNER_LEFT_BUTTON 1
#define SPINNER_RIGHT_BUTTON 2 #define SPINNER_RIGHT_BUTTON 2
#define SPINNER_BUTTON_WIDTH 35 #define SPINNER_BUTTON_WIDTH 35
Vector2 mousePoint = GetMousePosition(); GuiControlState state = guiState;
static int framesCounter = 0; static int framesCounter = 0;
static bool valueSpeed = false;; static bool valueSpeed = false;;
@ -1187,77 +1245,82 @@ RAYGUIDEF int GuiSpinner(Rectangle bounds, int value, int minValue, int maxValue
if (bounds.height < textHeight) bounds.height = textHeight; if (bounds.height < textHeight) bounds.height = textHeight;
// Update control // Update control
//-------------------------------------------------------------------- //--------------------------------------------------------------------
if (CheckCollisionPointRec(mousePoint, leftButtonBound)) if (state != DISABLED)
{ {
state = FOCUSED; Vector2 mousePoint = GetMousePosition();
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) if (CheckCollisionPointRec(mousePoint, leftButtonBound))
{ {
state = PRESSED; state = FOCUSED;
if (!valueSpeed)
{
if (value > minValue) value--;
valueSpeed = true;
}
else framesCounter++;
if (value > minValue) if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
{ {
if (framesCounter >= 30) value -= 1; state = PRESSED;
if (!valueSpeed)
{
if (value > minValue) value--;
valueSpeed = true;
}
else framesCounter++;
if (value > minValue)
{
if (framesCounter >= 30) value -= 1;
}
} }
} }
} else if (CheckCollisionPointRec(mousePoint, rightButtonBound))
else if (CheckCollisionPointRec(mousePoint, rightButtonBound))
{
state = FOCUSED;
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
{ {
state = PRESSED; state = FOCUSED;
if (!valueSpeed) if (IsMouseButtonDown(MOUSE_LEFT_BUTTON))
{ {
if (value < maxValue) value++; state = PRESSED;
valueSpeed = true;
} if (!valueSpeed)
else framesCounter++; {
if (value < maxValue) value++;
valueSpeed = true;
}
else framesCounter++;
if (value < maxValue) if (value < maxValue)
{
if (framesCounter >= 30) value += 1;
}
}
}
if (IsMouseButtonUp(MOUSE_LEFT_BUTTON))
{
valueSpeed = false;
framesCounter = 0;
}
/*
if (CheckCollisionPointRec(mousePoint, leftButtonBound) ||
CheckCollisionPointRec(mousePoint, rightButtonBound) ||
CheckCollisionPointRec(mousePoint, spinner))
{
if (IsKeyDown(KEY_LEFT))
{ {
if (framesCounter >= 30) value += 1; state = PRESSED;
buttonSide = 1;
if (value > minValue) value -= 1;
} }
} else if (IsKeyDown(KEY_RIGHT))
} {
state = PRESSED;
buttonSide = 2;
if (IsMouseButtonUp(MOUSE_LEFT_BUTTON)) if (value < maxValue) value += 1;
{ }
valueSpeed = false;
framesCounter = 0;
}
/*
if (CheckCollisionPointRec(mousePoint, leftButtonBound) ||
CheckCollisionPointRec(mousePoint, rightButtonBound) ||
CheckCollisionPointRec(mousePoint, spinner))
{
if (IsKeyDown(KEY_LEFT))
{
state = PRESSED;
buttonSide = 1;
if (value > minValue) value -= 1;
}
else if (IsKeyDown(KEY_RIGHT))
{
state = PRESSED;
buttonSide = 2;
if (value < maxValue) value += 1;
} }
*/
} }
*/
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// Draw control // Draw control
@ -1302,6 +1365,11 @@ RAYGUIDEF int GuiSpinner(Rectangle bounds, int value, int minValue, int maxValue
DrawRectangleT(spinner.x + 1, spinner.y + 1, spinner.width - 2, spinner.height - 2, GetColor(style[SPINNER_BASE_COLOR_PRESSED])); DrawRectangleT(spinner.x + 1, spinner.y + 1, spinner.width - 2, spinner.height - 2, GetColor(style[SPINNER_BASE_COLOR_PRESSED]));
DrawText(FormatText("%i", value), spinner.x + (spinner.width/2 - textWidth/2), spinner.y + (spinner.height/2 - (styleGeneric[DEFAULT_TEXT_SIZE]/2)), styleGeneric[DEFAULT_TEXT_SIZE], GetColor(style[SPINNER_TEXT_COLOR_PRESSED])); DrawText(FormatText("%i", value), spinner.x + (spinner.width/2 - textWidth/2), spinner.y + (spinner.height/2 - (styleGeneric[DEFAULT_TEXT_SIZE]/2)), styleGeneric[DEFAULT_TEXT_SIZE], GetColor(style[SPINNER_TEXT_COLOR_PRESSED]));
} break;
case DISABLED:
{
} break; } break;
default: break; default: break;
} }
@ -1312,18 +1380,21 @@ RAYGUIDEF int GuiSpinner(Rectangle bounds, int value, int minValue, int maxValue
// Texture button control, returns true when clicked // Texture button control, returns true when clicked
RAYGUIDEF bool GuiTexture(Rectangle bounds, Texture2D texture) RAYGUIDEF bool GuiTexture(Rectangle bounds, Texture2D texture)
{ {
ControlState state = NORMAL; GuiControlState state = guiState;
Vector2 mousePoint = GetMousePosition();
bool clicked = false; bool clicked = false;
// Update control // Update control
//-------------------------------------------------------------------- //--------------------------------------------------------------------
if (CheckCollisionPointRec(mousePoint, bounds)) // Check button state if (state != DISABLED)
{ {
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = PRESSED; Vector2 mousePoint = GetMousePosition();
else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) clicked = true;
else state = FOCUSED; if (CheckCollisionPointRec(mousePoint, bounds)) // Check button state
{
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = PRESSED;
else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) clicked = true;
else state = FOCUSED;
}
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@ -1348,13 +1419,16 @@ RAYGUIDEF bool GuiTexture(Rectangle bounds, Texture2D texture)
DrawRectangleRecT(bounds, GetColor(style[BUTTON_BORDER_COLOR_PRESSED])); DrawRectangleRecT(bounds, GetColor(style[BUTTON_BORDER_COLOR_PRESSED]));
DrawRectangleT(bounds.x + style[BUTTON_BORDER_WIDTH], bounds.y + style[BUTTON_BORDER_WIDTH], bounds.width - 2*style[BUTTON_BORDER_WIDTH], bounds.height - 2*style[BUTTON_BORDER_WIDTH], GetColor(style[BUTTON_BASE_COLOR_PRESSED])); DrawRectangleT(bounds.x + style[BUTTON_BORDER_WIDTH], bounds.y + style[BUTTON_BORDER_WIDTH], bounds.width - 2*style[BUTTON_BORDER_WIDTH], bounds.height - 2*style[BUTTON_BORDER_WIDTH], GetColor(style[BUTTON_BASE_COLOR_PRESSED]));
DrawTexture(texture, bounds.x, bounds.y, GetColor(style[BUTTON_BASE_COLOR_PRESSED])); DrawTexture(texture, bounds.x, bounds.y, GetColor(style[BUTTON_BASE_COLOR_PRESSED]));
} break;
case DISABLED:
{
} break; } break;
default: break; default: break;
} }
//------------------------------------------------------------------ //------------------------------------------------------------------
if (clicked) return true; return clicked;
else return false;
} }
// Color Picker control // Color Picker control
@ -1367,7 +1441,7 @@ RAYGUIDEF bool GuiTexture(Rectangle bounds, Texture2D texture)
// unsigned char GuiColorBarLuminance() [BLACK->WHITE] // unsigned char GuiColorBarLuminance() [BLACK->WHITE]
Color GuiColorPicker(Rectangle bounds, Color color) Color GuiColorPicker(Rectangle bounds, Color color)
{ {
ControlState state = NORMAL; GuiControlState state = NORMAL;
Vector2 mousePoint = GetMousePosition(); Vector2 mousePoint = GetMousePosition();
@ -1520,6 +1594,10 @@ Color GuiColorPicker(Rectangle bounds, Color color)
return color; return color;
} }
RAYGUIDEF void GuiEnable(void) { guiState = NORMAL; } // Enable gui global state
RAYGUIDEF void GuiDisable(void) { guiState = DISABLED; } // Disable gui global state
#if defined(RAYGUI_STYLE_SAVE_LOAD) #if defined(RAYGUI_STYLE_SAVE_LOAD)
// Load GUI style from an image file // Load GUI style from an image file
RAYGUIDEF void LoadGuiStyleImage(const char *fileName) RAYGUIDEF void LoadGuiStyleImage(const char *fileName)