mirror of
https://github.com/raysan5/raygui.git
synced 2026-01-31 11:19:18 -05:00
GuiCheckBoxEx and GuiLabelButton review
This commit is contained in:
@ -52,6 +52,8 @@ int main()
|
|||||||
|
|
||||||
bool dropDown000EditMode = false;
|
bool dropDown000EditMode = false;
|
||||||
bool dropDown001EditMode = false;
|
bool dropDown001EditMode = false;
|
||||||
|
|
||||||
|
bool forceSquaredChecked = false;
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
Font font = LoadFontEx("fonts/NorthernLights.ttf", 30, 0, 0);
|
Font font = LoadFontEx("fonts/NorthernLights.ttf", 30, 0, 0);
|
||||||
@ -89,8 +91,10 @@ int main()
|
|||||||
|
|
||||||
//GuiScrollPanel((Rectangle){ 325, 225, 225, 125 }, "SAMPLE TEXT");
|
//GuiScrollPanel((Rectangle){ 325, 225, 225, 125 }, "SAMPLE TEXT");
|
||||||
if (GuiDropdownBox((Rectangle){ 25, 75, 125, 30 }, DropdownBox000TextList, 3, &DropdownBox001Active, dropDown001EditMode)) dropDown001EditMode = !dropDown001EditMode;
|
if (GuiDropdownBox((Rectangle){ 25, 75, 125, 30 }, DropdownBox000TextList, 3, &DropdownBox001Active, dropDown001EditMode)) dropDown001EditMode = !dropDown001EditMode;
|
||||||
|
//forceSquaredChecked = GuiCheckBoxEx((Rectangle){ 25, 65, 15, 15 }, forceSquaredChecked, "Force Square");
|
||||||
|
GuiDisable();
|
||||||
if (GuiDropdownBox((Rectangle){ 25, 25, 125, 30 }, DropdownBox000TextList, 3, &DropdownBox000Active, dropDown000EditMode)) dropDown000EditMode = !dropDown000EditMode;
|
if (GuiDropdownBox((Rectangle){ 25, 25, 125, 30 }, DropdownBox000TextList, 3, &DropdownBox000Active, dropDown000EditMode)) dropDown000EditMode = !dropDown000EditMode;
|
||||||
|
GuiEnable();
|
||||||
|
|
||||||
GuiLock();
|
GuiLock();
|
||||||
GuiState(0); if (GuiButton((Rectangle){ 25, 400, 125, 30 }, "SAMPLE TEXT")) Button005();
|
GuiState(0); if (GuiButton((Rectangle){ 25, 400, 125, 30 }, "SAMPLE TEXT")) Button005();
|
||||||
|
|||||||
14
src/raygui.h
14
src/raygui.h
@ -1197,7 +1197,7 @@ RAYGUIDEF bool GuiButton(Rectangle bounds, const char *text)
|
|||||||
RAYGUIDEF bool GuiLabelButton(Rectangle bounds, const char *text)
|
RAYGUIDEF bool GuiLabelButton(Rectangle bounds, const char *text)
|
||||||
{
|
{
|
||||||
GuiControlState state = guiState;
|
GuiControlState state = guiState;
|
||||||
bool clicked = false;
|
bool pressed = false;
|
||||||
|
|
||||||
int textWidth = GuiTextWidth(text);
|
int textWidth = GuiTextWidth(text);
|
||||||
int textHeight = style[DEFAULT_TEXT_SIZE];
|
int textHeight = style[DEFAULT_TEXT_SIZE];
|
||||||
@ -1211,12 +1211,13 @@ RAYGUIDEF bool GuiLabelButton(Rectangle bounds, const char *text)
|
|||||||
{
|
{
|
||||||
Vector2 mousePoint = GetMousePosition();
|
Vector2 mousePoint = GetMousePosition();
|
||||||
|
|
||||||
// Check label state
|
// Check checkbox state
|
||||||
if (CheckCollisionPointRec(mousePoint, bounds))
|
if (CheckCollisionPointRec(mousePoint, bounds))
|
||||||
{
|
{
|
||||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = PRESSED;
|
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = PRESSED;
|
||||||
else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) clicked = true;
|
|
||||||
else state = FOCUSED;
|
else state = FOCUSED;
|
||||||
|
|
||||||
|
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
@ -1233,7 +1234,7 @@ RAYGUIDEF bool GuiLabelButton(Rectangle bounds, const char *text)
|
|||||||
}
|
}
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
return clicked;
|
return pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Image button control, returns true when clicked
|
// Image button control, returns true when clicked
|
||||||
@ -1495,8 +1496,9 @@ RAYGUIDEF bool GuiCheckBoxEx(Rectangle bounds, bool checked, const char *text)
|
|||||||
if (CheckCollisionPointRec(mousePoint, bounds))
|
if (CheckCollisionPointRec(mousePoint, bounds))
|
||||||
{
|
{
|
||||||
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = PRESSED;
|
if (IsMouseButtonDown(MOUSE_LEFT_BUTTON)) state = PRESSED;
|
||||||
else if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) checked = !checked;
|
|
||||||
else state = FOCUSED;
|
else state = FOCUSED;
|
||||||
|
|
||||||
|
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) checked = !checked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
@ -1755,7 +1757,7 @@ RAYGUIDEF bool GuiDropdownBox(Rectangle bounds, const char **text, int count, in
|
|||||||
{
|
{
|
||||||
DrawRectangle(bounds.x, bounds.y, bounds.width, bounds.height, Fade(GetColor(style[DEFAULT_BASE_COLOR_DISABLED]), guiAlpha));
|
DrawRectangle(bounds.x, bounds.y, bounds.width, bounds.height, Fade(GetColor(style[DEFAULT_BASE_COLOR_DISABLED]), guiAlpha));
|
||||||
DrawRectangleLinesEx(bounds, DROPDOWNBOX_BORDER_WIDTH, Fade(GetColor(style[LISTVIEW_BORDER_COLOR_DISABLED]), guiAlpha));
|
DrawRectangleLinesEx(bounds, DROPDOWNBOX_BORDER_WIDTH, Fade(GetColor(style[LISTVIEW_BORDER_COLOR_DISABLED]), guiAlpha));
|
||||||
GuiListElement((Rectangle){ bounds.x, bounds.y, bounds.width, bounds.height }, text[activeAux], false, true);
|
GuiListElement((Rectangle){ bounds.x, bounds.y, bounds.width, bounds.height }, text[activeAux], false, false);
|
||||||
|
|
||||||
DrawTriangle((Vector2){ bounds.x + bounds.width - DROPDOWNBOX_ARROW_RIGHT_PADDING, bounds.y + bounds.height/2 - 2 },
|
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 },
|
(Vector2){ bounds.x + bounds.width - DROPDOWNBOX_ARROW_RIGHT_PADDING + 5, bounds.y + bounds.height/2 - 2 + 5 },
|
||||||
|
|||||||
Reference in New Issue
Block a user