From 95f03bae31ab695f55c4cb4b166e0af80814d841 Mon Sep 17 00:00:00 2001 From: jussi Date: Thu, 21 Mar 2024 23:18:35 +0200 Subject: Raygui lib callbacks to single table. --- changelog | 1 + devnotes | 2 +- examples/raygui_examples/calculator.lua | 43 +- examples/raygui_extensions/main.lua | 105 ++-- examples/raygui_extensions/property_list.lua | 20 +- examples/raygui_extensions/sprite_button.lua | 12 +- examples/raygui_extensions/tree_item.lua | 6 +- examples/raygui_extensions/tree_view.lua | 16 +- examples/raygui_lib/main.lua | 149 ++++-- examples/resources/lib/raygui.lua | 747 +++++++++++++-------------- 10 files changed, 568 insertions(+), 533 deletions(-) diff --git a/changelog b/changelog index 04ee3e8..b15bebf 100644 --- a/changelog +++ b/changelog @@ -5,6 +5,7 @@ KEY CHANGES: - CHANGE: Process renamed to update to be more inline with naming of raylib and common convention. - ADDED: apiScanner.lua for searching unimplemented functions from raylib. - ADDED Automation events. + - CHANGE: Raygui lib callbacks to single table. DETAILED CHANGES: - ADDED: GetBufferElementSize and GetBufferLength. diff --git a/devnotes b/devnotes index 02f480c..9c078f3 100644 --- a/devnotes +++ b/devnotes @@ -3,7 +3,7 @@ Current { Backlog { * Raygui - * Set callbacks to single table. + * File browser. * Raygui lib * Check if could remove flickering from changing draw order by making queue for order changing and only change them after everything is drawn. diff --git a/examples/raygui_examples/calculator.lua b/examples/raygui_examples/calculator.lua index 2b3fcb1..1915c41 100644 --- a/examples/raygui_examples/calculator.lua +++ b/examples/raygui_examples/calculator.lua @@ -16,12 +16,11 @@ function Calculator:new( pos ) object.window = Gui:WindowBox( Rect:new( pos.x, pos.y, 188, 216 ), "Calculator", - -- Close callback. - function() object:setVisible( false ) end, - -- Grab callback. - function() object:set2Top() end, - -- Drag callback. - function( self ) object:setPosition( Vec2:new( self.bounds.x, self.bounds.y ) ) end + { -- Callbacks. + close = function() object:setVisible( false ) end, + grab = function() object:set2Top() end, + drag = function( self ) object:setPosition( Vec2:new( self.bounds.x, self.bounds.y ) ) end + } ) object.display = Gui:Label( Rect:new( 0, 0, 180, 20 ), @@ -31,22 +30,22 @@ function Calculator:new( pos ) object.buttons = {} local buttons = { - { "7", function() object:addNumber( 7 ) end }, - { "8", function() object:addNumber( 8 ) end }, - { "9", function() object:addNumber( 9 ) end }, - { "/", function() object:addOperation( self.OPERATIONS.DIV ) end }, - { "4", function() object:addNumber( 4 ) end }, - { "5", function() object:addNumber( 5 ) end }, - { "6", function() object:addNumber( 6 ) end }, - { "*", function() object:addOperation( self.OPERATIONS.MUL ) end }, - { "1", function() object:addNumber( 1 ) end }, - { "2", function() object:addNumber( 2 ) end }, - { "3", function() object:addNumber( 3 ) end }, - { "-", function() object:addOperation( self.OPERATIONS.SUB ) end }, - { "0", function() object:addNumber( 0 ) end }, - { "C", function() object:addOperation( self.OPERATIONS.CLEAR ) end }, - { "=", function() object:addOperation( self.OPERATIONS.EQUAL ) end }, - { "+", function() object:addOperation( self.OPERATIONS.ADD ) end }, + { "7", { pressed = function() object:addNumber( 7 ) end } }, + { "8", { pressed = function() object:addNumber( 8 ) end } }, + { "9", { pressed = function() object:addNumber( 9 ) end } }, + { "/", { pressed = function() object:addOperation( self.OPERATIONS.DIV ) end } }, + { "4", { pressed = function() object:addNumber( 4 ) end } }, + { "5", { pressed = function() object:addNumber( 5 ) end } }, + { "6", { pressed = function() object:addNumber( 6 ) end } }, + { "*", { pressed = function() object:addOperation( self.OPERATIONS.MUL ) end } }, + { "1", { pressed = function() object:addNumber( 1 ) end } }, + { "2", { pressed = function() object:addNumber( 2 ) end } }, + { "3", { pressed = function() object:addNumber( 3 ) end } }, + { "-", { pressed = function() object:addOperation( self.OPERATIONS.SUB ) end } }, + { "0", { pressed = function() object:addNumber( 0 ) end } }, + { "C", { pressed = function() object:addOperation( self.OPERATIONS.CLEAR ) end } }, + { "=", { pressed = function() object:addOperation( self.OPERATIONS.EQUAL ) end } }, + { "+", { pressed = function() object:addOperation( self.OPERATIONS.ADD ) end } }, } local rowCount = 4 local buttonRect = Rect:new( 5, 64, 40, 32 ) diff --git a/examples/raygui_extensions/main.lua b/examples/raygui_extensions/main.lua index 6efa18d..cdfd7b8 100644 --- a/examples/raygui_extensions/main.lua +++ b/examples/raygui_extensions/main.lua @@ -55,13 +55,13 @@ local function addSpriteButtons() local buttonSize = Vec2:new( 216, 32 ) local bounds = Rect:new( winSize.x / 2 - buttonSize.x / 2, 200, 216, 32 ) local gap = buttonSize.y + 2 - addButton( bounds, "Start New Game", function() print( "New Game!" ) end ) + addButton( bounds, "Start New Game", { pressed = function() print( "New Game!" ) end } ) bounds.y = bounds.y + gap - addButton( bounds, "Load Game", function() print( "Load Game!" ) end ) + addButton( bounds, "Load Game", { pressed = function() print( "Load Game!" ) end } ) bounds.y = bounds.y + gap - addButton( bounds, "Options", function() print( "Options!" ) end ) + addButton( bounds, "Options", { pressed = function() print( "Options!" ) end } ) bounds.y = bounds.y + gap - addButton( bounds, "Quit", function() RL.CloseWindow() end ) + addButton( bounds, "Quit", { pressed = function() RL.CloseWindow() end } ) end local function getTextValue( text ) @@ -74,10 +74,10 @@ local function addPropertyList() PropertyList = Gui:PropertyList( Rect:new( 20, 20, 256, 328 ), "Property List", - nil, -- Callback. - function( self ) Gui:set2Top( self ) end, -- Grab callback. - nil, -- Drag callback. - { + { -- Callbacks. + grab = function( self ) Gui:set2Top( self ) end, + }, + { -- Styles. properties = { -- { RL.SCROLLBAR, RL.ARROWS_VISIBLE, RL.ARROWS_VISIBLE }, { RL.LISTVIEW, RL.BORDER_COLOR_FOCUSED, RL.GuiGetStyle( RL.LISTVIEW, RL.BORDER_COLOR_NORMAL ) }, @@ -106,11 +106,13 @@ local function addPropertyList() cat.dest.x, 32, false, - function( self ) - self.value = getTextValue( self.text ) - self.text = tostring( self.value ) - cat.dest.x = self.value - end, + { -- Callbacks. + edit = function( self ) + self.value = getTextValue( self.text ) + self.text = tostring( self.value ) + cat.dest.x = self.value + end + }, nil, "Position X" ), transformGroup, true ) @@ -119,11 +121,13 @@ local function addPropertyList() cat.dest.y, 32, false, - function( self ) - self.value = getTextValue( self.text ) - self.text = tostring( self.value ) - cat.dest.y = self.value - end, + { -- Callbacks. + edit = function( self ) + self.value = getTextValue( self.text ) + self.text = tostring( self.value ) + cat.dest.y = self.value + end + }, nil, "Position Y" ), transformGroup ) @@ -137,11 +141,13 @@ local function addPropertyList() cat.dest.x, 32, false, - function( self ) - self.value = getTextValue( self.text ) - self.text = tostring( self.value ) - cat.origin.x = self.value - end, + { -- Callbacks. + edit = function( self ) + self.value = getTextValue( self.text ) + self.text = tostring( self.value ) + cat.origin.x = self.value + end + }, nil, "Origin X" ), transformGroup, true ) @@ -150,11 +156,13 @@ local function addPropertyList() cat.dest.y, 32, false, - function( self ) - self.value = getTextValue( self.text ) - self.text = tostring( self.value ) - cat.origin.y = self.value - end, + { -- Callbacks. + edit = function( self ) + self.value = getTextValue( self.text ) + self.text = tostring( self.value ) + cat.origin.y = self.value + end + }, nil, "Origin Y" ), transformGroup ) @@ -166,11 +174,13 @@ local function addPropertyList() 0, 0, 360, - function( self ) - self.value = Util.round( self.value ) - cat.rotation = self.value - self.textRight = self.value - end, + { -- Callbacks. + edit = function( self ) + self.value = Util.round( self.value ) + cat.rotation = self.value + self.textRight = self.value + end + }, nil, "Rotation angle" ), transformGroup ) @@ -179,7 +189,9 @@ local function addPropertyList() Rect:new( 0, 0, 20, 20 ), "Flipped", cat.flipped, - function( self ) cat.flipped = self.checked end, + { -- Callbacks. + pressed = function( self ) cat.flipped = self.checked end + }, nil, "Flips the image" ), transformGroup ) @@ -192,7 +204,9 @@ local function addPropertyList() Rect:new( 0, 0, 20, 20 ), "Visible", cat.visible, - function( self ) cat.visible = self.checked end, + { -- Callbacks. + pressed = function( self ) cat.visible = self.checked end + }, { properties = { { RL.CHECKBOX, RL.TEXT_ALIGNMENT, RL.TEXT_ALIGN_RIGHT }, @@ -206,7 +220,9 @@ local function addPropertyList() Rect:new( 0, 0, 128, 128 ), "Color Picker", Color:new(), - function( self ) cat.tint = self.color end + { -- Callbacks. + edit = function( self ) cat.tint = self.color end + } ), tintGroup ) PropertyList:addControl( PropertyList.gui:Line( @@ -219,7 +235,9 @@ local function addPropertyList() "Dog\nGiraffe\nLion\nHorse", 0, false, - function( self ) print( self:getItem( self.active ) ) end + { -- Callbacks. + select = function( self ) print( self:getItem( self.active ) ) end + } ) ) local test = PropertyList:addGroup( "Test", false ) @@ -229,7 +247,9 @@ local function addPropertyList() Rect:new( 128, 0, 20, 20 ), i.."_Visible", false, - function( self ) print( "Checked" ) end, + { -- Callbacks. + pressed = function( self ) print( "Checked" ) end + }, { properties = { -- { RL.CHECKBOX, RL.TEXT_ALIGNMENT, RL.TEXT_ALIGN_LEFT }, @@ -250,10 +270,11 @@ local function addTreeView() TreeView = Gui:TreeView( Rect:new( 600, 20, 256, 328 ), "Tree View", - function( controls ) selected( controls ) end, -- Callback. - function( self ) Gui:set2Top( self ) end, -- Grab callback. - nil, -- Drag callback. - { + { -- Callbacks. + select = function( controls ) selected( controls ) end, + grab = function( self ) Gui:set2Top( self ) end, + }, + { -- Styles. properties = { -- { RL.SCROLLBAR, RL.ARROWS_VISIBLE, RL.ARROWS_VISIBLE }, { RL.LISTVIEW, RL.BORDER_COLOR_FOCUSED, RL.GuiGetStyle( RL.LISTVIEW, RL.BORDER_COLOR_NORMAL ) }, diff --git a/examples/raygui_extensions/property_list.lua b/examples/raygui_extensions/property_list.lua index 492f394..6d218e6 100644 --- a/examples/raygui_extensions/property_list.lua +++ b/examples/raygui_extensions/property_list.lua @@ -1,7 +1,7 @@ local PropertyList = {} PropertyList.__index = PropertyList -function PropertyList:new( bounds, text, callback, grabCallback, dragCallback, styles, tooltip ) +function PropertyList:new( bounds, text, callbacks, styles, tooltip ) local object = setmetatable( {}, self ) object._gui = nil @@ -12,9 +12,7 @@ function PropertyList:new( bounds, text, callback, grabCallback, dragCallback, s object.text = text object.scroll = Vec2:new() object.view = Rect:new() - object.callback = callback - object.grabCallback = grabCallback - object.dragCallback = dragCallback + object.callbacks = callbacks -- scroll, grab, drag. object.styles = styles object.tooltip = tooltip @@ -140,8 +138,10 @@ function PropertyList:addGroup( name, active, group ) self:getDefaultBounds(), setGroupText( name, active ), active, - function( this ) this.text = setGroupText( name, this.active ) self:updateContent() end, - { + { -- Callbacks. + pressed = function( this ) this.text = setGroupText( name, this.active ) self:updateContent() end, + }, + { -- Styles. properties = { { RL.TOGGLE, RL.TEXT_ALIGNMENT, RL.TEXT_ALIGN_LEFT } } @@ -194,8 +194,8 @@ function PropertyList:draw() self:updateMouseOffset() self.gui.view:set( -self.scroll.x, -self.scroll.y, self.view.width, self.view.height ) - if self.callback ~= nil then - self.callback( self ) + if self.callbacks.scroll ~= nil then + self.callbacks.scroll( self ) end end @@ -250,8 +250,8 @@ function PropertyList:setSize( size ) end function PropertyList:register( gui ) - function gui:PropertyList( bounds, text, callback, grabCallback, dragCallback, styles, tooltip ) - return self:addControl( PropertyList:new( bounds, text, callback, grabCallback, dragCallback, styles, tooltip ) ) + function gui:PropertyList( bounds, text, callbacks, styles, tooltip ) + return self:addControl( PropertyList:new( bounds, text, callbacks, styles, tooltip ) ) end end diff --git a/examples/raygui_extensions/sprite_button.lua b/examples/raygui_extensions/sprite_button.lua index ba4b704..8a3027b 100644 --- a/examples/raygui_extensions/sprite_button.lua +++ b/examples/raygui_extensions/sprite_button.lua @@ -1,7 +1,7 @@ local SpriteButton = {} SpriteButton.__index = SpriteButton -function SpriteButton:new( bounds, text, texture, nPatchNormal, nPatchPressed, callback, styles, tooltip ) +function SpriteButton:new( bounds, text, texture, nPatchNormal, nPatchPressed, callbacks, styles, tooltip ) local object = setmetatable( {}, self ) object._gui = nil @@ -10,7 +10,7 @@ function SpriteButton:new( bounds, text, texture, nPatchNormal, nPatchPressed, c object.buttonTexture = texture object.nPatchNormal = nPatchNormal object.nPatchPressed = nPatchPressed - object.callback = callback + object.callbacks = callbacks -- pressed. object.styles = styles object.tooltip = tooltip @@ -33,8 +33,8 @@ function SpriteButton:draw() local result = RL.GuiLabelButton( self.bounds, self.text ) - if result == 1 and self.callback ~= nil and self._gui:clickedInBounds( self.bounds ) then - self.callback( self ) + if result == 1 and self.callbacks.pressed ~= nil and self._gui:clickedInBounds( self.bounds ) then + self.callbacks.pressed( self ) end end @@ -44,8 +44,8 @@ function SpriteButton:setPosition( pos ) end function SpriteButton:register( gui ) - function gui:SpriteButton( bounds, text, texture, nPatchNormal, nPatchPressed, callback, styles, tooltip ) - return self:addControl( SpriteButton:new( bounds, text, texture, nPatchNormal, nPatchPressed, callback, styles, tooltip ) ) + function gui:SpriteButton( bounds, text, texture, nPatchNormal, nPatchPressed, callbacks, styles, tooltip ) + return self:addControl( SpriteButton:new( bounds, text, texture, nPatchNormal, nPatchPressed, callbacks, styles, tooltip ) ) end end diff --git a/examples/raygui_extensions/tree_item.lua b/examples/raygui_extensions/tree_item.lua index 043e348..1986faf 100644 --- a/examples/raygui_extensions/tree_item.lua +++ b/examples/raygui_extensions/tree_item.lua @@ -9,7 +9,7 @@ function TreeItem:new( bounds, text, callbacks, styles, tooltip ) object.bounds = bounds:clone() object.text = text - object.callbacks = callbacks -- toggle, open. + object.callbacks = callbacks -- select, open. object.controls = {} @@ -68,8 +68,8 @@ function TreeItem:draw() local oldActive = self.active _, self.active = RL.GuiToggle( toggleRect, self.text, self.active ) - if self.callbacks.toggle and oldActive ~= self.active then - self.callbacks.toggle( self ) + if self.callbacks.select and oldActive ~= self.active then + self.callbacks.select( self ) end if hasContainer then diff --git a/examples/raygui_extensions/tree_view.lua b/examples/raygui_extensions/tree_view.lua index 5b231be..ceb0359 100644 --- a/examples/raygui_extensions/tree_view.lua +++ b/examples/raygui_extensions/tree_view.lua @@ -10,7 +10,7 @@ TreeView.MOVE_ITEM_IN = 1 TreeView.MOVE_ITEM_UP = 2 TreeView.MOVE_ITEM_DOWN = 3 -function TreeView:new( bounds, text, callback, grabCallback, dragCallback, styles, tooltip ) +function TreeView:new( bounds, text, callbacks, styles, tooltip ) local object = setmetatable( {}, self ) object._gui = nil @@ -22,9 +22,7 @@ function TreeView:new( bounds, text, callback, grabCallback, dragCallback, style object.text = text object.scroll = Vec2:new() object.view = Rect:new() - object.callback = callback - object.grabCallback = grabCallback - object.dragCallback = dragCallback + object.callbacks = callbacks -- select, grab, drag. object.styles = styles object.tooltip = tooltip @@ -132,7 +130,7 @@ function TreeView:addItem( name, group ) name, { -- Callbacks. open = function( this ) self:updateContent() end, - toggle = function( this ) self:itemSelect( this ) end, + select = function( this ) self:itemSelect( this ) end, }, { -- Styles. properties = { @@ -262,8 +260,8 @@ function TreeView:itemSelect( item ) self._lastActiveItem = item -- Old clicked. end - if self.callback ~= nil then - -- self.callback( self.selectedItems ) + if self.callbacks.select ~= nil then + self.callbacks.select( self.selectedItems ) end end @@ -399,8 +397,8 @@ function TreeView:setSize( size ) end function TreeView:register( gui ) - function gui:TreeView( bounds, text, callback, grabCallback, dragCallback, styles, tooltip ) - return self:addControl( TreeView:new( bounds, text, callback, grabCallback, dragCallback, styles, tooltip ) ) + function gui:TreeView( bounds, text, callbacks, styles, tooltip ) + return self:addControl( TreeView:new( bounds, text, callbacks, styles, tooltip ) ) end end diff --git a/examples/raygui_lib/main.lua b/examples/raygui_lib/main.lua index 477e2b3..1539ea3 100644 --- a/examples/raygui_lib/main.lua +++ b/examples/raygui_lib/main.lua @@ -63,12 +63,16 @@ function RL.init() Rect:new( 68, 16, 64, 32 ), "Cat\nDog", 0, - function( self ) print( self:getItem( self.active ) ) end + { -- Callbacks. + select = function( self ) print( self:getItem( self.active ) ) end + } ) local button = Gui:Button( Rect:new( 245, 188, 64, 32 ), "Dog", - function() toggleGroup:setText( "Dog;Cat\nEagle" ) end, + { -- Callbacks. + pressed = function() toggleGroup:setText( "Dog;Cat\nEagle" ) end + }, { properties = { { RL.DEFAULT, RL.TEXT_COLOR_NORMAL, RL.ColorToInt( RL.RED ) }, @@ -82,25 +86,30 @@ function RL.init() Rect:new( 116, 128, 20, 20 ), "Visible", toggleGroup.visible, - function( self ) toggleGroup.visible = self.checked end + { -- Callbacks. + pressed = function( self ) toggleGroup.visible = self.checked end + } ) local toggle = Gui:Toggle( Rect:new( 32, 160, 100, 32 ), "Toggle", false, - nil + {} -- Callbacks. ) local combobox = Gui:ComboBox( Rect:new( 64, 256, 128, 32 ), "Dog\nCow\nDonkey", - 0 + 0, + {} -- Callbacks. ) local dropdownbox = Gui:DropdownBox( Rect:new( 256, 128, 128, 32 ), "Dog\nGiraffe\nLion\nHorse", 0, false, - function( self ) print( self:getItem( self.active ) ) end + { -- Callbacks. + select = function( self ) print( self:getItem( self.active ) ) end + } ) local spinner = Gui:Spinner( Rect:new( 464, 256, 128, 32 ), @@ -109,7 +118,9 @@ function RL.init() 0, 10, false, - function( self ) print( "Spinner value changed to "..self.value ) end + { -- Callbacks. + edit = function( self ) print( "Spinner value changed to "..self.value ) end + } ) local valuebox = Gui:ValueBox( Rect:new( 464, 316, 128, 32 ), @@ -118,21 +129,28 @@ function RL.init() 0, 100, false, - function( self ) print( "ValueBox value changed to "..self.value ) end + { -- Callbacks. + edit = function( self ) print( "ValueBox value changed to "..self.value ) end + } ) local textbox = Gui:TextBox( Rect:new( 32, 316, 256, 32 ), "Name", 32, false, - function( self ) print( "Set text "..self.text ) end + { -- Callbacks. + edit = function( self ) print( "Set text "..self.text ) end, + -- editMode = function( self ) print( "Entered edit mode" ) end + } ) local textbox2 = Gui:TextBox( Rect:new( 32, 380, 256, 32 ), "Name", 32, false, - function( self ) print( "Set text "..self.text ) end + { -- Callbacks. + edit = function( self ) print( "Set text 2 "..self.text ) end + } ) local slider = Gui:Slider( Rect:new( 50, 500, 256, 32 ), @@ -141,8 +159,10 @@ function RL.init() 0, 0, 100, - function( self ) print( "Changed value "..self.value ) end, - { + { -- Callbacks. + edit = function( self ) print( "Changed value "..self.value ) end, + }, + { -- Styles. texture = { texture = texture, rect = textureRect }, } ) @@ -153,7 +173,9 @@ function RL.init() 0, 0, 100, - function( self ) print( "Changed value "..self.value ) end + { -- Callbacks. + edit = function( self ) print( "Changed value "..self.value ) end + } ) local progressbar = Gui:ProgressBar( Rect:new( 50, 600, 256, 32 ), @@ -162,7 +184,9 @@ function RL.init() 20, 0, 100, - function( self ) print( "Changed value "..self.value ) end + { -- Callbacks. + edit = function( self ) print( "Changed value "..self.value ) end + } ) local statusbar = Gui:StatusBar( Rect:new( 50, 650, 256, 32 ), @@ -176,17 +200,17 @@ function RL.init() Rect:new( 400, 400, 256, 256 ), "Grid", 32, - 2 + 2, + {} -- Callbacks. ) windowbox = Gui:WindowBox( Rect:new( 720, 250, 256, 256 ), "WindowBox", - -- Close callback. - function( self ) self.visible = false end, - -- Grab callback. - function( self ) Gui:set2Top( self ) end, - nil, - { + { -- Callbacks. + close = function( self ) self.visible = false end, + grab = function( self ) Gui:set2Top( self ) end, + }, + { -- Styles. properties = { { RL.DEFAULT, RL.TEXT_COLOR_NORMAL, RL.ColorToInt( RL.RED ) }, }, @@ -205,10 +229,10 @@ function RL.init() local panel = Gui:Panel( Rect:new( 400, 64, 256, 128 ), "Panel", - -- Grab callback. - function( self ) Gui:set2Top( self ) end, - nil, - { + { -- Callbacks. + grab = function( self ) Gui:set2Top( self ) end + }, + { -- Styles. properties = { { RL.DEFAULT, RL.TEXT_COLOR_NORMAL, RL.ColorToInt( RL.MAGENTA ) }, { RL.DEFAULT, RL.TEXT_ALIGNMENT, RL.TEXT_ALIGN_CENTER }, @@ -220,25 +244,28 @@ function RL.init() Rect:new( 700, 520, 700, 32 ), "Cat;Dog;Horse;Cow;Dog;Horse;Cow", 0, - nil, - closeTab + { -- Callbacks. + close = closeTab + } ) local scrollpanel = Gui:ScrollPanel( Rect:new( 800, 64, 256, 256 ), "ScrollPanel", Rect:new( 0, 0, 300, 600 ), Vec2:new( 0, 0 ), - -- Callback. - function( self ) print( self.scroll ) end, - -- Grab callback. - function( self ) Gui:set2Top( self ) end + { -- Callbacks. + scroll = function( self ) print( self.scroll ) end, + grab = function( self ) Gui:set2Top( self ) end + } ) local listview = Gui:ListView( Rect:new( 1100, 64, 128, 128 ), "Cat;Dog;Horse;Cow;Pig;Eagle;Lion", 0, 0, - function( self ) print( self:getItem( self.active ) ) end + { -- Callbacks. + select = function( self ) print( self:getItem( self.active ) ) end + } ) local listviewex = Gui:ListViewEx( Rect:new( 1300, 64, 128, 128 ), @@ -246,8 +273,10 @@ function RL.init() 0, 0, 0, - function( self ) print( self:getItem( self.active ) ) end, - { + { -- Callbacks. + select = function( self ) print( self:getItem( self.active ) ) end + }, + { -- Styles. properties = { { RL.DEFAULT, RL.TEXT_COLOR_NORMAL, RL.ColorToInt( RL.RED ) }, { RL.DEFAULT, RL.TEXT_COLOR_FOCUSED, RL.ColorToInt( RL.ORANGE ) }, @@ -261,17 +290,18 @@ function RL.init() "Title", "Should we disable\nwindow box?", "No;Yes", - function( self ) - if 0 < self.buttonIndex then - if self.buttonIndex == 1 then - windowbox.disabled = false - elseif self.buttonIndex == 2 then - windowbox.disabled = true + { -- Callbacks. + pressed = function( self ) + if 0 < self.buttonIndex then + if self.buttonIndex == 1 then + windowbox.disabled = false + elseif self.buttonIndex == 2 then + windowbox.disabled = true + end end - end - end, - -- Grab callback. - function( self ) Gui:set2Top( self ) end + end, + grab = function( self ) Gui:set2Top( self ) end + } ) local textinputbox = Gui:TextInputBox( Rect:new( 1100, 300, 300, 128 ), @@ -281,40 +311,47 @@ function RL.init() "Text", 8, false, - function( self ) - if 0 < self.buttonIndex then - print( "You pressed "..self:getItem( self.buttonIndex ) ) - end - end, - -- Grab callback. - function( self ) Gui:set2Top( self ) end + { -- Callbacks. + pressed = function( self ) + if 0 < self.buttonIndex then + print( "You pressed "..self:getItem( self.buttonIndex ) ) + end + end, + grab = function( self ) Gui:set2Top( self ) end + } ) local colorpicker = Gui:ColorPicker( Rect:new( 1500, 32, 128, 128 ), "Color Picker", - Color:new() + Color:new(), + {} -- Callbacks. ) local colorpanel = Gui:ColorPanel( Rect:new( 1700, 32, 128, 128 ), "Color Panel", - Color:new() + Color:new(), + {} -- Callbacks. ) local colorbaralpha = Gui:ColorBarAlpha( Rect:new( 1700, 180, 128, 20 ), "Color Panel", - 1.0 + 1.0, + {} -- Callbacks. ) local colorbarhue = Gui:ColorBarHue( Rect:new( 1840, 32, 20, 128 ), "Color Panel", - 1.0 + 1.0, + {} -- Callbacks. ) local scrollbar = Gui:GuiScrollBar( Rect:new( 50, 760, 256, 16 ), 0, 0, 256, - function( self ) print( "Scrollbar value: ", self.value ) end + { -- Callbacks. + scroll = function( self ) print( "Scrollbar value: ", self.value ) end + } ) end diff --git a/examples/resources/lib/raygui.lua b/examples/resources/lib/raygui.lua index 11c57fc..c6c9d51 100644 --- a/examples/resources/lib/raygui.lua +++ b/examples/resources/lib/raygui.lua @@ -52,15 +52,13 @@ end local WindowBox = {} WindowBox.__index = WindowBox -function WindowBox:new( bounds, text, callback, grabCallback, dragCallback, styles, tooltip ) +function WindowBox:new( bounds, text, callbacks, styles, tooltip ) local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.callback = callback - object.grabCallback = grabCallback - object.dragCallback = dragCallback + object.bounds = bounds:clone() + object.text = text + object.callbacks = callbacks -- close, grab, drag. object.visible = true object.disabled = false @@ -80,10 +78,10 @@ function WindowBox:draw() if result == 1 then -- //TODO Could add self._gui:clickedInBounds( closeButtonBounds ) - if self.callback ~= nil then - self.callback( self ) + if self.callbacks.close ~= nil then + self.callbacks.close( self ) end - end + end end function WindowBox:setPosition( pos ) @@ -97,11 +95,11 @@ local GroupBox = {} GroupBox.__index = GroupBox function GroupBox:new( bounds, text, styles, tooltip ) - local object = setmetatable( {}, self ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text + object.bounds = bounds:clone() + object.text = text object.styles = styles object.tooltip = tooltip @@ -112,7 +110,7 @@ function GroupBox:new( bounds, text, styles, tooltip ) end function GroupBox:update() - return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) + return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) end function GroupBox:draw() @@ -131,11 +129,11 @@ local Line = {} Line.__index = Line function Line:new( bounds, text, styles, tooltip ) - local object = setmetatable( {}, self ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text + object.bounds = bounds:clone() + object.text = text object.visible = true object.disabled = false @@ -146,7 +144,7 @@ function Line:new( bounds, text, styles, tooltip ) end function Line:update() - return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) + return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) end function Line:draw() @@ -164,14 +162,13 @@ end local Panel = {} Panel.__index = Panel -function Panel:new( bounds, text, grabCallback, dragCallback, styles, tooltip ) - local object = setmetatable( {}, self ) +function Panel:new( bounds, text, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.grabCallback = grabCallback - object.dragCallback = dragCallback + object.bounds = bounds:clone() + object.text = text + object.callbacks = callbacks -- grab, drag. object.visible = true object.disabled = false @@ -183,7 +180,7 @@ function Panel:new( bounds, text, grabCallback, dragCallback, styles, tooltip ) end function Panel:update() - return self._gui:drag( self ) + return self._gui:drag( self ) end function Panel:draw() @@ -201,15 +198,14 @@ end local GuiTabBar = {} GuiTabBar.__index = GuiTabBar -function GuiTabBar:new( bounds, text, active, callback, closeCallback, styles, tooltip ) - local object = setmetatable( {}, self ) +function GuiTabBar:new( bounds, text, active, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.active = active - object.callback = callback - object.closeCallback = closeCallback + object.bounds = bounds:clone() + object.text = text + object.active = active + object.callbacks = callbacks -- select, close, grab, drag. object.visible = true object.disabled = false @@ -220,7 +216,7 @@ function GuiTabBar:new( bounds, text, active, callback, closeCallback, styles, t end function GuiTabBar:update() - return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) + return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) end function GuiTabBar:draw() @@ -235,12 +231,12 @@ function GuiTabBar:draw() return end - if self.callback ~= nil then - self.callback( self ) + if self.callbacks.select ~= nil then + self.callbacks.select( self ) end end - if 0 <= result and self.closeCallback ~= nil and self._gui:clickedInBounds( self.bounds ) then - self.closeCallback( self, result ) + if 0 <= result and self.callbacks.close ~= nil and self._gui:clickedInBounds( self.bounds ) then + self.callbacks.close( self, result ) end end @@ -255,18 +251,16 @@ end local ScrollPanel = {} ScrollPanel.__index = ScrollPanel -function ScrollPanel:new( bounds, text, content, scroll, callback, grabCallback, dragCallback, styles, tooltip ) - local object = setmetatable( {}, self ) +function ScrollPanel:new( bounds, text, content, scroll, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.content = content:clone() - object.scroll = scroll:clone() + object.bounds = bounds:clone() + object.text = text + object.content = content:clone() + object.scroll = scroll:clone() object.view = Rect:new() - object.callback = callback - object.grabCallback = grabCallback - object.dragCallback = dragCallback + object.callbacks = callbacks -- scroll, grab, drag. object.visible = true object.disabled = false @@ -278,7 +272,7 @@ function ScrollPanel:new( bounds, text, content, scroll, callback, grabCallback, end function ScrollPanel:update() - return self._gui:drag( self ) + return self._gui:drag( self ) end function ScrollPanel:draw() @@ -290,8 +284,8 @@ function ScrollPanel:draw() if self.scroll ~= oldScroll then self._gui:checkScrolling() - if self.callback ~= nil then - self.callback( self ) + if self.callbacks.scroll ~= nil then + self.callbacks.scroll( self ) end end end @@ -311,11 +305,11 @@ local Label = {} Label.__index = Label function Label:new( bounds, text, styles, tooltip ) - local object = setmetatable( {}, self ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text + object.bounds = bounds:clone() + object.text = text object.visible = true object.disabled = false @@ -326,11 +320,11 @@ function Label:new( bounds, text, styles, tooltip ) end function Label:update() - return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) + return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) end function Label:draw() - RL.GuiLabel( self.bounds, self.text ) + RL.GuiLabel( self.bounds, self.text ) end function Label:setPosition( pos ) @@ -344,13 +338,13 @@ end local Button = {} Button.__index = Button -function Button:new( bounds, text, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function Button:new( bounds, text, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.callback = callback + object.bounds = bounds:clone() + object.text = text + object.callbacks = callbacks -- pressed. object.visible = true object.disabled = false @@ -361,15 +355,15 @@ function Button:new( bounds, text, callback, styles, tooltip ) end function Button:update() - return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) + return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) end function Button:draw() - local result = RL.GuiButton( self.bounds, self.text ) + local result = RL.GuiButton( self.bounds, self.text ) - if result == 1 and self.callback ~= nil and self._gui:clickedInBounds( self.bounds ) then - self.callback( self ) - end + if result == 1 and self.callbacks.pressed ~= nil and self._gui:clickedInBounds( self.bounds ) then + self.callbacks.pressed( self ) + end end function Button:setPosition( pos ) @@ -383,13 +377,13 @@ end local LabelButton = {} LabelButton.__index = LabelButton -function LabelButton:new( bounds, text, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function LabelButton:new( bounds, text, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.callback = callback + object.bounds = bounds:clone() + object.text = text + object.callbacks = callbacks -- pressed. object.visible = true object.disabled = false @@ -400,15 +394,15 @@ function LabelButton:new( bounds, text, callback, styles, tooltip ) end function LabelButton:update() - return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) + return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) end function LabelButton:draw() - local result = RL.GuiLabelButton( self.bounds, self.text ) + local result = RL.GuiLabelButton( self.bounds, self.text ) - if result == 1 and self.callback ~= nil and self._gui:clickedInBounds( self.bounds ) then - self.callback( self ) - end + if result == 1 and self.callbacks.pressed ~= nil and self._gui:clickedInBounds( self.bounds ) then + self.callbacks.pressed( self ) + end end function LabelButton:setPosition( pos ) @@ -422,14 +416,14 @@ end local Toggle = {} Toggle.__index = Toggle -function Toggle:new( bounds, text, active, callback, styles, tooltip ) +function Toggle:new( bounds, text, active, callbacks, styles, tooltip ) local object = setmetatable( {}, self ) object._gui = nil object.bounds = bounds:clone() object.text = text object.active = active - object.callback = callback + object.callbacks = callbacks -- pressed. object.visible = true object.disabled = false @@ -440,24 +434,24 @@ function Toggle:new( bounds, text, active, callback, styles, tooltip ) end function Toggle:update() - return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) + return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) end function Toggle:draw() - local oldActive = self.active + local oldActive = self.active _, self.active = RL.GuiToggle( self.bounds, self.text, self.active ) - if self.active ~= oldActive then + if self.active ~= oldActive then if not self._gui:clickedInBounds( self.bounds ) then self.active = oldActive return end - if self.callback ~= nil then - self.callback( self ) + if self.callbacks.pressed ~= nil then + self.callbacks.pressed( self ) end - end + end end function Toggle:setPosition( pos ) @@ -471,14 +465,14 @@ end local ToggleGroup = {} ToggleGroup.__index = ToggleGroup -function ToggleGroup:new( bounds, text, active, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function ToggleGroup:new( bounds, text, active, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.active = active - object.callback = callback + object.bounds = bounds:clone() + object.text = text + object.active = active + object.callbacks = callbacks -- select. object.visible = true object.disabled = false @@ -486,15 +480,15 @@ function ToggleGroup:new( bounds, text, active, callback, styles, tooltip ) object.viewBounds = bounds:clone() object.styles = styles object.tooltip = tooltip - object:updateFocusBounds() + object:updateFocusBounds() return object end function ToggleGroup:setText( text ) - self.text = text + self.text = text - self:updateFocusBounds() + self:updateFocusBounds() end function ToggleGroup:getItem( id ) @@ -538,11 +532,11 @@ function ToggleGroup:update() end function ToggleGroup:draw() - local oldActive = self.active + local oldActive = self.active _, self.active = RL.GuiToggleGroup( self.bounds, self.text, self.active ) - if self.active ~= oldActive then + if self.active ~= oldActive then local inBounds = false for _, bounds in ipairs( self.focusBounds ) do @@ -557,10 +551,10 @@ function ToggleGroup:draw() return end - if self.callback ~= nil then - self.callback( self ) + if self.callbacks.select ~= nil then + self.callbacks.select( self ) end - end + end end function ToggleGroup:setPosition( pos ) @@ -576,19 +570,19 @@ end local CheckBox = {} CheckBox.__index = CheckBox -function CheckBox:new( bounds, text, checked, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function CheckBox:new( bounds, text, checked, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.checked = checked - object.callback = callback + object.bounds = bounds:clone() + object.text = text + object.checked = checked + object.callbacks = callbacks -- pressed. object.visible = true object.disabled = false object.textBounds = Rect:new() - object.focusBounds = bounds:clone() + object.focusBounds = bounds:clone() object._focusBoundsOffset = Vec2:new() -- Used in set position. object.styles = styles @@ -598,11 +592,11 @@ function CheckBox:new( bounds, text, checked, callback, styles, tooltip ) end function CheckBox:update() - return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.focusBounds ) + return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.focusBounds ) end function CheckBox:draw() - local oldChecked = self.checked + local oldChecked = self.checked local textBounds = nil _, self.checked, textBounds = RL.GuiCheckBox( self.bounds, self.text, self.checked ) @@ -610,15 +604,15 @@ function CheckBox:draw() self.focusBounds = self.bounds:fit( self.textBounds ) self._focusBoundsOffset:set( self.focusBounds.x - self.bounds.x, self.focusBounds.y - self.bounds.y ) - if self.checked ~= oldChecked then + if self.checked ~= oldChecked then if not self._gui:clickedInBounds( self.focusBounds ) then self.checked = oldChecked end - if self.callback ~= nil then - self.callback( self ) + if self.callbacks.pressed ~= nil then + self.callbacks.pressed( self ) end - end + end end function CheckBox:setPosition( pos ) @@ -634,14 +628,14 @@ end local ComboBox = {} ComboBox.__index = ComboBox -function ComboBox:new( bounds, text, active, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function ComboBox:new( bounds, text, active, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.active = active - object.callback = callback + object.bounds = bounds:clone() + object.text = text + object.active = active + object.callbacks = callbacks -- select. object.visible = true object.disabled = false @@ -652,24 +646,24 @@ function ComboBox:new( bounds, text, active, callback, styles, tooltip ) end function ComboBox:update() - return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) + return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds ) end function ComboBox:draw() - local oldActive = self.active + local oldActive = self.active _, self.active = RL.GuiComboBox( self.bounds, self.text, self.active ) - if self.active ~= oldActive then + if self.active ~= oldActive then if not self._gui:clickedInBounds( self.bounds ) then self.active = oldActive return end - if self.callback ~= nil then - self.callback( self ) + if self.callbacks.select ~= nil then + self.callbacks.select( self ) end - end + end end function ComboBox:setPosition( pos ) @@ -683,15 +677,15 @@ end local DropdownBox = {} DropdownBox.__index = DropdownBox -function DropdownBox:new( bounds, text, active, editMode, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function DropdownBox:new( bounds, text, active, editMode, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.active = active - object.editMode = editMode - object.callback = callback + object.bounds = bounds:clone() + object.text = text + object.active = active + object.editMode = editMode + object.callbacks = callbacks -- select. object.visible = true object.disabled = false @@ -730,13 +724,13 @@ function DropdownBox:draw() result, self.active = RL.GuiDropdownBox( self.bounds, self.text, self.active, self.editMode ) - if result == 1 then + if result == 1 then self.editMode = not self.editMode - if not self.editMode and self.callback ~= nil then - self.callback( self ) + if not self.editMode and self.callbacks.select ~= nil then + self.callbacks.select( self ) end - end + end end function DropdownBox:setPosition( pos ) @@ -750,7 +744,7 @@ end local Spinner = {} Spinner.__index = Spinner -function Spinner:new( bounds, text, value, minValue, maxValue, editMode, callback, styles, tooltip ) +function Spinner:new( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip ) local object = setmetatable( {}, self ) object._gui = nil @@ -760,7 +754,7 @@ function Spinner:new( bounds, text, value, minValue, maxValue, editMode, callbac object.minValue = minValue object.maxValue = maxValue object.editMode = editMode - object.callback = callback + object.callbacks = callbacks -- edit. object.visible = true object.disabled = false @@ -775,7 +769,7 @@ function Spinner:new( bounds, text, value, minValue, maxValue, editMode, callbac end function Spinner:setText( text ) - self.text = text + self.text = text end function Spinner:update() @@ -792,18 +786,18 @@ function Spinner:draw() self.viewBounds = self.bounds:fit( self.textBounds ) self._viewBoundsOffset:set( self.viewBounds.x - self.bounds.x, self.viewBounds.y - self.bounds.y ) - if result == 1 then + if result == 1 then self._gui:editMode( self.editMode ) self.editMode = not self.editMode - end + end if self.value ~= oldValue then if not self._gui:clickedInBounds( self.bounds ) then self.value = oldValue return end - if self.callback ~= nil then - self.callback( self ) + if self.callbacks.edit ~= nil then + self.callbacks.edit( self ) end end end @@ -821,8 +815,8 @@ end local ValueBox = {} ValueBox.__index = ValueBox -function ValueBox:new( bounds, text, value, minValue, maxValue, editMode, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function ValueBox:new( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil object.bounds = bounds:clone() @@ -831,7 +825,7 @@ function ValueBox:new( bounds, text, value, minValue, maxValue, editMode, callba object.minValue = minValue object.maxValue = maxValue object.editMode = editMode - object.callback = callback + object.callbacks = callbacks -- edit. object.visible = true object.disabled = false @@ -863,12 +857,12 @@ function ValueBox:draw() self.viewBounds = self.bounds:fit( self.textBounds ) self._viewBoundsOffset:set( self.viewBounds.x - self.bounds.x, self.viewBounds.y - self.bounds.y ) - if result == 1 then + if result == 1 then self._gui:editMode( self.editMode ) self.editMode = not self.editMode - end - if self.value ~= oldValue and self.callback ~= nil then - self.callback( self ) + end + if self.value ~= oldValue and self.callbacks.edit ~= nil then + self.callbacks.edit( self ) end end @@ -885,15 +879,15 @@ end local TextBox = {} TextBox.__index = TextBox -function TextBox:new( bounds, text, textSize, editMode, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function TextBox:new( bounds, text, textSize, editMode, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.textSize = textSize - object.editMode = editMode - object.callback = callback + object.bounds = bounds:clone() + object.text = text + object.textSize = textSize + object.editMode = editMode + object.callbacks = callbacks -- edit. -- Option for preventing text to be drawn outside bounds. object.scissorMode = false object.visible = true @@ -920,14 +914,14 @@ function TextBox:draw() if self.scissorMode then RL.EndScissorMode() end - if result == 1 then + if result == 1 then self._gui:editMode( self.editMode ) self.editMode = not self.editMode - if not self.editMode and self.callback ~= nil then - self.callback( self ) + if not self.editMode and self.callbacks.edit ~= nil then + self.callbacks.edit( self ) end - end + end end function TextBox:setPosition( pos ) @@ -941,8 +935,8 @@ end local Slider = {} Slider.__index = Slider -function Slider:new( bounds, textLeft, textRight, value, minValue, maxValue, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function Slider:new( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil object.bounds = bounds:clone() @@ -951,8 +945,8 @@ function Slider:new( bounds, textLeft, textRight, value, minValue, maxValue, cal object.value = value object.minValue = minValue object.maxValue = maxValue - object.callback = callback - + object.callbacks = callbacks -- edit. + object.visible = true object.disabled = false object.textLeftBounds = Rect:new() @@ -979,17 +973,17 @@ function Slider:draw() self.viewBounds = self.bounds:fit( self.textLeftBounds ):fit( self.textRightBounds ) self._viewBoundsOffset:set( self.viewBounds.x - self.bounds.x, self.viewBounds.y - self.bounds.y ) - if self.value ~= oldValue then + if self.value ~= oldValue then if not self._gui:clickedInBounds( self.bounds ) then self.value = oldValue return end self._gui:checkScrolling() - if self.callback ~= nil then - self.callback( self ) + if self.callbacks.edit ~= nil then + self.callbacks.edit( self ) end - end + end end function Slider:setPosition( pos ) @@ -1005,17 +999,17 @@ end local SliderBar = {} SliderBar.__index = SliderBar -function SliderBar:new( bounds, textLeft, textRight, value, minValue, maxValue, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function SliderBar:new( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.textLeft = textLeft - object.textRight = textRight - object.value = value - object.minValue = minValue - object.maxValue = maxValue - object.callback = callback + object.bounds = bounds:clone() + object.textLeft = textLeft + object.textRight = textRight + object.value = value + object.minValue = minValue + object.maxValue = maxValue + object.callbacks = callbacks -- edit. object.visible = true object.disabled = false @@ -1050,8 +1044,8 @@ function SliderBar:draw() end self._gui:checkScrolling() - if self.callback ~= nil then - self.callback( self ) + if self.callbacks.edit ~= nil then + self.callbacks.edit( self ) end end end @@ -1069,17 +1063,17 @@ end local ProgressBar = {} ProgressBar.__index = ProgressBar -function ProgressBar:new( bounds, textLeft, textRight, value, minValue, maxValue, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function ProgressBar:new( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.textLeft = textLeft - object.textRight = textRight - object.value = value - object.minValue = minValue - object.maxValue = maxValue - object.callback = callback + object.bounds = bounds:clone() + object.textLeft = textLeft + object.textRight = textRight + object.value = value + object.minValue = minValue + object.maxValue = maxValue + object.callbacks = callbacks -- edit. object.visible = true object.disabled = false @@ -1107,16 +1101,16 @@ function ProgressBar:draw() self.viewBounds = self.bounds:fit( self.textLeftBounds ):fit( self.textRightBounds ) self._viewBoundsOffset:set( self.viewBounds.x - self.bounds.x, self.viewBounds.y - self.bounds.y ) - if self.value ~= oldValue then + if self.value ~= oldValue then if not self._gui:clickedInBounds( self.bounds ) then self.value = oldValue return end - if self.callback ~= nil then - self.callback( self ) + if self.callbacks.edit ~= nil then + self.callbacks.edit( self ) end - end + end end function ProgressBar:setPosition( pos ) @@ -1170,8 +1164,8 @@ function DummyRec:new( bounds, text, styles, tooltip ) local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text + object.bounds = bounds:clone() + object.text = text object.visible = true object.disabled = false @@ -1200,15 +1194,15 @@ end local Grid = {} Grid.__index = Grid -function Grid:new( bounds, text, spacing, subdivs, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function Grid:new( bounds, text, spacing, subdivs, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.spacing = spacing - object.subdivs = subdivs - object.callback = callback + object.bounds = bounds:clone() + object.text = text + object.spacing = spacing + object.subdivs = subdivs + object.callbacks = callbacks -- cellChange. object.mouseCell = Vec2:new() object.visible = true @@ -1230,8 +1224,8 @@ function Grid:draw() _, mouseCell = RL.GuiGrid( self.bounds, self.text, self.spacing, self.subdivs, self.mouseCell ) self.mouseCell:set( mouseCell ) - if oldCell ~= self.mouseCell and self.callback ~= nil then - self.callback( self ) + if oldCell ~= self.mouseCell and self.callbacks.cellChange ~= nil then + self.callbacks.cellChange( self ) end end @@ -1250,15 +1244,15 @@ end local ListView = {} ListView.__index = ListView -function ListView:new( bounds, text, scrollIndex, active, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function ListView:new( bounds, text, scrollIndex, active, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.scrollIndex = scrollIndex - object.active = active - object.callback = callback + object.bounds = bounds:clone() + object.text = text + object.scrollIndex = scrollIndex + object.active = active + object.callbacks = callbacks -- select. object.visible = true object.disabled = false @@ -1285,8 +1279,8 @@ function ListView:draw() if self.scrollIndex ~= oldScrollIndex then self._gui:checkScrolling() end - if oldActive ~= self.active and self.callback ~= nil then - self.callback( self ) + if oldActive ~= self.active and self.callbacks.select ~= nil then + self.callbacks.select( self ) end end @@ -1301,16 +1295,16 @@ end local ListViewEx = {} ListViewEx.__index = ListViewEx -function ListViewEx:new( bounds, text, scrollIndex, active, focus, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function ListViewEx:new( bounds, text, scrollIndex, active, focus, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.scrollIndex = scrollIndex - object.active = active - object.focus = focus - object.callback = callback + object.bounds = bounds:clone() + object.text = text + object.scrollIndex = scrollIndex + object.active = active + object.focus = focus + object.callbacks = callbacks -- select. object.visible = true object.disabled = false @@ -1337,8 +1331,8 @@ function ListViewEx:draw() if self.scrollIndex ~= oldScrollIndex then self._gui:checkScrolling() end - if oldActive ~= self.active and self.callback ~= nil then - self.callback( self ) + if oldActive ~= self.active and self.callbacks.select ~= nil then + self.callbacks.select( self ) end end @@ -1353,17 +1347,15 @@ end local MessageBox = {} MessageBox.__index = MessageBox -function MessageBox:new( bounds, title, message, buttons, callback, grabCallback, dragCallback, styles, tooltip ) - local object = setmetatable( {}, self ) +function MessageBox:new( bounds, title, message, buttons, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.title = title - object.message = message - object.buttons = buttons - object.callback = callback - object.grabCallback = grabCallback - object.dragCallback = dragCallback + object.bounds = bounds:clone() + object.title = title + object.message = message + object.buttons = buttons + object.callbacks = callbacks -- pressed, grab, drag. object.buttonIndex = -1 object.visible = true @@ -1386,8 +1378,8 @@ end function MessageBox:draw() self.buttonIndex = RL.GuiMessageBox( self.bounds, self.title, self.message, self.buttons ) - if 0 <= self.buttonIndex and self.callback ~= nil and self._gui:clickedInBounds( self.bounds ) then - self.callback( self ) + if 0 <= self.buttonIndex and self.callbacks.pressed ~= nil and self._gui:clickedInBounds( self.bounds ) then + self.callbacks.pressed( self ) end end @@ -1402,20 +1394,18 @@ end local TextInputBox = {} TextInputBox.__index = TextInputBox -function TextInputBox:new( bounds, title, message, buttons, text, textMaxSize, secretViewActive, callback, grabCallback, dragCallback, styles, tooltip ) - local object = setmetatable( {}, self ) +function TextInputBox:new( bounds, title, message, buttons, text, textMaxSize, secretViewActive, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.title = title - object.message = message - object.buttons = buttons - object.text = text - object.textMaxSize = textMaxSize - object.secretViewActive = secretViewActive - object.callback = callback - object.grabCallback = grabCallback - object.dragCallback = dragCallback + object.bounds = bounds:clone() + object.title = title + object.message = message + object.buttons = buttons + object.text = text + object.textMaxSize = textMaxSize + object.secretViewActive = secretViewActive + object.callbacks = callbacks -- pressed, grab, drag. object.buttonIndex = -1 object.visible = true @@ -1438,8 +1428,8 @@ end function TextInputBox:draw() self.buttonIndex, self.text, self.secretViewActive = RL.GuiTextInputBox( self.bounds, self.title, self.message, self.buttons, self.text, self.textMaxSize, self.secretViewActive ) - if 0 <= self.buttonIndex and self.callback ~= nil and self._gui:clickedInBounds( self.bounds ) then - self.callback( self ) + if 0 <= self.buttonIndex and self.callbacks.pressed ~= nil and self._gui:clickedInBounds( self.bounds ) then + self.callbacks.pressed( self ) end end @@ -1454,14 +1444,14 @@ end local ColorPicker = {} ColorPicker.__index = ColorPicker -function ColorPicker:new( bounds, text, color, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function ColorPicker:new( bounds, text, color, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.color = color - object.callback = callback + object.bounds = bounds:clone() + object.text = text + object.color = color + object.callbacks = callbacks -- edit. object.visible = true object.disabled = false @@ -1502,8 +1492,8 @@ function ColorPicker:draw() end self._gui:checkScrolling() - if self.callback ~= nil then - self.callback( self ) + if self.callbacks.edit ~= nil then + self.callbacks.edit( self ) end end end @@ -1520,14 +1510,14 @@ end local ColorPanel = {} ColorPanel.__index = ColorPanel -function ColorPanel:new( bounds, text, color, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function ColorPanel:new( bounds, text, color, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.color = color - object.callback = callback + object.bounds = bounds:clone() + object.text = text + object.color = color + object.callbacks = callbacks -- edit. object.visible = true object.disabled = false @@ -1553,8 +1543,8 @@ function ColorPanel:draw() return end - if self.callback ~= nil then - self.callback( self ) + if self.callbacks.edit ~= nil then + self.callbacks.edit( self ) end end end @@ -1570,14 +1560,14 @@ end local ColorBarAlpha = {} ColorBarAlpha.__index = ColorBarAlpha -function ColorBarAlpha:new( bounds, text, alpha, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function ColorBarAlpha:new( bounds, text, alpha, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.alpha = alpha - object.callback = callback + object.bounds = bounds:clone() + object.text = text + object.alpha = alpha + object.callbacks = callbacks -- edit. object.visible = true object.disabled = false @@ -1602,8 +1592,8 @@ function ColorBarAlpha:draw() end self._gui:checkScrolling() - if self.callback ~= nil then - self.callback( self ) + if self.callbacks.edit ~= nil then + self.callbacks.edit( self ) end end end @@ -1619,14 +1609,14 @@ end local ColorBarHue = {} ColorBarHue.__index = ColorBarHue -function ColorBarHue:new( bounds, text, value, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function ColorBarHue:new( bounds, text, value, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.text = text - object.value = value - object.callback = callback + object.bounds = bounds:clone() + object.text = text + object.value = value + object.callbacks = callbacks -- edit. object.visible = true object.disabled = false @@ -1651,8 +1641,8 @@ function ColorBarHue:draw() end self._gui:checkScrolling() - if self.callback ~= nil then - self.callback( self ) + if self.callbacks.edit ~= nil then + self.callbacks.edit( self ) end end end @@ -1668,15 +1658,15 @@ end local GuiScrollBar = {} GuiScrollBar.__index = GuiScrollBar -function GuiScrollBar:new( bounds, value, minValue, maxValue, callback, styles, tooltip ) - local object = setmetatable( {}, self ) +function GuiScrollBar:new( bounds, value, minValue, maxValue, callbacks, styles, tooltip ) + local object = setmetatable( {}, self ) object._gui = nil - object.bounds = bounds:clone() - object.value = value - object.minValue = minValue - object.maxValue = maxValue - object.callback = callback + object.bounds = bounds:clone() + object.value = value + object.minValue = minValue + object.maxValue = maxValue + object.callbacks = callbacks -- edit. object.visible = true object.disabled = false @@ -1702,8 +1692,8 @@ function GuiScrollBar:draw() end self._gui:checkScrolling() - if self.callback ~= nil then - self.callback( self ) + if self.callbacks.edit ~= nil then + self.callbacks.edit( self ) end end end @@ -1818,8 +1808,8 @@ function Raygui:drag( control ) and mouseOver and mousePos.y - control.bounds.y <= self.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT then self.grabPos = mousePos - Vec2:new( control.bounds.x, control.bounds.y ) - if control.grabCallback ~= nil then - control.grabCallback( control ) + if control.callbacks.grab ~= nil then + control.callbacks.grab( control ) end self.dragging = control end @@ -1830,12 +1820,12 @@ function Raygui:drag( control ) end control:setPosition( mousePos - self.grabPos ) - if control.dragCallback ~= nil then - control.dragCallback( control ) + if control.callbacks.drag ~= nil then + control.callbacks.drag( control ) end end - return mouseOver + return mouseOver end -- Add property before current draw that we can then return them. @@ -1960,8 +1950,8 @@ function Raygui:editMode( editMode ) if control.editMode then control.editMode = false - if control.callback ~= nil then - control.callback( control ) + if control.callbacks.edit ~= nil then + control.callbacks.edit( control ) end end end @@ -2013,7 +2003,6 @@ end function Raygui:addControl( control ) control._gui = self - -- self:applyStyles( control ) self:drawControl( control ) table.insert( self.controls, control ) return control @@ -2025,13 +2014,11 @@ end ---@param bounds Rectangle ---@param text string ----@param callback function|nil ----@param grabCallback function|nil ----@param dragCallback function|nil +---@param callbacks table close, grab, drag. ---@param styles table|nil ---@return table WindowBox -function Raygui:WindowBox( bounds, text, callback, grabCallback, dragCallback, styles, tooltip ) - return self:addControl( WindowBox:new( bounds, text, callback, grabCallback, dragCallback, styles, tooltip ) ) +function Raygui:WindowBox( bounds, text, callbacks, styles, tooltip ) + return self:addControl( WindowBox:new( bounds, text, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle @@ -2052,36 +2039,32 @@ end ---@param bounds Rectangle ---@param text string ----@param grabCallback function|nil ----@param dragCallback function|nil +---@param callbacks table grab, drag. ---@param styles table|nil ---@return table Panel -function Raygui:Panel( bounds, text, grabCallback, dragCallback, styles, tooltip ) - return self:addControl( Panel:new( bounds, text, grabCallback, dragCallback, styles, tooltip ) ) +function Raygui:Panel( bounds, text, callbacks, styles, tooltip ) + return self:addControl( Panel:new( bounds, text, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle ---@param text string ----@param active boolean ----@param callback function|nil ----@param closeCallback function|nil +---@param active integer +---@param callbacks table select, close, grab, drag. ---@param styles table|nil ---@return table GuiTabBar -function Raygui:GuiTabBar( bounds, text, active, callback, closeCallback, styles, tooltip ) - return self:addControl( GuiTabBar:new( bounds, text, active, callback, closeCallback, styles, tooltip ) ) +function Raygui:GuiTabBar( bounds, text, active, callbacks, styles, tooltip ) + return self:addControl( GuiTabBar:new( bounds, text, active, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle ---@param text string ---@param content Rectangle ---@param scroll Vector2 ----@param callback function|nil ----@param grabCallback function|nil ----@param dragCallback function|nil +---@param callbacks table scroll, grab, drag. ---@param styles table|nil ---@return table ScrollPanel -function Raygui:ScrollPanel( bounds, text, content, scroll, callback, grabCallback, dragCallback, styles, tooltip ) - return self:addControl( ScrollPanel:new( bounds, text, content, scroll, callback, grabCallback, dragCallback, styles, tooltip ) ) +function Raygui:ScrollPanel( bounds, text, content, scroll, callbacks, styles, tooltip ) + return self:addControl( ScrollPanel:new( bounds, text, content, scroll, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle @@ -2094,71 +2077,71 @@ end ---@param bounds Rectangle ---@param text string ----@param callback function|nil +---@param callbacks table pressed. ---@param styles table|nil ---@return table Button -function Raygui:Button( bounds, text, callback, styles, tooltip ) - return self:addControl( Button:new( bounds, text, callback, styles, tooltip ) ) +function Raygui:Button( bounds, text, callbacks, styles, tooltip ) + return self:addControl( Button:new( bounds, text, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle ---@param text string ----@param callback function|nil +---@param callbacks table pressed. ---@param styles table|nil ---@return table LabelButton -function Raygui:LabelButton( bounds, text, callback, styles, tooltip ) - return self:addControl( LabelButton:new( bounds, text, callback, styles, tooltip ) ) +function Raygui:LabelButton( bounds, text, callbacks, styles, tooltip ) + return self:addControl( LabelButton:new( bounds, text, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle ---@param text string ---@param active boolean ----@param callback function|nil +---@param callbacks table pressed. ---@param styles table|nil ---@return table Toggle -function Raygui:Toggle( bounds, text, active, callback, styles, tooltip ) - return self:addControl( Toggle:new( bounds, text, active, callback, styles, tooltip ) ) +function Raygui:Toggle( bounds, text, active, callbacks, styles, tooltip ) + return self:addControl( Toggle:new( bounds, text, active, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle ---@param text string ---@param active integer ----@param callback function|nil +---@param callbacks table select. ---@param styles table|nil ---@return table ToggleGroup -function Raygui:ToggleGroup( bounds, text, active, callback, styles, tooltip ) - return self:addControl( ToggleGroup:new( bounds, text, active, callback, styles, tooltip ) ) +function Raygui:ToggleGroup( bounds, text, active, callbacks, styles, tooltip ) + return self:addControl( ToggleGroup:new( bounds, text, active, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle ---@param text string ---@param checked boolean ----@param callback function|nil +---@param callbacks table pressed. ---@param styles table|nil ---@return table CheckBox -function Raygui:CheckBox( bounds, text, checked, callback, styles, tooltip ) - return self:addControl( CheckBox:new( bounds, text, checked, callback, styles, tooltip ) ) +function Raygui:CheckBox( bounds, text, checked, callbacks, styles, tooltip ) + return self:addControl( CheckBox:new( bounds, text, checked, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle ---@param text string ---@param active integer ----@param callback function|nil +---@param callbacks table select. ---@param styles table|nil ---@return table ComboBox -function Raygui:ComboBox( bounds, text, active, callback, styles, tooltip ) - return self:addControl( ComboBox:new( bounds, text, active, callback, styles, tooltip ) ) +function Raygui:ComboBox( bounds, text, active, callbacks, styles, tooltip ) + return self:addControl( ComboBox:new( bounds, text, active, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle ---@param text string ---@param active integer ---@param editMode boolean ----@param callback function|nil +---@param callbacks table select. ---@param styles table|nil ---@return table DropdownBox -function Raygui:DropdownBox( bounds, text, active, editMode, callback, styles, tooltip ) - return self:addControl( DropdownBox:new( bounds, text, active, editMode, callback, styles, tooltip ) ) +function Raygui:DropdownBox( bounds, text, active, editMode, callbacks, styles, tooltip ) + return self:addControl( DropdownBox:new( bounds, text, active, editMode, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle @@ -2167,11 +2150,11 @@ end ---@param minValue integer ---@param maxValue integer ---@param editMode boolean ----@param callback function|nil +---@param callbacks table edit. ---@param styles table|nil ---@return table Spinner -function Raygui:Spinner( bounds, text, value, minValue, maxValue, editMode, callback, styles, tooltip ) - return self:addControl( Spinner:new( bounds, text, value, minValue, maxValue, editMode, callback, styles, tooltip ) ) +function Raygui:Spinner( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip ) + return self:addControl( Spinner:new( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle @@ -2180,22 +2163,22 @@ end ---@param minValue integer ---@param maxValue integer ---@param editMode boolean ----@param callback function|nil +---@param callbacks table edit. ---@param styles table|nil ---@return table ValueBox -function Raygui:ValueBox( bounds, text, value, minValue, maxValue, editMode, callback, styles, tooltip ) - return self:addControl( ValueBox:new( bounds, text, value, minValue, maxValue, editMode, callback, styles, tooltip ) ) +function Raygui:ValueBox( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip ) + return self:addControl( ValueBox:new( bounds, text, value, minValue, maxValue, editMode, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle ---@param text string ---@param textSize integer ---@param editMode boolean ----@param callback function|nil +---@param callbacks table edit. ---@param styles table|nil ---@return table TextBox -function Raygui:TextBox( bounds, text, textSize, editMode, callback, styles, tooltip ) - return self:addControl( TextBox:new( bounds, text, textSize, editMode, callback, styles, tooltip ) ) +function Raygui:TextBox( bounds, text, textSize, editMode, callbacks, styles, tooltip ) + return self:addControl( TextBox:new( bounds, text, textSize, editMode, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle @@ -2204,11 +2187,11 @@ end ---@param value number ---@param minValue number ---@param maxValue number ----@param callback function|nil +---@param callbacks table edit. ---@param styles table|nil ---@return table Slider -function Raygui:Slider( bounds, textLeft, textRight, value, minValue, maxValue, callback, styles, tooltip ) - return self:addControl( Slider:new( bounds, textLeft, textRight, value, minValue, maxValue, callback, styles, tooltip ) ) +function Raygui:Slider( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) + return self:addControl( Slider:new( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle @@ -2217,11 +2200,11 @@ end ---@param value number ---@param minValue number ---@param maxValue number ----@param callback function|nil +---@param callbacks table edit. ---@param styles table|nil ---@return table SliderBar -function Raygui:SliderBar( bounds, textLeft, textRight, value, minValue, maxValue, callback, styles, tooltip ) - return self:addControl( SliderBar:new( bounds, textLeft, textRight, value, minValue, maxValue, callback, styles, tooltip ) ) +function Raygui:SliderBar( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) + return self:addControl( SliderBar:new( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle @@ -2230,11 +2213,11 @@ end ---@param value number ---@param minValue number ---@param maxValue number ----@param callback function|nil +---@param callbacks table edit. ---@param styles table|nil ---@return table ProgressBar -function Raygui:ProgressBar( bounds, textLeft, textRight, value, minValue, maxValue, callback, styles, tooltip ) - return self:addControl( ProgressBar:new( bounds, textLeft, textRight, value, minValue, maxValue, callback, styles, tooltip ) ) +function Raygui:ProgressBar( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) + return self:addControl( ProgressBar:new( bounds, textLeft, textRight, value, minValue, maxValue, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle @@ -2257,22 +2240,22 @@ end ---@param text string ---@param spacing number ---@param subdivs integer ----@param callback function|nil +---@param callbacks table cellChange. ---@param styles table|nil ---@return table Grid -function Raygui:Grid( bounds, text, spacing, subdivs, callback, styles, tooltip ) - return self:addControl( Grid:new( bounds, text, spacing, subdivs, callback, styles, tooltip ) ) +function Raygui:Grid( bounds, text, spacing, subdivs, callbacks, styles, tooltip ) + return self:addControl( Grid:new( bounds, text, spacing, subdivs, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle ---@param text string ---@param scrollIndex integer ---@param active integer ----@param callback function|nil +---@param callbacks table select. ---@param styles table|nil ---@return table ListView -function Raygui:ListView( bounds, text, scrollIndex, active, callback, styles, tooltip ) - return self:addControl( ListView:new( bounds, text, scrollIndex, active, callback, styles, tooltip ) ) +function Raygui:ListView( bounds, text, scrollIndex, active, callbacks, styles, tooltip ) + return self:addControl( ListView:new( bounds, text, scrollIndex, active, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle @@ -2280,24 +2263,22 @@ end ---@param scrollIndex integer ---@param active integer ---@param focus integer ----@param callback function|nil +---@param callbacks table select. ---@param styles table|nil ---@return table ListViewEx -function Raygui:ListViewEx( bounds, text, scrollIndex, active, focus, callback, styles, tooltip ) - return self:addControl( ListViewEx:new( bounds, text, scrollIndex, active, focus, callback, styles, tooltip ) ) +function Raygui:ListViewEx( bounds, text, scrollIndex, active, focus, callbacks, styles, tooltip ) + return self:addControl( ListViewEx:new( bounds, text, scrollIndex, active, focus, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle ---@param title string ---@param message string ---@param buttons string ----@param callback function|nil ----@param grabCallback function|nil ----@param dragCallback function|nil +---@param callbacks table pressed, grab, drag. ---@param styles table|nil ---@return table MessageBox -function Raygui:MessageBox( bounds, title, message, buttons, callback, grabCallback, dragCallback, styles, tooltip ) - return self:addControl( MessageBox:new( bounds, title, message, buttons, callback, grabCallback, dragCallback, styles, tooltip ) ) +function Raygui:MessageBox( bounds, title, message, buttons, callbacks, styles, tooltip ) + return self:addControl( MessageBox:new( bounds, title, message, buttons, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle @@ -2307,64 +2288,62 @@ end ---@param text string ---@param textMaxSize integer ---@param secretViewActive boolean ----@param callback function|nil ----@param grabCallback function|nil ----@param dragCallback function|nil +---@param callbacks table pressed, grab, drag. ---@param styles table|nil ---@return table TextInputBox -function Raygui:TextInputBox( bounds, title, message, buttons, text, textMaxSize, secretViewActive, callback, grabCallback, dragCallback, styles, tooltip ) - return self:addControl( TextInputBox:new( bounds, title, message, buttons, text, textMaxSize, secretViewActive, callback, grabCallback, dragCallback, styles, tooltip ) ) +function Raygui:TextInputBox( bounds, title, message, buttons, text, textMaxSize, secretViewActive, callbacks, styles, tooltip ) + return self:addControl( TextInputBox:new( bounds, title, message, buttons, text, textMaxSize, secretViewActive, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle ---@param text string ---@param color Color ----@param callback function|nil +---@param callbacks table edit. ---@param styles table|nil ---@return table ColorPicker -function Raygui:ColorPicker( bounds, text, color, callback, styles, tooltip ) - return self:addControl( ColorPicker:new( bounds, text, color, callback, styles, tooltip ) ) +function Raygui:ColorPicker( bounds, text, color, callbacks, styles, tooltip ) + return self:addControl( ColorPicker:new( bounds, text, color, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle ---@param text string ---@param color Color ----@param callback function|nil +---@param callbacks table edit. ---@param styles table|nil ---@return table ColorPanel -function Raygui:ColorPanel( bounds, text, color, callback, styles, tooltip ) - return self:addControl( ColorPanel:new( bounds, text, color, callback, styles, tooltip ) ) +function Raygui:ColorPanel( bounds, text, color, callbacks, styles, tooltip ) + return self:addControl( ColorPanel:new( bounds, text, color, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle ---@param text string ---@param alpha number ----@param callback function|nil +---@param callbacks table edit. ---@param styles table|nil ---@return table ColorBarAlpha -function Raygui:ColorBarAlpha( bounds, text, alpha, callback, styles, tooltip ) - return self:addControl( ColorBarAlpha:new( bounds, text, alpha, callback, styles, tooltip ) ) +function Raygui:ColorBarAlpha( bounds, text, alpha, callbacks, styles, tooltip ) + return self:addControl( ColorBarAlpha:new( bounds, text, alpha, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle ---@param text string ---@param value number ----@param callback function|nil +---@param callbacks table edit. ---@param styles table|nil ---@return table ColorBarHue -function Raygui:ColorBarHue( bounds, text, value, callback, styles, tooltip ) - return self:addControl( ColorBarHue:new( bounds, text, value, callback, styles, tooltip ) ) +function Raygui:ColorBarHue( bounds, text, value, callbacks, styles, tooltip ) + return self:addControl( ColorBarHue:new( bounds, text, value, callbacks, styles, tooltip ) ) end ---@param bounds Rectangle ---@param value integer ---@param minValue integer ---@param maxValue integer ----@param callback function|nil +---@param callbacks table edit. ---@param styles table|nil ---@return table ColorBarHue -function Raygui:GuiScrollBar( bounds, value, minValue, maxValue, callback, styles, tooltip ) - return self:addControl( GuiScrollBar:new( bounds, value, minValue, maxValue, callback, styles, tooltip ) ) +function Raygui:GuiScrollBar( bounds, value, minValue, maxValue, callbacks, styles, tooltip ) + return self:addControl( GuiScrollBar:new( bounds, value, minValue, maxValue, callbacks, styles, tooltip ) ) end return Raygui -- cgit v1.2.3