update zpl

isolation_bkp/dynres
Dominik Madarász 2021-06-01 15:20:04 +02:00
parent 4ea2ba6188
commit e056395f8f
3 changed files with 17385 additions and 17404 deletions

View File

@ -2,6 +2,7 @@
#include "zpl.h"
#include "platform.h"
#ifdef ZPL_SYSTEM_WINDOWS
#include <Windows.h>
static BOOL WINAPI _sighandler_win32_control_handler(DWORD control_type)
{
@ -29,25 +30,25 @@ static void _sighandler_posix_signal_handler(int sig) {
#endif
void sighandler_register() {
#ifdef ZPL_SYSTEM_WINDOWS
#ifdef ZPL_SYSTEM_WINDOWS
{
if (!SetConsoleCtrlHandler(_sighandler_win32_control_handler, 1)) {
zpl_printf("Could not set up signal handler!\n");
}
}
#else // POSIX compliant
#else // POSIX compliant
signal(SIGINT, &_sighandler_posix_signal_handler);
signal(SIGTERM, &_sighandler_posix_signal_handler);
#endif
#endif
}
void sighandler_unregister() {
#ifdef ZPL_SYSTEM_WINDOWS
#ifdef ZPL_SYSTEM_WINDOWS
{
if (!SetConsoleCtrlHandler(_sighandler_win32_control_handler, 0)) {
zpl_printf("Could not uninstall signal handler!");
}
}
#else // POSIX compliant
#endif
#else // POSIX compliant
#endif
}

428
code/vendors/raygui.h vendored
View File

@ -134,36 +134,36 @@
#define RAYGUI_VERSION "2.9-dev"
#if !defined(RAYGUI_STANDALONE)
#include "raylib.h"
#include "raylib.h"
#endif
// Define functions scope to be used internally (static) or externally (extern) to the module including this file
#if defined(_WIN32)
// Microsoft attibutes to tell compiler that symbols are imported/exported from a .dll
#if defined(BUILD_LIBTYPE_SHARED)
#define RAYGUIDEF __declspec(dllexport) // We are building raygui as a Win32 shared library (.dll)
#elif defined(USE_LIBTYPE_SHARED)
#define RAYGUIDEF __declspec(dllimport) // We are using raygui as a Win32 shared library (.dll)
// Microsoft attibutes to tell compiler that symbols are imported/exported from a .dll
#if defined(BUILD_LIBTYPE_SHARED)
#define RAYGUIDEF __declspec(dllexport) // We are building raygui as a Win32 shared library (.dll)
#elif defined(USE_LIBTYPE_SHARED)
#define RAYGUIDEF __declspec(dllimport) // We are using raygui as a Win32 shared library (.dll)
#else
#define RAYGUIDEF // We are building or using raygui as a static library
#endif
#else
#define RAYGUIDEF // We are building or using raygui as a static library
#endif
#else
#define RAYGUIDEF // We are building or using raygui as a static library (or Linux shared library)
#define RAYGUIDEF // We are building or using raygui as a static library (or Linux shared library)
#endif
#if !defined(RAYGUI_MALLOC) && !defined(RAYGUI_CALLOC) && !defined(RAYGUI_FREE)
#include <stdlib.h> // Required for: malloc(), calloc(), free()
#include <stdlib.h> // Required for: malloc(), calloc(), free()
#endif
// Allow custom memory allocators
#ifndef RAYGUI_MALLOC
#define RAYGUI_MALLOC(sz) malloc(sz)
#define RAYGUI_MALLOC(sz) malloc(sz)
#endif
#ifndef RAYGUI_CALLOC
#define RAYGUI_CALLOC(n,sz) calloc(n,sz)
#define RAYGUI_CALLOC(n,sz) calloc(n,sz)
#endif
#ifndef RAYGUI_FREE
#define RAYGUI_FREE(p) free(p)
#define RAYGUI_FREE(p) free(p)
#endif
//----------------------------------------------------------------------------------
@ -179,17 +179,17 @@
extern "C" { // Prevents name mangling of functions
#endif
//----------------------------------------------------------------------------------
// Types and Structures Definition
// NOTE: Some types are required for RAYGUI_STANDALONE usage
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
// Types and Structures Definition
// NOTE: Some types are required for RAYGUI_STANDALONE usage
//----------------------------------------------------------------------------------
#if defined(RAYGUI_STANDALONE)
#ifndef __cplusplus
#ifndef __cplusplus
// Boolean type
#ifndef true
#ifndef true
typedef enum { false, true } bool;
#endif
#endif
#endif
#endif
// Vector2 type
typedef struct Vector2 {
@ -244,30 +244,30 @@ extern "C" { // Prevents name mangling of functions
} Font;
#endif
// Style property
typedef struct GuiStyleProp {
// Style property
typedef struct GuiStyleProp {
unsigned short controlId;
unsigned short propertyId;
int propertyValue;
} GuiStyleProp;
} GuiStyleProp;
// Gui control state
typedef enum {
// Gui control state
typedef enum {
GUI_STATE_NORMAL = 0,
GUI_STATE_FOCUSED,
GUI_STATE_PRESSED,
GUI_STATE_DISABLED,
} GuiControlState;
} GuiControlState;
// Gui control text alignment
typedef enum {
// Gui control text alignment
typedef enum {
GUI_TEXT_ALIGN_LEFT = 0,
GUI_TEXT_ALIGN_CENTER,
GUI_TEXT_ALIGN_RIGHT,
} GuiTextAlignment;
} GuiTextAlignment;
// Gui controls
typedef enum {
// Gui controls
typedef enum {
DEFAULT = 0,
LABEL, // LABELBUTTON
BUTTON, // IMAGEBUTTON
@ -284,10 +284,10 @@ extern "C" { // Prevents name mangling of functions
COLORPICKER,
SCROLLBAR,
STATUSBAR
} GuiControl;
} GuiControl;
// Gui base properties for every control
typedef enum {
// Gui base properties for every control
typedef enum {
BORDER_COLOR_NORMAL = 0,
BASE_COLOR_NORMAL,
TEXT_COLOR_NORMAL,
@ -304,204 +304,198 @@ extern "C" { // Prevents name mangling of functions
TEXT_PADDING,
TEXT_ALIGNMENT,
RESERVED
} GuiControlProperty;
} GuiControlProperty;
// Gui extended properties depend on control
// NOTE: We reserve a fixed size of additional properties per control
// Gui extended properties depend on control
// NOTE: We reserve a fixed size of additional properties per control
// DEFAULT properties
typedef enum {
// DEFAULT properties
typedef enum {
TEXT_SIZE = 16,
TEXT_SPACING,
LINE_COLOR,
BACKGROUND_COLOR,
} GuiDefaultProperty;
} GuiDefaultProperty;
// Label
//typedef enum { } GuiLabelProperty;
// Label
//typedef enum { } GuiLabelProperty;
// Button
//typedef enum { } GuiButtonProperty;
// Button
//typedef enum { } GuiButtonProperty;
// Toggle / ToggleGroup
typedef enum {
// Toggle / ToggleGroup
typedef enum {
GROUP_PADDING = 16,
} GuiToggleProperty;
} GuiToggleProperty;
// Slider / SliderBar
typedef enum {
// Slider / SliderBar
typedef enum {
SLIDER_WIDTH = 16,
SLIDER_PADDING
} GuiSliderProperty;
} GuiSliderProperty;
// ProgressBar
typedef enum {
// ProgressBar
typedef enum {
PROGRESS_PADDING = 16,
} GuiProgressBarProperty;
} GuiProgressBarProperty;
// CheckBox
typedef enum {
// CheckBox
typedef enum {
CHECK_PADDING = 16
} GuiCheckBoxProperty;
} GuiCheckBoxProperty;
// ComboBox
typedef enum {
// ComboBox
typedef enum {
COMBO_BUTTON_WIDTH = 16,
COMBO_BUTTON_PADDING
} GuiComboBoxProperty;
} GuiComboBoxProperty;
// DropdownBox
typedef enum {
// DropdownBox
typedef enum {
ARROW_PADDING = 16,
DROPDOWN_ITEMS_PADDING
} GuiDropdownBoxProperty;
} GuiDropdownBoxProperty;
// TextBox / TextBoxMulti / ValueBox / Spinner
typedef enum {
// TextBox / TextBoxMulti / ValueBox / Spinner
typedef enum {
TEXT_INNER_PADDING = 16,
TEXT_LINES_PADDING,
COLOR_SELECTED_FG,
COLOR_SELECTED_BG
} GuiTextBoxProperty;
} GuiTextBoxProperty;
// Spinner
typedef enum {
// Spinner
typedef enum {
SPIN_BUTTON_WIDTH = 16,
SPIN_BUTTON_PADDING,
} GuiSpinnerProperty;
} GuiSpinnerProperty;
// ScrollBar
typedef enum {
// ScrollBar
typedef enum {
ARROWS_SIZE = 16,
ARROWS_VISIBLE,
SCROLL_SLIDER_PADDING,
SCROLL_SLIDER_SIZE,
SCROLL_PADDING,
SCROLL_SPEED,
} GuiScrollBarProperty;
} GuiScrollBarProperty;
// ScrollBar side
typedef enum {
// ScrollBar side
typedef enum {
SCROLLBAR_LEFT_SIDE = 0,
SCROLLBAR_RIGHT_SIDE
} GuiScrollBarSide;
} GuiScrollBarSide;
// ListView
typedef enum {
// ListView
typedef enum {
LIST_ITEMS_HEIGHT = 16,
LIST_ITEMS_PADDING,
SCROLLBAR_WIDTH,
SCROLLBAR_SIDE,
} GuiListViewProperty;
} GuiListViewProperty;
// ColorPicker
typedef enum {
// ColorPicker
typedef enum {
COLOR_SELECTOR_SIZE = 16,
HUEBAR_WIDTH, // Right hue bar width
HUEBAR_PADDING, // Right hue bar separation from panel
HUEBAR_SELECTOR_HEIGHT, // Right hue bar selector height
HUEBAR_SELECTOR_OVERFLOW // Right hue bar selector overflow
} GuiColorPickerProperty;
} GuiColorPickerProperty;
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
// ...
//----------------------------------------------------------------------------------
// Global Variables Definition
//----------------------------------------------------------------------------------
// ...
//----------------------------------------------------------------------------------
// Module Functions Declaration
//----------------------------------------------------------------------------------
//----------------------------------------------------------------------------------
// Module Functions Declaration
//----------------------------------------------------------------------------------
// State modification functions
RAYGUIDEF void GuiEnable(void); // Enable gui controls (global state)
RAYGUIDEF void GuiDisable(void); // Disable gui controls (global state)
RAYGUIDEF void GuiLock(void); // Lock gui controls (global state)
RAYGUIDEF void GuiUnlock(void); // Unlock gui controls (global state)
RAYGUIDEF void GuiFade(float alpha); // Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f
RAYGUIDEF void GuiSetState(int state); // Set gui state (global state)
RAYGUIDEF int GuiGetState(void); // Get gui state (global state)
// State modification functions
RAYGUIDEF void GuiEnable(void); // Enable gui controls (global state)
RAYGUIDEF void GuiDisable(void); // Disable gui controls (global state)
RAYGUIDEF void GuiLock(void); // Lock gui controls (global state)
RAYGUIDEF void GuiUnlock(void); // Unlock gui controls (global state)
RAYGUIDEF void GuiFade(float alpha); // Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f
RAYGUIDEF void GuiSetState(int state); // Set gui state (global state)
RAYGUIDEF int GuiGetState(void); // Get gui state (global state)
// Font set/get functions
RAYGUIDEF void GuiSetFont(Font font); // Set gui custom font (global state)
RAYGUIDEF Font GuiGetFont(void); // Get gui custom font (global state)
// Font set/get functions
RAYGUIDEF void GuiSetFont(Font font); // Set gui custom font (global state)
RAYGUIDEF Font GuiGetFont(void); // Get gui custom font (global state)
// Style set/get functions
RAYGUIDEF void GuiSetStyle(int control, int property, int value); // Set one style property
RAYGUIDEF int GuiGetStyle(int control, int property); // Get one style property
// Style set/get functions
RAYGUIDEF void GuiSetStyle(int control, int property, int value); // Set one style property
RAYGUIDEF int GuiGetStyle(int control, int property); // Get one style property
// Container/separator controls, useful for controls organization
RAYGUIDEF bool GuiWindowBox(Rectangle bounds, const char *title); // Window Box control, shows a window that can be closed
RAYGUIDEF void GuiGroupBox(Rectangle bounds, const char *text); // Group Box control with text name
RAYGUIDEF void GuiLine(Rectangle bounds, const char *text); // Line separator control, could contain text
RAYGUIDEF void GuiPanel(Rectangle bounds); // Panel control, useful to group controls
RAYGUIDEF Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll); // Scroll Panel control
// Container/separator controls, useful for controls organization
RAYGUIDEF bool GuiWindowBox(Rectangle bounds, const char *title); // Window Box control, shows a window that can be closed
RAYGUIDEF void GuiGroupBox(Rectangle bounds, const char *text); // Group Box control with text name
RAYGUIDEF void GuiLine(Rectangle bounds, const char *text); // Line separator control, could contain text
RAYGUIDEF void GuiPanel(Rectangle bounds); // Panel control, useful to group controls
RAYGUIDEF Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll); // Scroll Panel control
// Basic controls set
RAYGUIDEF void GuiLabel(Rectangle bounds, const char *text); // Label control, shows text
RAYGUIDEF bool GuiButton(Rectangle bounds, const char *text); // Button control, returns true when clicked
RAYGUIDEF bool GuiLabelButton(Rectangle bounds, const char *text); // Label button control, show true when clicked
RAYGUIDEF bool GuiImageButton(Rectangle bounds, const char *text, Texture2D texture); // Image button control, returns true when clicked
RAYGUIDEF bool GuiImageButtonEx(Rectangle bounds, const char *text, Texture2D texture, Rectangle texSource); // Image button extended control, returns true when clicked
RAYGUIDEF bool GuiToggle(Rectangle bounds, const char *text, bool active); // Toggle Button control, returns true when active
RAYGUIDEF int GuiToggleGroup(Rectangle bounds, const char *text, int active); // Toggle Group control, returns active toggle index
RAYGUIDEF bool GuiCheckBox(Rectangle bounds, const char *text, bool checked); // Check Box control, returns true when active
RAYGUIDEF int GuiComboBox(Rectangle bounds, const char *text, int active); // Combo Box control, returns selected item index
RAYGUIDEF bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMode); // Dropdown Box control, returns selected item
RAYGUIDEF bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode); // Spinner control, returns selected value
RAYGUIDEF bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode); // Value Box control, updates input text with numbers
RAYGUIDEF bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode); // Text Box control, updates input text
RAYGUIDEF bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode); // Text Box control with multiple lines
RAYGUIDEF float GuiSlider(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue); // Slider control, returns selected value
RAYGUIDEF float GuiSliderBar(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue); // Slider Bar control, returns selected value
RAYGUIDEF float GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue); // Progress Bar control, shows current progress 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 control
// Basic controls set
RAYGUIDEF void GuiLabel(Rectangle bounds, const char *text); // Label control, shows text
RAYGUIDEF bool GuiButton(Rectangle bounds, const char *text); // Button control, returns true when clicked
RAYGUIDEF bool GuiLabelButton(Rectangle bounds, const char *text); // Label button control, show true when clicked
RAYGUIDEF bool GuiImageButton(Rectangle bounds, const char *text, Texture2D texture); // Image button control, returns true when clicked
RAYGUIDEF bool GuiImageButtonEx(Rectangle bounds, const char *text, Texture2D texture, Rectangle texSource); // Image button extended control, returns true when clicked
RAYGUIDEF bool GuiToggle(Rectangle bounds, const char *text, bool active); // Toggle Button control, returns true when active
RAYGUIDEF int GuiToggleGroup(Rectangle bounds, const char *text, int active); // Toggle Group control, returns active toggle index
RAYGUIDEF bool GuiCheckBox(Rectangle bounds, const char *text, bool checked); // Check Box control, returns true when active
RAYGUIDEF int GuiComboBox(Rectangle bounds, const char *text, int active); // Combo Box control, returns selected item index
RAYGUIDEF bool GuiDropdownBox(Rectangle bounds, const char *text, int *active, bool editMode); // Dropdown Box control, returns selected item
RAYGUIDEF bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode); // Spinner control, returns selected value
RAYGUIDEF bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode); // Value Box control, updates input text with numbers
RAYGUIDEF bool GuiTextBox(Rectangle bounds, char *text, int textSize, bool editMode); // Text Box control, updates input text
RAYGUIDEF bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode); // Text Box control with multiple lines
RAYGUIDEF float GuiSlider(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue); // Slider control, returns selected value
RAYGUIDEF float GuiSliderBar(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue); // Slider Bar control, returns selected value
RAYGUIDEF float GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRight, float value, float minValue, float maxValue); // Progress Bar control, shows current progress 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 control
// Advance controls set
RAYGUIDEF int GuiListView(Rectangle bounds, const char *text, int *scrollIndex, int active); // List View control, returns selected list item index
RAYGUIDEF int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, int *scrollIndex, int active); // List View with extended parameters
RAYGUIDEF int GuiMessageBox(Rectangle bounds, const char *title, const char *message, const char *buttons); // Message Box control, displays a message
RAYGUIDEF int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text); // Text Input Box control, ask for text
RAYGUIDEF Color GuiColorPicker(Rectangle bounds, Color color); // Color Picker control (multiple color controls)
RAYGUIDEF Color GuiColorPanel(Rectangle bounds, Color color); // Color Panel control
RAYGUIDEF float GuiColorBarAlpha(Rectangle bounds, float alpha); // Color Bar Alpha control
RAYGUIDEF float GuiColorBarHue(Rectangle bounds, float value); // Color Bar Hue control
// Advance controls set
RAYGUIDEF int GuiListView(Rectangle bounds, const char *text, int *scrollIndex, int active); // List View control, returns selected list item index
RAYGUIDEF int GuiListViewEx(Rectangle bounds, const char **text, int count, int *focus, int *scrollIndex, int active); // List View with extended parameters
RAYGUIDEF int GuiMessageBox(Rectangle bounds, const char *title, const char *message, const char *buttons); // Message Box control, displays a message
RAYGUIDEF int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text); // Text Input Box control, ask for text
RAYGUIDEF Color GuiColorPicker(Rectangle bounds, Color color); // Color Picker control (multiple color controls)
RAYGUIDEF Color GuiColorPanel(Rectangle bounds, Color color); // Color Panel control
RAYGUIDEF float GuiColorBarAlpha(Rectangle bounds, float alpha); // Color Bar Alpha control
RAYGUIDEF float GuiColorBarHue(Rectangle bounds, float value); // Color Bar Hue control
// Styles loading functions
RAYGUIDEF void GuiLoadStyle(const char *fileName); // Load style file (.rgs)
RAYGUIDEF void GuiLoadStyleDefault(void); // Load style default over global style
// Styles loading functions
RAYGUIDEF void GuiLoadStyle(const char *fileName); // Load style file (.rgs)
RAYGUIDEF void GuiLoadStyleDefault(void); // Load style default over global style
/*
typedef GuiStyle (unsigned int *)
RAYGUIDEF GuiStyle LoadGuiStyle(const char *fileName); // Load style from file (.rgs)
RAYGUIDEF void UnloadGuiStyle(GuiStyle style); // Unload style
*/
/*
typedef GuiStyle (unsigned int *)
RAYGUIDEF GuiStyle LoadGuiStyle(const char *fileName); // Load style from file (.rgs)
RAYGUIDEF void UnloadGuiStyle(GuiStyle style); // Unload style
*/
RAYGUIDEF const char *GuiIconText(int iconId, const char *text); // Get text with icon id prepended (if supported)
RAYGUIDEF const char *GuiIconText(int iconId, const char *text); // Get text with icon id prepended (if supported)
#if defined(RAYGUI_SUPPORT_ICONS)
// Gui icons functionality
RAYGUIDEF void GuiDrawIcon(int iconId, Vector2 position, int pixelSize, Color color);
// Gui icons functionality
RAYGUIDEF void GuiDrawIcon(int iconId, Vector2 position, int pixelSize, Color color);
RAYGUIDEF unsigned int *GuiGetIcons(void); // Get full icons data pointer
RAYGUIDEF unsigned int *GuiGetIconData(int iconId); // Get icon bit data
RAYGUIDEF void GuiSetIconData(int iconId, unsigned int *data); // Set icon bit data
RAYGUIDEF unsigned int *GuiGetIcons(void); // Get full icons data pointer
RAYGUIDEF unsigned int *GuiGetIconData(int iconId); // Get icon bit data
RAYGUIDEF void GuiSetIconData(int iconId, unsigned int *data); // Set icon bit data
RAYGUIDEF void GuiSetIconPixel(int iconId, int x, int y); // Set icon pixel value
RAYGUIDEF void GuiClearIconPixel(int iconId, int x, int y); // Clear icon pixel value
RAYGUIDEF bool GuiCheckIconPixel(int iconId, int x, int y); // Check icon pixel value
RAYGUIDEF void GuiSetIconPixel(int iconId, int x, int y); // Set icon pixel value
RAYGUIDEF void GuiClearIconPixel(int iconId, int x, int y); // Clear icon pixel value
RAYGUIDEF bool GuiCheckIconPixel(int iconId, int x, int y); // Check icon pixel value
#endif
#if defined(__cplusplus)
} // Prevents name mangling of functions
#endif
#endif // RAYGUI_H
/***********************************************************************************
*
* RAYGUI IMPLEMENTATION
@ -511,8 +505,8 @@ extern "C" { // Prevents name mangling of functions
#if defined(RAYGUI_IMPLEMENTATION)
#if defined(RAYGUI_SUPPORT_ICONS)
#define RICONS_IMPLEMENTATION
#include "ricons.h" // Required for: raygui icons data
#define RICONS_IMPLEMENTATION
#include "ricons.h" // Required for: raygui icons data
#endif
#include <stdio.h> // Required for: FILE, fopen(), fclose(), fprintf(), feof(), fscanf(), vsprintf()
@ -520,13 +514,13 @@ extern "C" { // Prevents name mangling of functions
#include <math.h> // Required for: roundf() on GuiColorPicker()
#if defined(RAYGUI_STANDALONE)
#include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end()
#include <stdarg.h> // Required for: va_list, va_start(), vfprintf(), va_end()
#endif
#ifdef __cplusplus
#define RAYGUI_CLITERAL(name) name
#define RAYGUI_CLITERAL(name) name
#else
#define RAYGUI_CLITERAL(name) (name)
#define RAYGUI_CLITERAL(name) (name)
#endif
//----------------------------------------------------------------------------------
@ -717,7 +711,7 @@ int GuiGetStyle(int control, int property)
bool GuiWindowBox(Rectangle bounds, const char *title)
{
// NOTE: This define is also used by GuiMessageBox() and GuiTextInputBox()
#define WINDOW_STATUSBAR_HEIGHT 22
#define WINDOW_STATUSBAR_HEIGHT 22
//GuiControlState state = guiState;
bool clicked = false;
@ -762,8 +756,8 @@ bool GuiWindowBox(Rectangle bounds, const char *title)
// Group Box control with text name
void GuiGroupBox(Rectangle bounds, const char *text)
{
#define GROUPBOX_LINE_THICK 1
#define GROUPBOX_TEXT_PADDING 10
#define GROUPBOX_LINE_THICK 1
#define GROUPBOX_TEXT_PADDING 10
GuiControlState state = guiState;
@ -780,7 +774,7 @@ void GuiGroupBox(Rectangle bounds, const char *text)
// Line control
void GuiLine(Rectangle bounds, const char *text)
{
#define LINE_TEXT_PADDING 10
#define LINE_TEXT_PADDING 10
GuiControlState state = guiState;
@ -808,7 +802,7 @@ void GuiLine(Rectangle bounds, const char *text)
// Panel control
void GuiPanel(Rectangle bounds)
{
#define PANEL_BORDER_WIDTH 1
#define PANEL_BORDER_WIDTH 1
GuiControlState state = guiState;
@ -1102,9 +1096,9 @@ bool GuiToggle(Rectangle bounds, const char *text, bool active)
// Toggle Group control, returns toggled button index
int GuiToggleGroup(Rectangle bounds, const char *text, int active)
{
#if !defined(TOGGLEGROUP_MAX_ELEMENTS)
#define TOGGLEGROUP_MAX_ELEMENTS 32
#endif
#if !defined(TOGGLEGROUP_MAX_ELEMENTS)
#define TOGGLEGROUP_MAX_ELEMENTS 32
#endif
float initBoundsX = bounds.x;
@ -1557,9 +1551,9 @@ bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, in
// NOTE: Requires static variables: framesCounter
bool GuiValueBox(Rectangle bounds, const char *text, int *value, int minValue, int maxValue, bool editMode)
{
#if !defined(VALUEBOX_MAX_CHARS)
#define VALUEBOX_MAX_CHARS 32
#endif
#if !defined(VALUEBOX_MAX_CHARS)
#define VALUEBOX_MAX_CHARS 32
#endif
static int framesCounter = 0; // Required for blinking cursor
@ -1684,14 +1678,14 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
bool pressed = false;
Rectangle textAreaBounds = {
bounds.x + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING),
bounds.y + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING),
bounds.width - 2*GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING),
bounds.height - 2*GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING)
bounds.x + GuiGetStyle(TEXTBOX, BORDER_WIDTH) + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING),
bounds.y + GuiGetStyle(TEXTBOX, BORDER_WIDTH) + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING),
bounds.width - 2 * (GuiGetStyle(TEXTBOX, BORDER_WIDTH) + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING)),
bounds.height - 2 * (GuiGetStyle(TEXTBOX, BORDER_WIDTH) + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING))
};
// Cursor position, [x, y] values should be updated
Rectangle cursor = { 0, 0, 1, (float)GuiGetStyle(DEFAULT, TEXT_SIZE) + 2 };
Rectangle cursor = { 0, 0, (GuiGetStyle(DEFAULT, TEXT_SIZE) < 10) ? 1 : (GuiGetStyle(DEFAULT, TEXT_SIZE) * 0.1f), (float)GuiGetStyle(DEFAULT, TEXT_SIZE) + 2 };
int textWidth = 0;
int currentLine = 0;
@ -1761,7 +1755,7 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
if (text[i] == ' ' || text[i] == '\n') lastBreakingPos = i;
if ( text[i] == '\n' || textWidth >= textAreaBounds.width)
if ( text[i] == '\n' || textWidth + 1 >= textAreaBounds.width)
{
currentLine++;
textWidth = 0;
@ -1773,8 +1767,8 @@ bool GuiTextBoxMulti(Rectangle bounds, char *text, int textSize, bool editMode)
}
}
cursor.x = bounds.x + GuiGetStyle(TEXTBOX, BORDER_WIDTH) + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING) + textWidth - GuiGetStyle(DEFAULT, TEXT_SPACING);
cursor.y = bounds.y + GuiGetStyle(TEXTBOX, BORDER_WIDTH) + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING)/2 + ((GuiGetStyle(DEFAULT, TEXT_SIZE) + GuiGetStyle(TEXTBOX, TEXT_INNER_PADDING))*currentLine);
cursor.x = textAreaBounds.x + textWidth - GuiGetStyle(DEFAULT, TEXT_SPACING);
cursor.y = textAreaBounds.y + ((GuiGetStyle(DEFAULT, TEXT_SIZE) + GuiGetStyle(DEFAULT, TEXT_SIZE)/2)*currentLine);
// Exit edit mode
if (!CheckCollisionPointRec(mousePoint, bounds) && IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) pressed = true;
@ -2391,7 +2385,7 @@ Color GuiColorPanel(Rectangle bounds, Color color)
// NOTE: Returns alpha value normalized [0..1]
float GuiColorBarAlpha(Rectangle bounds, float alpha)
{
#define COLORBARALPHA_CHECKED_SIZE 10
#define COLORBARALPHA_CHECKED_SIZE 10
GuiControlState state = guiState;
Rectangle selector = { (float)bounds.x + alpha*bounds.width - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW), (float)bounds.y - GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW), (float)GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_HEIGHT), (float)bounds.height + GuiGetStyle(COLORPICKER, HUEBAR_SELECTOR_OVERFLOW)*2 };
@ -2531,11 +2525,11 @@ Color GuiColorPicker(Rectangle bounds, Color color)
color = GuiColorPanel(bounds, color);
Rectangle boundsHue = { (float)bounds.x + bounds.width + GuiGetStyle(COLORPICKER, HUEBAR_PADDING), (float)bounds.y, (float)GuiGetStyle(COLORPICKER, HUEBAR_WIDTH), (float)bounds.height };
Rectangle boundsAlpha = { bounds.x, bounds.y + bounds.height + GuiGetStyle(COLORPICKER, HUEBAR_PADDING), bounds.width, GuiGetStyle(COLORPICKER, HUEBAR_WIDTH) };
//Rectangle boundsAlpha = { bounds.x, bounds.y + bounds.height + GuiGetStyle(COLORPICKER, BARS_PADDING), bounds.width, GuiGetStyle(COLORPICKER, BARS_THICK) };
Vector3 hsv = ConvertRGBtoHSV(RAYGUI_CLITERAL(Vector3){ color.r/255.0f, color.g/255.0f, color.b/255.0f });
hsv.x = GuiColorBarHue(boundsHue, hsv.x);
color.a = (unsigned char)(GuiColorBarAlpha(boundsAlpha, (float)color.a/255.0f)*255.0f);
//color.a = (unsigned char)(GuiColorBarAlpha(boundsAlpha, (float)color.a/255.0f)*255.0f);
Vector3 rgb = ConvertHSVtoRGB(hsv);
color = RAYGUI_CLITERAL(Color){ (unsigned char)roundf(rgb.x*255.0f), (unsigned char)roundf(rgb.y*255.0f), (unsigned char)roundf(rgb.z*255.0f), color.a };
@ -2545,8 +2539,8 @@ Color GuiColorPicker(Rectangle bounds, Color color)
// Message Box control
int GuiMessageBox(Rectangle bounds, const char *title, const char *message, const char *buttons)
{
#define MESSAGEBOX_BUTTON_HEIGHT 24
#define MESSAGEBOX_BUTTON_PADDING 10
#define MESSAGEBOX_BUTTON_HEIGHT 24
#define MESSAGEBOX_BUTTON_PADDING 10
int clicked = -1; // Returns clicked button from buttons list, 0 refers to closed window button
@ -2593,11 +2587,11 @@ int GuiMessageBox(Rectangle bounds, const char *title, const char *message, cons
// Text Input Box control, ask for text
int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, const char *buttons, char *text)
{
#define TEXTINPUTBOX_BUTTON_HEIGHT 24
#define TEXTINPUTBOX_BUTTON_PADDING 10
#define TEXTINPUTBOX_HEIGHT 30
#define TEXTINPUTBOX_BUTTON_HEIGHT 24
#define TEXTINPUTBOX_BUTTON_PADDING 10
#define TEXTINPUTBOX_HEIGHT 30
#define TEXTINPUTBOX_MAX_TEXT_LENGTH 256
#define TEXTINPUTBOX_MAX_TEXT_LENGTH 256
// Used to enable text edit mode
// WARNING: No more than one GuiTextInputBox() should be open at the same time
@ -2670,9 +2664,9 @@ int GuiTextInputBox(Rectangle bounds, const char *title, const char *message, co
// https://stackoverflow.com/questions/4435450/2d-opengl-drawing-lines-that-dont-exactly-fit-pixel-raster
Vector2 GuiGrid(Rectangle bounds, float spacing, int subdivs)
{
#if !defined(GRID_COLOR_ALPHA)
#define GRID_COLOR_ALPHA 0.15f // Grid lines alpha amount
#endif
#if !defined(GRID_COLOR_ALPHA)
#define GRID_COLOR_ALPHA 0.15f // Grid lines alpha amount
#endif
GuiControlState state = guiState;
Vector2 mousePoint = GetMousePosition();
@ -3100,7 +3094,7 @@ char **GuiLoadIcons(const char *fileName, bool loadIconsName)
// Draw selected icon using rectangles pixel-by-pixel
void GuiDrawIcon(int iconId, Vector2 position, int pixelSize, Color color)
{
#define BIT_CHECK(a,b) ((a) & (1<<(b)))
#define BIT_CHECK(a,b) ((a) & (1<<(b)))
for (int i = 0, y = 0; i < RICON_SIZE*RICON_SIZE/32; i++)
{
@ -3108,9 +3102,9 @@ void GuiDrawIcon(int iconId, Vector2 position, int pixelSize, Color color)
{
if (BIT_CHECK(guiIcons[iconId*RICON_DATA_ELEMENTS + i], k))
{
#if !defined(RAYGUI_STANDALONE)
#if !defined(RAYGUI_STANDALONE)
DrawRectangle(position.x + (k%RICON_SIZE)*pixelSize, position.y + y*pixelSize, pixelSize, pixelSize, color);
#endif
#endif
}
if ((k == 15) || (k == 31)) y++;
@ -3140,7 +3134,7 @@ void GuiSetIconData(int iconId, unsigned int *data)
// Set icon pixel value
void GuiSetIconPixel(int iconId, int x, int y)
{
#define BIT_SET(a,b) ((a) |= (1<<(b)))
#define BIT_SET(a,b) ((a) |= (1<<(b)))
// This logic works for any RICON_SIZE pixels icons,
// For example, in case of 16x16 pixels, every 2 lines fit in one unsigned int data element
@ -3150,7 +3144,7 @@ void GuiSetIconPixel(int iconId, int x, int y)
// Clear icon pixel value
void GuiClearIconPixel(int iconId, int x, int y)
{
#define BIT_CLEAR(a,b) ((a) &= ~((1)<<(b)))
#define BIT_CLEAR(a,b) ((a) &= ~((1)<<(b)))
// This logic works for any RICON_SIZE pixels icons,
// For example, in case of 16x16 pixels, every 2 lines fit in one unsigned int data element
@ -3160,7 +3154,7 @@ void GuiClearIconPixel(int iconId, int x, int y)
// Check icon pixel value
bool GuiCheckIconPixel(int iconId, int x, int y)
{
#define BIT_CHECK(a,b) ((a) & (1<<(b)))
#define BIT_CHECK(a,b) ((a) & (1<<(b)))
return (BIT_CHECK(guiIcons[iconId*8 + y/2], x + (y%2*16)));
}
@ -3243,7 +3237,7 @@ static const char *GetTextIcon(const char *text, int *iconId)
// Gui draw text using default font
static void GuiDrawText(const char *text, Rectangle bounds, int alignment, Color tint)
{
#define TEXT_VALIGN_PIXEL_OFFSET(h) ((int)h%2) // Vertical alignment for pixel perfect
#define TEXT_VALIGN_PIXEL_OFFSET(h) ((int)h%2) // Vertical alignment for pixel perfect
if ((text != NULL) && (text[0] != '\0'))
{
@ -3252,7 +3246,7 @@ static void GuiDrawText(const char *text, Rectangle bounds, int alignment, Color
// Get text position depending on alignment and iconId
//---------------------------------------------------------------------------------
#define ICON_TEXT_PADDING 4
#define ICON_TEXT_PADDING 4
Vector2 position = { bounds.x, bounds.y };
@ -3344,13 +3338,13 @@ static const char **GuiTextSplit(const char *text, int *count, int *textRow)
// 2. Maximum size of text to split is TEXTSPLIT_MAX_TEXT_LENGTH
// NOTE: Those definitions could be externally provided if required
#if !defined(TEXTSPLIT_MAX_TEXT_LENGTH)
#define TEXTSPLIT_MAX_TEXT_LENGTH 1024
#endif
#if !defined(TEXTSPLIT_MAX_TEXT_LENGTH)
#define TEXTSPLIT_MAX_TEXT_LENGTH 1024
#endif
#if !defined(TEXTSPLIT_MAX_TEXT_ELEMENTS)
#define TEXTSPLIT_MAX_TEXT_ELEMENTS 128
#endif
#if !defined(TEXTSPLIT_MAX_TEXT_ELEMENTS)
#define TEXTSPLIT_MAX_TEXT_ELEMENTS 128
#endif
static const char *result[TEXTSPLIT_MAX_TEXT_ELEMENTS] = { NULL };
static char buffer[TEXTSPLIT_MAX_TEXT_LENGTH] = { 0 };
@ -3557,7 +3551,7 @@ static Color Fade(Color color, float alpha)
// Formatting of text with variables to 'embed'
static const char *TextFormat(const char *text, ...)
{
#define MAX_FORMATTEXT_LENGTH 64
#define MAX_FORMATTEXT_LENGTH 64
static char buffer[MAX_FORMATTEXT_LENGTH];
@ -3679,3 +3673,9 @@ static const char *CodepointToUtf8(int codepoint, int *byteLength)
#endif // RAYGUI_STANDALONE
#endif // RAYGUI_IMPLEMENTATION
#if defined(__cplusplus)
} // Prevents name mangling of functions
#endif
#endif // RAYGUI_H

13846
code/vendors/zpl.h vendored

File diff suppressed because it is too large Load Diff