mirror of
https://github.com/raysan5/raygui.git
synced 2026-01-30 02:39:17 -05:00
Reviewed examples for latest raygui/raylib
This commit is contained in:
@ -1,24 +1,23 @@
|
||||
/*******************************************************************************************
|
||||
*
|
||||
* raygui - a custom property list control
|
||||
* raygui - custom property list control
|
||||
*
|
||||
* DEPENDENCIES:
|
||||
* raylib 3.0
|
||||
* raygui 2.7
|
||||
* raylib 4.0 - Windowing/input management and drawing.
|
||||
* raygui 3.0 - Immediate-mode GUI controls.
|
||||
*
|
||||
* COMPILATION (Windows - MinGW):
|
||||
* gcc -o $(NAME_PART).exe $(FILE_NAME) -I../../src -lraylib -lopengl32 -lgdi32 -std=c99
|
||||
*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* Copyright (c) 2020 Vlad Adrian (@Demizdor - https://github.com/Demizdor)
|
||||
* Copyright (c) 2020-2021 Vlad Adrian (@Demizdor) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#define RAYGUI_SUPPORT_RICONS
|
||||
#include "../../src/raygui.h"
|
||||
|
||||
#undef RAYGUI_IMPLEMENTATION // Avoid including raygui implementation again
|
||||
@ -26,8 +25,6 @@
|
||||
#define GUI_PROPERTY_LIST_IMPLEMENTATION
|
||||
#include "dm_property_list.h"
|
||||
|
||||
#define SCREEN_WIDTH 800
|
||||
#define SCREEN_HEIGHT 450
|
||||
#define SIZEOF(A) (sizeof(A)/sizeof(A[0]))
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
@ -37,7 +34,11 @@ int main()
|
||||
{
|
||||
// Initialization
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raygui - property list");
|
||||
|
||||
GuiDMProperty prop[] = {
|
||||
PBOOL("Bool", 0, true),
|
||||
PSECTION("#102#SECTION", 0, 2),
|
||||
@ -52,17 +53,17 @@ int main()
|
||||
PVEC4("Vec4", 0, 12, 13, 14, 15),
|
||||
PCOLOR("Color", 0, 0, 255, 0, 255),
|
||||
};
|
||||
int focus = 0, scroll = 0; // needed by GuiDMPropertyList()
|
||||
|
||||
InitWindow(SCREEN_WIDTH, SCREEN_HEIGHT, "raygui - property list");
|
||||
SetTargetFPS(60);
|
||||
|
||||
int focus = 0, scroll = 0; // Needed by GuiDMPropertyList()
|
||||
|
||||
GuiLoadStyleDefault();
|
||||
// adjust the default raygui style a bit
|
||||
|
||||
// Tweak the default raygui style a bit
|
||||
GuiSetStyle(LISTVIEW, LIST_ITEMS_HEIGHT, 24);
|
||||
GuiSetStyle(LISTVIEW, SCROLLBAR_WIDTH, 12);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
@ -70,11 +71,12 @@ int main()
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)));
|
||||
|
||||
GuiGrid((Rectangle){0,0,SCREEN_WIDTH,SCREEN_HEIGHT},20.0f, 2); // draw a fancy grid
|
||||
GuiGrid((Rectangle){0, 0, screenWidth, screenHeight},20.0f, 2); // Draw a fancy grid
|
||||
|
||||
GuiDMPropertyList((Rectangle){(SCREEN_WIDTH - 180)/2, (SCREEN_HEIGHT - 280)/2, 180, 280}, prop, SIZEOF(prop), &focus, &scroll);
|
||||
GuiDMPropertyList((Rectangle){(screenWidth - 180)/2, (screenHeight - 280)/2, 180, 280}, prop, SIZEOF(prop), &focus, &scroll);
|
||||
|
||||
if (prop[0].value.vbool >= 1)
|
||||
{
|
||||
@ -84,9 +86,13 @@ int main()
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
GuiDMSaveProperties("test.props", prop, SIZEOF(prop)); // Save properties to `test.props` file at exit
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
27
examples/property_list/test.props
Normal file
27
examples/property_list/test.props
Normal file
@ -0,0 +1,27 @@
|
||||
#
|
||||
# Property types:
|
||||
# b <name> <flags> <value> // Bool
|
||||
# i <name> <flags> <value> <min> <max> <step> // Int
|
||||
# f <name> <flags> <value> <min> <max> <step> <precision> // Float
|
||||
# t <name> <flags> <value> <edit_length> // Text
|
||||
# l <name> <flags> <value> <active> // Select
|
||||
# g <name> <flags> <value> // Section (Group)
|
||||
# v2 <name> <flags> <x> <y> // Vector 2D
|
||||
# v3 <name> <flags> <x> <y> <z> // Vector 3D
|
||||
# v4 <name> <flags> <x> <y> <z> <w> // Vector 4D
|
||||
# r <name> <flags> <x> <y> <width> <height> // Rectangle
|
||||
# c <name> <flags> <r> <g> <b> <a> // Color
|
||||
#
|
||||
|
||||
b Bool 0 1
|
||||
g #102#SECTION 0 2
|
||||
i Int 0 123 0 0 1
|
||||
f Float 0 0.990000 0.000000 0.000000 1.000000 3
|
||||
t Text 1 Hello! 30
|
||||
l Select 0 ONE;TWO;THREE;FOUR 3
|
||||
i Int Range 0 32 0 100 1
|
||||
r Rect 1 0 0 100 200
|
||||
v2 Vec2 1 20.000000 20.000000
|
||||
v3 Vec3 1 12.000000 13.000000 14.000000
|
||||
v4 Vec4 1 12.000000 13.000000 14.000000 15.000000
|
||||
c Color 1 94 68 197 160
|
||||
Reference in New Issue
Block a user