Reviewed raygui examples

This commit is contained in:
Ray
2018-11-08 10:41:31 +01:00
parent 6e0798fb18
commit 76d5234858
19 changed files with 83 additions and 181 deletions

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -1,9 +1,15 @@
/*******************************************************************************************
*
* raygui - image raw importer example
* raygui - image raw importer
*
* This example has been created using raylib v2.0 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
* DEPENDENCIES:
* raylib 2.1-dev - Windowing/input management and drawing.
* raygui 2.1-dev - 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) 2018 raylib technologies (@raylibtech)
*
@ -17,10 +23,6 @@
#include <string.h> // Required for: strcpy()
#include <stdlib.h> // Required for: atoi()
//----------------------------------------------------------------------------------
// Controls Functions Declaration
//----------------------------------------------------------------------------------
static void ImportRAW(); // Button: ImportRAW logic
//------------------------------------------------------------------------------------
// Program main entry point
@ -32,17 +34,21 @@ int main()
const int screenWidth = 800;
const int screenHeight = 600;
InitWindow(screenWidth, screenHeight, "Image RAW Importer");
InitWindow(screenWidth, screenHeight, "raygui - image raw importer");
Texture2D texture = { 0 };
// raw_importer: controls initialization
// GUI controls initialization
//----------------------------------------------------------------------------------
Vector2 windowOffset = { screenWidth/2 - 200/2, screenHeight/2 - 465/2 };
bool importWindowActive = false;
int widthValue = 0;
bool widthEditMode = false;
int heightValue = 0;
bool heightEditMode = false;
int pixelFormatActive = 0;
const char *pixelFormatTextList[8] = { "CUSTOM", "GRAYSCALE", "GRAY ALPHA", "R5G6B5", "R8G8B8", "R5G5B5A1", "R4G4B4A4", "R8G8B8A8" };
@ -50,7 +56,9 @@ int main()
const char *channelsTextList[4] = { "1", "2", "3", "4" };
int bitDepthActive = 0;
const char *bitDepthTextList[3] = { "8", "16", "32" };
int headerSizeValue = 0;
bool headerSizeEditMode = false;
//----------------------------------------------------------------------------------
// Image file info
@ -181,10 +189,10 @@ int main()
GuiLabel((Rectangle){ windowOffset.x + 85, windowOffset.y + 50, 75, 20 }, FormatText("%i bytes", dataSize));
GuiGroupBox((Rectangle){ windowOffset.x + 10, windowOffset.y + 85, 180, 80 }, "Resolution");
GuiLabel((Rectangle){ windowOffset.x + 20, windowOffset.y + 100, 33, 25 }, "Width:");
widthValue = GuiValueBox((Rectangle){ windowOffset.x + 60, windowOffset.y + 100, 80, 25 }, widthValue, 100);
if (GuiValueBox((Rectangle){ windowOffset.x + 60, windowOffset.y + 100, 80, 25 }, &widthValue, 0, 8192, widthEditMode)) widthEditMode = !widthEditMode;
GuiLabel((Rectangle){ windowOffset.x + 145, windowOffset.y + 100, 30, 25 }, "pixels");
GuiLabel((Rectangle){ windowOffset.x + 20, windowOffset.y + 130, 33, 25 }, "Height:");
heightValue = GuiValueBox((Rectangle){ windowOffset.x + 60, windowOffset.y + 130, 80, 25 }, heightValue, 100);
if (GuiValueBox((Rectangle){ windowOffset.x + 60, windowOffset.y + 130, 80, 25 }, &heightValue, 0, 8192, heightEditMode)) heightEditMode = !heightEditMode;
GuiLabel((Rectangle){ windowOffset.x + 145, windowOffset.y + 130, 30, 25 }, "pixels");
GuiGroupBox((Rectangle){ windowOffset.x + 10, windowOffset.y + 180, 180, 160 }, "Pixel Format");
pixelFormatActive = GuiComboBox((Rectangle){ windowOffset.x + 20, windowOffset.y + 195, 160, 25 }, pixelFormatTextList, 8, pixelFormatActive);
@ -199,7 +207,7 @@ int main()
GuiGroupBox((Rectangle){ windowOffset.x + 10, windowOffset.y + 355, 180, 50 }, "Header");
GuiLabel((Rectangle){ windowOffset.x + 25, windowOffset.y + 370, 27, 25 }, "Size:");
headerSizeValue = GuiValueBox((Rectangle){ windowOffset.x + 55, windowOffset.y + 370, 85, 25 }, headerSizeValue, 100);
if (GuiValueBox((Rectangle){ windowOffset.x + 55, windowOffset.y + 370, 85, 25 }, &headerSizeValue, 0, 10000, headerSizeEditMode)) headerSizeEditMode = !headerSizeEditMode;
GuiLabel((Rectangle){ windowOffset.x + 145, windowOffset.y + 370, 30, 25 }, "bytes");
btnLoadPressed = GuiButton((Rectangle){ windowOffset.x + 10, windowOffset.y + 420, 180, 30 }, "Import RAW");
@ -213,6 +221,7 @@ int main()
// De-Initialization
//--------------------------------------------------------------------------------------
if (texture.id != 0) UnloadTexture(texture);
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------