raygui/examples/controls_review/controls_review.c

143 lines
6.3 KiB
C
Raw Normal View History

2018-10-09 11:58:04 +02:00
/*******************************************************************************************
*
* layout_file_name - tool description
*
* LICENSE: zlib/libpng
*
* Copyright (c) 2018 raylib technologies
*
**********************************************************************************************/
#include "raylib.h"
#define RAYGUI_IMPLEMENTATION
#include "../../src/raygui.h"
//----------------------------------------------------------------------------------
// Controls Functions Declaration
//----------------------------------------------------------------------------------
static void Button005(); // Button: Button005 logic
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main()
{
// Initialization
//---------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 600;
InitWindow(screenWidth, screenHeight, "layout_file_name");
// layout_file_name: controls initialization
//----------------------------------------------------------------------------------
int DropdownBox000Active = 0;
int DropdownBox001Active = 0;
2018-10-09 11:58:04 +02:00
const char *DropdownBox000TextList[3] = { "ONE", "TWO", "THREE" };
int Spinner001Value = 0;
int ValueBox002Value = 0;
2018-10-17 12:22:12 +02:00
char TextBox003Text[64] = "SAMPLE TEXT";
int ListView004Active = -1;
2018-10-10 18:14:53 +02:00
const char *ListView004TextList[6] = { "Charmander", "Bulbasaur", "Squirtel", "Pikachu", "Eevee", "Pidgey" };
char TextBox006Text[141] = "SAMPLE TEXT";
bool spinnerEditMode = false;
bool valueBoxEditMode = false;
bool textBoxEditMode = false;
2018-10-10 13:58:16 +02:00
bool multiTextBoxEditMode = false;
2018-10-17 12:22:12 +02:00
2018-10-16 17:43:46 +02:00
bool listViewEditMode = false;
2018-10-17 12:22:12 +02:00
bool dropDown000EditMode = false;
bool dropDown001EditMode = false;
bool forceSquaredChecked = false;
2018-10-29 19:41:51 +01:00
//int *enableElements = (int *)malloc(6*sizeof(int));
int enableElements[6] = {0, 0, 0, 0, 0, 0};
for (int i = 0; i < 6; i++)
{
enableElements[i] = 1;
}
Color colorPickerValue = RED;
2018-10-09 11:58:04 +02:00
//----------------------------------------------------------------------------------
2018-10-18 17:19:09 +02:00
Font font = LoadFontEx("fonts/NorthernLights.ttf", 30, 0, 0);
2018-10-18 17:19:09 +02:00
GuiFont(font);
2018-10-09 11:58:04 +02:00
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]));
2018-10-10 13:58:16 +02:00
2018-10-09 11:58:04 +02:00
// raygui: controls drawing
//----------------------------------------------------------------------------------
if (dropDown000EditMode || dropDown001EditMode) GuiLock();
2018-10-29 19:41:51 +01:00
GuiDisable();
//if (GuiSpinner((Rectangle){ 25, 75, 125, 30 }, &Spinner001Value, 0, 100, 25, spinnerEditMode)) spinnerEditMode = !spinnerEditMode;
if (GuiValueBox((Rectangle){ 25, 125, 125, 30 }, &ValueBox002Value, 0, 100, valueBoxEditMode)) valueBoxEditMode = !valueBoxEditMode;
if (GuiTextBox((Rectangle){ 25, 175, 125, 30 }, TextBox003Text, 64, textBoxEditMode)) textBoxEditMode = !textBoxEditMode;
2018-10-17 12:22:12 +02:00
2018-10-29 19:41:51 +01:00
//if (GuiListView((Rectangle){ 175, 25, 120, 100 }, ListView004TextList, 6, &ListView004Active, listViewEditMode)) listViewEditMode = !listViewEditMode;
if (GuiListViewEx((Rectangle){ 175, 25, 120, 100 }, ListView004TextList, enableElements, 6, &ListView004Active, listViewEditMode)) listViewEditMode = !listViewEditMode;
2018-10-09 11:58:04 +02:00
if (GuiButton((Rectangle){ 25, 225, 125, 30 }, "SAMPLE TEXT")) Button005();
2018-10-16 17:43:46 +02:00
if (GuiTextBoxMulti((Rectangle){ 325, 25, 225, 175 }, TextBox006Text, 141, multiTextBoxEditMode)) multiTextBoxEditMode = !multiTextBoxEditMode;
2018-10-09 11:58:04 +02:00
//GuiScrollPanel((Rectangle){ 325, 225, 225, 125 }, "SAMPLE TEXT");
if (GuiDropdownBox((Rectangle){ 25, 75, 125, 30 }, DropdownBox000TextList, 3, &DropdownBox001Active, dropDown001EditMode)) dropDown001EditMode = !dropDown001EditMode;
forceSquaredChecked = GuiCheckBoxEx((Rectangle){ 25, 65, 15, 15 }, forceSquaredChecked, "Force Square");
//GuiDisable();
if (GuiDropdownBox((Rectangle){ 25, 25, 125, 30 }, DropdownBox000TextList, 3, &DropdownBox000Active, dropDown000EditMode)) dropDown000EditMode = !dropDown000EditMode;
colorPickerValue = GuiColorPicker((Rectangle){ 325, 220, 240, 240 }, colorPickerValue);
GuiEnable();
GuiUnlock();
GuiLock();
GuiState(0); if (GuiButton((Rectangle){ 25, 400, 125, 30 }, "SAMPLE TEXT")) Button005();
GuiState(1); if (GuiButton((Rectangle){ 25, 440, 125, 30 }, "SAMPLE TEXT")) Button005();
GuiState(2); if (GuiButton((Rectangle){ 25, 480, 125, 30 }, "SAMPLE TEXT")) Button005();
GuiState(3); if (GuiButton((Rectangle){ 25, 520, 125, 30 }, "SAMPLE TEXT")) Button005();
GuiState(1);
GuiUnlock();
2018-10-09 11:58:04 +02:00
//----------------------------------------------------------------------------------
EndDrawing();
//----------------------------------------------------------------------------------
}
2018-10-29 19:41:51 +01:00
//free(enableElements);
2018-10-09 11:58:04 +02:00
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
//------------------------------------------------------------------------------------
// Controls Functions Definitions (local)
//------------------------------------------------------------------------------------
// Button: Button005 logic
static void Button005()
{
// TODO: Implement control logic
}