From 4ac6419e7ee2c91dc5629c7118973c70b730dc19 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 16 Aug 2019 16:07:07 +0200 Subject: [PATCH] Review examples to latest raygui --- .../controls_test_suite/controls_test_suite.c | 6 +- examples/custom_file_dialog/gui_file_dialog.h | 9 +-- examples/image_exporter/image_exporter.c | 6 +- .../image_raw_importer/image_raw_importer.c | 3 +- examples/portable_window/portable_window.c | 2 +- examples/scroll_panel/gui_scroll_panel.c | 2 +- examples/text_box_selection/gui_text_box.c | 61 ++++++++++--------- 7 files changed, 47 insertions(+), 42 deletions(-) diff --git a/examples/controls_test_suite/controls_test_suite.c b/examples/controls_test_suite/controls_test_suite.c index 8e2c3e0..d0ba99b 100644 --- a/examples/controls_test_suite/controls_test_suite.c +++ b/examples/controls_test_suite/controls_test_suite.c @@ -148,9 +148,7 @@ int main() GuiSetStyle(BUTTON, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_CENTER); - //if (GuiButton((Rectangle){ 25, 255, 125, 30 }, "#05#Open File")) { }; - - if (GuiButton((Rectangle){ 25, 255, 125, 30 }, GuiIconText(RICON_FILE_OPEN, "Open File"))) { }; + if (GuiButton((Rectangle){ 25, 255, 125, 30 }, GuiIconText(RICON_FILE_SAVE, "Save File"))) showTextInputBox = true; GuiGroupBox((Rectangle){ 25, 310, 125, 150 }, "STATES"); GuiLock(); @@ -180,7 +178,7 @@ int main() if (GuiTextBoxMulti((Rectangle){ 320, 25, 225, 140 }, multiTextBoxText, 141, multiTextBoxEditMode)) multiTextBoxEditMode = !multiTextBoxEditMode; colorPickerValue = GuiColorPicker((Rectangle){ 320, 185, 196, 192 }, colorPickerValue); - sliderValue = GuiSlider((Rectangle){ 370, 400, 200, 20 }, "#49#TEST", sliderValue, -50, 100, true); + sliderValue = GuiSlider((Rectangle){ 370, 400, 200, 20 }, TextFormat("%2.2f", (float)sliderValue), sliderValue, -50, 100, true); sliderBarValue = GuiSliderBar((Rectangle){ 320, 430, 200, 20 }, NULL, sliderBarValue, 0, 100, true); progressValue = GuiProgressBar((Rectangle){ 320, 460, 200, 20 }, NULL, progressValue, 0, 1, true); diff --git a/examples/custom_file_dialog/gui_file_dialog.h b/examples/custom_file_dialog/gui_file_dialog.h index 5357d27..8520483 100644 --- a/examples/custom_file_dialog/gui_file_dialog.h +++ b/examples/custom_file_dialog/gui_file_dialog.h @@ -40,7 +40,6 @@ typedef struct { bool fileDialogActive; - bool dirBackPressed; bool dirPathEditMode; char dirPathText[256]; @@ -106,7 +105,7 @@ void GuiFileDialog(GuiFileDialogState *state); ************************************************************************************/ #if defined(GUI_FILE_DIALOG_IMPLEMENTATION) -#include "raygui.h" +#include "../../src/raygui.h" #include // Required for: strcpy() @@ -157,7 +156,6 @@ GuiFileDialogState InitGuiFileDialog(void) state.position = (Vector2){ GetScreenWidth()/2 - 480/2, GetScreenHeight()/2 - 305/2 }; state.fileDialogActive = false; - state.dirBackPressed = false; state.dirPathEditMode = false; state.filesListActive = -1; @@ -303,7 +301,10 @@ void GuiFileDialog(GuiFileDialogState *state) } } } - else strcpy(state->fileNameText, state->fileNameTextCopy); + else + { + strcpy(state->fileNameText, state->fileNameTextCopy); + } } state->fileNameEditMode = !state->fileNameEditMode; diff --git a/examples/image_exporter/image_exporter.c b/examples/image_exporter/image_exporter.c index 2a8ed8a..cc7dcf4 100644 --- a/examples/image_exporter/image_exporter.c +++ b/examples/image_exporter/image_exporter.c @@ -18,6 +18,7 @@ #include "raylib.h" #define RAYGUI_IMPLEMENTATION +#define RAYGUI_SUPPORT_RICONS #include "../../src/raygui.h" @@ -44,6 +45,7 @@ int main(int argc, char *argv[0]) int pixelFormatActive = 0; const char *pixelFormatTextList[7] = { "GRAYSCALE", "GRAY ALPHA", "R5G6B5", "R8G8B8", "R5G5B5A1", "R4G4B4A4", "R8G8B8A8" }; + bool textBoxEditMode = false; char fileName[32] = "untitled"; //-------------------------------------------------------------------------------------- @@ -168,8 +170,8 @@ int main(int argc, char *argv[0]) GuiLabel((Rectangle){ windowBoxRec.x + 10, windowBoxRec.y + 70, 63, 25 }, "Pixel format:"); pixelFormatActive = GuiComboBox((Rectangle){ windowBoxRec.x + 80, windowBoxRec.y + 70, 130, 25 }, TextJoin(pixelFormatTextList, 7, ";"), pixelFormatActive); GuiLabel((Rectangle){ windowBoxRec.x + 10, windowBoxRec.y + 105, 50, 25 }, "File name:"); - GuiTextBox((Rectangle){ windowBoxRec.x + 80, windowBoxRec.y + 105, 130, 25 }, fileName, 64, true); - + if (GuiTextBox((Rectangle){ windowBoxRec.x + 80, windowBoxRec.y + 105, 130, 25 }, fileName, 64, textBoxEditMode)) textBoxEditMode = !textBoxEditMode; + btnExport = GuiButton((Rectangle){ windowBoxRec.x + 10, windowBoxRec.y + 145, 200, 30 }, "Export Image"); } else btnExport = false; diff --git a/examples/image_raw_importer/image_raw_importer.c b/examples/image_raw_importer/image_raw_importer.c index 826a989..2a822cd 100644 --- a/examples/image_raw_importer/image_raw_importer.c +++ b/examples/image_raw_importer/image_raw_importer.c @@ -18,7 +18,8 @@ #include "raylib.h" #define RAYGUI_IMPLEMENTATION -#include "raygui.h" +#define RAYGUI_SUPPORT_RICONS +#include "../../src/raygui.h" #include // Required for: strcpy() #include // Required for: atoi() diff --git a/examples/portable_window/portable_window.c b/examples/portable_window/portable_window.c index 0b911dc..492b66e 100644 --- a/examples/portable_window/portable_window.c +++ b/examples/portable_window/portable_window.c @@ -18,7 +18,7 @@ #include "raylib.h" #define RAYGUI_IMPLEMENTATION -#include "raygui.h" +#include "../../src/raygui.h" //------------------------------------------------------------------------------------ // Program main entry point diff --git a/examples/scroll_panel/gui_scroll_panel.c b/examples/scroll_panel/gui_scroll_panel.c index c7f3dca..3bfd929 100644 --- a/examples/scroll_panel/gui_scroll_panel.c +++ b/examples/scroll_panel/gui_scroll_panel.c @@ -24,7 +24,7 @@ #include "raylib.h" #define RAYGUI_IMPLEMENTATION -#include "../src/raygui.h" +#include "../../src/raygui.h" static void DrawStyleEditControls(void); // Draw and process scroll bar style edition controls diff --git a/examples/text_box_selection/gui_text_box.c b/examples/text_box_selection/gui_text_box.c index 4eded64..e6d0c5e 100644 --- a/examples/text_box_selection/gui_text_box.c +++ b/examples/text_box_selection/gui_text_box.c @@ -24,9 +24,9 @@ #include "raylib.h" #define RAYGUI_IMPLEMENTATION -#define RAYGUI_RICONS_SUPPORT +#define RAYGUI_SUPPORT_RICONS #define RAYGUI_TEXTBOX_EXTENDED -#include "../src/raygui.h" +#include "../../src/raygui.h" #include #include @@ -57,7 +57,6 @@ struct { { .bounds = (Rectangle){680,60,100,25}, .maxWidth = 100 } }; - int fontSize = 10, fontSpacing = 1, padding = 0, border = 0; Font font = {0}; Color colorBG = {0}, colorFG = {0}, *colorSelected = NULL; @@ -66,8 +65,6 @@ bool showMenu = false; Rectangle menuRect = {0}; Texture2D pattern = {0}; - - // ----------------- // FUNCTIONS // ----------------- @@ -94,9 +91,9 @@ bool ColorButton(Rectangle bounds, Color color) void UpdateGUI() { // Check all of the 4 textboxes to get the active textbox - for(int i=0; ia; GuiSetStyle(SLIDER, TEXT_ALIGNMENT, GUI_TEXT_ALIGN_LEFT); // Slider for the selected color alpha value @@ -265,7 +268,7 @@ int main(int argc, char **argv) // Load initial style GuiLoadStyleDefault(); - //font = LoadFont("/home/adrian/Descărcări/raylib/examples/text/resources/notoCJK.fnt"); + //font = LoadFont("resources/notoCJK.fnt"); //GuiFont(font); fontSize = GuiGetStyle(DEFAULT, TEXT_SIZE);