Raygui updated to version 4.0.

This commit is contained in:
jussi
2023-11-21 23:34:47 +02:00
parent 01883035b0
commit 85a48cf093
18 changed files with 4141 additions and 2756 deletions

651
API.md
View File

@@ -2372,7 +2372,7 @@ Radians to degrees
--- ---
## Globals - GuiTextAlignment ## Globals - GuiControlTextAlignment
> TEXT_ALIGN_LEFT = 0 > TEXT_ALIGN_LEFT = 0
--- ---
@@ -2386,6 +2386,34 @@ Radians to degrees
--- ---
## Globals - GuiControlTextAlignmentVertical
> TEXT_ALIGN_TOP = 0
---
> TEXT_ALIGN_MIDDLE = 1
---
> TEXT_ALIGN_BOTTOM = 2
---
## Globals - GuiControlTextWrapMode
> TEXT_WRAP_NONE = 0
---
> TEXT_WRAP_CHAR = 1
---
> TEXT_WRAP_WORD = 2
---
## Globals - GuiControl ## Globals - GuiControl
> DEFAULT = 0 > DEFAULT = 0
@@ -2523,10 +2551,6 @@ Uses: BUTTON, VALUEBOX
--- ---
> RESERVED = 15
---
## Globals - GuiDefaultProperty ## Globals - GuiDefaultProperty
> TEXT_SIZE = 16 > TEXT_SIZE = 16
@@ -2553,6 +2577,24 @@ Background color
--- ---
> TEXT_LINE_SPACING = 20
Text spacing between lines
---
> TEXT_ALIGNMENT_VERTICAL = 21
Text vertical alignment inside text bounds (after border and padding)
---
> TEXT_WRAP_MODE = 22
Text wrap-mode inside text bounds
---
## Globals - GuiToggleProperty ## Globals - GuiToggleProperty
> GROUP_PADDING = 16 > GROUP_PADDING = 16
@@ -2648,16 +2690,10 @@ DropdownBox items separation
--- ---
## Globals - GuiTextBoxProperty ## Globals - TextBox/TextBoxMulti/ValueBox/Spinner
> TEXT_INNER_PADDING = 16 > TEXT_READONLY = 16
TextBox/TextBoxMulti/ValueBox/Spinner inner text padding TextBox in read-only mode: 0-text editable, 1-text no-editable
---
> TEXT_LINES_SPACING = 17
TextBoxMulti lines separation
--- ---
@@ -8315,7 +8351,7 @@ Check if gui is locked (global state)
--- ---
> RL.GuiFade( float alpha ) > RL.GuiSetAlpha( float alpha )
Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f
@@ -8371,262 +8407,6 @@ Get one style property
--- ---
## Gui - Container/separator controls, useful for controls organization
---
> state = RL.GuiWindowBox( Rectangle bounds, string title )
Window Box control, shows a window that can be closed
- Success return bool
---
> RL.GuiGroupBox( Rectangle bounds, string text )
Group Box control with text name
---
> RL.GuiLine( Rectangle bounds, string text )
Line separator control, could contain text
---
> RL.GuiPanel( Rectangle bounds, string text )
Panel control, useful to group controls
---
> view, scroll = RL.GuiScrollPanel( Rectangle bounds, string text, Rectangle content, Vector2 scroll )
Scroll Panel control
- Success return Rectangle, Vector2
---
## Gui - Basic controls set
---
> RL.GuiLabel( Rectangle bounds, string text )
Label control, shows text
---
> clicked = RL.GuiButton( Rectangle bounds, string text )
Button control, returns true when clicked
- Success return boolean
---
> clicked = RL.GuiLabelButton( Rectangle bounds, string text )
Label button control, show true when clicked
- Success return boolean
---
> active = RL.GuiToggle( Rectangle bounds, string text, bool active )
Toggle Button control, returns true when active
- Success return boolean
---
> index = RL.GuiToggleGroup( Rectangle bounds, string text, int active )
Toggle Group control, returns active toggle index
- Success return int
---
> active = RL.GuiCheckBox( Rectangle bounds, string text, bool checked )
Check Box control, returns true when active
- Success return boolean
---
> active = RL.GuiComboBox( Rectangle bounds, string text, int active )
Combo Box control, returns selected item index
- Success return int
---
> pressed, text = RL.GuiTextBox( Rectangle bounds, string text, int textSize, bool editMode )
Text Box control, updates input text
- Success return boolean, string
---
> pressed, text = RL.GuiTextBoxMulti( Rectangle bounds, string text, int textSize, bool editMode )
Text Box control with multiple lines
- Success return boolean, string
---
> pressed, value = RL.GuiSpinner( Rectangle bounds, string text, int value, int minValue, int maxValue, bool editMode )
Spinner control, returns selected value
- Success return boolean, int
---
> pressed, value = RL.GuiValueBox( Rectangle bounds, string text, int value, int minValue, int maxValue, bool editMode )
Value Box control, updates input text with numbers
- Success return boolean, int
---
> value = RL.GuiSlider( Rectangle bounds, string textLeft, string textRight, float value, float minValue, float maxValue )
Slider control, returns selected value
- Success return float
---
> value = RL.GuiSliderBar( Rectangle bounds, string textLeft, string textRight, float value, float minValue, float maxValue )
Slider Bar control, returns selected value
- Success return float
---
> value = RL.GuiProgressBar( Rectangle bounds, string textLeft, string textRight, float value, float minValue, float maxValue )
Progress Bar control, shows current progress value
- Success return float
---
> value = RL.GuiScrollBar( Rectangle bounds, int value, int minValue, int maxValue )
Scroll Bar control
- Success return int
---
> pressed, item = RL.GuiDropdownBox( Rectangle bounds, string text, int active, bool editMode )
Dropdown Box control, returns selected item
- Success return bool, int
---
> RL.GuiStatusBar( Rectangle bounds, string text )
Status Bar control, shows info text
---
> RL.GuiDummyRec( Rectangle bounds, string text )
Dummy control for placeholders
---
> cell = RL.GuiGrid( Rectangle bounds, string text, float spacing, int subdivs )
Grid control, returns mouse cell position
- Success return Vector2
---
## Gui - Advance controls set
---
> itemIndex, scrollIndex = RL.GuiListView( Rectangle bounds, string text, int scrollIndex, int active )
List View control, returns selected list item index and scroll index
- Success return int, int
---
> itemIndex, scrollIndex, focus = RL.GuiListViewEx( Rectangle bounds, string text, int focus, int scrollIndex, int active )
List View with extended parameters, returns selected list item index, scroll index and focus
- Success return int, int, int
---
> buttonIndex = RL.GuiMessageBox( Rectangle bounds, string title, string message, string buttons )
Message Box control, displays a message, returns button index (0 is x button)
- Success return int
---
> buttonIndex, text, secretViewActive = RL.GuiTextInputBox( Rectangle bounds, string title, string message, string buttons, string text, int textMaxSize, int secretViewActive )
Text Input Box control, ask for text, supports secret
- Success return int, string, int
---
> color = RL.GuiColorPicker( Rectangle bounds, string text, Color color )
Color Picker control (multiple color controls)
- Success return Color
---
> color = RL.GuiColorPanel( Rectangle bounds, string text, Color color )
Color Panel control
- Success return Color
---
> alpha = RL.GuiColorBarAlpha( Rectangle bounds, string text, float alpha )
Color Bar Alpha control
- Success return float
---
> hue = RL.GuiColorBarHue( Rectangle bounds, string text, float value )
Color Bar Hue control
- Success return float
---
## Gui - Styles loading functions ## Gui - Styles loading functions
--- ---
@@ -8635,7 +8415,7 @@ Color Bar Hue control
Load style file over global style variable (.rgs) Load style file over global style variable (.rgs)
- Failure return false - Failure return nil
- Success return true - Success return true
--- ---
@@ -8646,6 +8426,28 @@ Load style default over global style
--- ---
## Gui - Tooltips management functions
---
> RL.GuiEnableTooltip()
Enable gui tooltips (global state)
---
> RL.GuiDisableTooltip()
Disable gui tooltips (global state)
---
> RL.GuiSetTooltip( string tooltip )
Set tooltip string
---
## Gui - Icons functionality ## Gui - Icons functionality
--- ---
@@ -8658,38 +8460,319 @@ Get text with icon id prepended (if supported)
--- ---
> RL.GuiDrawIcon( int iconId, Vector2 pos, int pixelSize, Color color )
Draw icon
---
> RL.GuiSetIconScale( int scale ) > RL.GuiSetIconScale( int scale )
Set icon scale (1 by default) Set icon scale (1 by default)
--- ---
> RL.GuiSetIconPixel( int iconId, Vector2 pos ) > icons = RL.GuiGetIcons()
Set icon pixel value Get raygui icons data pointer
- Success return int
--- ---
> RL.GuiClearIconPixel( int iconId, Vector2 pos ) > iconNames = RL.GuiLoadIcons( string fileName, bool loadIconsName )
Clear icon pixel value Load raygui icons file (.rgi) into internal icons data
- Failure return nil
- Success return strings{}
--- ---
> value = RL.GuiCheckIconPixel( int iconId, Vector2 pos ) > RL.GuiDrawIcon( int iconId, Vector2 pos, int pixelSize, Color color )
Check icon pixel value Draw icon
---
## Gui - Container/separator controls, useful for controls organization
---
> result = RL.GuiWindowBox( Rectangle bounds, string title )
Window Box control, shows a window that can be closed
- Success return int
---
> result = RL.GuiGroupBox( Rectangle bounds, string text )
Group Box control with text name
- Success return int
---
> result = RL.GuiLine( Rectangle bounds, string text )
Line separator control, could contain text
- Success return int
---
> result = RL.GuiPanel( Rectangle bounds, string text )
Panel control, useful to group controls
- Success return int
---
> result, active = RL.GuiTabBar( Rectangle bounds, string text, int active )
Tab Bar control, returns TAB to be closed or -1
- Success return int, int
---
> result, scroll, view = RL.GuiScrollPanel( Rectangle bounds, string text, Rectangle content, Vector2 scroll, Rectangle view )
Scroll Panel control
- Success return int, Vector2, Rectangle
---
## Gui - Basic controls set
---
> result = RL.GuiLabel( Rectangle bounds, string text )
Label control, shows text
- Success return int
---
> result = RL.GuiButton( Rectangle bounds, string text )
Button control, returns true when clicked
- Success return int
---
> result = RL.GuiLabelButton( Rectangle bounds, string text )
Label button control, show true when clicked
- Success return int
---
> result, active = RL.GuiToggle( Rectangle bounds, string text, bool active )
Toggle Button control, returns true when active
- Success return int, bool
---
> result, active = RL.GuiToggleGroup( Rectangle bounds, string text, int active )
Toggle Group control, returns active toggle index
- Success return int, int
---
> result, active = RL.GuiToggleSlider( Rectangle bounds, string text, int active )
Toggle Slider control, returns true when clicked
- Success return int, int
---
> result, checked = RL.GuiCheckBox( Rectangle bounds, string text, bool checked )
Check Box control, returns true when active
- Success return bool - Success return bool
--- ---
> result, active = RL.GuiComboBox( Rectangle bounds, string text, int active )
Combo Box control, returns selected item index
- Success return int, int
---
> result, active = RL.GuiDropdownBox( Rectangle bounds, string text, int active, bool editMode )
Dropdown Box control, returns selected item
- Success return int, int
---
> result, value = RL.GuiSpinner( Rectangle bounds, string text, int value, int minValue, int maxValue, bool editMode )
Spinner control, returns selected value
- Success return int, int
---
> result, value = RL.GuiValueBox( Rectangle bounds, string text, int value, int minValue, int maxValue, bool editMode )
Value Box control, updates input text with numbers
- Success return int, int
---
> result, text = RL.GuiTextBox( Rectangle bounds, string text, int textSize, bool editMode )
Text Box control, updates input text
- Success return int, string
---
> result, value = RL.GuiSlider( Rectangle bounds, string textLeft, string textRight, float value, float minValue, float maxValue )
Slider control, returns selected value
- Success return int, float
---
> result, value = RL.GuiSliderBar( Rectangle bounds, string textLeft, string textRight, float value, float minValue, float maxValue )
Slider Bar control, returns selected value
- Success return int, float
---
> result, value = RL.GuiProgressBar( Rectangle bounds, string textLeft, string textRight, float value, float minValue, float maxValue )
Progress Bar control, shows current progress value
- Success return int, float
---
> result = RL.GuiStatusBar( Rectangle bounds, string text )
Status Bar control, shows info text
- Success return int
---
> result = RL.GuiDummyRec( Rectangle bounds, string text )
Dummy control for placeholders
- Success return int
---
> result, mouseCell = RL.GuiGrid( Rectangle bounds, string text, float spacing, int subdivs, Vector2 mouseCell )
Grid control, returns mouse cell position
- Success return int, Vector2
---
## Gui - Advance controls set
---
> result, scrollIndex, active = RL.GuiListView( Rectangle bounds, string text, int scrollIndex, int active )
List View control, returns selected list item index
- Success return int, int, int
---
> result, scrollIndex, active, focus = RL.GuiListViewEx( Rectangle bounds, string text, int scrollIndex, int active, int focus )
List View with extended parameters
- Success return int, int, int, int
---
> result = RL.GuiMessageBox( Rectangle bounds, string title, string message, string buttons )
Message Box control, displays a message
- Success return int
---
> result, text, secretViewActive = RL.GuiTextInputBox( Rectangle bounds, string title, string message, string buttons, string text, int textMaxSize, bool secretViewActive )
Text Input Box control, ask for text, supports secret
- Success return int, string, bool
---
> result, color = RL.GuiColorPicker( Rectangle bounds, string text, Color color )
Color Picker control (multiple color controls)
- Success return int, Color
---
> result, color = RL.GuiColorPanel( Rectangle bounds, string text, Color color )
Color Panel control
- Success return int, Color
---
> result, alpha = RL.GuiColorBarAlpha( Rectangle bounds, string text, float alpha )
Color Bar Alpha control
- Success return int, float
---
> result, value = RL.GuiColorBarHue( Rectangle bounds, string text, float value )
Color Bar Hue control
- Success return int, float
---
> result, colorHsv = RL.GuiColorPickerHSV( Rectangle bounds, string text, Vector3 colorHsv )
Color Picker control that avoids conversion to RGB on each call (multiple color controls)
- Success return int, Vector3
---
> result, colorHsv = RL.GuiColorPanelHSV( Rectangle bounds, string text, Vector3 colorHsv )
Color Panel control that returns HSV color value, used by GuiColorPickerHSV()
- Success return int, Vector3
---
## Lights - Light management functions ## Lights - Light management functions
--- ---

View File

@@ -753,12 +753,24 @@ RL.STATE_FOCUSED=1
RL.STATE_PRESSED=2 RL.STATE_PRESSED=2
RL.STATE_DISABLED=3 RL.STATE_DISABLED=3
-- Globals - GuiTextAlignment -- Globals - GuiControlTextAlignment
RL.TEXT_ALIGN_LEFT=0 RL.TEXT_ALIGN_LEFT=0
RL.TEXT_ALIGN_CENTER=1 RL.TEXT_ALIGN_CENTER=1
RL.TEXT_ALIGN_RIGHT=2 RL.TEXT_ALIGN_RIGHT=2
-- Globals - GuiControlTextAlignmentVertical
RL.TEXT_ALIGN_TOP=0
RL.TEXT_ALIGN_MIDDLE=1
RL.TEXT_ALIGN_BOTTOM=2
-- Globals - GuiControlTextWrapMode
RL.TEXT_WRAP_NONE=0
RL.TEXT_WRAP_CHAR=1
RL.TEXT_WRAP_WORD=2
-- Globals - GuiControl -- Globals - GuiControl
RL.DEFAULT=0 RL.DEFAULT=0
@@ -800,7 +812,6 @@ RL.TEXT_COLOR_DISABLED=11
RL.BORDER_WIDTH=12 RL.BORDER_WIDTH=12
RL.TEXT_PADDING=13 RL.TEXT_PADDING=13
RL.TEXT_ALIGNMENT=14 RL.TEXT_ALIGNMENT=14
RL.RESERVED=15
-- Globals - GuiDefaultProperty -- Globals - GuiDefaultProperty
@@ -812,6 +823,12 @@ RL.TEXT_SPACING=17
RL.LINE_COLOR=18 RL.LINE_COLOR=18
---Background color ---Background color
RL.BACKGROUND_COLOR=19 RL.BACKGROUND_COLOR=19
---Text spacing between lines
RL.TEXT_LINE_SPACING=20
---Text vertical alignment inside text bounds (after border and padding)
RL.TEXT_ALIGNMENT_VERTICAL=21
---Text wrap-mode inside text bounds
RL.TEXT_WRAP_MODE=22
-- Globals - GuiToggleProperty -- Globals - GuiToggleProperty
@@ -859,12 +876,10 @@ RL.ARROW_PADDING=16
---DropdownBox items separation ---DropdownBox items separation
RL.DROPDOWN_ITEMS_SPACING=17 RL.DROPDOWN_ITEMS_SPACING=17
-- Globals - GuiTextBoxProperty -- Globals - TextBox/TextBoxMulti/ValueBox/Spinner
---TextBox/TextBoxMulti/ValueBox/Spinner inner text padding ---TextBox in read-only mode: 0-text editable, 1-text no-editable
RL.TEXT_INNER_PADDING=16 RL.TEXT_READONLY=16
---TextBoxMulti lines separation
RL.TEXT_LINES_SPACING=17
-- Globals - GuiSpinnerProperty -- Globals - GuiSpinnerProperty
@@ -5475,8 +5490,8 @@ function RL.GuiIsLocked() end
---Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f ---Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f
---@param alpha number ---@param alpha number
---@return any RL.GuiFade ---@return any RL.GuiSetAlpha
function RL.GuiFade( alpha ) end function RL.GuiSetAlpha( alpha ) end
---Set gui state (global state) ---Set gui state (global state)
---@param state integer ---@param state integer
@@ -5516,297 +5531,10 @@ function RL.GuiSetStyle( control, property, value ) end
---@return any value ---@return any value
function RL.GuiGetStyle( control, property ) end function RL.GuiGetStyle( control, property ) end
-- Gui - Container/separator controls, useful for controls organization
---Window Box control, shows a window that can be closed
---- Success return bool
---@param bounds table
---@param title string
---@return any state
function RL.GuiWindowBox( bounds, title ) end
---Group Box control with text name
---@param bounds table
---@param text string
---@return any RL.GuiGroupBox
function RL.GuiGroupBox( bounds, text ) end
---Line separator control, could contain text
---@param bounds table
---@param text string
---@return any RL.GuiLine
function RL.GuiLine( bounds, text ) end
---Panel control, useful to group controls
---@param bounds table
---@param text string
---@return any RL.GuiPanel
function RL.GuiPanel( bounds, text ) end
---Scroll Panel control
---- Success return Rectangle, Vector2
---@param bounds table
---@param text string
---@param content table
---@param scroll table
---@return any view
---@return any scroll
function RL.GuiScrollPanel( bounds, text, content, scroll ) end
-- Gui - Basic controls set
---Label control, shows text
---@param bounds table
---@param text string
---@return any RL.GuiLabel
function RL.GuiLabel( bounds, text ) end
---Button control, returns true when clicked
---- Success return boolean
---@param bounds table
---@param text string
---@return any clicked
function RL.GuiButton( bounds, text ) end
---Label button control, show true when clicked
---- Success return boolean
---@param bounds table
---@param text string
---@return any clicked
function RL.GuiLabelButton( bounds, text ) end
---Toggle Button control, returns true when active
---- Success return boolean
---@param bounds table
---@param text string
---@param active boolean
---@return any active
function RL.GuiToggle( bounds, text, active ) end
---Toggle Group control, returns active toggle index
---- Success return int
---@param bounds table
---@param text string
---@param active integer
---@return any index
function RL.GuiToggleGroup( bounds, text, active ) end
---Check Box control, returns true when active
---- Success return boolean
---@param bounds table
---@param text string
---@param checked boolean
---@return any active
function RL.GuiCheckBox( bounds, text, checked ) end
---Combo Box control, returns selected item index
---- Success return int
---@param bounds table
---@param text string
---@param active integer
---@return any active
function RL.GuiComboBox( bounds, text, active ) end
---Text Box control, updates input text
---- Success return boolean, string
---@param bounds table
---@param text string
---@param textSize integer
---@param editMode boolean
---@return any pressed
---@return any text
function RL.GuiTextBox( bounds, text, textSize, editMode ) end
---Text Box control with multiple lines
---- Success return boolean, string
---@param bounds table
---@param text string
---@param textSize integer
---@param editMode boolean
---@return any pressed
---@return any text
function RL.GuiTextBoxMulti( bounds, text, textSize, editMode ) end
---Spinner control, returns selected value
---- Success return boolean, int
---@param bounds table
---@param text string
---@param value integer
---@param minValue integer
---@param maxValue integer
---@param editMode boolean
---@return any pressed
---@return any value
function RL.GuiSpinner( bounds, text, value, minValue, maxValue, editMode ) end
---Value Box control, updates input text with numbers
---- Success return boolean, int
---@param bounds table
---@param text string
---@param value integer
---@param minValue integer
---@param maxValue integer
---@param editMode boolean
---@return any pressed
---@return any value
function RL.GuiValueBox( bounds, text, value, minValue, maxValue, editMode ) end
---Slider control, returns selected value
---- Success return float
---@param bounds table
---@param textLeft string
---@param textRight string
---@param value number
---@param minValue number
---@param maxValue number
---@return any value
function RL.GuiSlider( bounds, textLeft, textRight, value, minValue, maxValue ) end
---Slider Bar control, returns selected value
---- Success return float
---@param bounds table
---@param textLeft string
---@param textRight string
---@param value number
---@param minValue number
---@param maxValue number
---@return any value
function RL.GuiSliderBar( bounds, textLeft, textRight, value, minValue, maxValue ) end
---Progress Bar control, shows current progress value
---- Success return float
---@param bounds table
---@param textLeft string
---@param textRight string
---@param value number
---@param minValue number
---@param maxValue number
---@return any value
function RL.GuiProgressBar( bounds, textLeft, textRight, value, minValue, maxValue ) end
---Scroll Bar control
---- Success return int
---@param bounds table
---@param value integer
---@param minValue integer
---@param maxValue integer
---@return any value
function RL.GuiScrollBar( bounds, value, minValue, maxValue ) end
---Dropdown Box control, returns selected item
---- Success return bool, int
---@param bounds table
---@param text string
---@param active integer
---@param editMode boolean
---@return any pressed
---@return any item
function RL.GuiDropdownBox( bounds, text, active, editMode ) end
---Status Bar control, shows info text
---@param bounds table
---@param text string
---@return any RL.GuiStatusBar
function RL.GuiStatusBar( bounds, text ) end
---Dummy control for placeholders
---@param bounds table
---@param text string
---@return any RL.GuiDummyRec
function RL.GuiDummyRec( bounds, text ) end
---Grid control, returns mouse cell position
---- Success return Vector2
---@param bounds table
---@param text string
---@param spacing number
---@param subdivs integer
---@return any cell
function RL.GuiGrid( bounds, text, spacing, subdivs ) end
-- Gui - Advance controls set
---List View control, returns selected list item index and scroll index
---- Success return int, int
---@param bounds table
---@param text string
---@param scrollIndex integer
---@param active integer
---@return any itemIndex
---@return any scrollIndex
function RL.GuiListView( bounds, text, scrollIndex, active ) end
---List View with extended parameters, returns selected list item index, scroll index and focus
---- Success return int, int, int
---@param bounds table
---@param text string
---@param focus integer
---@param scrollIndex integer
---@param active integer
---@return any itemIndex
---@return any scrollIndex
---@return any focus
function RL.GuiListViewEx( bounds, text, focus, scrollIndex, active ) end
---Message Box control, displays a message, returns button index (0 is x button)
---- Success return int
---@param bounds table
---@param title string
---@param message string
---@param buttons string
---@return any buttonIndex
function RL.GuiMessageBox( bounds, title, message, buttons ) end
---Text Input Box control, ask for text, supports secret
---- Success return int, string, int
---@param bounds table
---@param title string
---@param message string
---@param buttons string
---@param text string
---@param textMaxSize integer
---@param secretViewActive integer
---@return any buttonIndex
---@return any text
---@return any secretViewActive
function RL.GuiTextInputBox( bounds, title, message, buttons, text, textMaxSize, secretViewActive ) end
---Color Picker control (multiple color controls)
---- Success return Color
---@param bounds table
---@param text string
---@param color table
---@return any color
function RL.GuiColorPicker( bounds, text, color ) end
---Color Panel control
---- Success return Color
---@param bounds table
---@param text string
---@param color table
---@return any color
function RL.GuiColorPanel( bounds, text, color ) end
---Color Bar Alpha control
---- Success return float
---@param bounds table
---@param text string
---@param alpha number
---@return any alpha
function RL.GuiColorBarAlpha( bounds, text, alpha ) end
---Color Bar Hue control
---- Success return float
---@param bounds table
---@param text string
---@param value number
---@return any hue
function RL.GuiColorBarHue( bounds, text, value ) end
-- Gui - Styles loading functions -- Gui - Styles loading functions
---Load style file over global style variable (.rgs) ---Load style file over global style variable (.rgs)
---- Failure return false ---- Failure return nil
---- Success return true ---- Success return true
---@param fileName string ---@param fileName string
---@return any success ---@return any success
@@ -5816,6 +5544,21 @@ function RL.GuiLoadStyle( fileName ) end
---@return any RL.GuiLoadStyleDefault ---@return any RL.GuiLoadStyleDefault
function RL.GuiLoadStyleDefault() end function RL.GuiLoadStyleDefault() end
-- Gui - Tooltips management functions
---Enable gui tooltips (global state)
---@return any RL.GuiEnableTooltip
function RL.GuiEnableTooltip() end
---Disable gui tooltips (global state)
---@return any RL.GuiDisableTooltip
function RL.GuiDisableTooltip() end
---Set tooltip string
---@param tooltip string
---@return any RL.GuiSetTooltip
function RL.GuiSetTooltip( tooltip ) end
-- Gui - Icons functionality -- Gui - Icons functionality
---Get text with icon id prepended (if supported) ---Get text with icon id prepended (if supported)
@@ -5825,6 +5568,24 @@ function RL.GuiLoadStyleDefault() end
---@return any text ---@return any text
function RL.GuiIconText( iconId, text ) end function RL.GuiIconText( iconId, text ) end
---Set icon scale (1 by default)
---@param scale integer
---@return any RL.GuiSetIconScale
function RL.GuiSetIconScale( scale ) end
---Get raygui icons data pointer
---- Success return int
---@return any icons
function RL.GuiGetIcons() end
---Load raygui icons file (.rgi) into internal icons data
---- Failure return nil
---- Success return strings{}
---@param fileName string
---@param loadIconsName boolean
---@return any iconNames
function RL.GuiLoadIcons( fileName, loadIconsName ) end
---Draw icon ---Draw icon
---@param iconId integer ---@param iconId integer
---@param pos table ---@param pos table
@@ -5833,29 +5594,332 @@ function RL.GuiIconText( iconId, text ) end
---@return any RL.GuiDrawIcon ---@return any RL.GuiDrawIcon
function RL.GuiDrawIcon( iconId, pos, pixelSize, color ) end function RL.GuiDrawIcon( iconId, pos, pixelSize, color ) end
---Set icon scale (1 by default) -- Gui - Container/separator controls, useful for controls organization
---@param scale integer
---@return any RL.GuiSetIconScale
function RL.GuiSetIconScale( scale ) end
---Set icon pixel value ---Window Box control, shows a window that can be closed
---@param iconId integer ---- Success return int
---@param pos table ---@param bounds table
---@return any RL.GuiSetIconPixel ---@param title string
function RL.GuiSetIconPixel( iconId, pos ) end ---@return any result
function RL.GuiWindowBox( bounds, title ) end
---Clear icon pixel value ---Group Box control with text name
---@param iconId integer ---- Success return int
---@param pos table ---@param bounds table
---@return any RL.GuiClearIconPixel ---@param text string
function RL.GuiClearIconPixel( iconId, pos ) end ---@return any result
function RL.GuiGroupBox( bounds, text ) end
---Check icon pixel value ---Line separator control, could contain text
---- Success return int
---@param bounds table
---@param text string
---@return any result
function RL.GuiLine( bounds, text ) end
---Panel control, useful to group controls
---- Success return int
---@param bounds table
---@param text string
---@return any result
function RL.GuiPanel( bounds, text ) end
---Tab Bar control, returns TAB to be closed or -1
---- Success return int, int
---@param bounds table
---@param text string
---@param active integer
---@return any result
---@return any active
function RL.GuiTabBar( bounds, text, active ) end
---Scroll Panel control
---- Success return int, Vector2, Rectangle
---@param bounds table
---@param text string
---@param content table
---@param scroll table
---@param view table
---@return any result
---@return any scroll
---@return any view
function RL.GuiScrollPanel( bounds, text, content, scroll, view ) end
-- Gui - Basic controls set
---Label control, shows text
---- Success return int
---@param bounds table
---@param text string
---@return any result
function RL.GuiLabel( bounds, text ) end
---Button control, returns true when clicked
---- Success return int
---@param bounds table
---@param text string
---@return any result
function RL.GuiButton( bounds, text ) end
---Label button control, show true when clicked
---- Success return int
---@param bounds table
---@param text string
---@return any result
function RL.GuiLabelButton( bounds, text ) end
---Toggle Button control, returns true when active
---- Success return int, bool
---@param bounds table
---@param text string
---@param active boolean
---@return any result
---@return any active
function RL.GuiToggle( bounds, text, active ) end
---Toggle Group control, returns active toggle index
---- Success return int, int
---@param bounds table
---@param text string
---@param active integer
---@return any result
---@return any active
function RL.GuiToggleGroup( bounds, text, active ) end
---Toggle Slider control, returns true when clicked
---- Success return int, int
---@param bounds table
---@param text string
---@param active integer
---@return any result
---@return any active
function RL.GuiToggleSlider( bounds, text, active ) end
---Check Box control, returns true when active
---- Success return bool ---- Success return bool
---@param iconId integer ---@param bounds table
---@param pos table ---@param text string
---@param checked boolean
---@return any result
---@return any checked
function RL.GuiCheckBox( bounds, text, checked ) end
---Combo Box control, returns selected item index
---- Success return int, int
---@param bounds table
---@param text string
---@param active integer
---@return any result
---@return any active
function RL.GuiComboBox( bounds, text, active ) end
---Dropdown Box control, returns selected item
---- Success return int, int
---@param bounds table
---@param text string
---@param active integer
---@param editMode boolean
---@return any result
---@return any active
function RL.GuiDropdownBox( bounds, text, active, editMode ) end
---Spinner control, returns selected value
---- Success return int, int
---@param bounds table
---@param text string
---@param value integer
---@param minValue integer
---@param maxValue integer
---@param editMode boolean
---@return any result
---@return any value ---@return any value
function RL.GuiCheckIconPixel( iconId, pos ) end function RL.GuiSpinner( bounds, text, value, minValue, maxValue, editMode ) end
---Value Box control, updates input text with numbers
---- Success return int, int
---@param bounds table
---@param text string
---@param value integer
---@param minValue integer
---@param maxValue integer
---@param editMode boolean
---@return any result
---@return any value
function RL.GuiValueBox( bounds, text, value, minValue, maxValue, editMode ) end
---Text Box control, updates input text
---- Success return int, string
---@param bounds table
---@param text string
---@param textSize integer
---@param editMode boolean
---@return any result
---@return any text
function RL.GuiTextBox( bounds, text, textSize, editMode ) end
---Slider control, returns selected value
---- Success return int, float
---@param bounds table
---@param textLeft string
---@param textRight string
---@param value number
---@param minValue number
---@param maxValue number
---@return any result
---@return any value
function RL.GuiSlider( bounds, textLeft, textRight, value, minValue, maxValue ) end
---Slider Bar control, returns selected value
---- Success return int, float
---@param bounds table
---@param textLeft string
---@param textRight string
---@param value number
---@param minValue number
---@param maxValue number
---@return any result
---@return any value
function RL.GuiSliderBar( bounds, textLeft, textRight, value, minValue, maxValue ) end
---Progress Bar control, shows current progress value
---- Success return int, float
---@param bounds table
---@param textLeft string
---@param textRight string
---@param value number
---@param minValue number
---@param maxValue number
---@return any result
---@return any value
function RL.GuiProgressBar( bounds, textLeft, textRight, value, minValue, maxValue ) end
---Status Bar control, shows info text
---- Success return int
---@param bounds table
---@param text string
---@return any result
function RL.GuiStatusBar( bounds, text ) end
---Dummy control for placeholders
---- Success return int
---@param bounds table
---@param text string
---@return any result
function RL.GuiDummyRec( bounds, text ) end
---Grid control, returns mouse cell position
---- Success return int, Vector2
---@param bounds table
---@param text string
---@param spacing number
---@param subdivs integer
---@param mouseCell table
---@return any result
---@return any mouseCell
function RL.GuiGrid( bounds, text, spacing, subdivs, mouseCell ) end
-- Gui - Advance controls set
---List View control, returns selected list item index
---- Success return int, int, int
---@param bounds table
---@param text string
---@param scrollIndex integer
---@param active integer
---@return any result
---@return any scrollIndex
---@return any active
function RL.GuiListView( bounds, text, scrollIndex, active ) end
---List View with extended parameters
---- Success return int, int, int, int
---@param bounds table
---@param text string
---@param scrollIndex integer
---@param active integer
---@param focus integer
---@return any result
---@return any scrollIndex
---@return any active
---@return any focus
function RL.GuiListViewEx( bounds, text, scrollIndex, active, focus ) end
---Message Box control, displays a message
---- Success return int
---@param bounds table
---@param title string
---@param message string
---@param buttons string
---@return any result
function RL.GuiMessageBox( bounds, title, message, buttons ) end
---Text Input Box control, ask for text, supports secret
---- Success return int, string, bool
---@param bounds table
---@param title string
---@param message string
---@param buttons string
---@param text string
---@param textMaxSize integer
---@param secretViewActive boolean
---@return any result
---@return any text
---@return any secretViewActive
function RL.GuiTextInputBox( bounds, title, message, buttons, text, textMaxSize, secretViewActive ) end
---Color Picker control (multiple color controls)
---- Success return int, Color
---@param bounds table
---@param text string
---@param color table
---@return any result
---@return any color
function RL.GuiColorPicker( bounds, text, color ) end
---Color Panel control
---- Success return int, Color
---@param bounds table
---@param text string
---@param color table
---@return any result
---@return any color
function RL.GuiColorPanel( bounds, text, color ) end
---Color Bar Alpha control
---- Success return int, float
---@param bounds table
---@param text string
---@param alpha number
---@return any result
---@return any alpha
function RL.GuiColorBarAlpha( bounds, text, alpha ) end
---Color Bar Hue control
---- Success return int, float
---@param bounds table
---@param text string
---@param value number
---@return any result
---@return any value
function RL.GuiColorBarHue( bounds, text, value ) end
---Color Picker control that avoids conversion to RGB on each call (multiple color controls)
---- Success return int, Vector3
---@param bounds table
---@param text string
---@param colorHsv table
---@return any result
---@return any colorHsv
function RL.GuiColorPickerHSV( bounds, text, colorHsv ) end
---Color Panel control that returns HSV color value, used by GuiColorPickerHSV()
---- Success return int, Vector3
---@param bounds table
---@param text string
---@param colorHsv table
---@return any result
---@return any colorHsv
function RL.GuiColorPanelHSV( bounds, text, colorHsv ) end
-- Lights - Light management functions -- Lights - Light management functions

View File

@@ -8,6 +8,7 @@ KEY CHANGES:
- ADDED: Random values generation functions. - ADDED: Random values generation functions.
- ADDED: More Window-related functions. - ADDED: More Window-related functions.
- ADDED: Spline functions. - ADDED: Spline functions.
- CHANGE: Raygui to version 4.0. Gui libs also updated.
DETAILED CHANGES: DETAILED CHANGES:
- REMOVED: DrawLineBezierQuad, DrawLineBezierCubic. - REMOVED: DrawLineBezierQuad, DrawLineBezierCubic.

View File

@@ -1,9 +1,9 @@
Current { Current {
* Shapes
* Splines.
} }
Backlog { Backlog {
* SDL_Desktop platform option. Might have to move events to platform specific file since events are not
the same in different platforms.
* Text * Text
* Text codepoints management functions (unicode characters)? Could be usefull for luajit. * Text codepoints management functions (unicode characters)? Could be usefull for luajit.
* Some of the Text strings management functions could be easier to use than the Lua ones. * Some of the Text strings management functions could be easier to use than the Lua ones.

View File

@@ -8,17 +8,18 @@ local spinnerActive = false
local spinnerValueRange = { 0, 10 } local spinnerValueRange = { 0, 10 }
local sliderValue = 5.0 local sliderValue = 5.0
local sliderValueRange = { 0.0, 10.0 } local sliderValueRange = { 0.0, 10.0 }
local scrollbarValue = 0.0
local dropdownValue = 0 local dropdownValue = 0
local dropdownActive = false local dropdownActive = false
local index = 0 local index = 0
local listView = { item = 0, scroll = 0 } local listView = { item = 0, scroll = 0 }
local listViewEx = { item = 0, scroll = 0, focus = 0 } local textInputBox = { buttonIndex = 0, text = "", secretViewActive = false }
local messageBox = { buttonIndex = -1 }
local textInputBox = { buttonIndex = 0, text = "", secretViewActive = 1 }
local colorPicker = { color = { 255, 255, 255 } } local colorPicker = { color = { 255, 255, 255 } }
local colorPanel = { color = { 255, 255, 255 }, alpha = 1.0, hue = 1.0, oldHue = 1.0 } local colorPanel = { color = { 255, 255, 255 }, alpha = 1.0, hue = 1.0, oldHue = 1.0 }
local comboBoxActive = 0 local comboBoxActive = 0
local scrollPanel = { scroll = { 0, 0 }, view = { 0, 0, 320, 200 } }
local guiTabBarActive = 0
local colorPickerHSV = { 0, 0, 0 }
local colorPanelHSV = { 0, 0, 0 }
function RL.init() function RL.init()
local monitor = 0 local monitor = 0
@@ -36,79 +37,86 @@ end
function RL.draw() function RL.draw()
RL.ClearBackground( { 50, 20, 75 } ) RL.ClearBackground( { 50, 20, 75 } )
local result = 0
-- RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SIZE, 10 ) -- RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SIZE, 10 )
if RL.GuiButton( { 112, 16, 96, 32 }, RL.GuiIconText( 113, "Exit" ) ) then if RL.GuiButton( { 112, 16, 96, 32 }, RL.GuiIconText( 113, "Exit" ) ) == 1 then
RL.CloseWindow() RL.CloseWindow()
end end
-- RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SIZE, 20 ) RL.GuiButton( { 112, 64, 96, 32 }, RL.GuiIconText( 100, "Cat" ) )
RL.GuiButton( { 112, 64, 96, 32 }, RL.GuiIconText( 113, "Cat" ) )
-- RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SIZE, 10 )
if windowOpen and RL.GuiWindowBox( { 300, 16, 200, 320 }, "Window" ) then if windowOpen and RL.GuiWindowBox( { 300, 16, 200, 320 }, "Window" ) == 1 then
windowOpen = false windowOpen = false
end end
RL.GuiPanel( { 60, 260, 100, 100 }, "Panel" ) RL.GuiPanel( { 60, 260, 100, 100 }, "Panel" )
toggled = RL.GuiToggle( { 200, 260, 64, 32 }, "Toggle", toggled ) _, toggled = RL.GuiToggle( { 200, 260, 64, 32 }, "Toggle", toggled )
index = RL.GuiToggleGroup( { 520, 30, 64, 32 }, "Cat\nDog\nMonkey", index )
checkbox = RL.GuiCheckBox( { 200, 300, 16, 16 }, "CheckBox", checkbox )
local textBoxToggle = false _, index = RL.GuiToggleGroup( { 520, 30, 64, 32 }, "Cat\nDog\nMonkey", index )
textBoxToggle, textBoxText = RL.GuiTextBox( { 32, 400, 120, 32 }, textBoxText, 32, textBoxActive )
-- textBoxToggle, textBoxText = RL.GuiTextBoxMulti( { 32, 400, 120, 64 }, textBoxText, 120, textBoxActive )
if textBoxToggle then _, checkbox = RL.GuiCheckBox( { 200, 300, 16, 16 }, "CheckBox", checkbox )
result, textBoxText = RL.GuiTextBox( { 32, 400, 120, 32 }, textBoxText, 32, textBoxActive )
if result == 1 then
textBoxActive = not textBoxActive textBoxActive = not textBoxActive
end end
local spinnerToggle = false result, spinnerValue = RL.GuiSpinner( { 64, 450, 96, 32 }, "Value", spinnerValue, spinnerValueRange[1], spinnerValueRange[2], spinnerActive )
spinnerToggle, spinnerValue = RL.GuiSpinner( { 64, 450, 96, 32 }, "Value", spinnerValue, spinnerValueRange[1], spinnerValueRange[2], spinnerActive ) if result == 1 then
-- spinnerToggle, spinnerValue = RL.GuiValueBox( { 64, 450, 96, 32 }, "Value", spinnerValue, spinnerValueRange[1], spinnerValueRange[2], spinnerActive )
if spinnerToggle then
spinnerActive = not spinnerActive spinnerActive = not spinnerActive
end end
sliderValue = RL.GuiSliderBar( { 64, 510, 96, 32 }, "min", "max", sliderValue, sliderValueRange[1], sliderValueRange[2] ) _, sliderValue = RL.GuiSliderBar( { 64, 510, 96, 32 }, "min", "max", sliderValue, sliderValueRange[1], sliderValueRange[2] )
scrollbarValue = RL.GuiScrollBar( { 64, 550, 130, 32 }, scrollbarValue, 0, 10 )
local dropdownToggle = false result, dropdownValue = RL.GuiDropdownBox( { 2, 2, 96, 16 }, "Cat\nDog\nMonkey", dropdownValue, dropdownActive )
dropdownToggle, dropdownValue = RL.GuiDropdownBox( { 2, 2, 96, 16 }, "Cat\nDog\nMonkey", dropdownValue, dropdownActive ) if result == 1 then
if dropdownToggle then
dropdownActive = not dropdownActive dropdownActive = not dropdownActive
end end
listView.item, listView.scroll = RL.GuiListView( { 200, 400, 200, 200 }, "Cat\nElefant\nSquirrel", listView.scroll, listView.item ) _, listView.scroll, listView.item = RL.GuiListView( { 200, 400, 200, 200 }, "Cat;Elefant;Squirrel", listView.scroll, listView.item )
messageBox.buttonIndex = RL.GuiMessageBox( { 420, 400, 200, 100 }, "Message", "Are you sure about this?", "Yes\nNo" )
if 0 <= messageBox.buttonIndex then result = RL.GuiMessageBox( { 420, 400, 200, 100 }, "Message", "Are you sure about this?", "Yes;No" )
print( "messageBox.buttonIndex", messageBox.buttonIndex ) if 0 <= result then
print( "messageBox.buttonIndex", result )
end end
textInputBox.buttonIndex, textInputBox.text, textInputBox.secretViewActive result, textInputBox.text, textInputBox.secretViewActive
= RL.GuiTextInputBox( { 420, 510, 300, 150 }, "Input Box", "Put text here", "Button", textInputBox.text, 200, textInputBox.secretViewActive ) = RL.GuiTextInputBox( { 420, 510, 300, 150 }, "Input Box", "Put text here", "Button", textInputBox.text, 200, textInputBox.secretViewActive )
if 0 <= result then
if 0 <= textInputBox.buttonIndex then print( "textInputBox.buttonIndex", result )
print( "textInputBox.buttonIndex", textInputBox.buttonIndex )
end end
colorPicker.color = RL.GuiColorPicker( { 620, 20, 150, 150 }, "Color Picker", colorPicker.color ) _, colorPicker.color = RL.GuiColorPicker( { 620, 20, 150, 150 }, "Color Picker", colorPicker.color )
colorPanel.color = RL.GuiColorPanel( { 820, 20, 150, 150 }, "Color Panel", colorPanel.color ) _, colorPanel.color = RL.GuiColorPanel( { 820, 20, 150, 150 }, "Color Panel", colorPanel.color )
colorPanel.alpha = RL.GuiColorBarAlpha( { 820, 180, 150, 20 }, "Color alpha", colorPanel.alpha ) _, colorPanel.alpha = RL.GuiColorBarAlpha( { 820, 180, 150, 20 }, "Color alpha", colorPanel.alpha )
colorPanel.hue = RL.GuiColorBarHue( { 980, 20, 20, 150 }, "Color hue", colorPanel.hue ) _, colorPanel.hue = RL.GuiColorBarHue( { 980, 20, 20, 150 }, "Color hue", colorPanel.hue )
if colorPanel.hue ~= colorPanel.oldHue then if colorPanel.hue ~= colorPanel.oldHue then
colorPanel.oldHue = colorPanel.hue colorPanel.oldHue = colorPanel.hue
colorPanel.color = RL.ColorFromHSV( colorPanel.hue, 1.0, 1.0 ) colorPanel.color = RL.ColorFromHSV( colorPanel.hue, 1.0, 1.0 )
end end
RL.GuiDrawIcon( 121, { 6, 20 }, 2, RL.WHITE ) RL.GuiDrawIcon( 121, { 6, 80 }, 2, RL.BLACK )
comboBoxActive = RL.GuiComboBox( { 5, 50, 80, 20 }, "One\nTwo\nThree", comboBoxActive ) _, comboBoxActive = RL.GuiComboBox( { 5, 150, 80, 20 }, "One;Two;Three", comboBoxActive )
result, scrollPanel.scroll, scrollPanel.view = RL.GuiScrollPanel(
{ 64, 640, 320, 200 },
"Scroll panel",
{ 0, 0, 640, 400 },
scrollPanel.scroll,
scrollPanel.view
)
_, guiTabBarActive = RL.GuiTabBar(
{ 420, 680, 320, 32 },
RL.GuiIconText( 13, "Play" )..";"..RL.GuiIconText( 12, "Cat.png" )..";"..RL.GuiIconText( 16, "Files" ),
guiTabBarActive
)
_, colorPickerHSV = RL.GuiColorPickerHSV( { 1024, 20, 150, 150 }, "GuiColorPuckerHSV", colorPickerHSV )
_, colorPanelHSV = RL.GuiColorPanelHSV( { 1230, 20, 150, 150 }, "GuiColorPuckerHSV", colorPanelHSV )
end end

View File

@@ -32,13 +32,11 @@ function RL.init()
end end
function RL.process( delta ) function RL.process( delta )
-- Gui:process()
Raygui:process() Raygui:process()
end end
function RL.draw() function RL.draw()
RL.ClearBackground( RL.DARKBLUE ) RL.ClearBackground( RL.DARKBLUE )
-- Gui:draw()
Raygui:draw() Raygui:draw()
end end

View File

@@ -8,7 +8,26 @@ Raygui = require( "raygui" )
local grid = {} local grid = {}
local windowbox = {} local windowbox = {}
local winOpen = true local tabBar = {}
local function closeTab( self, id )
local splits = Util.split( tabBar.text, ";" )
local newText = ""
if #splits == 1 then
Raygui.remove( tabBar )
end
table.remove( splits, id + 1 )
for i, tab in ipairs( splits ) do
newText = newText..tab
if i < #splits then
newText = newText..";"
end
end
self.text = newText
end
function RL.init() function RL.init()
local monitor = 0 local monitor = 0
@@ -82,13 +101,6 @@ function RL.init()
false, false,
function( self ) print( "Set text "..self.text ) end function( self ) print( "Set text "..self.text ) end
) )
local textboxmulti = Raygui.TextBoxMulti:new(
Rect:new( 32, 400, 256, 64 ),
"Buggy?",
32,
false,
function( self ) print( "Set text "..self.text ) end
)
local slider = Raygui.Slider:new( local slider = Raygui.Slider:new(
Rect:new( 50, 500, 256, 32 ), Rect:new( 50, 500, 256, 32 ),
"min", "min",
@@ -152,6 +164,14 @@ function RL.init()
-- Grab callback. -- Grab callback.
function( self ) Raygui.set2Top( self ) end function( self ) Raygui.set2Top( self ) end
) )
tabBar = Raygui.GuiTabBar:new(
Rect:new( 700, 520, 700, 32 ),
"Cat;Dog;Horse;Cow",
0,
-- function( self ) Raygui.set2Top( self ) end
nil,
closeTab
)
local scrollpanel = Raygui.ScrollPanel:new( local scrollpanel = Raygui.ScrollPanel:new(
Rect:new( 800, 64, 256, 256 ), Rect:new( 800, 64, 256, 256 ),
"ScrollPanel", "ScrollPanel",
@@ -164,14 +184,14 @@ function RL.init()
) )
local listview = Raygui.ListView:new( local listview = Raygui.ListView:new(
Rect:new( 1100, 64, 128, 80 ), Rect:new( 1100, 64, 128, 80 ),
"Cat\nDog\nHorse\nCow\nPig\nEagle\nLion", "Cat;Dog;Horse;Cow;Pig;Eagle;Lion",
0, 0,
0, 0,
function( self ) print( self:getItem( self.active ) ) end function( self ) print( self:getItem( self.active ) ) end
) )
local listviewex = Raygui.ListViewEx:new( local listviewex = Raygui.ListViewEx:new(
Rect:new( 1300, 64, 128, 80 ), Rect:new( 1300, 64, 128, 80 ),
"Cat\nDog\nHorse\nCow\nPig\nEagle\nLion", "Cat;Dog;Horse;Cow;Pig;Eagle;Lion",
0, 0,
0, 0,
0, 0,
@@ -181,7 +201,7 @@ function RL.init()
Rect:new( 1100, 150, 300, 128 ), Rect:new( 1100, 150, 300, 128 ),
"Title", "Title",
"Message", "Message",
"Cancel\nOk", "Cancel;Ok",
function( self ) function( self )
if 0 < self.buttonIndex then if 0 < self.buttonIndex then
print( "You pressed "..self:getItem( self.buttonIndex ) ) print( "You pressed "..self:getItem( self.buttonIndex ) )
@@ -200,10 +220,10 @@ function RL.init()
Rect:new( 1100, 300, 300, 128 ), Rect:new( 1100, 300, 300, 128 ),
"Title", "Title",
"Message", "Message",
"Cancel\nOk", "Cancel;Ok",
"Text", "Text",
8, 8,
0, false,
function( self ) function( self )
if 0 < self.buttonIndex then if 0 < self.buttonIndex then
print( "You pressed "..self:getItem( self.buttonIndex ) ) print( "You pressed "..self:getItem( self.buttonIndex ) )
@@ -249,11 +269,11 @@ end
function RL.draw() function RL.draw()
RL.ClearBackground( { 50, 20, 75 } ) RL.ClearBackground( { 50, 20, 75 } )
if 0 <= grid.cell.x then if 0 <= grid.mouseCell.x then
RL.DrawRectangleLines( RL.DrawRectangleLines(
{ {
grid.bounds.x + grid.cell.x * 32, grid.bounds.x + grid.mouseCell.x * 32,
grid.bounds.y + grid.cell.y * 32, grid.bounds.y + grid.mouseCell.y * 32,
32, 32,
32 32
}, },

View File

@@ -32,11 +32,14 @@ Color.meta = {
__idiv = function( c, v ) __idiv = function( c, v )
return Color:new( c.r // v, c.g // v, c.b // v, c.a // v ) return Color:new( c.r // v, c.g // v, c.b // v, c.a // v )
end, end,
__len = function( _ ) __len = function()
return 4 return 4
end, end,
__eq = function( c1, c2 ) __eq = function( c1, c2 )
return c1.r == c2.r and c1.g == c2.g and c1.b == c2.b and c1.a == c2.a return math.floor( c1.r ) == math.floor( c2.r )
and math.floor( c1.g ) == math.floor( c2.g )
and math.floor( c1.b ) == math.floor( c2.b )
and math.floor( c1.a ) == math.floor( c2.a )
end, end,
} }
@@ -65,7 +68,7 @@ function Color:set( r, g, b, a )
if type( r ) == "table" then if type( r ) == "table" then
r, g, b, a = table.unpack( r ) r, g, b, a = table.unpack( r )
elseif type( r ) == "nil" then elseif type( r ) == "nil" then
r, g, b, a = 0, 0, 0, 0 r, g, b, a = 0, 0, 0, 255
end end
if a == nil then if a == nil then
@@ -87,7 +90,7 @@ function Color:unpack()
end end
function Color:clone() function Color:clone()
return Color:new( self ) return Color:new( self.r, self.g, self.b, self.a )
end end
function Color:scale( scalar ) function Color:scale( scalar )

View File

@@ -264,7 +264,7 @@ function Text:draw()
return return
end end
RL.DrawText( self.font, self.text, { self._parent.bounds.x + self.bounds.x, self._parent.bounds.y + self.bounds.y }, self.fontSize, self.spacing, self.color ) RL.DrawTextEx( self.font, self.text, { self._parent.bounds.x + self.bounds.x, self._parent.bounds.y + self.bounds.y }, self.fontSize, self.spacing, self.color )
end end
-- Texture. -- Texture.

View File

@@ -27,7 +27,7 @@ Quaternion.meta = {
__unm = function( q ) __unm = function( q )
return Quaternion:new( RL.QuaternionInvert( q ) ) return Quaternion:new( RL.QuaternionInvert( q ) )
end, end,
__len = function( _ ) __len = function()
return 4 return 4
end, end,
__eq = function( q1, q2 ) __eq = function( q1, q2 )

View File

@@ -1,9 +1,9 @@
-- Wrapper for raygui that should make using it a bit more convenient. -- Wrapper for raygui that should make using it a bit more convenient.
Util = require( "utillib" ) local Util = require( "utillib" )
Rect = require( "rectangle" ) local Rect = require( "rectangle" )
Vec2 = require( "vector2" ) local Vec2 = require( "vector2" )
Color = require( "color" ) local Color = require( "color" )
---@param text string ---@param text string
---@return integer count, table rowItemCounts ---@return integer count, table rowItemCounts
@@ -54,6 +54,7 @@ local Raygui = {
focused = 0, focused = 0,
dragging = nil, dragging = nil,
grabPos = Vec2:new(), grabPos = Vec2:new(),
scrolling = false,
} }
function Raygui.process() function Raygui.process()
@@ -110,7 +111,11 @@ function Raygui.drag( element )
end end
function Raygui.draw() function Raygui.draw()
RL.GuiLock() if not Raygui.scrolling then
RL.GuiLock()
elseif RL.IsMouseButtonReleased( RL.MOUSE_BUTTON_LEFT ) then
Raygui.scrolling = false
end
for i, element in ipairs( Raygui.elements ) do for i, element in ipairs( Raygui.elements ) do
if i == Raygui.focused then if i == Raygui.focused then
@@ -143,6 +148,16 @@ function Raygui.set2Back( element )
end end
end end
function Raygui.remove( element )
for i, curElement in ipairs( Raygui.elements ) do
if element == curElement then
table.remove( Raygui.elements, i )
return
end
end
end
--[[ --[[
Container/separator controls, useful for controls organization Container/separator controls, useful for controls organization
]]-- ]]--
@@ -189,7 +204,9 @@ function WindowBox:process()
end end
function WindowBox:draw() function WindowBox:draw()
if RL.GuiWindowBox( self.bounds, self.text ) and self.callback ~= nil then local result = RL.GuiWindowBox( self.bounds, self.text )
if result == 1 and self.callback ~= nil then
self.callback( self ) self.callback( self )
end end
end end
@@ -304,6 +321,52 @@ function Panel:setPosition( pos )
self.bounds.y = pos.y self.bounds.y = pos.y
end end
-- GuiTabBar.
--- Tab Bar control, returns TAB to be closed or -1
GuiTabBar = {}
GuiTabBar.__index = GuiTabBar
function GuiTabBar:new( bounds, text, active, callback, closeCallback )
local object = setmetatable( {}, GuiTabBar )
object.bounds = bounds:clone()
object.text = text
object.active = active
object.visible = true
object.callback = callback
object.closeCallback = closeCallback
table.insert( Raygui.elements, object )
return object
end
function GuiTabBar:process()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end
function GuiTabBar:draw()
local oldActive = self.active
local result = -1
result, self.active = RL.GuiTabBar( self.bounds, self.text, self.active )
if self.active ~= oldActive and self.callback ~= nil then
self.callback( self )
end
if 0 <= result and self.closeCallback ~= nil then
self.closeCallback( self, result )
end
end
function GuiTabBar:setPosition( pos )
self.bounds.x = pos.x
self.bounds.y = pos.y
end
-- ScrollPanel. -- ScrollPanel.
--- Scroll Panel control --- Scroll Panel control
@@ -336,14 +399,17 @@ end
function ScrollPanel:draw() function ScrollPanel:draw()
local oldScroll = self.scroll:clone() local oldScroll = self.scroll:clone()
local _, scroll, view = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll, self.view )
local view, scroll = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll )
self.view = Rect:new( view ) self.view = Rect:new( view )
self.scroll = Vec2:new( scroll ) self.scroll = Vec2:new( scroll )
if self.scroll ~= oldScroll and self.callback ~= nil then if self.scroll ~= oldScroll then
self.callback( self ) Raygui.scrolling = true
if self.callback ~= nil then
self.callback( self )
end
end end
end end
@@ -401,7 +467,6 @@ function Button:new( bounds, text, callback )
object.text = text object.text = text
object.callback = callback object.callback = callback
object.clicked = false
object.visible = true object.visible = true
table.insert( Raygui.elements, object ) table.insert( Raygui.elements, object )
@@ -414,9 +479,9 @@ function Button:process()
end end
function Button:draw() function Button:draw()
self.clicked = RL.GuiButton( self.bounds, self.text ) local result = RL.GuiButton( self.bounds, self.text )
if self.clicked and self.callback ~= nil then if result == 1 and self.callback ~= nil then
self.callback( self ) self.callback( self )
end end
end end
@@ -439,7 +504,6 @@ function LabelButton:new( bounds, text, callback )
object.text = text object.text = text
object.callback = callback object.callback = callback
object.clicked = false
object.visible = true object.visible = true
table.insert( Raygui.elements, object ) table.insert( Raygui.elements, object )
@@ -452,9 +516,9 @@ function LabelButton:process()
end end
function LabelButton:draw() function LabelButton:draw()
self.clicked = RL.GuiLabelButton( self.bounds, self.text ) local result = RL.GuiLabelButton( self.bounds, self.text )
if self.clicked and self.callback ~= nil then if result == 1 and self.callback ~= nil then
self.callback( self ) self.callback( self )
end end
end end
@@ -492,7 +556,7 @@ end
function Toggle:draw() function Toggle:draw()
local oldActive = self.active local oldActive = self.active
self.active = RL.GuiToggle( self.bounds, self.text, self.active ) _, self.active = RL.GuiToggle( self.bounds, self.text, self.active )
if self.active ~= oldActive and self.callback ~= nil then if self.active ~= oldActive and self.callback ~= nil then
self.callback( self ) self.callback( self )
@@ -573,15 +637,11 @@ end
function ToggleGroup:draw() function ToggleGroup:draw()
local oldActive = self.active local oldActive = self.active
self.active = RL.GuiToggleGroup( self.bounds, self.text, self.active ) _, self.active = RL.GuiToggleGroup( self.bounds, self.text, self.active )
if self.active ~= oldActive and self.callback ~= nil then if self.active ~= oldActive and self.callback ~= nil then
self.callback( self ) self.callback( self )
end end
-- for _, rect in ipairs( self.focusBounds ) do
-- RL.DrawRectangleLines( rect, RL.RED )
-- end
end end
function ToggleGroup:setPosition( pos ) function ToggleGroup:setPosition( pos )
@@ -658,7 +718,7 @@ end
function CheckBox:draw() function CheckBox:draw()
local oldChecked = self.checked local oldChecked = self.checked
self.checked = RL.GuiCheckBox( self.bounds, self.text, self.checked ) _, self.checked = RL.GuiCheckBox( self.bounds, self.text, self.checked )
if self.checked ~= oldChecked and self.callback ~= nil then if self.checked ~= oldChecked and self.callback ~= nil then
self.callback( self ) self.callback( self )
@@ -702,7 +762,7 @@ end
function ComboBox:draw() function ComboBox:draw()
local oldActive = self.active local oldActive = self.active
self.active = RL.GuiComboBox( self.bounds, self.text, self.active ) _, self.active = RL.GuiComboBox( self.bounds, self.text, self.active )
if self.active ~= oldActive and self.callback ~= nil then if self.active ~= oldActive and self.callback ~= nil then
self.callback( self ) self.callback( self )
@@ -768,11 +828,11 @@ function DropdownBox:process()
end end
function DropdownBox:draw() function DropdownBox:draw()
local pressed = false local result = 0
pressed, self.active = RL.GuiDropdownBox( self.bounds, self.text, self.active, self.editMode ) result, self.active = RL.GuiDropdownBox( self.bounds, self.text, self.active, self.editMode )
if pressed then if result == 1 then
self.editMode = not self.editMode self.editMode = not self.editMode
if not self.editMode and self.callback ~= nil then if not self.editMode and self.callback ~= nil then
@@ -815,12 +875,12 @@ function Spinner:process()
end end
function Spinner:draw() function Spinner:draw()
local pressed = false local result = 0
local oldValue = self.value local oldValue = self.value
pressed, self.value = RL.GuiSpinner( self.bounds, self.text, self.value, self.minValue, self.maxValue, self.editMode ) result, self.value = RL.GuiSpinner( self.bounds, self.text, self.value, self.minValue, self.maxValue, self.editMode )
if pressed then if result == 1 then
self.editMode = not self.editMode self.editMode = not self.editMode
end end
@@ -863,12 +923,12 @@ function ValueBox:process()
end end
function ValueBox:draw() function ValueBox:draw()
local pressed = false local result = 0
local oldValue = self.value local oldValue = self.value
pressed, self.value = RL.GuiValueBox( self.bounds, self.text, self.value, self.minValue, self.maxValue, self.editMode ) result, self.value = RL.GuiValueBox( self.bounds, self.text, self.value, self.minValue, self.maxValue, self.editMode )
if pressed then if result == 1 then
self.editMode = not self.editMode self.editMode = not self.editMode
end end
@@ -910,19 +970,19 @@ function TextBox:process()
end end
function TextBox:draw() function TextBox:draw()
local pressed = false local result = 0
if self.scissorMode then if self.scissorMode then
RL.BeginScissorMode( self.bounds ) RL.BeginScissorMode( self.bounds )
end end
pressed, self.text = RL.GuiTextBox( self.bounds, self.text, self.textSize, self.editMode ) result, self.text = RL.GuiTextBox( self.bounds, self.text, self.textSize, self.editMode )
if self.scissorMode then if self.scissorMode then
RL.EndScissorMode() RL.EndScissorMode()
end end
if pressed then if result == 1 then
self.editMode = not self.editMode self.editMode = not self.editMode
if not self.editMode and self.callback ~= nil then if not self.editMode and self.callback ~= nil then
@@ -936,51 +996,6 @@ function TextBox:setPosition( pos )
self.bounds.y = pos.y self.bounds.y = pos.y
end end
-- TextBoxMulti.
-- Text Box control with multiple lines
TextBoxMulti = {}
TextBoxMulti.__index = TextBoxMulti
function TextBoxMulti:new( bounds, text, textSize, editMode, callback )
local object = setmetatable( {}, TextBoxMulti )
object.bounds = bounds:clone()
object.text = text
object.textSize = textSize
object.editMode = editMode
object.callback = callback
object.visible = true
table.insert( Raygui.elements, object )
return object
end
function TextBoxMulti:process()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end
function TextBoxMulti:draw()
local pressed = false
pressed, self.text = RL.GuiTextBoxMulti( self.bounds, self.text, self.textSize, self.editMode )
if pressed then
self.editMode = not self.editMode
if not self.editMode and self.callback ~= nil then
self.callback( self )
end
end
end
function TextBoxMulti:setPosition( pos )
self.bounds.x = pos.x
self.bounds.y = pos.y
end
-- Slider. -- Slider.
--- Slider control --- Slider control
@@ -1012,10 +1027,14 @@ end
function Slider:draw() function Slider:draw()
local oldValue = self.value local oldValue = self.value
self.value = RL.GuiSlider( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue ) _, self.value = RL.GuiSlider( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue )
if self.value ~= oldValue then if self.value ~= oldValue then
self.callback( self ) Raygui.scrolling = true
if self.callback ~= nil then
self.callback( self )
end
end end
end end
@@ -1055,10 +1074,14 @@ end
function SliderBar:draw() function SliderBar:draw()
local oldValue = self.value local oldValue = self.value
self.value = RL.GuiSliderBar( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue ) _, self.value = RL.GuiSliderBar( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue )
if self.value ~= oldValue then if self.value ~= oldValue then
self.callback( self ) Raygui.scrolling = true
if self.callback ~= nil then
self.callback( self )
end
end end
end end
@@ -1098,7 +1121,7 @@ end
function ProgressBar:draw() function ProgressBar:draw()
local oldValue = self.value local oldValue = self.value
self.value = RL.GuiProgressBar( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue ) _, self.value = RL.GuiProgressBar( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue )
if self.value ~= oldValue then if self.value ~= oldValue then
self.callback( self ) self.callback( self )
@@ -1189,7 +1212,7 @@ function Grid:new( bounds, text, spacing, subdivs, callback )
object.subdivs = subdivs object.subdivs = subdivs
object.callback = callback object.callback = callback
object.cell = Vec2:new() object.mouseCell = Vec2:new()
object.visible = true object.visible = true
table.insert( Raygui.elements, object ) table.insert( Raygui.elements, object )
@@ -1202,11 +1225,13 @@ function Grid:process()
end end
function Grid:draw() function Grid:draw()
local oldCell = self.cell:clone() local oldCell = self.mouseCell:clone()
local mouseCell = {}
self.cell = Vec2:new( RL.GuiGrid( self.bounds, self.text, self.spacing, self.subdivs ) ) _, mouseCell = RL.GuiGrid( self.bounds, self.text, self.spacing, self.subdivs, self.mouseCell )
self.mouseCell = Vec2:new( mouseCell )
if oldCell ~= self.cell and self.callback ~= nil then if oldCell ~= self.mouseCell and self.callback ~= nil then
self.callback( self ) self.callback( self )
end end
end end
@@ -1251,9 +1276,13 @@ end
function ListView:draw() function ListView:draw()
local oldActive = self.active local oldActive = self.active
local oldScrollIndex = self.scrollIndex
self.active, self.scrollIndex = RL.GuiListView( self.bounds, self.text, self.scrollIndex, self.active ) _, self.scrollIndex, self.active = RL.GuiListView( self.bounds, self.text, self.scrollIndex, self.active )
if self.scrollIndex ~= oldScrollIndex then
Raygui.scrolling = true
end
if oldActive ~= self.active and self.callback ~= nil then if oldActive ~= self.active and self.callback ~= nil then
self.callback( self ) self.callback( self )
end end
@@ -1270,14 +1299,14 @@ end
ListViewEx = {} ListViewEx = {}
ListViewEx.__index = ListViewEx ListViewEx.__index = ListViewEx
function ListViewEx:new( bounds, text, focus, scrollIndex, active, callback ) function ListViewEx:new( bounds, text, scrollIndex, active, focus, callback )
local object = setmetatable( {}, ListViewEx ) local object = setmetatable( {}, ListViewEx )
object.bounds = bounds:clone() object.bounds = bounds:clone()
object.text = text object.text = text
object.focus = focus
object.scrollIndex = scrollIndex object.scrollIndex = scrollIndex
object.active = active object.active = active
object.focus = focus
object.callback = callback object.callback = callback
object.visible = true object.visible = true
@@ -1296,9 +1325,13 @@ end
function ListViewEx:draw() function ListViewEx:draw()
local oldActive = self.active local oldActive = self.active
local oldScrollIndex = self.scrollIndex
self.active, self.scrollIndex, self.focus = RL.GuiListViewEx( self.bounds, self.text, self.focus, self.scrollIndex, self.active ) _, self.scrollIndex, self.active, self.focus = RL.GuiListViewEx( self.bounds, self.text, self.scrollIndex, self.active, self.focus )
if self.scrollIndex ~= oldScrollIndex then
Raygui.scrolling = true
end
if oldActive ~= self.active and self.callback ~= nil then if oldActive ~= self.active and self.callback ~= nil then
self.callback( self ) self.callback( self )
end end
@@ -1421,24 +1454,41 @@ function ColorPicker:new( bounds, text, color, callback )
object.callback = callback object.callback = callback
object.visible = true object.visible = true
object.focusBounds = Rect:new()
object:updateFocusBounds()
table.insert( Raygui.elements, object ) table.insert( Raygui.elements, object )
return object return object
end end
function ColorPicker:process() function ColorPicker:process()
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.focusBounds )
end
function ColorPicker:updateFocusBounds()
local boundsHue = Rect:new(
self.bounds.x + self.bounds.width + RL.GuiGetStyle( RL.COLORPICKER, RL.HUEBAR_PADDING ),
self.bounds.y,
RL.GuiGetStyle( RL.COLORPICKER, RL.HUEBAR_WIDTH ),
self.bounds.height
)
self.focusBounds = self.bounds:fit( boundsHue )
end end
function ColorPicker:draw() function ColorPicker:draw()
local oldColor = self.color:clone() local oldColor = self.color:clone()
local color = RL.GuiColorPicker( self.bounds, self.text, self.color ) local _, color = RL.GuiColorPicker( self.bounds, self.text, self.color )
self.color = Color:new( color ) self.color = Color:new( color )
if oldColor ~= self.color and self.callback ~= nil then if self.color ~= oldColor then
self.callback( self ) Raygui.scrolling = true
if self.callback ~= nil then
self.callback( self )
end
end end
end end
@@ -1474,7 +1524,7 @@ end
function ColorPanel:draw() function ColorPanel:draw()
local oldColor = self.color:clone() local oldColor = self.color:clone()
local color = RL.GuiColorPanel( self.bounds, self.text, self.color ) local _, color = RL.GuiColorPanel( self.bounds, self.text, self.color )
self.color = Color:new( color ) self.color = Color:new( color )
@@ -1515,10 +1565,14 @@ end
function ColorBarAlpha:draw() function ColorBarAlpha:draw()
local oldAlpha = self.alpha local oldAlpha = self.alpha
self.alpha = RL.GuiColorBarAlpha( self.bounds, self.text, self.alpha ) _, self.alpha = RL.GuiColorBarAlpha( self.bounds, self.text, self.alpha )
if self.alpha ~= oldAlpha and self.callback ~= nil then if self.alpha ~= oldAlpha then
self.callback( self ) Raygui.scrolling = true
if self.callback ~= nil then
self.callback( self )
end
end end
end end
@@ -1554,10 +1608,14 @@ end
function ColorBarHue:draw() function ColorBarHue:draw()
local oldValue = self.value local oldValue = self.value
self.value = RL.GuiColorBarHue( self.bounds, self.text, self.value ) _, self.value = RL.GuiColorBarHue( self.bounds, self.text, self.value )
if self.value ~= oldValue and self.callback ~= nil then if self.value ~= oldValue then
self.callback( self ) Raygui.scrolling = true
if self.callback ~= nil then
self.callback( self )
end
end end
end end
@@ -1572,6 +1630,7 @@ Raygui.WindowBox = WindowBox
Raygui.GroupBox = GroupBox Raygui.GroupBox = GroupBox
Raygui.Line = Line Raygui.Line = Line
Raygui.Panel = Panel Raygui.Panel = Panel
Raygui.GuiTabBar = GuiTabBar
Raygui.ScrollPanel = ScrollPanel Raygui.ScrollPanel = ScrollPanel
Raygui.Label = Label Raygui.Label = Label
@@ -1585,7 +1644,6 @@ Raygui.DropdownBox = DropdownBox
Raygui.Spinner = Spinner Raygui.Spinner = Spinner
Raygui.ValueBox = ValueBox Raygui.ValueBox = ValueBox
Raygui.TextBox = TextBox Raygui.TextBox = TextBox
Raygui.TextBoxMulti = TextBoxMulti
Raygui.Slider = Slider Raygui.Slider = Slider
Raygui.SliderBar = SliderBar Raygui.SliderBar = SliderBar
Raygui.ProgressBar = ProgressBar Raygui.ProgressBar = ProgressBar

View File

@@ -3,6 +3,8 @@ if table.unpack == nil then
table.unpack = unpack table.unpack = unpack
end end
local Vector2 = require( "vector2" )
Rectangle = {} Rectangle = {}
Rectangle.meta = { Rectangle.meta = {
@@ -34,7 +36,7 @@ Rectangle.meta = {
__idiv = function( r, v ) __idiv = function( r, v )
return Rectangle:new( r.x // v, r.y // v, r.width // v, r.height // v ) return Rectangle:new( r.x // v, r.y // v, r.width // v, r.height // v )
end, end,
__len = function( _ ) __len = function()
return 4 return 4
end, end,
__eq = function( r1, r2 ) __eq = function( r1, r2 )
@@ -108,6 +110,17 @@ function Rectangle:area()
return self.width * self.height return self.width * self.height
end end
function Rectangle:fit( rec )
local pos = Vector2:new( math.min( self.x, rec.x ), math.min( self.y, rec.y ) )
return Rectangle:new(
pos.x,
pos.y,
math.max( self.x + self.width - pos.x, rec.x + rec.width - pos.x ),
math.max( self.y + self.height - pos.y, rec.y + rec.height - pos.y )
)
end
function Rectangle:checkCollisionRec( rec ) function Rectangle:checkCollisionRec( rec )
return RL.CheckCollisionRecs( self, rec ) return RL.CheckCollisionRecs( self, rec )
end end

View File

@@ -30,7 +30,7 @@ Vector2.meta = {
__unm = function( v ) __unm = function( v )
return Vector2:new( -v.x, -v.y ) return Vector2:new( -v.x, -v.y )
end, end,
__len = function( _ ) __len = function()
return 2 return 2
end, end,
__eq = function( v1, v2 ) __eq = function( v1, v2 )

View File

@@ -30,7 +30,7 @@ Vector3.meta = {
__unm = function( v ) __unm = function( v )
return Vector3:new( -v.x, -v.y, -v.z ) return Vector3:new( -v.x, -v.y, -v.z )
end, end,
__len = function( _ ) __len = function()
return 3 return 3
end, end,
__eq = function( v1, v2 ) __eq = function( v1, v2 )

File diff suppressed because it is too large Load Diff

View File

@@ -1,47 +1,60 @@
#pragma once #pragma once
/* Global. */ /* Global gui state control functions. */
int lguiGuiEnable( lua_State *L ); int lguiGuiEnable( lua_State *L );
int lguiGuiDisable( lua_State *L ); int lguiGuiDisable( lua_State *L );
int lguiGuiLock( lua_State *L ); int lguiGuiLock( lua_State *L );
int lguiGuiUnlock( lua_State *L ); int lguiGuiUnlock( lua_State *L );
int lguiGuiIsLocked( lua_State *L ); int lguiGuiIsLocked( lua_State *L );
int lguiGuiFade( lua_State *L ); int lguiGuiSetAlpha( lua_State *L );
int lguiGuiSetState( lua_State *L ); int lguiGuiSetState( lua_State *L );
int lguiGuiGetState( lua_State *L ); int lguiGuiGetState( lua_State *L );
/* Font. */ /* Font set/get functions. */
int lguiGuiSetFont( lua_State *L ); int lguiGuiSetFont( lua_State *L );
int lguiGuiGetFont( lua_State *L ); int lguiGuiGetFont( lua_State *L );
/* Style */ /* Style set/get functions. */
int lguiGuiSetStyle( lua_State *L ); int lguiGuiSetStyle( lua_State *L );
int lguiGuiGetStyle( lua_State *L ); int lguiGuiGetStyle( lua_State *L );
/* Container. */ /* Styles loading functions. */
int lguiGuiLoadStyle( lua_State *L );
int lguiGuiLoadStyleDefault( lua_State *L );
/* Tooltips management functions. */
int lguiGuiEnableTooltip( lua_State *L );
int lguiGuiDisableTooltip( lua_State *L );
int lguiGuiSetTooltip( lua_State *L );
/* Icons functionality. */
int lguiGuiIconText( lua_State *L );
int lguiGuiSetIconScale( lua_State *L );
int lguiGuiGetIcons( lua_State *L );
int lguiGuiLoadIcons( lua_State *L );
int lguiGuiDrawIcon( lua_State *L );
/* Container/separator controls, useful for controls organization. */
int lguiGuiWindowBox( lua_State *L ); int lguiGuiWindowBox( lua_State *L );
int lguiGuiGroupBox( lua_State *L ); int lguiGuiGroupBox( lua_State *L );
int lguiGuiLine( lua_State *L ); int lguiGuiLine( lua_State *L );
int lguiGuiPanel( lua_State *L ); int lguiGuiPanel( lua_State *L );
int lguiGuiTabBar( lua_State *L );
int lguiGuiScrollPanel( lua_State *L ); int lguiGuiScrollPanel( lua_State *L );
/* Basic. */ /* Basic controls set. */
int lguiGuiLabel( lua_State *L ); int lguiGuiLabel( lua_State *L );
int lguiGuiButton( lua_State *L ); int lguiGuiButton( lua_State *L );
int lguiGuiLabelButton( lua_State *L ); int lguiGuiLabelButton( lua_State *L );
int lguiGuiToggle( lua_State *L ); int lguiGuiToggle( lua_State *L );
int lguiGuiToggleGroup( lua_State *L ); int lguiGuiToggleGroup( lua_State *L );
int lguiGuiToggleSlider( lua_State *L );
int lguiGuiCheckBox( lua_State *L ); int lguiGuiCheckBox( lua_State *L );
int lguiGuiComboBox( lua_State *L ); int lguiGuiComboBox( lua_State *L );
int lguiGuiTextBox( lua_State *L ); int lguiGuiDropdownBox( lua_State *L );
int lguiGuiTextBoxMulti( lua_State *L );
int lguiGuiSpinner( lua_State *L ); int lguiGuiSpinner( lua_State *L );
int lguiGuiValueBox( lua_State *L ); int lguiGuiValueBox( lua_State *L );
int lguiGuiTextBox( lua_State *L );
int lguiGuiSlider( lua_State *L ); int lguiGuiSlider( lua_State *L );
int lguiGuiSliderBar( lua_State *L ); int lguiGuiSliderBar( lua_State *L );
int lguiGuiProgressBar( lua_State *L ); int lguiGuiProgressBar( lua_State *L );
int lguiGuiScrollBar( lua_State *L );
int lguiGuiDropdownBox( lua_State *L );
int lguiGuiStatusBar( lua_State *L ); int lguiGuiStatusBar( lua_State *L );
int lguiGuiDummyRec( lua_State *L ); int lguiGuiDummyRec( lua_State *L );
int lguiGuiGrid( lua_State *L ); int lguiGuiGrid( lua_State *L );
/* Advanced. */ /* Advance controls set. */
int lguiGuiListView( lua_State *L ); int lguiGuiListView( lua_State *L );
int lguiGuiListViewEx( lua_State *L ); int lguiGuiListViewEx( lua_State *L );
int lguiGuiMessageBox( lua_State *L ); int lguiGuiMessageBox( lua_State *L );
@@ -50,13 +63,5 @@ int lguiGuiColorPicker( lua_State *L );
int lguiGuiColorPanel( lua_State *L ); int lguiGuiColorPanel( lua_State *L );
int lguiGuiColorBarAlpha( lua_State *L ); int lguiGuiColorBarAlpha( lua_State *L );
int lguiGuiColorBarHue( lua_State *L ); int lguiGuiColorBarHue( lua_State *L );
/* Styles loading functions */ int lguiGuiColorPickerHSV( lua_State *L );
int lguiGuiLoadStyle( lua_State *L ); int lguiGuiColorPanelHSV( lua_State *L );
int lguiGuiLoadStyleDefault( lua_State *L );
/* Icons. */
int lguiGuiIconText( lua_State *L );
int lguiGuiDrawIcon( lua_State *L );
int lguiGuiSetIconScale( lua_State *L );
int lguiGuiSetIconPixel( lua_State *L );
int lguiGuiClearIconPixel( lua_State *L );
int lguiGuiCheckIconPixel( lua_State *L );

View File

@@ -677,10 +677,18 @@ static void defineGlobals() {
assignGlobalInt( STATE_FOCUSED, "STATE_FOCUSED" ); assignGlobalInt( STATE_FOCUSED, "STATE_FOCUSED" );
assignGlobalInt( STATE_PRESSED, "STATE_PRESSED" ); assignGlobalInt( STATE_PRESSED, "STATE_PRESSED" );
assignGlobalInt( STATE_DISABLED, "STATE_DISABLED" ); assignGlobalInt( STATE_DISABLED, "STATE_DISABLED" );
/* GuiTextAlignment */ /* GuiControlTextAlignment */
assignGlobalInt( TEXT_ALIGN_LEFT, "TEXT_ALIGN_LEFT" ); assignGlobalInt( TEXT_ALIGN_LEFT, "TEXT_ALIGN_LEFT" );
assignGlobalInt( TEXT_ALIGN_CENTER, "TEXT_ALIGN_CENTER" ); assignGlobalInt( TEXT_ALIGN_CENTER, "TEXT_ALIGN_CENTER" );
assignGlobalInt( TEXT_ALIGN_RIGHT, "TEXT_ALIGN_RIGHT" ); assignGlobalInt( TEXT_ALIGN_RIGHT, "TEXT_ALIGN_RIGHT" );
/* GuiControlTextAlignmentVertical */
assignGlobalInt( TEXT_ALIGN_TOP, "TEXT_ALIGN_TOP" );
assignGlobalInt( TEXT_ALIGN_MIDDLE, "TEXT_ALIGN_MIDDLE" );
assignGlobalInt( TEXT_ALIGN_BOTTOM, "TEXT_ALIGN_BOTTOM" );
/* GuiControlTextWrapMode */
assignGlobalInt( TEXT_WRAP_NONE, "TEXT_WRAP_NONE" );
assignGlobalInt( TEXT_WRAP_CHAR, "TEXT_WRAP_CHAR" );
assignGlobalInt( TEXT_WRAP_WORD, "TEXT_WRAP_WORD" );
/* GuiControl */ /* GuiControl */
assignGlobalInt( DEFAULT, "DEFAULT" ); assignGlobalInt( DEFAULT, "DEFAULT" );
assignGlobalInt( LABEL, "LABEL" ); // Used also for: LABELBUTTON assignGlobalInt( LABEL, "LABEL" ); // Used also for: LABELBUTTON
@@ -714,12 +722,14 @@ static void defineGlobals() {
assignGlobalInt( BORDER_WIDTH, "BORDER_WIDTH" ); assignGlobalInt( BORDER_WIDTH, "BORDER_WIDTH" );
assignGlobalInt( TEXT_PADDING, "TEXT_PADDING" ); assignGlobalInt( TEXT_PADDING, "TEXT_PADDING" );
assignGlobalInt( TEXT_ALIGNMENT, "TEXT_ALIGNMENT" ); assignGlobalInt( TEXT_ALIGNMENT, "TEXT_ALIGNMENT" );
assignGlobalInt( RESERVED, "RESERVED" );
/* GuiDefaultProperty */ /* GuiDefaultProperty */
assignGlobalInt( TEXT_SIZE, "TEXT_SIZE" ); // Text size (glyphs max height) assignGlobalInt( TEXT_SIZE, "TEXT_SIZE" ); // Text size (glyphs max height)
assignGlobalInt( TEXT_SPACING, "TEXT_SPACING" ); // Text spacing between glyphs assignGlobalInt( TEXT_SPACING, "TEXT_SPACING" ); // Text spacing between glyphs
assignGlobalInt( LINE_COLOR, "LINE_COLOR" ); // Line control color assignGlobalInt( LINE_COLOR, "LINE_COLOR" ); // Line control color
assignGlobalInt( BACKGROUND_COLOR, "BACKGROUND_COLOR" ); // Background color assignGlobalInt( BACKGROUND_COLOR, "BACKGROUND_COLOR" ); // Background color
assignGlobalInt( TEXT_LINE_SPACING, "TEXT_LINE_SPACING" ); // Text spacing between lines
assignGlobalInt( TEXT_ALIGNMENT_VERTICAL, "TEXT_ALIGNMENT_VERTICAL" ); // Text vertical alignment inside text bounds (after border and padding)
assignGlobalInt( TEXT_WRAP_MODE, "TEXT_WRAP_MODE" ); // Text wrap-mode inside text bounds
/* GuiToggleProperty */ /* GuiToggleProperty */
assignGlobalInt( GROUP_PADDING, "GROUP_PADDING" ); // ToggleGroup separation between toggles assignGlobalInt( GROUP_PADDING, "GROUP_PADDING" ); // ToggleGroup separation between toggles
/* GuiSliderProperty */ /* GuiSliderProperty */
@@ -742,9 +752,8 @@ static void defineGlobals() {
/* GuiDropdownBoxProperty */ /* GuiDropdownBoxProperty */
assignGlobalInt( ARROW_PADDING, "ARROW_PADDING" ); // DropdownBox arrow separation from border and items assignGlobalInt( ARROW_PADDING, "ARROW_PADDING" ); // DropdownBox arrow separation from border and items
assignGlobalInt( DROPDOWN_ITEMS_SPACING, "DROPDOWN_ITEMS_SPACING" ); // DropdownBox items separation assignGlobalInt( DROPDOWN_ITEMS_SPACING, "DROPDOWN_ITEMS_SPACING" ); // DropdownBox items separation
/* GuiTextBoxProperty */ /* TextBox/TextBoxMulti/ValueBox/Spinner */
assignGlobalInt( TEXT_INNER_PADDING, "TEXT_INNER_PADDING" ); // TextBox/TextBoxMulti/ValueBox/Spinner inner text padding assignGlobalInt( TEXT_READONLY, "TEXT_READONLY" ); // TextBox in read-only mode: 0-text editable, 1-text no-editable
assignGlobalInt( TEXT_LINES_SPACING, "TEXT_LINES_SPACING" ); // TextBoxMulti lines separation
/* GuiSpinnerProperty */ /* GuiSpinnerProperty */
assignGlobalInt( SPIN_BUTTON_WIDTH, "SPIN_BUTTON_WIDTH" ); // Spinner left/right buttons width assignGlobalInt( SPIN_BUTTON_WIDTH, "SPIN_BUTTON_WIDTH" ); // Spinner left/right buttons width
assignGlobalInt( SPIN_BUTTON_SPACING, "SPIN_BUTTON_SPACING" ); // Spinner buttons separation assignGlobalInt( SPIN_BUTTON_SPACING, "SPIN_BUTTON_SPACING" ); // Spinner buttons separation
@@ -2204,48 +2213,61 @@ void luaRegister() {
assingGlobalFunction( "QuaternionEquals", lmathQuaternionEquals ); assingGlobalFunction( "QuaternionEquals", lmathQuaternionEquals );
/* Gui. */ /* Gui. */
/* Global. */ /* Global gui state control functions. */
assingGlobalFunction( "GuiEnable", lguiGuiEnable ); assingGlobalFunction( "GuiEnable", lguiGuiEnable );
assingGlobalFunction( "GuiDisable", lguiGuiDisable ); assingGlobalFunction( "GuiDisable", lguiGuiDisable );
assingGlobalFunction( "GuiLock", lguiGuiLock ); assingGlobalFunction( "GuiLock", lguiGuiLock );
assingGlobalFunction( "GuiUnlock", lguiGuiUnlock ); assingGlobalFunction( "GuiUnlock", lguiGuiUnlock );
assingGlobalFunction( "GuiIsLocked", lguiGuiIsLocked ); assingGlobalFunction( "GuiIsLocked", lguiGuiIsLocked );
assingGlobalFunction( "GuiFade", lguiGuiFade ); assingGlobalFunction( "GuiSetAlpha", lguiGuiSetAlpha );
assingGlobalFunction( "GuiSetState", lguiGuiSetState ); assingGlobalFunction( "GuiSetState", lguiGuiSetState );
assingGlobalFunction( "GuiGetState", lguiGuiGetState ); assingGlobalFunction( "GuiGetState", lguiGuiGetState );
/* Font. */ /* Font set/get functions. */
assingGlobalFunction( "GuiSetFont", lguiGuiSetFont ); assingGlobalFunction( "GuiSetFont", lguiGuiSetFont );
assingGlobalFunction( "GuiGetFont", lguiGuiGetFont ); assingGlobalFunction( "GuiGetFont", lguiGuiGetFont );
/* Style. */ /* Style set/get functions. */
assingGlobalFunction( "GuiSetStyle", lguiGuiSetStyle ); assingGlobalFunction( "GuiSetStyle", lguiGuiSetStyle );
assingGlobalFunction( "GuiGetStyle", lguiGuiGetStyle ); assingGlobalFunction( "GuiGetStyle", lguiGuiGetStyle );
/* Container. */ /* Styles loading functions */
assingGlobalFunction( "GuiLoadStyle", lguiGuiLoadStyle );
assingGlobalFunction( "GuiLoadStyleDefault", lguiGuiLoadStyleDefault );
/* Tooltips management functions. */
assingGlobalFunction( "GuiEnableTooltip", lguiGuiEnableTooltip );
assingGlobalFunction( "GuiDisableTooltip", lguiGuiDisableTooltip );
assingGlobalFunction( "GuiSetTooltip", lguiGuiSetTooltip );
/* Icons functionality. */
assingGlobalFunction( "GuiIconText", lguiGuiIconText );
assingGlobalFunction( "GuiSetIconScale", lguiGuiSetIconScale );
assingGlobalFunction( "GuiGetIcons", lguiGuiGetIcons );
assingGlobalFunction( "GuiLoadIcons", lguiGuiLoadIcons );
assingGlobalFunction( "GuiDrawIcon", lguiGuiDrawIcon );
/* Container/separator controls, useful for controls organization. */
assingGlobalFunction( "GuiWindowBox", lguiGuiWindowBox ); assingGlobalFunction( "GuiWindowBox", lguiGuiWindowBox );
assingGlobalFunction( "GuiGroupBox", lguiGuiGroupBox ); assingGlobalFunction( "GuiGroupBox", lguiGuiGroupBox );
assingGlobalFunction( "GuiLine", lguiGuiLine ); assingGlobalFunction( "GuiLine", lguiGuiLine );
assingGlobalFunction( "GuiPanel", lguiGuiPanel ); assingGlobalFunction( "GuiPanel", lguiGuiPanel );
assingGlobalFunction( "GuiTabBar", lguiGuiTabBar );
assingGlobalFunction( "GuiScrollPanel", lguiGuiScrollPanel ); assingGlobalFunction( "GuiScrollPanel", lguiGuiScrollPanel );
/* Basic. */ /* Basic controls set. */
assingGlobalFunction( "GuiLabel", lguiGuiLabel ); assingGlobalFunction( "GuiLabel", lguiGuiLabel );
assingGlobalFunction( "GuiButton", lguiGuiButton ); assingGlobalFunction( "GuiButton", lguiGuiButton );
assingGlobalFunction( "GuiLabelButton", lguiGuiLabelButton ); assingGlobalFunction( "GuiLabelButton", lguiGuiLabelButton );
assingGlobalFunction( "GuiToggle", lguiGuiToggle ); assingGlobalFunction( "GuiToggle", lguiGuiToggle );
assingGlobalFunction( "GuiToggleGroup", lguiGuiToggleGroup ); assingGlobalFunction( "GuiToggleGroup", lguiGuiToggleGroup );
assingGlobalFunction( "GuiToggleSlider", lguiGuiToggleSlider );
assingGlobalFunction( "GuiCheckBox", lguiGuiCheckBox ); assingGlobalFunction( "GuiCheckBox", lguiGuiCheckBox );
assingGlobalFunction( "GuiComboBox", lguiGuiComboBox ); assingGlobalFunction( "GuiComboBox", lguiGuiComboBox );
assingGlobalFunction( "GuiTextBox", lguiGuiTextBox ); assingGlobalFunction( "GuiDropdownBox", lguiGuiDropdownBox );
assingGlobalFunction( "GuiTextBoxMulti", lguiGuiTextBoxMulti );
assingGlobalFunction( "GuiSpinner", lguiGuiSpinner ); assingGlobalFunction( "GuiSpinner", lguiGuiSpinner );
assingGlobalFunction( "GuiValueBox", lguiGuiValueBox ); assingGlobalFunction( "GuiValueBox", lguiGuiValueBox );
assingGlobalFunction( "GuiTextBox", lguiGuiTextBox );
assingGlobalFunction( "GuiSlider", lguiGuiSlider ); assingGlobalFunction( "GuiSlider", lguiGuiSlider );
assingGlobalFunction( "GuiSliderBar", lguiGuiSliderBar ); assingGlobalFunction( "GuiSliderBar", lguiGuiSliderBar );
assingGlobalFunction( "GuiProgressBar", lguiGuiProgressBar ); assingGlobalFunction( "GuiProgressBar", lguiGuiProgressBar );
assingGlobalFunction( "GuiScrollBar", lguiGuiScrollBar );
assingGlobalFunction( "GuiDropdownBox", lguiGuiDropdownBox );
assingGlobalFunction( "GuiStatusBar", lguiGuiStatusBar ); assingGlobalFunction( "GuiStatusBar", lguiGuiStatusBar );
assingGlobalFunction( "GuiDummyRec", lguiGuiDummyRec ); assingGlobalFunction( "GuiDummyRec", lguiGuiDummyRec );
assingGlobalFunction( "GuiGrid", lguiGuiGrid ); assingGlobalFunction( "GuiGrid", lguiGuiGrid );
/* Advanced. */ /* Advance controls set. */
assingGlobalFunction( "GuiListView", lguiGuiListView ); assingGlobalFunction( "GuiListView", lguiGuiListView );
assingGlobalFunction( "GuiListViewEx", lguiGuiListViewEx ); assingGlobalFunction( "GuiListViewEx", lguiGuiListViewEx );
assingGlobalFunction( "GuiMessageBox", lguiGuiMessageBox ); assingGlobalFunction( "GuiMessageBox", lguiGuiMessageBox );
@@ -2254,16 +2276,8 @@ void luaRegister() {
assingGlobalFunction( "GuiColorPanel", lguiGuiColorPanel ); assingGlobalFunction( "GuiColorPanel", lguiGuiColorPanel );
assingGlobalFunction( "GuiColorBarAlpha", lguiGuiColorBarAlpha ); assingGlobalFunction( "GuiColorBarAlpha", lguiGuiColorBarAlpha );
assingGlobalFunction( "GuiColorBarHue", lguiGuiColorBarHue ); assingGlobalFunction( "GuiColorBarHue", lguiGuiColorBarHue );
/* Styles loading functions */ assingGlobalFunction( "GuiColorPickerHSV", lguiGuiColorPickerHSV );
assingGlobalFunction( "GuiLoadStyle", lguiGuiLoadStyle ); assingGlobalFunction( "GuiColorPanelHSV", lguiGuiColorPanelHSV );
assingGlobalFunction( "GuiLoadStyleDefault", lguiGuiLoadStyleDefault );
/* Icons. */
assingGlobalFunction( "GuiIconText", lguiGuiIconText );
assingGlobalFunction( "GuiDrawIcon", lguiGuiDrawIcon );
assingGlobalFunction( "GuiSetIconScale", lguiGuiSetIconScale );
assingGlobalFunction( "GuiSetIconPixel", lguiGuiSetIconPixel );
assingGlobalFunction( "GuiClearIconPixel", lguiGuiClearIconPixel );
assingGlobalFunction( "GuiCheckIconPixel", lguiGuiCheckIconPixel );
/* Lights */ /* Lights */
/* Light management functions. */ /* Light management functions. */

1298
src/rgui.c

File diff suppressed because it is too large Load Diff