summaryrefslogtreecommitdiff
path: root/examples/raygui_extensions/main.lua
diff options
context:
space:
mode:
authorjussi2024-03-20 19:18:01 +0200
committerjussi2024-03-20 19:18:01 +0200
commit842e0efe360417556ad0e757d91ef05449bfc8ee (patch)
treed51e0734bf31082d3483f6c6a56eb1195372132a /examples/raygui_extensions/main.lua
parentae1d0b65f16b24f2e0db39cb8baef4af57b2a12f (diff)
downloadreilua-enhanced-842e0efe360417556ad0e757d91ef05449bfc8ee.tar.gz
reilua-enhanced-842e0efe360417556ad0e757d91ef05449bfc8ee.tar.bz2
reilua-enhanced-842e0efe360417556ad0e757d91ef05449bfc8ee.zip
Raygui tree view.
Diffstat (limited to 'examples/raygui_extensions/main.lua')
-rw-r--r--examples/raygui_extensions/main.lua47
1 files changed, 42 insertions, 5 deletions
diff --git a/examples/raygui_extensions/main.lua b/examples/raygui_extensions/main.lua
index 35cf48a..f47d396 100644
--- a/examples/raygui_extensions/main.lua
+++ b/examples/raygui_extensions/main.lua
@@ -10,6 +10,8 @@ Raygui = require( "raygui" )
require( "sprite_button" ):register( Raygui )
require( "property_list" ):register( Raygui )
+require( "tree_view" ):register( Raygui )
+require( "tree_item" ):register( Raygui )
Gui = Raygui:new()
@@ -72,11 +74,9 @@ local function addPropertyList()
PropertyList = Gui:PropertyList(
Rect:new( 20, 20, 256, 328 ),
"Property List",
- -- Callback.
- nil,
- -- Grab callback.
- function( self ) Gui:set2Top( self ) end,
- nil,
+ nil, -- Callback.
+ function( self ) Gui:set2Top( self ) end, -- Grab callback.
+ nil, -- Drag callback.
{
properties = {
-- { RL.SCROLLBAR, RL.ARROWS_VISIBLE, RL.ARROWS_VISIBLE },
@@ -240,6 +240,42 @@ local function addPropertyList()
end
end
+local function selected( controls )
+ for i, control in ipairs( controls ) do
+ print( i, control.text, control._id )
+ end
+end
+
+local function addTreeView()
+ TreeView = Gui:TreeView(
+ Rect:new( 600, 20, 256, 328 ),
+ -- Rect:new( 600, 20, 256, 600 ),
+ "Tree View",
+ function( controls ) selected( controls ) end, -- Callback.
+ function( self ) Gui:set2Top( self ) end, -- Grab callback.
+ nil, -- Drag callback.
+ {
+ properties = {
+ -- { RL.SCROLLBAR, RL.ARROWS_VISIBLE, RL.ARROWS_VISIBLE },
+ { RL.LISTVIEW, RL.BORDER_COLOR_FOCUSED, RL.GuiGetStyle( RL.LISTVIEW, RL.BORDER_COLOR_NORMAL ) },
+ { RL.LISTVIEW, RL.BORDER_COLOR_PRESSED, RL.GuiGetStyle( RL.LISTVIEW, RL.BORDER_COLOR_NORMAL ) },
+ }
+ }
+ )
+ -- Items.
+
+ local folder = TreeView:addItem( RL.GuiIconText( 1, "Images" ) )
+ local folderEmpty = TreeView:addItem( RL.GuiIconText( 1, "Empty Folder" ) )
+ local folder2 = TreeView:addItem( RL.GuiIconText( 1, "More images" ), folder )
+ TreeView:addItem( RL.GuiIconText( 12, "Cat.png" ), folder )
+ TreeView:addItem( RL.GuiIconText( 12, "Dog.png" ), folder2 )
+ TreeView:addItem( RL.GuiIconText( 12, "Horse.png" ), folder2 )
+
+ for i = 0, 10 do
+ TreeView:addItem( RL.GuiIconText( 12, "Duck"..i..".png" ), folder2 )
+ end
+end
+
function RL.init()
local monitor = 0
local mPos = Vec2:new( RL.GetMonitorPosition( monitor ) )
@@ -264,6 +300,7 @@ function RL.init()
addSpriteButtons()
addPropertyList()
+ addTreeView()
end
function RL.update( delta )