From 2be7c7be1ac645471b95d6921e56f78f309b9812 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 22 May 2018 12:58:26 +0200 Subject: [PATCH] Controls test sample --- .../scrollpanel_text_multiline.c | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 examples/controls_test/scrollpanel_text_multiline.c diff --git a/examples/controls_test/scrollpanel_text_multiline.c b/examples/controls_test/scrollpanel_text_multiline.c new file mode 100644 index 0000000..15de8ab --- /dev/null +++ b/examples/controls_test/scrollpanel_text_multiline.c @@ -0,0 +1,79 @@ +/******************************************************************************************* +* +* Some new GUI controls testing program +* +* Controls to test: +* - GuiScrollPanel() +* - GuiTextBoxMulti() +* +* Compile this program using: +* gcc -o $(NAME_PART).exe $(NAME_PART).c -I..\..\src -lraylib -lopengl32 -lgdi32 -std=c99 -Wall +* +* LICENSE: zlib/libpng +* +* Copyright (c) 2018 raylib technologies +* +**********************************************************************************************/ + +#include "raylib.h" + +#define RAYGUI_IMPLEMENTATION +#include "raygui.h" + +//---------------------------------------------------------------------------------- +// Controls Functions Declaration +//---------------------------------------------------------------------------------- + +//------------------------------------------------------------------------------------ +// Program main entry point +//------------------------------------------------------------------------------------ +int main() +{ + // Initialization + //--------------------------------------------------------------------------------------- + int screenWidth = 800; + int screenHeight = 600; + + InitWindow(screenWidth, screenHeight, "Controls testing suite"); + + // GuiTextBoxMulti() variables + int textMultiSize = 128; + char textMulti[128] = ""; + + // GuiScrollPanel() variables + Rectangle scrollBox = { 100, 100, 200, 300 }; + Rectangle scrollContent = { 0, 0, 200, 600 }; + Vector2 scrollPosition = { 0, 0 }; + + SetTargetFPS(60); + //-------------------------------------------------------------------------------------- + + // Main game loop + while (!WindowShouldClose()) // Detect window close button or ESC key + { + // Update + //---------------------------------------------------------------------------------- + // TODO: Implement required update logic + //---------------------------------------------------------------------------------- + + // Draw + //---------------------------------------------------------------------------------- + BeginDrawing(); + + ClearBackground(GetColor(style[DEFAULT_BACKGROUND_COLOR])); + + GuiTextBoxMulti((Rectangle){ 500, 100, 100, 200 }, textMulti, textMultiSize, true); + + scrollPosition = GuiScrollPanel(scrollBox, scrollContent, scrollPosition); + + EndDrawing(); + //---------------------------------------------------------------------------------- + } + + // De-Initialization + //-------------------------------------------------------------------------------------- + CloseWindow(); // Close window and OpenGL context + //-------------------------------------------------------------------------------------- + + return 0; +} \ No newline at end of file