More raygui functions and updated to raygui v3.2-dev.
This commit is contained in:
12
src/core.c
12
src/core.c
@@ -301,6 +301,18 @@ int lcoreSetWindowTitle( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> count = RL_GetMonitorCount()
|
||||
|
||||
Get number of connected monitors
|
||||
|
||||
- Success return int
|
||||
*/
|
||||
int lcoreGetMonitorCount( lua_State *L ) {
|
||||
lua_pushinteger( L, GetMonitorCount() );
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> RL_CloseWindow()
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "audio.h"
|
||||
#include "rmath.h"
|
||||
#include "rgui.h"
|
||||
#include "raygui.h"
|
||||
|
||||
static void assignGlobalInt( int value, const char *name ) {
|
||||
lua_State *L = state->luaState;
|
||||
@@ -201,6 +202,93 @@ void defineGlobals() {
|
||||
assignGlobalColor( BLUE, "BLUE" );
|
||||
/* Math */
|
||||
assignGlobalFloat( PI, "PI" );
|
||||
/* GuiControlState */
|
||||
assignGlobalInt( GUI_STATE_NORMAL, "GUI_STATE_NORMAL" );
|
||||
assignGlobalInt( GUI_STATE_FOCUSED, "GUI_STATE_FOCUSED" );
|
||||
assignGlobalInt( GUI_STATE_PRESSED, "GUI_STATE_PRESSED" );
|
||||
assignGlobalInt( GUI_STATE_DISABLED, "GUI_STATE_DISABLED" );
|
||||
/* GuiTextAlignment */
|
||||
assignGlobalInt( GUI_TEXT_ALIGN_LEFT, "GUI_TEXT_ALIGN_LEFT" );
|
||||
assignGlobalInt( GUI_TEXT_ALIGN_CENTER, "GUI_TEXT_ALIGN_CENTER" );
|
||||
assignGlobalInt( GUI_TEXT_ALIGN_RIGHT, "GUI_TEXT_ALIGN_RIGHT" );
|
||||
/* GuiControls */
|
||||
assignGlobalInt( DEFAULT, "DEFAULT" );
|
||||
assignGlobalInt( LABEL, "LABEL" );
|
||||
assignGlobalInt( BUTTON, "BUTTON" );
|
||||
assignGlobalInt( TOGGLE, "TOGGLE" );
|
||||
assignGlobalInt( SLIDER, "SLIDER" );
|
||||
assignGlobalInt( PROGRESSBAR, "PROGRESSBAR" );
|
||||
assignGlobalInt( CHECKBOX, "CHECKBOX" );
|
||||
assignGlobalInt( COMBOBOX, "COMBOBOX" );
|
||||
assignGlobalInt( DROPDOWNBOX, "DROPDOWNBOX" );
|
||||
assignGlobalInt( TEXTBOX, "TEXTBOX" );
|
||||
assignGlobalInt( VALUEBOX, "VALUEBOX" );
|
||||
assignGlobalInt( SPINNER, "SPINNER" );
|
||||
assignGlobalInt( LISTVIEW, "LISTVIEW" );
|
||||
assignGlobalInt( COLORPICKER, "COLORPICKER" );
|
||||
assignGlobalInt( SCROLLBAR, "SCROLLBAR" );
|
||||
assignGlobalInt( STATUSBAR, "STATUSBAR" );
|
||||
/* GuiControlProperty */
|
||||
assignGlobalInt( BORDER_COLOR_NORMAL, "BORDER_COLOR_NORMAL" );
|
||||
assignGlobalInt( BASE_COLOR_NORMAL, "BASE_COLOR_NORMAL" );
|
||||
assignGlobalInt( TEXT_COLOR_NORMAL, "TEXT_COLOR_NORMAL" );
|
||||
assignGlobalInt( BORDER_COLOR_FOCUSED, "BORDER_COLOR_FOCUSED" );
|
||||
assignGlobalInt( BASE_COLOR_FOCUSED, "BASE_COLOR_FOCUSED" );
|
||||
assignGlobalInt( TEXT_COLOR_FOCUSED, "TEXT_COLOR_FOCUSED" );
|
||||
assignGlobalInt( BORDER_COLOR_PRESSED, "BORDER_COLOR_PRESSED" );
|
||||
assignGlobalInt( BASE_COLOR_PRESSED, "BASE_COLOR_PRESSED" );
|
||||
assignGlobalInt( TEXT_COLOR_PRESSED, "TEXT_COLOR_PRESSED" );
|
||||
assignGlobalInt( BORDER_COLOR_DISABLED, "BORDER_COLOR_DISABLED" );
|
||||
assignGlobalInt( BASE_COLOR_DISABLED, "BASE_COLOR_DISABLED" );
|
||||
assignGlobalInt( TEXT_COLOR_DISABLED, "TEXT_COLOR_DISABLED" );
|
||||
assignGlobalInt( BORDER_WIDTH, "BORDER_WIDTH" );
|
||||
assignGlobalInt( TEXT_PADDING, "TEXT_PADDING" );
|
||||
assignGlobalInt( TEXT_ALIGNMENT, "TEXT_ALIGNMENT" );
|
||||
assignGlobalInt( RESERVED, "RESERVED" );
|
||||
/* GuiDefaultProperty */
|
||||
assignGlobalInt( TEXT_SIZE, "TEXT_SIZE" );
|
||||
assignGlobalInt( TEXT_SPACING, "TEXT_SPACING" );
|
||||
assignGlobalInt( LINE_COLOR, "LINE_COLOR" );
|
||||
assignGlobalInt( BACKGROUND_COLOR, "BACKGROUND_COLOR" );
|
||||
/* GuiToggleProperty */
|
||||
assignGlobalInt( GROUP_PADDING, "GROUP_PADDING" );
|
||||
/* GuiSliderProperty */
|
||||
assignGlobalInt( SLIDER_WIDTH, "SLIDER_WIDTH" );
|
||||
assignGlobalInt( SLIDER_PADDING, "SLIDER_PADDING" );
|
||||
/* GuiProgressBarProperty */
|
||||
assignGlobalInt( PROGRESS_PADDING, "PROGRESS_PADDING" );
|
||||
/* GuiCheckBoxProperty */
|
||||
assignGlobalInt( CHECK_PADDING, "CHECK_PADDING" );
|
||||
/* GuiComboBoxProperty */
|
||||
assignGlobalInt( COMBO_BUTTON_WIDTH, "COMBO_BUTTON_WIDTH" );
|
||||
assignGlobalInt( COMBO_BUTTON_SPACING, "COMBO_BUTTON_SPACING" );
|
||||
/* GuiDropdownBoxProperty */
|
||||
assignGlobalInt( ARROW_PADDING, "ARROW_PADDING" );
|
||||
assignGlobalInt( DROPDOWN_ITEMS_SPACING, "DROPDOWN_ITEMS_SPACING" );
|
||||
/* GuiTextBoxProperty */
|
||||
assignGlobalInt( TEXT_INNER_PADDING, "TEXT_INNER_PADDING" );
|
||||
assignGlobalInt( TEXT_LINES_SPACING, "TEXT_LINES_SPACING" );
|
||||
/* GuiSpinnerProperty */
|
||||
assignGlobalInt( SPIN_BUTTON_WIDTH, "SPIN_BUTTON_WIDTH" );
|
||||
assignGlobalInt( SPIN_BUTTON_SPACING, "SPIN_BUTTON_SPACING" );
|
||||
/* GuiScrollBarProperty */
|
||||
assignGlobalInt( ARROWS_SIZE, "ARROWS_SIZE" );
|
||||
assignGlobalInt( ARROWS_VISIBLE, "ARROWS_VISIBLE" );
|
||||
assignGlobalInt( SCROLL_SLIDER_PADDING, "SCROLL_SLIDER_PADDING" );
|
||||
assignGlobalInt( SCROLL_SLIDER_SIZE, "SCROLL_SLIDER_SIZE" );
|
||||
assignGlobalInt( SCROLL_PADDING, "SCROLL_PADDING" );
|
||||
assignGlobalInt( SCROLL_SPEED, "SCROLL_SPEED" );
|
||||
/* GuiListViewProperty */
|
||||
assignGlobalInt( LIST_ITEMS_HEIGHT, "LIST_ITEMS_HEIGHT" );
|
||||
assignGlobalInt( LIST_ITEMS_SPACING, "LIST_ITEMS_SPACING" );
|
||||
assignGlobalInt( SCROLLBAR_WIDTH, "SCROLLBAR_WIDTH" );
|
||||
assignGlobalInt( SCROLLBAR_SIDE, "SCROLLBAR_SIDE" );
|
||||
/* GuiColorPickerProperty */
|
||||
assignGlobalInt( COLOR_SELECTOR_SIZE, "COLOR_SELECTOR_SIZE" );
|
||||
assignGlobalInt( HUEBAR_WIDTH, "HUEBAR_WIDTH" );
|
||||
assignGlobalInt( HUEBAR_PADDING, "HUEBAR_PADDING" );
|
||||
assignGlobalInt( HUEBAR_SELECTOR_HEIGHT, "HUEBAR_SELECTOR_HEIGHT" );
|
||||
assignGlobalInt( HUEBAR_SELECTOR_OVERFLOW, "HUEBAR_SELECTOR_OVERFLOW" );
|
||||
/*DOC_END*/
|
||||
}
|
||||
|
||||
@@ -397,6 +485,7 @@ void luaRegister() {
|
||||
lua_register( L, "RL_IsWindowResized", lcoreIsWindowResized );
|
||||
lua_register( L, "RL_SetWindowIcon", lcoreSetWindowIcon );
|
||||
lua_register( L, "RL_SetWindowTitle", lcoreSetWindowTitle );
|
||||
lua_register( L, "RL_GetMonitorCount", lcoreGetMonitorCount );
|
||||
lua_register( L, "RL_CloseWindow", lcoreCloseWindow );
|
||||
/* Timing. */
|
||||
lua_register( L, "RL_SetTargetFPS", lcoreSetTargetFPS );
|
||||
@@ -719,14 +808,20 @@ void luaRegister() {
|
||||
lua_register( L, "RL_GuiUnlock", lguiGuiUnlock );
|
||||
/* Font. */
|
||||
lua_register( L, "RL_GuiSetFont", lguiGuiSetFont );
|
||||
/* Style. */
|
||||
lua_register( L, "RL_GuiSetStyle", lguiGuiSetStyle );
|
||||
lua_register( L, "RL_GuiGetStyle", lguiGuiGetStyle );
|
||||
/* Container. */
|
||||
lua_register( L, "RL_GuiWindowBox", lguiGuiWindowBox );
|
||||
lua_register( L, "RL_GuiGroupBox", lguiGuiGroupBox );
|
||||
lua_register( L, "RL_GuiLine", lguiGuiLine );
|
||||
lua_register( L, "RL_GuiPanel", lguiGuiPanel );
|
||||
lua_register( L, "RL_GuiScrollPanel", lguiGuiScrollPanel );
|
||||
/* Basic. */
|
||||
lua_register( L, "RL_GuiLabel", lguiGuiLabel );
|
||||
lua_register( L, "RL_GuiButton", lguiGuiButton );
|
||||
lua_register( L, "RL_GuiToggle", lguiGuiToggle );
|
||||
lua_register( L, "RL_GuiToggleGroup", lguiGuiToggleGroup );
|
||||
lua_register( L, "RL_GuiCheckBox", lguiGuiCheckBox );
|
||||
lua_register( L, "RL_GuiTextBox", lguiGuiTextBox );
|
||||
lua_register( L, "RL_GuiTextBoxMulti", lguiGuiTextBoxMulti );
|
||||
|
||||
141
src/rgui.c
141
src/rgui.c
@@ -78,6 +78,49 @@ int lguiGuiSetFont( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
## Gui - Style
|
||||
*/
|
||||
|
||||
/*
|
||||
> success = RL_GuiSetStyle( int control, int property, int value )
|
||||
|
||||
Set one style property
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
*/
|
||||
int lguiGuiSetStyle( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiSetStyle( int control, int property, int value )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
GuiSetStyle( lua_tointeger( L, -3 ), lua_tointeger( L, -2 ), lua_tointeger( L, -1 ) );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> value = RL_GuiGetStyle( int control, int property )
|
||||
|
||||
Get one style property
|
||||
|
||||
- Failure return false
|
||||
- Success return int
|
||||
*/
|
||||
int lguiGuiGetStyle( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiGetStyle( int control, int property )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
lua_pushinteger( L, GuiGetStyle( lua_tointeger( L, -2 ), lua_tointeger( L, -1 ) ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
## Gui - Container
|
||||
*/
|
||||
@@ -107,7 +150,57 @@ int lguiGuiWindowBox( lua_State *L ) {
|
||||
}
|
||||
|
||||
/*
|
||||
> success = RL_GuiPanel( Rectangle bounds )
|
||||
> success = RL_GuiGroupBox( Rectangle bounds, string text )
|
||||
|
||||
Group Box control with text name
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
*/
|
||||
int lguiGuiGroupBox( lua_State *L ) {
|
||||
if ( !lua_istable( L, -2 ) || !lua_isstring( L, -1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiGroupBox( Rectangle bounds, string text )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
char text[ STRING_LEN ] = { '\0' };
|
||||
strcpy( text, lua_tostring( L, -1 ) );
|
||||
lua_pop( L, 1 );
|
||||
Rectangle rect = uluaGetRectangle( L );
|
||||
|
||||
GuiGroupBox( rect, text );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> success = RL_GuiLine( Rectangle bounds, string text )
|
||||
|
||||
Line separator control, could contain text
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
*/
|
||||
int lguiGuiLine( lua_State *L ) {
|
||||
if ( !lua_istable( L, -2 ) || !lua_isstring( L, -1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiLine( Rectangle bounds, string text )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
char text[ STRING_LEN ] = { '\0' };
|
||||
strcpy( text, lua_tostring( L, -1 ) );
|
||||
lua_pop( L, 1 );
|
||||
Rectangle rect = uluaGetRectangle( L );
|
||||
|
||||
GuiLine( rect, text );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> success = RL_GuiPanel( Rectangle bounds, string text )
|
||||
|
||||
Panel control, useful to group controls
|
||||
|
||||
@@ -115,21 +208,24 @@ Panel control, useful to group controls
|
||||
- Success return true
|
||||
*/
|
||||
int lguiGuiPanel( lua_State *L ) {
|
||||
if ( !lua_istable( L, -1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiPanel( Rectangle bounds )" );
|
||||
if ( !lua_istable( L, -2 ) || !lua_isstring( L, -1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiPanel( Rectangle bounds, string text )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
char text[ STRING_LEN ] = { '\0' };
|
||||
strcpy( text, lua_tostring( L, -1 ) );
|
||||
lua_pop( L, 1 );
|
||||
Rectangle rect = uluaGetRectangle( L );
|
||||
|
||||
GuiPanel( rect );
|
||||
GuiPanel( rect, text );
|
||||
lua_pushboolean( L, true );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> view, scroll = RL_GuiScrollPanel( Rectangle bounds, Rectangle content, Vector2 scroll )
|
||||
> view, scroll = RL_GuiScrollPanel( Rectangle bounds, string text, Rectangle content, Vector2 scroll )
|
||||
|
||||
Scroll Panel control
|
||||
|
||||
@@ -137,8 +233,8 @@ Scroll Panel control
|
||||
- Success return Rectangle, Vector2
|
||||
*/
|
||||
int lguiGuiScrollPanel( lua_State *L ) {
|
||||
if ( !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiScrollPanel( Rectangle bounds, Rectangle content, Vector2 scroll )" );
|
||||
if ( !lua_istable( L, -4 ) || !lua_isstring( L, -3 ) || lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiScrollPanel( Rectangle bounds, string text, Rectangle content, Vector2 scroll )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
@@ -146,9 +242,12 @@ int lguiGuiScrollPanel( lua_State *L ) {
|
||||
lua_pop( L, 1 );
|
||||
Rectangle content = uluaGetRectangle( L );
|
||||
lua_pop( L, 1 );
|
||||
char text[ STRING_LEN ] = { '\0' };
|
||||
strcpy( text, lua_tostring( L, -1 ) );
|
||||
lua_pop( L, 1 );
|
||||
Rectangle bounds = uluaGetRectangle( L );
|
||||
|
||||
uluaPushRectangle( L, GuiScrollPanel( bounds, content, &scroll ) );
|
||||
uluaPushRectangle( L, GuiScrollPanel( bounds, text, content, &scroll ) );
|
||||
uluaPushVector2( L, scroll );
|
||||
|
||||
return 2;
|
||||
@@ -233,6 +332,32 @@ int lguiGuiToggle( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> index = RL_GuiToggleGroup( Rectangle bounds, string text, int active )
|
||||
|
||||
Toggle Group control, returns active toggle index
|
||||
|
||||
- Failure return false
|
||||
- Success return int
|
||||
*/
|
||||
int lguiGuiToggleGroup( lua_State *L ) {
|
||||
if ( !lua_istable( L, -3 ) || !lua_isstring( L, -2 ) || !lua_isnumber( L, -1 ) ) {
|
||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GuiToggleGroup( Rectangle bounds, string text, bool active )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
int active = lua_tointeger( L, -1 );
|
||||
lua_pop( L, 1 );
|
||||
char text[ STRING_LEN ] = { '\0' };
|
||||
strcpy( text, lua_tostring( L, -1 ) );
|
||||
lua_pop( L, 1 );
|
||||
Rectangle rect = uluaGetRectangle( L );
|
||||
|
||||
lua_pushinteger( L, GuiToggleGroup( rect, text, active ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> active = RL_GuiCheckBox( Rectangle bounds, string text, bool checked )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user