Skip to content

Commit 2b45fea

Browse files
committed
Update examples
1 parent 665520d commit 2b45fea

File tree

2 files changed

+10
-167
lines changed

2 files changed

+10
-167
lines changed

examples/controls_test_suite/controls_test_suite.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
*
2222
*
2323
* DEPENDENCIES:
24-
* raylib 4.0 - Windowing/input management and drawing.
25-
* raygui 3.2 - Immediate-mode GUI controls.
24+
* raylib 4.5 - Windowing/input management and drawing
25+
* raygui 3.5 - Immediate-mode GUI controls with custom styling and icons
2626
*
2727
* COMPILATION (Windows - MinGW):
2828
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
@@ -188,19 +188,17 @@ int main()
188188
toggleGroupActive = GuiToggleGroup((Rectangle){ 165, 400, 140, 25 }, "#1#ONE\n#3#TWO\n#8#THREE\n#23#", toggleGroupActive);
189189

190190
// Third GUI column
191-
//if (GuiTextBoxMulti((Rectangle){ 320, 25, 225, 140 }, multiTextBoxText, 256, multiTextBoxEditMode)) multiTextBoxEditMode = !multiTextBoxEditMode;
191+
GuiPanel((Rectangle){ 320, 25, 225, 140 }, "Panel Info");
192192
colorPickerValue = GuiColorPicker((Rectangle){ 320, 185, 196, 192 }, NULL, colorPickerValue);
193193

194194
sliderValue = GuiSlider((Rectangle){ 355, 400, 165, 20 }, "TEST", TextFormat("%2.2f", (float)sliderValue), sliderValue, -50, 100);
195195
sliderBarValue = GuiSliderBar((Rectangle){ 320, 430, 200, 20 }, NULL, TextFormat("%i", (int)sliderBarValue), sliderBarValue, 0, 100);
196196
progressValue = GuiProgressBar((Rectangle){ 320, 460, 200, 20 }, NULL, NULL, progressValue, 0, 1);
197197

198198
// NOTE: View rectangle could be used to perform some scissor test
199-
Rectangle view = GuiScrollPanel((Rectangle){ 560, 25, 100, 160 }, NULL, (Rectangle){ 560, 25, 200, 400 }, &viewScroll);
199+
Rectangle view = GuiScrollPanel((Rectangle){ 560, 25, 102, 354 }, NULL, (Rectangle){ 560, 25, 300, 1200 }, &viewScroll);
200200

201-
GuiPanel((Rectangle){ 560, 25 + 180, 100, 160 }, "Panel Info");
202-
203-
GuiGrid((Rectangle) { 560, 25 + 180 + 180, 100, 120 }, NULL, 20, 2);
201+
GuiGrid((Rectangle) { 560, 25 + 180 + 195, 100, 120 }, NULL, 20, 2);
204202

205203
GuiStatusBar((Rectangle){ 0, (float)GetScreenHeight() - 20, (float)GetScreenWidth(), 20 }, "This is a status bar");
206204

examples/style_selector/style_selector.c

Lines changed: 5 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,10 @@
11
/*******************************************************************************************
22
*
3-
* raygui - controls test suite
4-
*
5-
* TEST CONTROLS:
6-
* - GuiDropdownBox()
7-
* - GuiCheckBox()
8-
* - GuiSpinner()
9-
* - GuiValueBox()
10-
* - GuiTextBox()
11-
* - GuiButton()
12-
* - GuiComboBox()
13-
* - GuiListView()
14-
* - GuiToggleGroup()
15-
* - GuiColorPicker()
16-
* - GuiSlider()
17-
* - GuiSliderBar()
18-
* - GuiProgressBar()
19-
* - GuiColorBarAlpha()
20-
* - GuiScrollPanel()
21-
*
3+
* raygui - style selector
224
*
235
* DEPENDENCIES:
24-
* raylib 4.0 - Windowing/input management and drawing.
25-
* raygui 3.2 - Immediate-mode GUI controls.
6+
* raylib 4.5 - Windowing/input management and drawing
7+
* raygui 3.5 - Immediate-mode GUI controls with custom styling and icons
268
*
279
* COMPILATION (Windows - MinGW):
2810
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
@@ -63,52 +45,8 @@ int main()
6345
InitWindow(screenWidth, screenHeight, "raygui - controls test suite");
6446
SetExitKey(0);
6547

66-
// GUI controls initialization
67-
//----------------------------------------------------------------------------------
68-
int dropdownBox000Active = 0;
69-
bool dropDown000EditMode = false;
70-
71-
int dropdownBox001Active = 0;
72-
bool dropDown001EditMode = false;
73-
74-
int spinner001Value = 0;
75-
bool spinnerEditMode = false;
76-
77-
int valueBox002Value = 0;
78-
bool valueBoxEditMode = false;
79-
80-
char textBoxText[64] = "Text box";
81-
bool textBoxEditMode = false;
82-
83-
int listViewScrollIndex = 0;
84-
int listViewActive = -1;
85-
86-
int listViewExScrollIndex = 0;
87-
int listViewExActive = 2;
88-
int listViewExFocus = -1;
89-
const char *listViewExList[8] = { "This", "is", "a", "list view", "with", "disable", "elements", "amazing!" };
90-
91-
char multiTextBoxText[256] = "Multi text box";
92-
bool multiTextBoxEditMode = false;
93-
Color colorPickerValue = RED;
94-
95-
int sliderValue = 50;
96-
int sliderBarValue = 60;
97-
float progressValue = 0.4f;
98-
99-
bool forceSquaredChecked = false;
100-
101-
float alphaValue = 0.5f;
102-
103-
int comboBoxActive = 1;
104-
105-
int toggleGroupActive = 0;
106-
107-
Vector2 viewScroll = { 0, 0 };
108-
//----------------------------------------------------------------------------------
109-
11048
// Custom GUI font loading
111-
//Font font = LoadFontEx("fonts/rainyhearts16.ttf", 12, 0, 0);
49+
//Font font = LoadFontEx("fonts/custom_font.ttf", 12, 0, 0);
11250
//GuiSetFont(font);
11351

11452
bool exitWindow = false;
@@ -119,6 +57,7 @@ int main()
11957

12058
char textInputFileName[256] = { 0 };
12159

60+
// Load default style
12261
GuiLoadStyleBluish();
12362
int visualStyleActive = 4;
12463
int prevVisualStyleActive = 4;
@@ -182,100 +121,6 @@ int main()
182121
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_RIGHT);
183122
GuiButton((Rectangle){ 25, 255, 300, 30 }, GuiIconText(ICON_FILE_SAVE, "Save File"));
184123
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
185-
186-
/*
187-
// raygui: controls drawing
188-
//----------------------------------------------------------------------------------
189-
if (dropDown000EditMode || dropDown001EditMode) GuiLock();
190-
else if (!dropDown000EditMode && !dropDown001EditMode) GuiUnlock();
191-
//GuiDisable();
192-
193-
// First GUI column
194-
//GuiSetStyle(CHECKBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
195-
forceSquaredChecked = GuiCheckBox((Rectangle){ 25, 108, 15, 15 }, "FORCE CHECK!", forceSquaredChecked);
196-
197-
GuiSetStyle(TEXTBOX, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
198-
//GuiSetStyle(VALUEBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
199-
if (GuiSpinner((Rectangle){ 25, 135, 125, 30 }, NULL, &spinner001Value, 0, 100, spinnerEditMode)) spinnerEditMode = !spinnerEditMode;
200-
if (GuiValueBox((Rectangle){ 25, 175, 125, 30 }, NULL, &valueBox002Value, 0, 100, valueBoxEditMode)) valueBoxEditMode = !valueBoxEditMode;
201-
GuiSetStyle(TEXTBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
202-
if (GuiTextBox((Rectangle){ 25, 215, 125, 30 }, textBoxText, 64, textBoxEditMode)) textBoxEditMode = !textBoxEditMode;
203-
204-
GuiSetStyle(BUTTON, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
205-
206-
if (GuiButton((Rectangle){ 25, 255, 125, 30 }, GuiIconText(ICON_FILE_SAVE, "Save File"))) showTextInputBox = true;
207-
208-
GuiGroupBox((Rectangle){ 25, 310, 125, 150 }, "STATES");
209-
//GuiLock();
210-
GuiSetState(STATE_NORMAL); if (GuiButton((Rectangle){ 30, 320, 115, 30 }, "NORMAL")) { }
211-
GuiSetState(STATE_FOCUSED); if (GuiButton((Rectangle){ 30, 355, 115, 30 }, "FOCUSED")) { }
212-
GuiSetState(STATE_PRESSED); if (GuiButton((Rectangle){ 30, 390, 115, 30 }, "#15#PRESSED")) { }
213-
GuiSetState(STATE_DISABLED); if (GuiButton((Rectangle){ 30, 425, 115, 30 }, "DISABLED")) { }
214-
GuiSetState(STATE_NORMAL);
215-
//GuiUnlock();
216-
217-
comboBoxActive = GuiComboBox((Rectangle){ 25, 470, 125, 30 }, "ONE;TWO;THREE;FOUR", comboBoxActive);
218-
219-
// NOTE: GuiDropdownBox must draw after any other control that can be covered on unfolding
220-
GuiSetStyle(DROPDOWNBOX, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
221-
if (GuiDropdownBox((Rectangle){ 25, 65, 125, 30 }, "#01#ONE;#02#TWO;#03#THREE;#04#FOUR", &dropdownBox001Active, dropDown001EditMode)) dropDown001EditMode = !dropDown001EditMode;
222-
223-
GuiSetStyle(DROPDOWNBOX, TEXT_ALIGNMENT, TEXT_ALIGN_CENTER);
224-
if (GuiDropdownBox((Rectangle){ 25, 25, 125, 30 }, "ONE;TWO;THREE", &dropdownBox000Active, dropDown000EditMode)) dropDown000EditMode = !dropDown000EditMode;
225-
226-
// Second GUI column
227-
listViewActive = GuiListView((Rectangle){ 165, 25, 140, 140 }, "Charmander;Bulbasaur;#18#Squirtel;Pikachu;Eevee;Pidgey", &listViewScrollIndex, listViewActive);
228-
listViewExActive = GuiListViewEx((Rectangle){ 165, 180, 140, 200 }, listViewExList, 8, &listViewExFocus, &listViewExScrollIndex, listViewExActive);
229-
230-
toggleGroupActive = GuiToggleGroup((Rectangle){ 165, 400, 140, 25 }, "#1#ONE\n#3#TWO\n#8#THREE\n#23#", toggleGroupActive);
231-
232-
// Third GUI column
233-
if (GuiTextBoxMulti((Rectangle){ 320, 25, 225, 140 }, multiTextBoxText, 256, multiTextBoxEditMode)) multiTextBoxEditMode = !multiTextBoxEditMode;
234-
colorPickerValue = GuiColorPicker((Rectangle){ 320, 185, 196, 192 }, NULL, colorPickerValue);
235-
236-
sliderValue = GuiSlider((Rectangle){ 355, 400, 165, 20 }, "TEST", TextFormat("%2.2f", (float)sliderValue), sliderValue, -50, 100);
237-
sliderBarValue = GuiSliderBar((Rectangle){ 320, 430, 200, 20 }, NULL, TextFormat("%i", (int)sliderBarValue), sliderBarValue, 0, 100);
238-
progressValue = GuiProgressBar((Rectangle){ 320, 460, 200, 20 }, NULL, NULL, progressValue, 0, 1);
239-
240-
// NOTE: View rectangle could be used to perform some scissor test
241-
Rectangle view = GuiScrollPanel((Rectangle){ 560, 25, 100, 160 }, NULL, (Rectangle){ 560, 25, 200, 400 }, &viewScroll);
242-
243-
GuiPanel((Rectangle){ 560, 25 + 180, 100, 160 }, "Panel Info");
244-
245-
GuiGrid((Rectangle) { 560, 25 + 180 + 180, 100, 120 }, NULL, 20, 2);
246-
247-
GuiStatusBar((Rectangle){ 0, (float)GetScreenHeight() - 20, (float)GetScreenWidth(), 20 }, "This is a status bar");
248-
249-
alphaValue = GuiColorBarAlpha((Rectangle){ 320, 490, 200, 30 }, NULL, alphaValue);
250-
251-
if (showMessageBox)
252-
{
253-
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, 0.8f));
254-
int result = GuiMessageBox((Rectangle){ (float)GetScreenWidth()/2 - 125, (float)GetScreenHeight()/2 - 50, 250, 100 }, GuiIconText(ICON_EXIT, "Close Window"), "Do you really want to exit?", "Yes;No");
255-
256-
if ((result == 0) || (result == 2)) showMessageBox = false;
257-
else if (result == 1) exitWindow = true;
258-
}
259-
260-
if (showTextInputBox)
261-
{
262-
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(RAYWHITE, 0.8f));
263-
int result = GuiTextInputBox((Rectangle){ (float)GetScreenWidth()/2 - 120, (float)GetScreenHeight()/2 - 60, 240, 140 }, "Save", GuiIconText(ICON_FILE_SAVE, "Save file as..."), "Ok;Cancel", textInput, 255, NULL);
264-
265-
if (result == 1)
266-
{
267-
// TODO: Validate textInput value and save
268-
269-
strcpy(textInputFileName, textInput);
270-
}
271-
272-
if ((result == 0) || (result == 1) || (result == 2))
273-
{
274-
showTextInputBox = false;
275-
strcpy(textInput, "\0");
276-
}
277-
}
278-
*/
279124
//----------------------------------------------------------------------------------
280125

281126
EndDrawing();

0 commit comments

Comments
 (0)