Review examples

This commit is contained in:
Ray 2019-07-05 20:47:15 +02:00
parent 511c2254c9
commit f157062acd
4 changed files with 26 additions and 31 deletions

View File

@ -16,7 +16,7 @@
#include "raylib.h"
#define RAYGUI_IMPLEMENTATION
#include "raygui.h"
#include "../../src/raygui.h"
//------------------------------------------------------------------------------------
@ -143,7 +143,7 @@ int main(int argc, char *argv[0])
DrawTextureEx(texture, (Vector2){ screenWidth/2 - (float)texture.width*imageScale/2, screenHeight/2 - (float)texture.height*imageScale/2 }, 0.0f, imageScale, WHITE);
DrawRectangleLinesEx(imageRec, 1, CheckCollisionPointRec(GetMousePosition(), imageRec) ? RED : DARKGRAY);
DrawText(FormatText("SCALE: %.2f%%", imageScale*100.0f), 20, screenHeight - 40, 20, GetColor(style[DEFAULT_LINES_COLOR]));
DrawText(FormatText("SCALE: %.2f%%", imageScale*100.0f), 20, screenHeight - 40, 20, GetColor(GuiGetStyle(DEFAULT, LINE_COLOR)));
}
else
{
@ -158,13 +158,13 @@ int main(int argc, char *argv[0])
//-----------------------------------------------------------------------------
if (windowBoxActive)
{
DrawRectangle(0, 0, screenWidth, screenHeight, Fade(GetColor(style[DEFAULT_BACKGROUND_COLOR]), 0.7f));
DrawRectangle(0, 0, screenWidth, screenHeight, Fade(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)), 0.7f));
windowBoxActive = !GuiWindowBox((Rectangle){ windowBoxRec.x, windowBoxRec.y, 220, 190 }, "Image Export Options");
GuiLabel((Rectangle){ windowBoxRec.x + 10, windowBoxRec.y + 35, 60, 25 }, "File format:");
fileFormatActive = GuiComboBox((Rectangle){ windowBoxRec.x + 80, windowBoxRec.y + 35, 130, 25 }, fileFormatTextList, 3, fileFormatActive);
fileFormatActive = GuiComboBox((Rectangle){ windowBoxRec.x + 80, windowBoxRec.y + 35, 130, 25 }, TextJoin(fileFormatTextList, 3, ";"), fileFormatActive);
GuiLabel((Rectangle){ windowBoxRec.x + 10, windowBoxRec.y + 70, 63, 25 }, "Pixel format:");
pixelFormatActive = GuiComboBox((Rectangle){ windowBoxRec.x + 80, windowBoxRec.y + 70, 130, 25 }, pixelFormatTextList, 7, pixelFormatActive);
pixelFormatActive = GuiComboBox((Rectangle){ windowBoxRec.x + 80, windowBoxRec.y + 70, 130, 25 }, TextJoin(pixelFormatTextList, 7, ";"), pixelFormatActive);
GuiLabel((Rectangle){ windowBoxRec.x + 10, windowBoxRec.y + 105, 50, 25 }, "File name:");
GuiTextBox((Rectangle){ windowBoxRec.x + 80, windowBoxRec.y + 105, 130, 25 }, fileName, 64, true);

View File

@ -1,6 +1,6 @@
/*******************************************************************************************
*
* raygui - standalone window
* raygui - portable window
*
* DEPENDENCIES:
* raylib 2.1 - Windowing/input management and drawing.
@ -20,7 +20,6 @@
#define RAYGUI_IMPLEMENTATION
#include "raygui.h"
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
@ -32,20 +31,18 @@ int main()
int screenHeight = 600;
SetConfigFlags(FLAG_WINDOW_UNDECORATED);
InitWindow(screenWidth, screenHeight, "raygui - standalone window");
// GUI controls initialization
//----------------------------------------------------------------------------------
bool exitWindow = false;
//----------------------------------------------------------------------------------
InitWindow(screenWidth, screenHeight, "raygui - portable window");
// General variables
Vector2 mousePos = { 0 };
Vector2 windowPos = { 500, 200 };
Vector2 panOffset = mousePos;
Vector2 mousePosition = { 0 };
Vector2 windowPosition = { 500, 200 };
Vector2 panOffset = mousePosition;
bool dragWindow = false;
SetWindowPosition(windowPos.x, windowPos.y);
SetWindowPosition(windowPosition.x, windowPosition.y);
bool exitWindow = false;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -54,25 +51,25 @@ int main()
{
// Update
//----------------------------------------------------------------------------------
mousePos = GetMousePosition();
mousePosition = GetMousePosition();
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{
if (CheckCollisionPointRec(mousePos, (Rectangle){ 0, 0, screenWidth, 20 }))
if (CheckCollisionPointRec(mousePosition, (Rectangle){ 0, 0, screenWidth, 20 }))
{
dragWindow = true;
panOffset = mousePos;
panOffset = mousePosition;
}
}
if (dragWindow)
{
windowPos.x += (mousePos.x - panOffset.x);
windowPos.y += (mousePos.y - panOffset.y);
windowPosition.x += (mousePosition.x - panOffset.x);
windowPosition.y += (mousePosition.y - panOffset.y);
if (IsMouseButtonReleased(MOUSE_LEFT_BUTTON)) dragWindow = false;
SetWindowPosition(windowPos.x, windowPos.y);
SetWindowPosition(windowPosition.x, windowPosition.y);
}
//----------------------------------------------------------------------------------
@ -82,11 +79,9 @@ int main()
ClearBackground(RAYWHITE);
// raygui: controls drawing
//----------------------------------------------------------------------------------
exitWindow = GuiWindowBox((Rectangle){ 0, 0, screenWidth, screenHeight }, "STANDALONE WINDOW");
DrawText(FormatText("Mouse Position: [ %.0f, %.0f ]", mousePos.x, mousePos.y), 10, 40, 10, DARKGRAY);
//----------------------------------------------------------------------------------
exitWindow = GuiWindowBox((Rectangle){ 0, 0, screenWidth, screenHeight }, "PORTABLE WINDOW");
DrawText(FormatText("Mouse Position: [ %.0f, %.0f ]", mousePosition.x, mousePosition.y), 10, 40, 10, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------

View File

@ -115,8 +115,8 @@ static void DrawStyleEditControls(void)
GuiSpinner((Rectangle){ 670, 240, 90, 20 }, &style, 0, 14, false);
GuiSetStyle(SCROLLBAR, INNER_PADDING, style);
style = GuiCheckBox((Rectangle){ 565, 280, 20, 20 }, "SHOW_SPINNER_BUTTONS", GuiGetStyle(SCROLLBAR, SHOW_SPINNER_BUTTONS));
GuiSetStyle(SCROLLBAR, SHOW_SPINNER_BUTTONS, style);
style = GuiCheckBox((Rectangle){ 565, 280, 20, 20 }, "ARROWS_VISIBLE", GuiGetStyle(SCROLLBAR, ARROWS_VISIBLE));
GuiSetStyle(SCROLLBAR, ARROWS_VISIBLE, style);
style = GuiGetStyle(SCROLLBAR, SLIDER_PADDING);
GuiLabel((Rectangle){ 555, 325, 110, 10 }, "SLIDER_PADDING");

View File

@ -435,7 +435,7 @@ RAYGUIDEF float GuiProgressBar(Rectangle bounds, const char *text, float value,
RAYGUIDEF void GuiStatusBar(Rectangle bounds, const char *text); // Status Bar control, shows info text
RAYGUIDEF void GuiDummyRec(Rectangle bounds, const char *text); // Dummy control for placeholders
RAYGUIDEF int GuiScrollBar(Rectangle bounds, int value, int minValue, int maxValue); // Scroll Bar control
RAYGUIDEF Vector2 GuiGrid(Rectangle bounds, float spacing, int subdivs); // Grid
RAYGUIDEF Vector2 GuiGrid(Rectangle bounds, float spacing, int subdivs); // Grid control
// Advance controls set
RAYGUIDEF bool GuiListView(Rectangle bounds, const char *text, int *active, int *scrollIndex, bool editMode); // List View control, returns selected list element index