From 7053724fd6209682f203b188c6f309214880b84f Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 6 Mar 2016 12:24:44 +0100 Subject: Default style tweak --- src/raygui.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/raygui.c') diff --git a/src/raygui.c b/src/raygui.c index 60df2121..3d7a67ec 100644 --- a/src/raygui.c +++ b/src/raygui.c @@ -59,16 +59,16 @@ static int style[NUM_PROPERTIES] = { 1, // GLOBAL_BORDER_WIDTH 0xf5f5f5ff, // BACKGROUND_COLOR 1, // LABEL_BORDER_WIDTH - 0x000000ff, // LABEL_TEXT_COLOR + 0x4d4d4dff, // LABEL_TEXT_COLOR 20, // LABEL_TEXT_PADDING 2, // BUTTON_BORDER_WIDTH 20, // BUTTON_TEXT_PADDING 0x828282ff, // BUTTON_DEFAULT_BORDER_COLOR 0xc8c8c8ff, // BUTTON_DEFAULT_INSIDE_COLOR - 0x000000ff, // BUTTON_DEFAULT_TEXT_COLOR + 0x4d4d4dff, // BUTTON_DEFAULT_TEXT_COLOR 0xc8c8c8ff, // BUTTON_HOVER_BORDER_COLOR 0xffffffff, // BUTTON_HOVER_INSIDE_COLOR - 0x000000ff, // BUTTON_HOVER_TEXT_COLOR + 0x353535ff, // BUTTON_HOVER_TEXT_COLOR 0x7bb0d6ff, // BUTTON_PRESSED_BORDER_COLOR 0xbcecffff, // BUTTON_PRESSED_INSIDE_COLOR 0x5f9aa7ff, // BUTTON_PRESSED_TEXT_COLOR @@ -120,7 +120,7 @@ static int style[NUM_PROPERTIES] = { 0x000000ff, // SPINNER_PRESSED_TEXT_COLOR 1, // COMBOBOX_PADDING 30, // COMBOBOX_BUTTON_WIDTH - 30, // COMBOBOX_BUTTON_HEIGHT + 20, // COMBOBOX_BUTTON_HEIGHT 1, // COMBOBOX_BORDER_WIDTH 0x828282ff, // COMBOBOX_DEFAULT_BORDER_COLOR 0xc8c8c8ff, // COMBOBOX_DEFAULT_INSIDE_COLOR -- cgit v1.2.3 From 6ee5718b2e65c69fca695fdf999fa1838c63aa0b Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 6 Mar 2016 19:30:16 +0100 Subject: Improved function GetKeyPressed() To support multiple keys (including function keys) --- src/raygui.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/raygui.c') diff --git a/src/raygui.c b/src/raygui.c index 3d7a67ec..e66c33b5 100644 --- a/src/raygui.c +++ b/src/raygui.c @@ -789,11 +789,11 @@ int GuiSpinner(Rectangle bounds, int value, int minValue, int maxValue) // NOTE: Requires static variables: framesCounter - ERROR! char *GuiTextBox(Rectangle bounds, char *text) { - #define MAX_CHARS_LENGTH 20 - #define KEY_BACKSPACE_TEXT 3 + #define MAX_CHARS_LENGTH 20 + #define KEY_BACKSPACE_TEXT 259 // GLFW BACKSPACE: 3 + 256 int initPos = bounds.x + 4; - char letter = -1; + int letter = -1; static int framesCounter = 0; Vector2 mousePoint = GetMousePosition(); @@ -822,12 +822,15 @@ char *GuiTextBox(Rectangle bounds, char *text) } else { - for (int i = 0; i < MAX_CHARS_LENGTH; i++) + if ((letter >= 32) && (letter < 127)) { - if (text[i] == '\0') + for (int i = 0; i < MAX_CHARS_LENGTH; i++) { - text[i] = letter; - break; + if (text[i] == '\0') + { + text[i] = (char)letter; + break; + } } } } -- cgit v1.2.3 From 18a13679fd4d9257d7328a5d4d55eefaf7558d6a Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 7 Mar 2016 09:38:55 +0100 Subject: Review GuiToggleButton() --- src/raygui.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/raygui.c') diff --git a/src/raygui.c b/src/raygui.c index e66c33b5..95cea0b6 100644 --- a/src/raygui.c +++ b/src/raygui.c @@ -258,15 +258,28 @@ bool GuiToggleButton(Rectangle bounds, const char *text, bool toggle) //-------------------------------------------------------------------- if (toggleButton.width < textWidth) toggleButton.width = textWidth + style[TOGGLE_TEXT_PADDING]; if (toggleButton.height < textHeight) toggleButton.height = textHeight + style[TOGGLE_TEXT_PADDING]/2; + + if (toggle) toggleState = TOGGLE_ACTIVE; + else toggleState = TOGGLE_UNACTIVE; + if (CheckCollisionPointRec(mousePoint, toggleButton)) { if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) toggleState = TOGGLE_PRESSED; - else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) toggleState = TOGGLE_ACTIVE; + else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) + { + if (toggle) + { + toggle = false; + toggleState = TOGGLE_UNACTIVE; + } + else + { + toggle = true; + toggleState = TOGGLE_ACTIVE; + } + } else toggleState = TOGGLE_HOVER; } - - if (toggleState == TOGGLE_ACTIVE && !toggle) toggle = true; - if (toggle) toggleState = TOGGLE_ACTIVE; //-------------------------------------------------------------------- // Draw control -- cgit v1.2.3