244 lines
11 KiB
C
244 lines
11 KiB
C
|
|
|
|
// 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 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 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
|
|
|
|
// DEFAULT properties
|
|
typedef enum {
|
|
TEXT_SIZE = 16,
|
|
TEXT_SPACING,
|
|
LINE_COLOR,
|
|
BACKGROUND_COLOR,
|
|
} GuiDefaultProperty;
|
|
|
|
// Label
|
|
//typedef enum { } GuiLabelProperty;
|
|
|
|
// Button
|
|
//typedef enum { } GuiButtonProperty;
|
|
|
|
// Toggle / ToggleGroup
|
|
typedef enum {
|
|
GROUP_PADDING = 16,
|
|
} GuiToggleProperty;
|
|
|
|
// Slider / SliderBar
|
|
typedef enum {
|
|
SLIDER_WIDTH = 16,
|
|
SLIDER_PADDING
|
|
} GuiSliderProperty;
|
|
|
|
// ProgressBar
|
|
typedef enum {
|
|
PROGRESS_PADDING = 16,
|
|
} GuiProgressBarProperty;
|
|
|
|
// CheckBox
|
|
typedef enum {
|
|
CHECK_PADDING = 16
|
|
} GuiCheckBoxProperty;
|
|
|
|
// ComboBox
|
|
typedef enum {
|
|
COMBO_BUTTON_WIDTH = 16,
|
|
COMBO_BUTTON_PADDING
|
|
} GuiComboBoxProperty;
|
|
|
|
// 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;
|
|
|
|
// 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 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;
|
|
|
|
// 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 gui state control 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)
|
|
|
|
// 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
|
|
|
|
// 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
|
|
|
|
// Styles loading functions
|
|
RAYGUIDEF void GuiLoadStyle(const char *fileName); // Load style file over global style variable (.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
|
|
*/
|
|
|
|
RAYGUIDEF const char *GuiIconText(int iconId, const char *text); // Get text with icon id prepended (if supported)
|
|
|
|
|
|
// 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 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
|
|
|