summaryrefslogtreecommitdiff
path: root/examples/raygui_lib/main.lua
diff options
context:
space:
mode:
Diffstat (limited to 'examples/raygui_lib/main.lua')
-rw-r--r--examples/raygui_lib/main.lua153
1 files changed, 82 insertions, 71 deletions
diff --git a/examples/raygui_lib/main.lua b/examples/raygui_lib/main.lua
index f2594fe..39f25cd 100644
--- a/examples/raygui_lib/main.lua
+++ b/examples/raygui_lib/main.lua
@@ -6,8 +6,6 @@ Vec2 = require( "vector2" )
Color = require( "color" )
Raygui = require( "raygui" )
-local raygui = Raygui:new()
-
local grid = {}
local windowbox = {}
local winOpen = true
@@ -27,39 +25,39 @@ function RL.init()
RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SPACING, 4 )
RL.GuiSetStyle( RL.SPINNER, RL.TEXT_ALIGNMENT, RL.TEXT_ALIGN_RIGHT )
- local label = raygui:add( raygui.Label:new(
+ local label = Raygui.Label:new(
Rect:new( 16, 16, 64, 32 ),
"Cat"
- ) )
- local toggleGroup = raygui:add( raygui.ToggleGroup:new(
+ )
+ local toggleGroup = Raygui.ToggleGroup:new(
Rect:new( 68, 16, 64, 32 ),
"Cat\nDog",
0,
function( self ) print( self:getItem( self.active ) ) end
- ) )
- local button = raygui:add( raygui.Button:new(
+ )
+ local button = Raygui.Button:new(
Rect:new( 245, 188, 64, 32 ),
"Dog",
function() toggleGroup:setText( "Dog;Cat\nEagle" ) end
- ) )
- local checkbox = raygui:add( raygui.CheckBox:new(
+ )
+ local checkbox = Raygui.CheckBox:new(
Rect:new( 64, 128, 20, 20 ),
"Dog",
false
- ) )
- local combobox = raygui:add( raygui.ComboBox:new(
+ )
+ local combobox = Raygui.ComboBox:new(
Rect:new( 64, 256, 128, 32 ),
"Dog\nCow\nDonkey",
0
- ) )
- local dropdownbox = raygui:add( raygui.DropdownBox:new(
+ )
+ local dropdownbox = Raygui.DropdownBox:new(
Rect:new( 256, 128, 128, 32 ),
"Dog\nGiraffe\nLion\nHorse",
0,
false,
function( self ) print( self:getItem( self.active ) ) end
- ) )
- local spinner = raygui:add( raygui.Spinner:new(
+ )
+ local spinner = Raygui.Spinner:new(
Rect:new( 464, 256, 128, 32 ),
"Health",
0,
@@ -67,8 +65,8 @@ function RL.init()
10,
false,
function( self ) print( "Spinner value changed to "..self.value ) end
- ) )
- local valuebox = raygui:add( raygui.ValueBox:new(
+ )
+ local valuebox = Raygui.ValueBox:new(
Rect:new( 464, 316, 128, 32 ),
"Health",
0,
@@ -76,22 +74,22 @@ function RL.init()
100,
false,
function( self ) print( "ValueBox value changed to "..self.value ) end
- ) )
- local textbox = raygui:add( raygui.TextBox:new(
+ )
+ local textbox = Raygui.TextBox:new(
Rect:new( 32, 316, 256, 32 ),
"Name",
32,
false,
function( self ) print( "Set text "..self.text ) end
- ) )
- local textboxmulti = raygui:add( raygui.TextBoxMulti:new(
+ )
+ 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:add( raygui.Slider:new(
+ )
+ local slider = Raygui.Slider:new(
Rect:new( 50, 500, 256, 32 ),
"min",
"max",
@@ -99,8 +97,8 @@ function RL.init()
0,
100,
function( self ) print( "Changed value "..self.value ) end
- ) )
- local sliderbar = raygui:add( raygui.SliderBar:new(
+ )
+ local sliderbar = Raygui.SliderBar:new(
Rect:new( 50, 550, 256, 32 ),
"min",
"max",
@@ -108,8 +106,8 @@ function RL.init()
0,
100,
function( self ) print( "Changed value "..self.value ) end
- ) )
- local progressbar = raygui:add( raygui.ProgressBar:new(
+ )
+ local progressbar = Raygui.ProgressBar:new(
Rect:new( 50, 600, 256, 32 ),
"min",
"max",
@@ -117,60 +115,69 @@ function RL.init()
0,
100,
function( self ) print( "Changed value "..self.value ) end
- ) )
- local statusbar = raygui:add( raygui.StatusBar:new(
+ )
+ local statusbar = Raygui.StatusBar:new(
Rect:new( 50, 650, 256, 32 ),
"StatusBar"
- ) )
- local dummyrec = raygui:add( raygui.DummyRec:new(
+ )
+ local dummyrec = Raygui.DummyRec:new(
Rect:new( 50, 700, 256, 32 ),
"DummyRec"
- ) )
- grid = raygui:add( raygui.Grid:new(
+ )
+ grid = Raygui.Grid:new(
Rect:new( 400, 400, 256, 256 ),
"Grid",
32,
2
- ) )
- windowbox = raygui:add( raygui.WindowBox:new(
+ )
+ windowbox = Raygui.WindowBox:new(
Rect:new( 720, 250, 256, 256 ),
"WindowBox",
- function( self ) self.visible = false end
- ) )
- local groupbox = raygui:add( raygui.GroupBox:new(
+ -- Close callback.
+ function( self ) self.visible = false end,
+ -- Grab callback.
+ function( self ) Raygui.set2Top( self ) end
+ )
+ local groupbox = Raygui.GroupBox:new(
Rect:new( 400, 700, 256, 256 ),
"GroupBox"
- ) )
- local line = raygui:add( raygui.Line:new(
+ )
+ local line = Raygui.Line:new(
Rect:new( 400, 32, 256, 16 ),
"Line"
- ) )
- local panel = raygui:add( raygui.Panel:new(
+ )
+ local panel = Raygui.Panel:new(
Rect:new( 400, 64, 256, 128 ),
- "Panel"
- ) )
- local scrollpanel = raygui:add( raygui.ScrollPanel:new(
+ "Panel",
+ -- Grab callback.
+ function( self ) Raygui.set2Top( self ) end
+ )
+ local scrollpanel = Raygui.ScrollPanel:new(
Rect:new( 800, 64, 256, 256 ),
"ScrollPanel",
Rect:new( 0, 0, 256, 600 ),
- Vec2:new( 0, 0 )
- ) )
- local listview = raygui:add( raygui.ListView:new(
+ Vec2:new( 0, 0 ),
+ -- Callback.
+ nil,
+ -- Grab callback.
+ function( self ) Raygui.set2Top( self ) end
+ )
+ local listview = Raygui.ListView:new(
Rect:new( 1100, 64, 128, 80 ),
"Cat\nDog\nHorse\nCow\nPig\nEagle\nLion",
0,
0,
function( self ) print( self:getItem( self.active ) ) end
- ) )
- local listviewex = raygui:add( raygui.ListViewEx:new(
+ )
+ local listviewex = Raygui.ListViewEx:new(
Rect:new( 1300, 64, 128, 80 ),
"Cat\nDog\nHorse\nCow\nPig\nEagle\nLion",
0,
0,
0,
function( self ) print( self:getItem( self.active ) ) end
- ) )
- local messagebox = raygui:add( raygui.MessageBox:new(
+ )
+ local messagebox = Raygui.MessageBox:new(
Rect:new( 1100, 150, 300, 128 ),
"Title",
"Message",
@@ -180,14 +187,16 @@ function RL.init()
print( "You pressed "..self:getItem( self.buttonIndex ) )
if self.buttonIndex == 1 then
- raygui:set2Back( windowbox )
+ Raygui.set2Back( windowbox )
elseif self.buttonIndex == 2 then
- raygui:set2Top( windowbox )
+ Raygui.set2Top( windowbox )
end
end
- end
- ) )
- local textinputbox = raygui:add( raygui.TextInputBox:new(
+ end,
+ -- Grab callback.
+ function( self ) Raygui.set2Top( self ) end
+ )
+ local textinputbox = Raygui.TextInputBox:new(
Rect:new( 1100, 300, 300, 128 ),
"Title",
"Message",
@@ -199,40 +208,42 @@ function RL.init()
if 0 < self.buttonIndex then
print( "You pressed "..self:getItem( self.buttonIndex ) )
end
- end
- ) )
- local colorpicker = raygui:add( raygui.ColorPicker:new(
+ end,
+ -- Grab callback.
+ function( self ) Raygui.set2Top( self ) end
+ )
+ local colorpicker = Raygui.ColorPicker:new(
Rect:new( 1500, 32, 128, 128 ),
"Color Picker",
Color:new()
- ) )
- local colorpanel = raygui:add( raygui.ColorPanel:new(
+ )
+ local colorpanel = Raygui.ColorPanel:new(
Rect:new( 1700, 32, 128, 128 ),
"Color Panel",
Color:new()
- ) )
- local colorbaralpha = raygui:add( raygui.ColorBarAlpha:new(
+ )
+ local colorbaralpha = Raygui.ColorBarAlpha:new(
Rect:new( 1700, 180, 128, 20 ),
"Color Panel",
1.0
- ) )
- local colorbarhue = raygui:add( raygui.ColorBarHue:new(
+ )
+ local colorbarhue = Raygui.ColorBarHue:new(
Rect:new( 1840, 32, 20, 128 ),
"Color Panel",
1.0
- ) )
+ )
end
function RL.process( delta )
if RL.IsKeyPressed( RL.KEY_R ) then
- raygui:set2Top( windowbox )
+ Raygui.set2Top( windowbox )
end
if RL.IsKeyPressed( RL.KEY_F ) then
- raygui:set2Back( windowbox )
+ Raygui.set2Back( windowbox )
end
- raygui:process()
+ Raygui.process()
end
function RL.draw()
@@ -250,5 +261,5 @@ function RL.draw()
)
end
- raygui:draw()
+ Raygui.draw()
end