From 1fa1e001ff0cc4b5819c09395310d8eabff38f72 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 9 Nov 2018 18:58:15 +0100 Subject: [PATCH] Minor tweaks to correct issues --- .../controls_test_suite/controls_test_suite.c | 10 ++++----- src/raygui.h | 22 +++++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/examples/controls_test_suite/controls_test_suite.c b/examples/controls_test_suite/controls_test_suite.c index f5c9867..e8eafd4 100644 --- a/examples/controls_test_suite/controls_test_suite.c +++ b/examples/controls_test_suite/controls_test_suite.c @@ -127,11 +127,11 @@ int main() // Fourth GUI column GuiLock(); - GuiState(0); if (GuiButton((Rectangle){ 600, 25, 125, 30 }, "DISABLE")) { } - GuiState(1); if (GuiButton((Rectangle){ 600, 65, 125, 30 }, "NORMAL")) { } - GuiState(2); if (GuiButton((Rectangle){ 600, 105, 125, 30 }, "FOCUSED")) { } - GuiState(3); if (GuiButton((Rectangle){ 600, 145, 125, 30 }, "PRESSED")) { } - GuiState(1); + GuiState(GUI_STATE_NORMAL); if (GuiButton((Rectangle){ 600, 25, 125, 30 }, "NORMAL")) { } + GuiState(GUI_STATE_FOCUSED); if (GuiButton((Rectangle){ 600, 65, 125, 30 }, "FOCUSED")) { } + GuiState(GUI_STATE_PRESSED); if (GuiButton((Rectangle){ 600, 105, 125, 30 }, "PRESSED")) { } + GuiState(GUI_STATE_DISABLED); if (GuiButton((Rectangle){ 600, 145, 125, 30 }, "DISABLED")) { } + GuiState(GUI_STATE_NORMAL); GuiUnlock(); //---------------------------------------------------------------------------------- diff --git a/src/raygui.h b/src/raygui.h index bc1e9a9..27b2ad4 100644 --- a/src/raygui.h +++ b/src/raygui.h @@ -181,6 +181,14 @@ } Rectangle; #endif +// Gui global state enum +typedef enum GuiStateMode { + GUI_STATE_NORMAL = 0, + GUI_STATE_FOCUSED, + GUI_STATE_PRESSED, + GUI_STATE_DISABLE, +} GuiStateMode; + // Gui properties enumeration typedef enum GuiProperty { //-------------------------------------------- @@ -459,10 +467,10 @@ RAYGUIDEF void GuiUpdateStyleComplete(void); // Updat // GUI controls state typedef enum GuiControlState { - DISABLED = 0, - NORMAL, + NORMAL = 0, FOCUSED, PRESSED, + DISABLED } GuiControlState; //---------------------------------------------------------------------------------- @@ -1018,6 +1026,8 @@ RAYGUIDEF void GuiGroupBox(Rectangle bounds, const char *text) switch (state) { case NORMAL: + case FOCUSED: + case PRESSED: { DrawRectangle(bounds.x, bounds.y, GROUPBOX_LINE_THICK, bounds.height, Fade(GetColor(style[DEFAULT_LINES_COLOR]), guiAlpha)); DrawRectangle(bounds.x, bounds.y + bounds.height - 1, bounds.width, GROUPBOX_LINE_THICK, Fade(GetColor(style[DEFAULT_LINES_COLOR]), guiAlpha)); @@ -1030,8 +1040,6 @@ RAYGUIDEF void GuiGroupBox(Rectangle bounds, const char *text) GuiDrawText(text, bounds.x + GROUPBOX_TEXT_PADDING + 2*GROUPBOX_PADDING, bounds.y - 2*GROUPBOX_PADDING - GROUPBOX_LINE_THICK, Fade(GetColor(style[LABEL_TEXT_COLOR_NORMAL]), guiAlpha)); } } break; - case FOCUSED: break; // NOTE: State not used on this control - case PRESSED: break; // NOTE: State not used on this control case DISABLED: { DrawRectangle(bounds.x, bounds.y, GROUPBOX_LINE_THICK, bounds.height, Fade(GetColor(style[DEFAULT_BORDER_COLOR_DISABLED]), guiAlpha)); @@ -1675,7 +1683,7 @@ RAYGUIDEF bool GuiDropdownBox(Rectangle bounds, const char **text, int count, in } break; case FOCUSED: { - GuiListElement((Rectangle){ bounds.x, bounds.y, bounds.width, bounds.height }, text[auxActive], false, true); + GuiListElement((Rectangle){ bounds.x, bounds.y, bounds.width, bounds.height }, text[auxActive], false, editMode); DrawTriangle((Vector2){ bounds.x + bounds.width - DROPDOWNBOX_ARROW_RIGHT_PADDING, bounds.y + bounds.height/2 - 2 }, (Vector2){ bounds.x + bounds.width - DROPDOWNBOX_ARROW_RIGHT_PADDING + 5, bounds.y + bounds.height/2 - 2 + 5 }, @@ -2446,13 +2454,13 @@ RAYGUIDEF float GuiProgressBarEx(Rectangle bounds, float value, float minValue, switch (state) { case NORMAL: + case FOCUSED: + case PRESSED: { DrawRectangleLinesEx(bounds, style[PROGRESSBAR_BORDER_WIDTH], Fade(GetColor(style[PROGRESSBAR_BORDER_COLOR_NORMAL]), guiAlpha)); DrawRectangle(bounds.x + style[PROGRESSBAR_BORDER_WIDTH], bounds.y + style[PROGRESSBAR_BORDER_WIDTH], bounds.width - 2*style[PROGRESSBAR_BORDER_WIDTH], bounds.height - 2*style[PROGRESSBAR_BORDER_WIDTH], Fade(GetColor(style[DEFAULT_BACKGROUND_COLOR]), guiAlpha)); DrawRectangleRec(progress, Fade(GetColor(style[PROGRESSBAR_BASE_COLOR_NORMAL]), guiAlpha)); } break; - case FOCUSED: break; // NOTE: State not used on this control - case PRESSED: break; // NOTE: State not used on this control case DISABLED: { DrawRectangleLinesEx(bounds, style[PROGRESSBAR_BORDER_WIDTH], Fade(GetColor(style[PROGRESSBAR_BORDER_COLOR_DISABLED]), guiAlpha));