From 8fef0f4fc0c0a90e2a8cb551ef9d7497fc2633ea Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 4 Jul 2023 18:57:04 +0200 Subject: [PATCH] Support style change on controls_test_suite example --- .../controls_test_suite/controls_test_suite.c | 49 ++++++++++++++++--- .../styles/style_bluish.h | 0 .../{style_selector => }/styles/style_cyber.h | 0 .../{style_selector => }/styles/style_dark.h | 0 .../styles/style_jungle.h | 0 .../styles/style_lavanda.h | 0 .../styles/style_terminal.h | 0 7 files changed, 43 insertions(+), 6 deletions(-) rename examples/{style_selector => }/styles/style_bluish.h (100%) rename examples/{style_selector => }/styles/style_cyber.h (100%) rename examples/{style_selector => }/styles/style_dark.h (100%) rename examples/{style_selector => }/styles/style_jungle.h (100%) rename examples/{style_selector => }/styles/style_lavanda.h (100%) rename examples/{style_selector => }/styles/style_terminal.h (100%) diff --git a/examples/controls_test_suite/controls_test_suite.c b/examples/controls_test_suite/controls_test_suite.c index c6414e7..79f7d1e 100644 --- a/examples/controls_test_suite/controls_test_suite.c +++ b/examples/controls_test_suite/controls_test_suite.c @@ -40,7 +40,14 @@ //#include "gui_icons.h" // External icons data provided, it can be generated with rGuiIcons tool #include "../../src/raygui.h" -#include // Required for: strcpy() +// raygui embedded styles +#include "../styles/style_cyber.h" // raygui style: cyber +#include "../styles/style_jungle.h" // raygui style: jungle +#include "../styles/style_lavanda.h" // raygui style: lavanda +#include "../styles/style_dark.h" // raygui style: dark +#include "../styles/style_bluish.h" // raygui style: bluish +#include "../styles/style_terminal.h" // raygui style: terminal + //------------------------------------------------------------------------------------ // Program main entry point @@ -92,7 +99,9 @@ int main() float alphaValue = 0.5f; - int comboBoxActive = 1; + //int comboBoxActive = 1; + int visualStyleActive = 0; + int prevVisualStyleActive = 0; int toggleGroupActive = 0; @@ -133,6 +142,31 @@ int main() UnloadDroppedFiles(droppedFiles); // Clear internal buffers } + + progressValue += 0.002f; + //if (progressValue >= 1.0f) progressValue = 0.0f; + if (IsKeyPressed(KEY_SPACE)) progressValue = 0.2f; + + if (visualStyleActive != prevVisualStyleActive) + { + GuiLoadStyleDefault(); + + switch (visualStyleActive) + { + case 0: break; // Default style + case 1: GuiLoadStyleJungle(); break; + case 2: GuiLoadStyleLavanda(); break; + case 3: GuiLoadStyleDark(); break; + case 4: GuiLoadStyleBluish(); break; + case 5: GuiLoadStyleCyber(); break; + case 6: GuiLoadStyleTerminal(); break; + default: break; + } + + GuiSetStyle(LABEL, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT); + + prevVisualStyleActive = visualStyleActive; + } //---------------------------------------------------------------------------------- // Draw @@ -171,7 +205,7 @@ int main() GuiSetState(STATE_NORMAL); //GuiUnlock(); - GuiComboBox((Rectangle){ 25, 470, 125, 30 }, "ONE;TWO;THREE;FOUR", &comboBoxActive); + GuiComboBox((Rectangle){ 25, 470, 125, 30 }, "default;Jungle;Lavanda;Dark;Bluish;Cyber;Terminal", &visualStyleActive); // NOTE: GuiDropdownBox must draw after any other control that can be covered on unfolding GuiUnlock(); @@ -192,9 +226,12 @@ int main() GuiPanel((Rectangle){ 320, 25, 225, 140 }, "Panel Info"); GuiColorPicker((Rectangle){ 320, 185, 196, 192 }, NULL, &colorPickerValue); + //GuiDisable(); GuiSlider((Rectangle){ 355, 400, 165, 20 }, "TEST", TextFormat("%2.2f", sliderValue), &sliderValue, -50, 100); GuiSliderBar((Rectangle){ 320, 430, 200, 20 }, NULL, TextFormat("%i", (int)sliderBarValue), &sliderBarValue, 0, 100); - GuiProgressBar((Rectangle){ 320, 460, 200, 20 }, NULL, NULL, &progressValue, 0, 1); + + GuiProgressBar((Rectangle){ 320, 460, 200, 20 }, NULL, TextFormat(" %i%%", (int)(progressValue*100)), &progressValue, 0.0f, 1.0f); + GuiEnable(); // NOTE: View rectangle could be used to perform some scissor test Rectangle view = { 0 }; @@ -225,13 +262,13 @@ int main() { // TODO: Validate textInput value and save - strcpy(textInputFileName, textInput); + TextCopy(textInputFileName, textInput); } if ((result == 0) || (result == 1) || (result == 2)) { showTextInputBox = false; - strcpy(textInput, "\0"); + TextCopy(textInput, "\0"); } } //---------------------------------------------------------------------------------- diff --git a/examples/style_selector/styles/style_bluish.h b/examples/styles/style_bluish.h similarity index 100% rename from examples/style_selector/styles/style_bluish.h rename to examples/styles/style_bluish.h diff --git a/examples/style_selector/styles/style_cyber.h b/examples/styles/style_cyber.h similarity index 100% rename from examples/style_selector/styles/style_cyber.h rename to examples/styles/style_cyber.h diff --git a/examples/style_selector/styles/style_dark.h b/examples/styles/style_dark.h similarity index 100% rename from examples/style_selector/styles/style_dark.h rename to examples/styles/style_dark.h diff --git a/examples/style_selector/styles/style_jungle.h b/examples/styles/style_jungle.h similarity index 100% rename from examples/style_selector/styles/style_jungle.h rename to examples/styles/style_jungle.h diff --git a/examples/style_selector/styles/style_lavanda.h b/examples/styles/style_lavanda.h similarity index 100% rename from examples/style_selector/styles/style_lavanda.h rename to examples/styles/style_lavanda.h diff --git a/examples/style_selector/styles/style_terminal.h b/examples/styles/style_terminal.h similarity index 100% rename from examples/style_selector/styles/style_terminal.h rename to examples/styles/style_terminal.h