summaryrefslogtreecommitdiff
path: root/examples/raygui_extensions/property_list.lua
diff options
context:
space:
mode:
authorjussi2024-03-21 23:18:35 +0200
committerjussi2024-03-21 23:18:35 +0200
commit95f03bae31ab695f55c4cb4b166e0af80814d841 (patch)
tree0cdf6a07a96537553b1439ba6b9d1d2c1814638c /examples/raygui_extensions/property_list.lua
parenta7528da4ebd937d8023796998eb6975707b2f026 (diff)
downloadreilua-enhanced-95f03bae31ab695f55c4cb4b166e0af80814d841.tar.gz
reilua-enhanced-95f03bae31ab695f55c4cb4b166e0af80814d841.tar.bz2
reilua-enhanced-95f03bae31ab695f55c4cb4b166e0af80814d841.zip
Raygui lib callbacks to single table.
Diffstat (limited to 'examples/raygui_extensions/property_list.lua')
-rw-r--r--examples/raygui_extensions/property_list.lua20
1 files changed, 10 insertions, 10 deletions
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