aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRay <raysan5@gmail.com>2016-03-07 09:38:55 +0100
committerRay <raysan5@gmail.com>2016-03-07 09:38:55 +0100
commit18a13679fd4d9257d7328a5d4d55eefaf7558d6a (patch)
tree9c110a1a533eae4f33a077ffefaaa6dabf1fb1c5 /src
parent6ee5718b2e65c69fca695fdf999fa1838c63aa0b (diff)
downloadraylib-18a13679fd4d9257d7328a5d4d55eefaf7558d6a.tar.gz
raylib-18a13679fd4d9257d7328a5d4d55eefaf7558d6a.zip
Review GuiToggleButton()
Diffstat (limited to 'src')
-rw-r--r--src/raygui.c21
1 files changed, 17 insertions, 4 deletions
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