2020-03-11 13:32:56 +02:00
|
|
|
/*******************************************************************************************
|
|
|
|
*
|
2021-10-05 14:10:35 +02:00
|
|
|
* raygui - custom property list control
|
2020-03-11 13:32:56 +02:00
|
|
|
*
|
|
|
|
* DEPENDENCIES:
|
2021-10-05 14:10:35 +02:00
|
|
|
* raylib 4.0 - Windowing/input management and drawing.
|
|
|
|
* raygui 3.0 - Immediate-mode GUI controls.
|
2020-03-11 13:32:56 +02:00
|
|
|
*
|
|
|
|
* COMPILATION (Windows - MinGW):
|
|
|
|
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
|
|
|
*
|
|
|
|
* LICENSE: zlib/libpng
|
|
|
|
*
|
2022-07-25 00:51:43 +02:00
|
|
|
* Copyright (c) 2020-2022 Vlad Adrian (@Demizdor) and Ramon Santamaria (@raysan5)
|
2020-03-11 13:32:56 +02:00
|
|
|
*
|
|
|
|
**********************************************************************************************/
|
|
|
|
|
|
|
|
#include "raylib.h"
|
|
|
|
|
|
|
|
#define RAYGUI_IMPLEMENTATION
|
|
|
|
#include "../../src/raygui.h"
|
|
|
|
|
|
|
|
#undef RAYGUI_IMPLEMENTATION // Avoid including raygui implementation again
|
|
|
|
|
|
|
|
#define GUI_PROPERTY_LIST_IMPLEMENTATION
|
|
|
|
#include "dm_property_list.h"
|
|
|
|
|
|
|
|
#define SIZEOF(A) (sizeof(A)/sizeof(A[0]))
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------
|
|
|
|
// Program main entry point
|
|
|
|
//------------------------------------------------------------------------------------
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
// Initialization
|
|
|
|
//---------------------------------------------------------------------------------------
|
2021-10-05 14:10:35 +02:00
|
|
|
const int screenWidth = 800;
|
|
|
|
const int screenHeight = 450;
|
|
|
|
|
|
|
|
InitWindow(screenWidth, screenHeight, "raygui - property list");
|
|
|
|
|
2020-03-11 13:32:56 +02:00
|
|
|
GuiDMProperty prop[] = {
|
|
|
|
PBOOL("Bool", 0, true),
|
|
|
|
PSECTION("#102#SECTION", 0, 2),
|
|
|
|
PINT("Int", 0, 123),
|
|
|
|
PFLOAT("Float", 0, 0.99f),
|
|
|
|
PTEXT("Text", 0, (char*)&(char[30]){"Hello!"}, 30),
|
|
|
|
PSELECT("Select", 0, "ONE;TWO;THREE;FOUR", 0),
|
|
|
|
PINT_RANGE("Int Range", 0, 32, 1, 0, 100),
|
|
|
|
PRECT("Rect", 0, 0, 0, 100, 200),
|
|
|
|
PVEC2("Vec2", 0, 20, 20),
|
|
|
|
PVEC3("Vec3", 0, 12, 13, 14),
|
|
|
|
PVEC4("Vec4", 0, 12, 13, 14, 15),
|
|
|
|
PCOLOR("Color", 0, 0, 255, 0, 255),
|
|
|
|
};
|
|
|
|
|
2021-10-05 14:10:35 +02:00
|
|
|
int focus = 0, scroll = 0; // Needed by GuiDMPropertyList()
|
|
|
|
|
2020-03-11 13:32:56 +02:00
|
|
|
GuiLoadStyleDefault();
|
2021-10-05 14:10:35 +02:00
|
|
|
|
|
|
|
// Tweak the default raygui style a bit
|
2020-03-11 13:32:56 +02:00
|
|
|
GuiSetStyle(LISTVIEW, LIST_ITEMS_HEIGHT, 24);
|
|
|
|
GuiSetStyle(LISTVIEW, SCROLLBAR_WIDTH, 12);
|
|
|
|
|
2021-10-05 14:10:35 +02:00
|
|
|
SetTargetFPS(60);
|
|
|
|
//--------------------------------------------------------------------------------------
|
2020-03-11 13:32:56 +02:00
|
|
|
|
|
|
|
// Main game loop
|
|
|
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
|
|
|
{
|
|
|
|
// Draw
|
|
|
|
//----------------------------------------------------------------------------------
|
|
|
|
BeginDrawing();
|
2021-10-05 14:10:35 +02:00
|
|
|
|
2020-03-11 13:32:56 +02:00
|
|
|
ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)));
|
|
|
|
|
2022-03-14 17:20:20 -04:00
|
|
|
GuiGrid((Rectangle){0, 0, screenWidth, screenHeight}, "Property List", 20.0f, 2); // Draw a fancy grid
|
2020-03-11 13:32:56 +02:00
|
|
|
|
2021-10-05 14:10:35 +02:00
|
|
|
GuiDMPropertyList((Rectangle){(screenWidth - 180)/2, (screenHeight - 280)/2, 180, 280}, prop, SIZEOF(prop), &focus, &scroll);
|
2020-03-11 13:32:56 +02:00
|
|
|
|
2021-04-02 16:32:14 +02:00
|
|
|
if (prop[0].value.vbool >= 1)
|
|
|
|
{
|
2020-03-11 13:32:56 +02:00
|
|
|
DrawText(TextFormat("FOCUS:%i | SCROLL:%i | FPS:%i", focus, scroll, GetFPS()), prop[8].value.v2.x, prop[8].value.v2.y, 20, prop[11].value.vcolor);
|
2021-04-02 16:32:14 +02:00
|
|
|
}
|
|
|
|
|
2021-07-28 12:55:58 +02:00
|
|
|
EndDrawing();
|
|
|
|
//----------------------------------------------------------------------------------
|
2020-03-11 13:32:56 +02:00
|
|
|
}
|
2021-10-05 14:10:35 +02:00
|
|
|
|
|
|
|
// De-Initialization
|
|
|
|
//--------------------------------------------------------------------------------------
|
2020-03-11 13:32:56 +02:00
|
|
|
GuiDMSaveProperties("test.props", prop, SIZEOF(prop)); // Save properties to `test.props` file at exit
|
2021-10-05 14:10:35 +02:00
|
|
|
|
|
|
|
CloseWindow(); // Close window and OpenGL context
|
|
|
|
//--------------------------------------------------------------------------------------
|
2020-03-11 13:32:56 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|