mirror of
https://github.com/raysan5/raygui.git
synced 2026-01-28 01:39:17 -05:00
Added GuiToggleGroupEx()
Improved GuiToggleGroup()
This commit is contained in:
@ -83,6 +83,8 @@ int main()
|
|||||||
bool forceSquaredChecked = false;
|
bool forceSquaredChecked = false;
|
||||||
|
|
||||||
int comboBoxActive = 1;
|
int comboBoxActive = 1;
|
||||||
|
|
||||||
|
int toggleGroupActive = 0;
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Custom GUI font loading
|
// Custom GUI font loading
|
||||||
@ -127,7 +129,7 @@ int main()
|
|||||||
GuiState(GUI_STATE_NORMAL);
|
GuiState(GUI_STATE_NORMAL);
|
||||||
GuiUnlock();
|
GuiUnlock();
|
||||||
|
|
||||||
comboBoxActive = GuiComboBox((Rectangle){25, 470, 125, 30}, dropdownBox001TextList, 5, comboBoxActive);
|
comboBoxActive = GuiComboBox((Rectangle){ 25, 470, 125, 30 }, dropdownBox001TextList, 5, comboBoxActive);
|
||||||
|
|
||||||
// NOTE: GuiDropdownBox must draw after any other control that can be covered on unfolding
|
// NOTE: GuiDropdownBox must draw after any other control that can be covered on unfolding
|
||||||
if (GuiDropdownBox((Rectangle){ 25, 65, 125, 30 }, dropdownBox001TextList, 5, &dropdownBox001Active, dropDown001EditMode)) dropDown001EditMode = !dropDown001EditMode;
|
if (GuiDropdownBox((Rectangle){ 25, 65, 125, 30 }, dropdownBox001TextList, 5, &dropdownBox001Active, dropDown001EditMode)) dropDown001EditMode = !dropDown001EditMode;
|
||||||
@ -138,12 +140,14 @@ int main()
|
|||||||
if (GuiListViewEx((Rectangle){ 165, 180, 140, 200 }, listViewExList, listViewExElementsEnable, 8, &listViewExScrollIndex, &listViewExActive, &listViewExFocus, listViewExEditMode)) listViewExEditMode = !listViewExEditMode;
|
if (GuiListViewEx((Rectangle){ 165, 180, 140, 200 }, listViewExList, listViewExElementsEnable, 8, &listViewExScrollIndex, &listViewExActive, &listViewExFocus, listViewExEditMode)) listViewExEditMode = !listViewExEditMode;
|
||||||
if (listViewExFocus >= 0 && listViewExFocus < 8) DrawText(FormatText("FOCUS: %s", listViewExList[listViewExFocus]), 165, 390, 10, listViewExElementsEnable[listViewExFocus] ? LIME : MAROON);
|
if (listViewExFocus >= 0 && listViewExFocus < 8) DrawText(FormatText("FOCUS: %s", listViewExList[listViewExFocus]), 165, 390, 10, listViewExElementsEnable[listViewExFocus] ? LIME : MAROON);
|
||||||
|
|
||||||
|
toggleGroupActive = GuiToggleGroupPro((Rectangle){ 165, 400, 140, 25 }, dropdownBox001TextList, 4, toggleGroupActive, 4, 1);
|
||||||
|
|
||||||
// Third GUI column
|
// Third GUI column
|
||||||
if (GuiTextBoxMulti((Rectangle){ 320, 25, 225, 140 }, multiTextBoxText, 141, multiTextBoxEditMode)) multiTextBoxEditMode = !multiTextBoxEditMode;
|
if (GuiTextBoxMulti((Rectangle){ 320, 25, 225, 140 }, multiTextBoxText, 141, multiTextBoxEditMode)) multiTextBoxEditMode = !multiTextBoxEditMode;
|
||||||
colorPickerValue = GuiColorPicker((Rectangle){ 320, 185, 196, 192 }, colorPickerValue);
|
colorPickerValue = GuiColorPicker((Rectangle){ 320, 185, 196, 192 }, colorPickerValue);
|
||||||
|
|
||||||
sliderValue = GuiSliderEx((Rectangle){ 320, 400, 200, 20 }, sliderValue, -50, 100, "SLIDER", true);
|
sliderValue = GuiSliderEx((Rectangle){ 320, 400, 200, 20 }, sliderValue, -50, 100, " ", true);
|
||||||
sliderBarValue = GuiSliderBarEx((Rectangle){ 320, 430, 200, 20 }, sliderBarValue, 0, 100, "SLIDERBAR", true);
|
sliderBarValue = GuiSliderBarEx((Rectangle){ 320, 430, 200, 20 }, sliderBarValue, 0, 100, " ", true);
|
||||||
progressValue = GuiProgressBarEx((Rectangle){ 320, 460, 200, 20 }, progressValue, 0, 1, true);
|
progressValue = GuiProgressBarEx((Rectangle){ 320, 460, 200, 20 }, progressValue, 0, 1, true);
|
||||||
|
|
||||||
//GuiEnable();
|
//GuiEnable();
|
||||||
|
|||||||
25
src/raygui.h
25
src/raygui.h
@ -334,6 +334,7 @@ RAYGUIDEF bool GuiImageButton(Rectangle bounds, Texture2D texture);
|
|||||||
RAYGUIDEF bool GuiImageButtonEx(Rectangle bounds, Texture2D texture, Rectangle texSource, const char *text); // Image button extended control, returns true when clicked
|
RAYGUIDEF bool GuiImageButtonEx(Rectangle bounds, Texture2D texture, Rectangle texSource, const char *text); // Image button extended control, returns true when clicked
|
||||||
RAYGUIDEF bool GuiToggle(Rectangle bounds, const char *text, bool toggle); // Toggle Button control, returns true when active
|
RAYGUIDEF bool GuiToggle(Rectangle bounds, const char *text, bool toggle); // Toggle Button control, returns true when active
|
||||||
RAYGUIDEF int GuiToggleGroup(Rectangle bounds, const char **text, int count, int active); // Toggle Group control, returns toggled button index
|
RAYGUIDEF int GuiToggleGroup(Rectangle bounds, const char **text, int count, int active); // Toggle Group control, returns toggled button index
|
||||||
|
RAYGUIDEF int GuiToggleGroupEx(Rectangle bounds, const char **text, int count, int active, int padding, int columns); // Toggle Group with extended parameters
|
||||||
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 bool GuiCheckBoxEx(Rectangle bounds, bool checked, const char *text); // Check Box control with text, returns true when active
|
RAYGUIDEF bool GuiCheckBoxEx(Rectangle bounds, bool checked, const char *text); // Check Box control with text, returns true when active
|
||||||
RAYGUIDEF int GuiComboBox(Rectangle bounds, const char **text, int count, int active); // Combo Box control, returns selected item index
|
RAYGUIDEF int GuiComboBox(Rectangle bounds, const char **text, int count, int active); // Combo Box control, returns selected item index
|
||||||
@ -1040,10 +1041,30 @@ RAYGUIDEF bool GuiToggle(Rectangle bounds, const char *text, bool active)
|
|||||||
// Toggle Group control, returns toggled button index
|
// Toggle Group control, returns toggled button index
|
||||||
RAYGUIDEF int GuiToggleGroup(Rectangle bounds, const char **text, int count, int active)
|
RAYGUIDEF int GuiToggleGroup(Rectangle bounds, const char **text, int count, int active)
|
||||||
{
|
{
|
||||||
|
return GuiToggleGroupEx(bounds, text, count, active, GuiGetStyle(TOGGLE, GROUP_PADDING), 512);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggle Group with pro parameters, returns toggled button index
|
||||||
|
// NOTE: bounds refer to an individual toggle size, spacing refers to toggles separation and columns defines number of columns
|
||||||
|
RAYGUIDEF int GuiToggleGroupEx(Rectangle bounds, const char **text, int count, int active, int padding, int columns)
|
||||||
|
{
|
||||||
|
float initBoundsX = bounds.x;
|
||||||
|
int currentColumn = 0;
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if (i == active) GuiToggle((Rectangle){ bounds.x + i*(bounds.width/count + GuiGetStyle(TOGGLE, GROUP_PADDING)), bounds.y, (int)(bounds.width - GuiGetStyle(TOGGLE, GROUP_PADDING)*(count -1))/count, bounds.height }, text[i], true);
|
if (i == active) GuiToggle(bounds, text[i], true);
|
||||||
else if (GuiToggle((Rectangle){ bounds.x + i*(bounds.width/count + GuiGetStyle(TOGGLE, GROUP_PADDING)), bounds.y, (int)(bounds.width - GuiGetStyle(TOGGLE, GROUP_PADDING)*(count -1))/count, bounds.height }, text[i], false) == true) active = i;
|
else if (GuiToggle(bounds, text[i], false) == true) active = i;
|
||||||
|
|
||||||
|
bounds.x += (bounds.width + padding);
|
||||||
|
currentColumn++;
|
||||||
|
|
||||||
|
if ((currentColumn + 1) > columns)
|
||||||
|
{
|
||||||
|
currentColumn = 0;
|
||||||
|
bounds.y += (bounds.height + padding);
|
||||||
|
bounds.x = initBoundsX;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return active;
|
return active;
|
||||||
|
|||||||
Reference in New Issue
Block a user