better color picker

isolation_bkp/dynres
Dominik Madarász 2021-05-15 17:48:15 +02:00
parent 0fdc718e44
commit 8623c18127
4 changed files with 833 additions and 914 deletions

Binary file not shown.

View File

@ -1,138 +1,56 @@
#define PARAM(k,n,v) { .kind = k, .name = n, .str = v }
static td_op default_ops[] = {
{
OP(TOP_CLEAR),
.num_params = 1,
.params = (td_param[]) {
{
.kind = TPARAM_COLOR,
.name = "color",
.str = "ffffffff"
}
PARAM(TPARAM_COLOR, "color", "ffffffff"),
}
},
{
OP(TOP_DRAW_RECT),
.num_params = 5,
.params = (td_param[]) {
{
.kind = TPARAM_INT,
.name = "x",
.str = "0"
},
{
.kind = TPARAM_INT,
.name = "y",
.str = "0"
},
{
.kind = TPARAM_INT,
.name = "w",
.str = "10"
},
{
.kind = TPARAM_INT,
.name = "h",
.str = "10"
},
{
.kind = TPARAM_COLOR,
.name = "color",
.str = "ff0000ff"
},
PARAM(TPARAM_INT, "x", "0"),
PARAM(TPARAM_INT, "y", "0"),
PARAM(TPARAM_INT, "w", "10"),
PARAM(TPARAM_INT, "h", "10"),
PARAM(TPARAM_COLOR, "color", "0"),
}
},
{
OP(TOP_DRAW_LINE),
.num_params = 5,
.params = (td_param[]) {
{
.kind = TPARAM_INT,
.name = "x1",
.str = "0"
},
{
.kind = TPARAM_INT,
.name = "y1",
.str = "0"
},
{
.kind = TPARAM_INT,
.name = "x2",
.str = "64"
},
{
.kind = TPARAM_INT,
.name = "y2",
.str = "64"
},
{
.kind = TPARAM_COLOR,
.name = "color",
.str = "ffff00ff"
},
PARAM(TPARAM_INT, "x1", "0"),
PARAM(TPARAM_INT, "y1", "0"),
PARAM(TPARAM_INT, "x2", "64"),
PARAM(TPARAM_INT, "y2", "64"),
PARAM(TPARAM_COLOR, "color", "0"),
}
},
{
OP(TOP_DITHER),
.num_params = 4,
.params = (td_param[]) {
{
.kind = TPARAM_INT,
.name = "r_bpp",
.str = "8",
},
{
.kind = TPARAM_INT,
.name = "g_bpp",
.str = "8",
},
{
.kind = TPARAM_INT,
.name = "b_bpp",
.str = "8",
},
{
.kind = TPARAM_INT,
.name = "a_bpp",
.str = "8",
},
PARAM(TPARAM_INT, "r_bpp", "8"),
PARAM(TPARAM_INT, "g_bpp", "8"),
PARAM(TPARAM_INT, "b_bpp", "8"),
PARAM(TPARAM_INT, "a_bpp", "8"),
}
},
{
OP(TOP_LOAD_IMAGE),
.num_params = 6,
.params = (td_param[]) {
{
.kind = TPARAM_STRING,
.name = "src",
.str = ""
},
{
.kind = TPARAM_INT,
.name = "x",
.str = "0"
},
{
.kind = TPARAM_INT,
.name = "y",
.str = "0"
},
{
.kind = TPARAM_INT,
.name = "w",
.str = "-1"
},
{
.kind = TPARAM_INT,
.name = "h",
.str = "-1"
},
{
.kind = TPARAM_COLOR,
.name = "tint",
.str = "ffffffff",
},
PARAM(TPARAM_STRING, "src", "art/natives/test.png"),
PARAM(TPARAM_INT, "x", "0"),
PARAM(TPARAM_INT, "y", "0"),
PARAM(TPARAM_INT, "w", "-1"),
PARAM(TPARAM_INT, "h", "-1"),
PARAM(TPARAM_COLOR, "tint", "ffffffff"),
}
}
};

View File

@ -182,13 +182,14 @@ void texed_draw_props_pane(zpl_aabb2 r) {
switch (p->kind) {
case TPARAM_COLOR: {
if (!p->edit_mode && GuiTextBox(aabb2_ray(tbox_r), p->str, 64, p->edit_mode)) {
if (GuiTextBox(aabb2_ray(tbox_r), p->str, 64, p->edit_mode)) {
p->edit_mode = true;
}
if (p->edit_mode) {
zpl_aabb2 ok_r = zpl_aabb2_cut_left(&tbox_r, 50.0f);
p->color = GuiColorPicker(aabb2_ray(tbox_r), p->color);
zpl_aabb2 extra_r = zpl_aabb2_add_bottom(&tbox_r, prop_height);
zpl_aabb2 ok_r = zpl_aabb2_cut_left(&extra_r, 50.0f);
p->color = GuiColorPicker(aabb2_ray(extra_r), p->color);
if (GuiButton(aabb2_ray(ok_r), "OK")) {
p->edit_mode = false;

400
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)
#else
#define RAYGUIDEF // We are building or using raygui as a static library
#endif
// 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 (or Linux shared library)
#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)
#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 @@ typedef enum {
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,195 +304,195 @@ typedef enum {
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
@ -511,8 +511,8 @@ RAYGUIDEF bool GuiCheckIconPixel(int iconId, int x, int y); // Check icon pi
#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 +520,13 @@ RAYGUIDEF bool GuiCheckIconPixel(int iconId, int x, int y); // Check icon pi
#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 +717,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 +762,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 +780,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 +808,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 +1102,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 +1557,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
@ -2391,7 +2391,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 +2531,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, BARS_PADDING), bounds.width, GuiGetStyle(COLORPICKER, BARS_THICK) };
Rectangle boundsAlpha = { bounds.x, bounds.y + bounds.height + GuiGetStyle(COLORPICKER, HUEBAR_PADDING), bounds.width, GuiGetStyle(COLORPICKER, HUEBAR_WIDTH) };
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 +2545,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 +2593,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 +2670,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 +3100,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 +3108,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 +3140,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 +3150,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 +3160,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 +3243,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 +3252,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 +3344,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 +3557,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];