update zpl
parent
4ea2ba6188
commit
e056395f8f
|
@ -2,19 +2,20 @@
|
|||
#include "zpl.h"
|
||||
#include "platform.h"
|
||||
#ifdef ZPL_SYSTEM_WINDOWS
|
||||
#include <Windows.h>
|
||||
|
||||
static BOOL WINAPI _sighandler_win32_control_handler(DWORD control_type)
|
||||
{
|
||||
switch (control_type)
|
||||
{
|
||||
case CTRL_C_EVENT:
|
||||
case DBG_CONTROL_C:
|
||||
case CTRL_C_EVENT:
|
||||
case DBG_CONTROL_C:
|
||||
platform_shutdown();
|
||||
return 0;
|
||||
case CTRL_CLOSE_EVENT:
|
||||
case CTRL_LOGOFF_EVENT:
|
||||
case CTRL_BREAK_EVENT:
|
||||
case CTRL_SHUTDOWN_EVENT:
|
||||
case CTRL_CLOSE_EVENT:
|
||||
case CTRL_LOGOFF_EVENT:
|
||||
case CTRL_BREAK_EVENT:
|
||||
case CTRL_SHUTDOWN_EVENT:
|
||||
platform_shutdown();
|
||||
return 1;
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
typedef enum { false, true } bool;
|
||||
#endif
|
||||
#endif
|
||||
#ifndef true
|
||||
typedef enum { false, true } bool;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Vector2 type
|
||||
typedef struct Vector2 {
|
||||
|
@ -244,264 +244,258 @@ extern "C" { // Prevents name mangling of functions
|
|||
} Font;
|
||||
#endif
|
||||
|
||||
// Style property
|
||||
typedef struct GuiStyleProp {
|
||||
unsigned short controlId;
|
||||
unsigned short propertyId;
|
||||
int propertyValue;
|
||||
} GuiStyleProp;
|
||||
// Style property
|
||||
typedef struct GuiStyleProp {
|
||||
unsigned short controlId;
|
||||
unsigned short propertyId;
|
||||
int propertyValue;
|
||||
} GuiStyleProp;
|
||||
|
||||
// Gui control state
|
||||
typedef enum {
|
||||
GUI_STATE_NORMAL = 0,
|
||||
GUI_STATE_FOCUSED,
|
||||
GUI_STATE_PRESSED,
|
||||
GUI_STATE_DISABLED,
|
||||
} GuiControlState;
|
||||
// Gui control state
|
||||
typedef enum {
|
||||
GUI_STATE_NORMAL = 0,
|
||||
GUI_STATE_FOCUSED,
|
||||
GUI_STATE_PRESSED,
|
||||
GUI_STATE_DISABLED,
|
||||
} GuiControlState;
|
||||
|
||||
// Gui control text alignment
|
||||
typedef enum {
|
||||
GUI_TEXT_ALIGN_LEFT = 0,
|
||||
GUI_TEXT_ALIGN_CENTER,
|
||||
GUI_TEXT_ALIGN_RIGHT,
|
||||
} GuiTextAlignment;
|
||||
// Gui control text alignment
|
||||
typedef enum {
|
||||
GUI_TEXT_ALIGN_LEFT = 0,
|
||||
GUI_TEXT_ALIGN_CENTER,
|
||||
GUI_TEXT_ALIGN_RIGHT,
|
||||
} GuiTextAlignment;
|
||||
|
||||
// Gui controls
|
||||
typedef enum {
|
||||
DEFAULT = 0,
|
||||
LABEL, // LABELBUTTON
|
||||
BUTTON, // IMAGEBUTTON
|
||||
TOGGLE, // TOGGLEGROUP
|
||||
SLIDER, // SLIDERBAR
|
||||
PROGRESSBAR,
|
||||
CHECKBOX,
|
||||
COMBOBOX,
|
||||
DROPDOWNBOX,
|
||||
TEXTBOX, // TEXTBOXMULTI
|
||||
VALUEBOX,
|
||||
SPINNER,
|
||||
LISTVIEW,
|
||||
COLORPICKER,
|
||||
SCROLLBAR,
|
||||
STATUSBAR
|
||||
} GuiControl;
|
||||
// Gui controls
|
||||
typedef enum {
|
||||
DEFAULT = 0,
|
||||
LABEL, // LABELBUTTON
|
||||
BUTTON, // IMAGEBUTTON
|
||||
TOGGLE, // TOGGLEGROUP
|
||||
SLIDER, // SLIDERBAR
|
||||
PROGRESSBAR,
|
||||
CHECKBOX,
|
||||
COMBOBOX,
|
||||
DROPDOWNBOX,
|
||||
TEXTBOX, // TEXTBOXMULTI
|
||||
VALUEBOX,
|
||||
SPINNER,
|
||||
LISTVIEW,
|
||||
COLORPICKER,
|
||||
SCROLLBAR,
|
||||
STATUSBAR
|
||||
} GuiControl;
|
||||
|
||||
// Gui base properties for every control
|
||||
typedef enum {
|
||||
BORDER_COLOR_NORMAL = 0,
|
||||
BASE_COLOR_NORMAL,
|
||||
TEXT_COLOR_NORMAL,
|
||||
BORDER_COLOR_FOCUSED,
|
||||
BASE_COLOR_FOCUSED,
|
||||
TEXT_COLOR_FOCUSED,
|
||||
BORDER_COLOR_PRESSED,
|
||||
BASE_COLOR_PRESSED,
|
||||
TEXT_COLOR_PRESSED,
|
||||
BORDER_COLOR_DISABLED,
|
||||
BASE_COLOR_DISABLED,
|
||||
TEXT_COLOR_DISABLED,
|
||||
BORDER_WIDTH,
|
||||
TEXT_PADDING,
|
||||
TEXT_ALIGNMENT,
|
||||
RESERVED
|
||||
} GuiControlProperty;
|
||||
// Gui base properties for every control
|
||||
typedef enum {
|
||||
BORDER_COLOR_NORMAL = 0,
|
||||
BASE_COLOR_NORMAL,
|
||||
TEXT_COLOR_NORMAL,
|
||||
BORDER_COLOR_FOCUSED,
|
||||
BASE_COLOR_FOCUSED,
|
||||
TEXT_COLOR_FOCUSED,
|
||||
BORDER_COLOR_PRESSED,
|
||||
BASE_COLOR_PRESSED,
|
||||
TEXT_COLOR_PRESSED,
|
||||
BORDER_COLOR_DISABLED,
|
||||
BASE_COLOR_DISABLED,
|
||||
TEXT_COLOR_DISABLED,
|
||||
BORDER_WIDTH,
|
||||
TEXT_PADDING,
|
||||
TEXT_ALIGNMENT,
|
||||
RESERVED
|
||||
} 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 {
|
||||
TEXT_SIZE = 16,
|
||||
TEXT_SPACING,
|
||||
LINE_COLOR,
|
||||
BACKGROUND_COLOR,
|
||||
} GuiDefaultProperty;
|
||||
// DEFAULT properties
|
||||
typedef enum {
|
||||
TEXT_SIZE = 16,
|
||||
TEXT_SPACING,
|
||||
LINE_COLOR,
|
||||
BACKGROUND_COLOR,
|
||||
} GuiDefaultProperty;
|
||||
|
||||
// Label
|
||||
//typedef enum { } GuiLabelProperty;
|
||||
// Label
|
||||
//typedef enum { } GuiLabelProperty;
|
||||
|
||||
// Button
|
||||
//typedef enum { } GuiButtonProperty;
|
||||
// Button
|
||||
//typedef enum { } GuiButtonProperty;
|
||||
|
||||
// Toggle / ToggleGroup
|
||||
typedef enum {
|
||||
GROUP_PADDING = 16,
|
||||
} GuiToggleProperty;
|
||||
// Toggle / ToggleGroup
|
||||
typedef enum {
|
||||
GROUP_PADDING = 16,
|
||||
} GuiToggleProperty;
|
||||
|
||||
// Slider / SliderBar
|
||||
typedef enum {
|
||||
SLIDER_WIDTH = 16,
|
||||
SLIDER_PADDING
|
||||
} GuiSliderProperty;
|
||||
// Slider / SliderBar
|
||||
typedef enum {
|
||||
SLIDER_WIDTH = 16,
|
||||
SLIDER_PADDING
|
||||
} GuiSliderProperty;
|
||||
|
||||
// ProgressBar
|
||||
typedef enum {
|
||||
PROGRESS_PADDING = 16,
|
||||
} GuiProgressBarProperty;
|
||||
// ProgressBar
|
||||
typedef enum {
|
||||
PROGRESS_PADDING = 16,
|
||||
} GuiProgressBarProperty;
|
||||
|
||||
// CheckBox
|
||||
typedef enum {
|
||||
CHECK_PADDING = 16
|
||||
} GuiCheckBoxProperty;
|
||||
// CheckBox
|
||||
typedef enum {
|
||||
CHECK_PADDING = 16
|
||||
} GuiCheckBoxProperty;
|
||||
|
||||
// ComboBox
|
||||
typedef enum {
|
||||
COMBO_BUTTON_WIDTH = 16,
|
||||
COMBO_BUTTON_PADDING
|
||||
} GuiComboBoxProperty;
|
||||
// ComboBox
|
||||
typedef enum {
|
||||
COMBO_BUTTON_WIDTH = 16,
|
||||
COMBO_BUTTON_PADDING
|
||||
} GuiComboBoxProperty;
|
||||
|
||||
// DropdownBox
|
||||
typedef enum {
|
||||
ARROW_PADDING = 16,
|
||||
DROPDOWN_ITEMS_PADDING
|
||||
} GuiDropdownBoxProperty;
|
||||
// DropdownBox
|
||||
typedef enum {
|
||||
ARROW_PADDING = 16,
|
||||
DROPDOWN_ITEMS_PADDING
|
||||
} GuiDropdownBoxProperty;
|
||||
|
||||
// TextBox / TextBoxMulti / ValueBox / Spinner
|
||||
typedef enum {
|
||||
TEXT_INNER_PADDING = 16,
|
||||
TEXT_LINES_PADDING,
|
||||
COLOR_SELECTED_FG,
|
||||
COLOR_SELECTED_BG
|
||||
} GuiTextBoxProperty;
|
||||
// TextBox / TextBoxMulti / ValueBox / Spinner
|
||||
typedef enum {
|
||||
TEXT_INNER_PADDING = 16,
|
||||
TEXT_LINES_PADDING,
|
||||
COLOR_SELECTED_FG,
|
||||
COLOR_SELECTED_BG
|
||||
} GuiTextBoxProperty;
|
||||
|
||||
// Spinner
|
||||
typedef enum {
|
||||
SPIN_BUTTON_WIDTH = 16,
|
||||
SPIN_BUTTON_PADDING,
|
||||
} GuiSpinnerProperty;
|
||||
// Spinner
|
||||
typedef enum {
|
||||
SPIN_BUTTON_WIDTH = 16,
|
||||
SPIN_BUTTON_PADDING,
|
||||
} GuiSpinnerProperty;
|
||||
|
||||
// ScrollBar
|
||||
typedef enum {
|
||||
ARROWS_SIZE = 16,
|
||||
ARROWS_VISIBLE,
|
||||
SCROLL_SLIDER_PADDING,
|
||||
SCROLL_SLIDER_SIZE,
|
||||
SCROLL_PADDING,
|
||||
SCROLL_SPEED,
|
||||
} GuiScrollBarProperty;
|
||||
// ScrollBar
|
||||
typedef enum {
|
||||
ARROWS_SIZE = 16,
|
||||
ARROWS_VISIBLE,
|
||||
SCROLL_SLIDER_PADDING,
|
||||
SCROLL_SLIDER_SIZE,
|
||||
SCROLL_PADDING,
|
||||
SCROLL_SPEED,
|
||||
} GuiScrollBarProperty;
|
||||
|
||||
// ScrollBar side
|
||||
typedef enum {
|
||||
SCROLLBAR_LEFT_SIDE = 0,
|
||||
SCROLLBAR_RIGHT_SIDE
|
||||
} GuiScrollBarSide;
|
||||
// ScrollBar side
|
||||
typedef enum {
|
||||
SCROLLBAR_LEFT_SIDE = 0,
|
||||
SCROLLBAR_RIGHT_SIDE
|
||||
} GuiScrollBarSide;
|
||||
|
||||
// ListView
|
||||
typedef enum {
|
||||
LIST_ITEMS_HEIGHT = 16,
|
||||
LIST_ITEMS_PADDING,
|
||||
SCROLLBAR_WIDTH,
|
||||
SCROLLBAR_SIDE,
|
||||
} GuiListViewProperty;
|
||||
// ListView
|
||||
typedef enum {
|
||||
LIST_ITEMS_HEIGHT = 16,
|
||||
LIST_ITEMS_PADDING,
|
||||
SCROLLBAR_WIDTH,
|
||||
SCROLLBAR_SIDE,
|
||||
} GuiListViewProperty;
|
||||
|
||||
// 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;
|
||||
// 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;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// 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;
|
||||
|
@ -730,7 +724,7 @@ bool GuiWindowBox(Rectangle bounds, const char *title)
|
|||
|
||||
Rectangle windowPanel = { bounds.x, bounds.y + (float)statusBarHeight - 1, bounds.width, bounds.height - (float)statusBarHeight };
|
||||
Rectangle closeButtonRec = { statusBar.x + statusBar.width - GuiGetStyle(STATUSBAR, BORDER_WIDTH) - 20,
|
||||
statusBar.y + statusBarHeight/2.0f - 18.0f/2.0f, 18, 18 };
|
||||
statusBar.y + statusBarHeight/2.0f - 18.0f/2.0f, 18, 18 };
|
||||
|
||||
// Update control
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -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;
|
||||
|
||||
|
@ -841,8 +835,8 @@ Rectangle GuiScrollPanel(Rectangle bounds, Rectangle content, Vector2 *scroll)
|
|||
|
||||
// Calculate view area (area without the scrollbars)
|
||||
Rectangle view = (GuiGetStyle(LISTVIEW, SCROLLBAR_SIDE) == SCROLLBAR_LEFT_SIDE)?
|
||||
RAYGUI_CLITERAL(Rectangle){ bounds.x + verticalScrollBarWidth + GuiGetStyle(DEFAULT, BORDER_WIDTH), bounds.y + GuiGetStyle(DEFAULT, BORDER_WIDTH), bounds.width - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - verticalScrollBarWidth, bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - horizontalScrollBarWidth } :
|
||||
RAYGUI_CLITERAL(Rectangle){ bounds.x + GuiGetStyle(DEFAULT, BORDER_WIDTH), bounds.y + GuiGetStyle(DEFAULT, BORDER_WIDTH), bounds.width - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - verticalScrollBarWidth, bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - horizontalScrollBarWidth };
|
||||
RAYGUI_CLITERAL(Rectangle){ bounds.x + verticalScrollBarWidth + GuiGetStyle(DEFAULT, BORDER_WIDTH), bounds.y + GuiGetStyle(DEFAULT, BORDER_WIDTH), bounds.width - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - verticalScrollBarWidth, bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - horizontalScrollBarWidth } :
|
||||
RAYGUI_CLITERAL(Rectangle){ bounds.x + GuiGetStyle(DEFAULT, BORDER_WIDTH), bounds.y + GuiGetStyle(DEFAULT, BORDER_WIDTH), bounds.width - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - verticalScrollBarWidth, bounds.height - 2*GuiGetStyle(DEFAULT, BORDER_WIDTH) - horizontalScrollBarWidth };
|
||||
|
||||
// Clip view area to the actual content size
|
||||
if (view.width > content.width) view.width = content.width;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -1180,9 +1174,9 @@ bool GuiCheckBox(Rectangle bounds, const char *text, bool checked)
|
|||
if (checked)
|
||||
{
|
||||
Rectangle check = { bounds.x + GuiGetStyle(CHECKBOX, BORDER_WIDTH) + GuiGetStyle(CHECKBOX, CHECK_PADDING),
|
||||
bounds.y + GuiGetStyle(CHECKBOX, BORDER_WIDTH) + GuiGetStyle(CHECKBOX, CHECK_PADDING),
|
||||
bounds.width - 2*(GuiGetStyle(CHECKBOX, BORDER_WIDTH) + GuiGetStyle(CHECKBOX, CHECK_PADDING)),
|
||||
bounds.height - 2*(GuiGetStyle(CHECKBOX, BORDER_WIDTH) + GuiGetStyle(CHECKBOX, CHECK_PADDING)) };
|
||||
bounds.y + GuiGetStyle(CHECKBOX, BORDER_WIDTH) + GuiGetStyle(CHECKBOX, CHECK_PADDING),
|
||||
bounds.width - 2*(GuiGetStyle(CHECKBOX, BORDER_WIDTH) + GuiGetStyle(CHECKBOX, CHECK_PADDING)),
|
||||
bounds.height - 2*(GuiGetStyle(CHECKBOX, BORDER_WIDTH) + GuiGetStyle(CHECKBOX, CHECK_PADDING)) };
|
||||
GuiDrawRectangle(check, 0, BLANK, Fade(GetColor(GuiGetStyle(CHECKBOX, TEXT + state*3)), guiAlpha));
|
||||
}
|
||||
|
||||
|
@ -1200,7 +1194,7 @@ int GuiComboBox(Rectangle bounds, const char *text, int active)
|
|||
bounds.width -= (GuiGetStyle(COMBOBOX, COMBO_BUTTON_WIDTH) + GuiGetStyle(COMBOBOX, COMBO_BUTTON_PADDING));
|
||||
|
||||
Rectangle selector = { (float)bounds.x + bounds.width + GuiGetStyle(COMBOBOX, COMBO_BUTTON_PADDING),
|
||||
(float)bounds.y, (float)GuiGetStyle(COMBOBOX, COMBO_BUTTON_WIDTH), (float)bounds.height };
|
||||
(float)bounds.y, (float)GuiGetStyle(COMBOBOX, COMBO_BUTTON_WIDTH), (float)bounds.height };
|
||||
|
||||
// Get substrings items from text (items pointers, lengths and count)
|
||||
int itemsCount = 0;
|
||||
|
@ -1487,7 +1481,7 @@ bool GuiSpinner(Rectangle bounds, const char *text, int *value, int minValue, in
|
|||
int tempValue = *value;
|
||||
|
||||
Rectangle spinner = { bounds.x + GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH) + GuiGetStyle(SPINNER, SPIN_BUTTON_PADDING), bounds.y,
|
||||
bounds.width - 2*(GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH) + GuiGetStyle(SPINNER, SPIN_BUTTON_PADDING)), bounds.height };
|
||||
bounds.width - 2*(GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH) + GuiGetStyle(SPINNER, SPIN_BUTTON_PADDING)), bounds.height };
|
||||
Rectangle leftButtonBound = { (float)bounds.x, (float)bounds.y, (float)GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH), (float)bounds.height };
|
||||
Rectangle rightButtonBound = { (float)bounds.x + bounds.width - GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH), (float)bounds.y, (float)GuiGetStyle(SPINNER, SPIN_BUTTON_WIDTH), (float)bounds.height };
|
||||
|
||||
|
@ -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;
|
||||
|
@ -1822,7 +1816,7 @@ float GuiSliderPro(Rectangle bounds, const char *textLeft, const char *textRight
|
|||
int sliderValue = (int)(((value - minValue)/(maxValue - minValue))*(bounds.width - 2*GuiGetStyle(SLIDER, BORDER_WIDTH)));
|
||||
|
||||
Rectangle slider = { bounds.x, bounds.y + GuiGetStyle(SLIDER, BORDER_WIDTH) + GuiGetStyle(SLIDER, SLIDER_PADDING),
|
||||
0, bounds.height - 2*GuiGetStyle(SLIDER, BORDER_WIDTH) - 2*GuiGetStyle(SLIDER, SLIDER_PADDING) };
|
||||
0, bounds.height - 2*GuiGetStyle(SLIDER, BORDER_WIDTH) - 2*GuiGetStyle(SLIDER, SLIDER_PADDING) };
|
||||
|
||||
if (sliderWidth > 0) // Slider
|
||||
{
|
||||
|
@ -1925,8 +1919,8 @@ float GuiProgressBar(Rectangle bounds, const char *textLeft, const char *textRig
|
|||
GuiControlState state = guiState;
|
||||
|
||||
Rectangle progress = { bounds.x + GuiGetStyle(PROGRESSBAR, BORDER_WIDTH),
|
||||
bounds.y + GuiGetStyle(PROGRESSBAR, BORDER_WIDTH) + GuiGetStyle(PROGRESSBAR, PROGRESS_PADDING), 0,
|
||||
bounds.height - 2*GuiGetStyle(PROGRESSBAR, BORDER_WIDTH) - 2*GuiGetStyle(PROGRESSBAR, PROGRESS_PADDING) };
|
||||
bounds.y + GuiGetStyle(PROGRESSBAR, BORDER_WIDTH) + GuiGetStyle(PROGRESSBAR, PROGRESS_PADDING), 0,
|
||||
bounds.height - 2*GuiGetStyle(PROGRESSBAR, BORDER_WIDTH) - 2*GuiGetStyle(PROGRESSBAR, PROGRESS_PADDING) };
|
||||
|
||||
// Update control
|
||||
//--------------------------------------------------------------------
|
||||
|
@ -2318,8 +2312,8 @@ Color GuiColorPanelEx(Rectangle bounds, Color color, float hue)
|
|||
Vector3 maxHue = { hue >= 0.0f ? hue : hsv.x, 1.0f, 1.0f };
|
||||
Vector3 rgbHue = ConvertHSVtoRGB(maxHue);
|
||||
Color maxHueCol = { (unsigned char)(255.0f*rgbHue.x),
|
||||
(unsigned char)(255.0f*rgbHue.y),
|
||||
(unsigned char)(255.0f*rgbHue.z), 255 };
|
||||
(unsigned char)(255.0f*rgbHue.y),
|
||||
(unsigned char)(255.0f*rgbHue.z), 255 };
|
||||
|
||||
const Color colWhite = { 255, 255, 255, 255 };
|
||||
const Color colBlack = { 0, 0, 0, 255 };
|
||||
|
@ -2350,9 +2344,9 @@ Color GuiColorPanelEx(Rectangle bounds, Color color, float hue)
|
|||
|
||||
// NOTE: Vector3ToColor() only available on raylib 1.8.1
|
||||
color = RAYGUI_CLITERAL(Color){ (unsigned char)(255.0f*rgb.x),
|
||||
(unsigned char)(255.0f*rgb.y),
|
||||
(unsigned char)(255.0f*rgb.z),
|
||||
(unsigned char)(255.0f*(float)color.a/255.0f) };
|
||||
(unsigned char)(255.0f*rgb.y),
|
||||
(unsigned char)(255.0f*rgb.z),
|
||||
(unsigned char)(255.0f*(float)color.a/255.0f) };
|
||||
|
||||
}
|
||||
else state = GUI_STATE_FOCUSED;
|
||||
|
@ -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
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue