From 7bb66e5c7f3e283995a43c68965ee82acc65637a Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 18 May 2024 07:40:44 +0200 Subject: [PATCH] Create gui_value_box_float.c --- .../controls_test_suite/gui_value_box_float.c | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 examples/controls_test_suite/gui_value_box_float.c diff --git a/examples/controls_test_suite/gui_value_box_float.c b/examples/controls_test_suite/gui_value_box_float.c new file mode 100644 index 0000000..8719375 --- /dev/null +++ b/examples/controls_test_suite/gui_value_box_float.c @@ -0,0 +1,71 @@ +/******************************************************************************************* +* +* raygui - controls test suite +* +* COMPILATION (Windows - MinGW): +* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99 +* +* LICENSE: zlib/libpng +* +* Copyright (c) 2016-2024 Ramon Santamaria (@raysan5) +* +**********************************************************************************************/ + +#include "raylib.h" + +#define RAYGUI_IMPLEMENTATION +#include "../../src/raygui.h" + +#include + +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ +int main() +{ + // Initialization + //--------------------------------------------------------------------------------------- + const int screenWidth = 800; + const int screenHeight = 450; + + InitWindow(screenWidth, screenHeight, "raygui - controls test suite"); + + float valueBoxValue = 0.0f; + bool valueBoxEditMode = false; + char valueBoxTextValue[32] = { 0 }; + + SetTargetFPS(60); + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR))); + + if (GuiValueBoxFloat((Rectangle){ 25, 175, 125, 30 }, NULL, valueBoxTextValue, &valueBoxValue, valueBoxEditMode)) + { + valueBoxEditMode = !valueBoxEditMode; + + printf("Value: %2.2f\n", valueBoxValue); + } + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +}