Reviewed examples for latest raygui/raylib
This commit is contained in:
parent
0ed765cd8b
commit
7c63e389b8
@ -37,11 +37,8 @@
|
||||
#include "raylib.h"
|
||||
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#define RAYGUI_SUPPORT_RICONS
|
||||
#include "../../src/raygui.h"
|
||||
|
||||
#undef RAYGUI_IMPLEMENTATION // Avoid including raygui implementation again
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
@ -49,8 +46,8 @@ int main()
|
||||
{
|
||||
// Initialization
|
||||
//---------------------------------------------------------------------------------------
|
||||
int screenWidth = 690;
|
||||
int screenHeight = 560;
|
||||
const int screenWidth = 690;
|
||||
const int screenHeight = 560;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raygui - controls test suite");
|
||||
SetExitKey(0);
|
||||
|
@ -3,26 +3,24 @@
|
||||
* raygui - custom file dialog to load image
|
||||
*
|
||||
* DEPENDENCIES:
|
||||
* raylib 2.6-dev - Windowing/input management and drawing.
|
||||
* raygui 2.6-dev - Immediate-mode GUI controls.
|
||||
* 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 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2016-2021 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
|
||||
|
||||
#define GUI_FILE_DIALOG_IMPLEMENTATION
|
||||
#include "gui_file_dialog.h"
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* Copyright (c) 2019-2020 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2019-2021 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
* This software is provided "as-is", without any express or implied warranty. In no event
|
||||
* will the authors be held liable for any damages arising from the use of this software.
|
||||
@ -257,7 +257,7 @@ void GuiFileDialog(GuiFileDialogState *state)
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
DrawRectangle(0, 0, GetScreenWidth(), GetScreenHeight(), Fade(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)), 0.85f));
|
||||
state->fileDialogActive = !GuiWindowBox((Rectangle){ state->position.x + 0, state->position.y + 0, winWidth, winHeight }, "#198#LuaJIT | Select File Dialog");
|
||||
state->fileDialogActive = !GuiWindowBox((Rectangle){ state->position.x + 0, state->position.y + 0, winWidth, winHeight }, "#198# Select File Dialog");
|
||||
|
||||
if (GuiButton((Rectangle){ state->position.x + winWidth - 50, state->position.y + 35, 40, 25 }, "< ..")) // || IsKeyReleased(KEY_DPAD_Y))
|
||||
{
|
||||
|
@ -3,25 +3,23 @@
|
||||
* raygui - image exporter
|
||||
*
|
||||
* DEPENDENCIES:
|
||||
* raylib 2.1 - Windowing/input management and drawing.
|
||||
* raygui 2.0 - Immediate-mode GUI controls.
|
||||
* 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 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2015-2021 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#define RAYGUI_SUPPORT_RICONS
|
||||
#include "../../src/raygui.h"
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
|
@ -3,22 +3,21 @@
|
||||
* raygui - image raw importer
|
||||
*
|
||||
* DEPENDENCIES:
|
||||
* raylib 2.1 - Windowing/input management and drawing.
|
||||
* raygui 2.0 - Immediate-mode GUI controls.
|
||||
* 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 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2015-2021 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#define RAYGUI_SUPPORT_RICONS
|
||||
#include "../../src/raygui.h"
|
||||
|
||||
#include <string.h> // Required for: strcpy()
|
||||
|
@ -3,22 +3,21 @@
|
||||
* raygui - portable window
|
||||
*
|
||||
* DEPENDENCIES:
|
||||
* raylib 2.1 - Windowing/input management and drawing.
|
||||
* raygui 2.0 - Immediate-mode GUI controls.
|
||||
* 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 Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2016-2021 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#define RAYGUI_SUPPORT_RICONS
|
||||
#include "../../src/raygui.h"
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
@ -28,8 +27,8 @@ int main()
|
||||
{
|
||||
// Initialization
|
||||
//---------------------------------------------------------------------------------------
|
||||
int screenWidth = 800;
|
||||
int screenHeight = 600;
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 600;
|
||||
|
||||
SetConfigFlags(FLAG_WINDOW_UNDECORATED);
|
||||
InitWindow(screenWidth, screenHeight, "raygui - portable window");
|
||||
|
@ -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
|
@ -6,18 +6,18 @@
|
||||
* - GuiScrollPanel()
|
||||
*
|
||||
* DEPENDENCIES:
|
||||
* raylib 2.4 - Windowing/input management and drawing.
|
||||
* raygui 2.0 - Immediate-mode GUI controls.
|
||||
* 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
|
||||
*
|
||||
* COMPILATION (Linux - gcc):
|
||||
* gcc -o $(NAME_PART) $(FILE_NAME) -I../../src -lraylib -std=c99
|
||||
* gcc -o $(NAME_PART) $(FILE_NAME) -I../../src -lraylib -lGL -lm -lpthread -ldl -lrt -lX11 -std=c99
|
||||
*
|
||||
* LICENSE: zlib/libpng
|
||||
*
|
||||
* Copyright (c) 2019 Vlad Adrian (@Demizdor) and Ramon Santamaria (@raysan5)
|
||||
* Copyright (c) 2019-2021 Vlad Adrian (@Demizdor) and Ramon Santamaria (@raysan5)
|
||||
*
|
||||
**********************************************************************************************/
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "raylib.h"
|
||||
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#define RAYGUI_SUPPORT_RICONS
|
||||
#include "../../src/raygui.h"
|
||||
|
||||
#undef RAYGUI_IMPLEMENTATION // Avoid including raygui implementation again
|
||||
|
@ -21,10 +21,8 @@
|
||||
#include "raylib.h"
|
||||
|
||||
#define RAYGUI_IMPLEMENTATION
|
||||
#define RAYGUI_SUPPORT_RICONS
|
||||
#include "../../src/raygui.h"
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Defines and Macros
|
||||
//----------------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user