2
0

gui_value_box_float.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*******************************************************************************************
  2. *
  3. * raygui - controls test suite
  4. *
  5. * COMPILATION (Windows - MinGW):
  6. * gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
  7. *
  8. * LICENSE: zlib/libpng
  9. *
  10. * Copyright (c) 2016-2024 Ramon Santamaria (@raysan5)
  11. *
  12. **********************************************************************************************/
  13. #include "raylib.h"
  14. #define RAYGUI_IMPLEMENTATION
  15. #include "../../src/raygui.h"
  16. #include <stdio.h>
  17. //------------------------------------------------------------------------------------
  18. // Program main entry point
  19. //------------------------------------------------------------------------------------
  20. int main()
  21. {
  22. // Initialization
  23. //---------------------------------------------------------------------------------------
  24. const int screenWidth = 800;
  25. const int screenHeight = 450;
  26. InitWindow(screenWidth, screenHeight, "raygui - controls test suite");
  27. float valueBoxValue = 0.0f;
  28. bool valueBoxEditMode = false;
  29. char valueBoxTextValue[32] = { 0 };
  30. SetTargetFPS(60);
  31. //--------------------------------------------------------------------------------------
  32. // Main game loop
  33. while (!WindowShouldClose()) // Detect window close button or ESC key
  34. {
  35. // Update
  36. //----------------------------------------------------------------------------------
  37. //----------------------------------------------------------------------------------
  38. // Draw
  39. //----------------------------------------------------------------------------------
  40. BeginDrawing();
  41. ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)));
  42. if (GuiValueBoxFloat((Rectangle){ 25, 175, 125, 30 }, NULL, valueBoxTextValue, &valueBoxValue, valueBoxEditMode))
  43. {
  44. valueBoxEditMode = !valueBoxEditMode;
  45. printf("Value: %2.2f\n", valueBoxValue);
  46. }
  47. EndDrawing();
  48. //----------------------------------------------------------------------------------
  49. }
  50. // De-Initialization
  51. //--------------------------------------------------------------------------------------
  52. CloseWindow(); // Close window and OpenGL context
  53. //--------------------------------------------------------------------------------------
  54. return 0;
  55. }