Raygui wrapper examples.
This commit is contained in:
14
devnotes
14
devnotes
@@ -1,18 +1,18 @@
|
|||||||
Current {
|
Current {
|
||||||
* Check new functions from https://github.com/raysan5/raylib/blob/master/CHANGELOG
|
* Check raylib changes from https://github.com/raysan5/raylib/blob/master/CHANGELOG
|
||||||
* Tilemap clib.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Backlog {
|
Backlog {
|
||||||
* IsWaveReady and other Is* ready functions.
|
|
||||||
* Extend color lib functionality.
|
|
||||||
|
|
||||||
* Platformer example physics process for true framerate independence.
|
* Platformer example physics process for true framerate independence.
|
||||||
* rlgl
|
* Extend color lib functionality.
|
||||||
* More low level functions. Could be usefull now when for example draw polygon is removed.
|
* Tilemap clib. Fast tilemap draw and clib example.
|
||||||
|
|
||||||
|
* IsWaveReady and other Is* ready functions.
|
||||||
* Text
|
* Text
|
||||||
* Ability to set font texture filtering.
|
* Ability to set font texture filtering.
|
||||||
* Codepoints?
|
* Codepoints?
|
||||||
|
* rlgl
|
||||||
|
* More low level functions. Could be usefull now when for example DrawTexturePoly is removed.
|
||||||
* Audio
|
* Audio
|
||||||
* AudioStream.
|
* AudioStream.
|
||||||
* Core.
|
* Core.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package.path = package.path..";"..RL.GetBasePath().."?.lua"
|
package.path = package.path..";"..RL.GetBasePath().."?.lua"
|
||||||
package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua"
|
package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua"
|
||||||
|
|
||||||
Util = require( "utillib" )
|
util = require( "utillib" )
|
||||||
Vec2 = require( "vector2" )
|
Vec2 = require( "vector2" )
|
||||||
Rect = require( "rectangle" )
|
Rect = require( "rectangle" )
|
||||||
Color = require( "color" )
|
Color = require( "color" )
|
||||||
|
|||||||
160
examples/raygui_examples/calculator.lua
Normal file
160
examples/raygui_examples/calculator.lua
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
Calculator = {}
|
||||||
|
Calculator.__index = Calculator
|
||||||
|
|
||||||
|
Calculator.OPERATIONS = {
|
||||||
|
ADD = 0,
|
||||||
|
SUB = 1,
|
||||||
|
DIV = 2,
|
||||||
|
MUL = 3,
|
||||||
|
EQUAL = 4,
|
||||||
|
CLEAR = 5,
|
||||||
|
}
|
||||||
|
|
||||||
|
function Calculator:new( pos )
|
||||||
|
local object = setmetatable( {}, Calculator )
|
||||||
|
|
||||||
|
object.window = Raygui.WindowBox:new(
|
||||||
|
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
|
||||||
|
)
|
||||||
|
object.display = Raygui.Label:new(
|
||||||
|
Rect:new( 0, 0, 180, 20 ),
|
||||||
|
""
|
||||||
|
)
|
||||||
|
object.display.position = Vec2:new( 10, 32 )
|
||||||
|
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 },
|
||||||
|
}
|
||||||
|
local rowCount = 4
|
||||||
|
local buttonRect = Rect:new( 5, 64, 40, 32 )
|
||||||
|
local startPos = Vec2:new( buttonRect.x, buttonRect.y )
|
||||||
|
local buttonSpacing = 6
|
||||||
|
|
||||||
|
for i, button in ipairs( buttons ) do
|
||||||
|
table.insert( object.buttons, Raygui.Button:new(
|
||||||
|
buttonRect:clone(),
|
||||||
|
button[1],
|
||||||
|
button[2]
|
||||||
|
) )
|
||||||
|
-- Set position in window.
|
||||||
|
object.buttons[i].position = Vec2:new( buttonRect.x, buttonRect.y )
|
||||||
|
|
||||||
|
if i % rowCount == 0 then
|
||||||
|
buttonRect.x = startPos.x
|
||||||
|
buttonRect.y = buttonRect.y + buttonRect.height + buttonSpacing
|
||||||
|
else
|
||||||
|
buttonRect.x = buttonRect.x + buttonRect.width + buttonSpacing
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
object.visible = true
|
||||||
|
object.numbers = { "", "" }
|
||||||
|
object.op = nil
|
||||||
|
|
||||||
|
object:setPosition( pos )
|
||||||
|
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
function Calculator:addNumber( num )
|
||||||
|
if self.op == nil then
|
||||||
|
self.numbers[1] = self.numbers[1]..tostring( num )
|
||||||
|
else
|
||||||
|
self.numbers[2] = self.numbers[2]..tostring( num )
|
||||||
|
end
|
||||||
|
|
||||||
|
self:updateDisplay()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Calculator:addOperation( op )
|
||||||
|
if op == self.OPERATIONS.EQUAL then
|
||||||
|
if self.op == self.OPERATIONS.ADD then
|
||||||
|
self.numbers[1] = tonumber( self.numbers[1] ) + tonumber( self.numbers[2] )
|
||||||
|
elseif self.op == self.OPERATIONS.SUB then
|
||||||
|
self.numbers[1] = tonumber( self.numbers[1] ) - tonumber( self.numbers[2] )
|
||||||
|
elseif self.op == self.OPERATIONS.MUL then
|
||||||
|
self.numbers[1] = tonumber( self.numbers[1] ) * tonumber( self.numbers[2] )
|
||||||
|
elseif self.op == self.OPERATIONS.DIV then
|
||||||
|
self.numbers[1] = tonumber( self.numbers[1] ) / tonumber( self.numbers[2] )
|
||||||
|
end
|
||||||
|
|
||||||
|
self.numbers[2] = ""
|
||||||
|
self.op = nil
|
||||||
|
elseif op == self.OPERATIONS.CLEAR then
|
||||||
|
self.numbers[1] = ""
|
||||||
|
self.numbers[2] = ""
|
||||||
|
self.op = nil
|
||||||
|
else
|
||||||
|
self.op = op
|
||||||
|
end
|
||||||
|
|
||||||
|
self:updateDisplay()
|
||||||
|
end
|
||||||
|
|
||||||
|
function Calculator:updateDisplay()
|
||||||
|
self.display.text = self.numbers[1]
|
||||||
|
|
||||||
|
if self.op == self.OPERATIONS.ADD then
|
||||||
|
self.display.text = self.display.text.."+"
|
||||||
|
elseif self.op == self.OPERATIONS.SUB then
|
||||||
|
self.display.text = self.display.text.."-"
|
||||||
|
elseif self.op == self.OPERATIONS.MUL then
|
||||||
|
self.display.text = self.display.text.."*"
|
||||||
|
elseif self.op == self.OPERATIONS.DIV then
|
||||||
|
self.display.text = self.display.text.."/"
|
||||||
|
end
|
||||||
|
|
||||||
|
self.display.text = self.display.text..self.numbers[2]
|
||||||
|
end
|
||||||
|
|
||||||
|
function Calculator:setPosition( pos )
|
||||||
|
self.display:setPosition( pos + self.display.position )
|
||||||
|
|
||||||
|
for _, button in ipairs( self.buttons ) do
|
||||||
|
button:setPosition( pos + button.position )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Calculator:set2Top()
|
||||||
|
Raygui.set2Top( self.window )
|
||||||
|
Raygui.set2Top( self.display )
|
||||||
|
|
||||||
|
for _, button in ipairs( self.buttons ) do
|
||||||
|
Raygui.set2Top( button )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Calculator:setVisible( visible )
|
||||||
|
self.visible = visible
|
||||||
|
self.window.visible = visible
|
||||||
|
self.display.visible = visible
|
||||||
|
|
||||||
|
for _, button in ipairs( self.buttons ) do
|
||||||
|
button.visible = visible
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return Calculator
|
||||||
44
examples/raygui_examples/main.lua
Normal file
44
examples/raygui_examples/main.lua
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
package.path = package.path..";"..RL.GetBasePath().."?.lua"
|
||||||
|
package.path = package.path..";"..RL.GetBasePath().."../resources/lib/?.lua"
|
||||||
|
|
||||||
|
|
||||||
|
Util = require( "utillib" )
|
||||||
|
Rect = require( "rectangle" )
|
||||||
|
Vec2 = require( "vector2" )
|
||||||
|
Color = require( "color" )
|
||||||
|
Raygui = require( "raygui" )
|
||||||
|
Calculator = require( "calculator" )
|
||||||
|
|
||||||
|
local calculator = nil
|
||||||
|
local calculator2 = nil
|
||||||
|
|
||||||
|
function RL.init()
|
||||||
|
local monitor = 0
|
||||||
|
local mPos = Vec2:new( RL.GetMonitorPosition( monitor ) )
|
||||||
|
local mSize = Vec2:new( RL.GetMonitorSize( monitor ) )
|
||||||
|
local winSize = Vec2:new( 1024, 800 )
|
||||||
|
|
||||||
|
RL.SetWindowTitle( "Raygui examples" )
|
||||||
|
RL.SetWindowState( RL.FLAG_WINDOW_RESIZABLE )
|
||||||
|
RL.SetWindowState( RL.FLAG_VSYNC_HINT )
|
||||||
|
RL.SetWindowSize( winSize )
|
||||||
|
RL.SetWindowPosition( { mPos.x + mSize.x / 2 - winSize.x / 2, mPos.y + mSize.y / 2 - winSize.y / 2 } )
|
||||||
|
|
||||||
|
RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SIZE, 20 )
|
||||||
|
RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SPACING, 4 )
|
||||||
|
|
||||||
|
calculator = Calculator:new( Vec2:new( 32, 32 ) )
|
||||||
|
calculator2 = Calculator:new( Vec2:new( 64, 65 ) )
|
||||||
|
end
|
||||||
|
|
||||||
|
function RL.process( delta )
|
||||||
|
-- Gui:process()
|
||||||
|
Raygui:process()
|
||||||
|
end
|
||||||
|
|
||||||
|
function RL.draw()
|
||||||
|
RL.ClearBackground( RL.DARKBLUE )
|
||||||
|
|
||||||
|
-- Gui:draw()
|
||||||
|
Raygui:draw()
|
||||||
|
end
|
||||||
@@ -6,8 +6,6 @@ Vec2 = require( "vector2" )
|
|||||||
Color = require( "color" )
|
Color = require( "color" )
|
||||||
Raygui = require( "raygui" )
|
Raygui = require( "raygui" )
|
||||||
|
|
||||||
local raygui = Raygui:new()
|
|
||||||
|
|
||||||
local grid = {}
|
local grid = {}
|
||||||
local windowbox = {}
|
local windowbox = {}
|
||||||
local winOpen = true
|
local winOpen = true
|
||||||
@@ -27,39 +25,39 @@ function RL.init()
|
|||||||
RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SPACING, 4 )
|
RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_SPACING, 4 )
|
||||||
RL.GuiSetStyle( RL.SPINNER, RL.TEXT_ALIGNMENT, RL.TEXT_ALIGN_RIGHT )
|
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 ),
|
Rect:new( 16, 16, 64, 32 ),
|
||||||
"Cat"
|
"Cat"
|
||||||
) )
|
)
|
||||||
local toggleGroup = raygui:add( raygui.ToggleGroup:new(
|
local toggleGroup = Raygui.ToggleGroup:new(
|
||||||
Rect:new( 68, 16, 64, 32 ),
|
Rect:new( 68, 16, 64, 32 ),
|
||||||
"Cat\nDog",
|
"Cat\nDog",
|
||||||
0,
|
0,
|
||||||
function( self ) print( self:getItem( self.active ) ) end
|
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 ),
|
Rect:new( 245, 188, 64, 32 ),
|
||||||
"Dog",
|
"Dog",
|
||||||
function() toggleGroup:setText( "Dog;Cat\nEagle" ) end
|
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 ),
|
Rect:new( 64, 128, 20, 20 ),
|
||||||
"Dog",
|
"Dog",
|
||||||
false
|
false
|
||||||
) )
|
)
|
||||||
local combobox = raygui:add( raygui.ComboBox:new(
|
local combobox = Raygui.ComboBox:new(
|
||||||
Rect:new( 64, 256, 128, 32 ),
|
Rect:new( 64, 256, 128, 32 ),
|
||||||
"Dog\nCow\nDonkey",
|
"Dog\nCow\nDonkey",
|
||||||
0
|
0
|
||||||
) )
|
)
|
||||||
local dropdownbox = raygui:add( raygui.DropdownBox:new(
|
local dropdownbox = Raygui.DropdownBox:new(
|
||||||
Rect:new( 256, 128, 128, 32 ),
|
Rect:new( 256, 128, 128, 32 ),
|
||||||
"Dog\nGiraffe\nLion\nHorse",
|
"Dog\nGiraffe\nLion\nHorse",
|
||||||
0,
|
0,
|
||||||
false,
|
false,
|
||||||
function( self ) print( self:getItem( self.active ) ) end
|
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 ),
|
Rect:new( 464, 256, 128, 32 ),
|
||||||
"Health",
|
"Health",
|
||||||
0,
|
0,
|
||||||
@@ -67,8 +65,8 @@ function RL.init()
|
|||||||
10,
|
10,
|
||||||
false,
|
false,
|
||||||
function( self ) print( "Spinner value changed to "..self.value ) end
|
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 ),
|
Rect:new( 464, 316, 128, 32 ),
|
||||||
"Health",
|
"Health",
|
||||||
0,
|
0,
|
||||||
@@ -76,22 +74,22 @@ function RL.init()
|
|||||||
100,
|
100,
|
||||||
false,
|
false,
|
||||||
function( self ) print( "ValueBox value changed to "..self.value ) end
|
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 ),
|
Rect:new( 32, 316, 256, 32 ),
|
||||||
"Name",
|
"Name",
|
||||||
32,
|
32,
|
||||||
false,
|
false,
|
||||||
function( self ) print( "Set text "..self.text ) end
|
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 ),
|
Rect:new( 32, 400, 256, 64 ),
|
||||||
"Buggy?",
|
"Buggy?",
|
||||||
32,
|
32,
|
||||||
false,
|
false,
|
||||||
function( self ) print( "Set text "..self.text ) end
|
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 ),
|
Rect:new( 50, 500, 256, 32 ),
|
||||||
"min",
|
"min",
|
||||||
"max",
|
"max",
|
||||||
@@ -99,8 +97,8 @@ function RL.init()
|
|||||||
0,
|
0,
|
||||||
100,
|
100,
|
||||||
function( self ) print( "Changed value "..self.value ) end
|
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 ),
|
Rect:new( 50, 550, 256, 32 ),
|
||||||
"min",
|
"min",
|
||||||
"max",
|
"max",
|
||||||
@@ -108,8 +106,8 @@ function RL.init()
|
|||||||
0,
|
0,
|
||||||
100,
|
100,
|
||||||
function( self ) print( "Changed value "..self.value ) end
|
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 ),
|
Rect:new( 50, 600, 256, 32 ),
|
||||||
"min",
|
"min",
|
||||||
"max",
|
"max",
|
||||||
@@ -117,60 +115,69 @@ function RL.init()
|
|||||||
0,
|
0,
|
||||||
100,
|
100,
|
||||||
function( self ) print( "Changed value "..self.value ) end
|
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 ),
|
Rect:new( 50, 650, 256, 32 ),
|
||||||
"StatusBar"
|
"StatusBar"
|
||||||
) )
|
)
|
||||||
local dummyrec = raygui:add( raygui.DummyRec:new(
|
local dummyrec = Raygui.DummyRec:new(
|
||||||
Rect:new( 50, 700, 256, 32 ),
|
Rect:new( 50, 700, 256, 32 ),
|
||||||
"DummyRec"
|
"DummyRec"
|
||||||
) )
|
)
|
||||||
grid = raygui:add( raygui.Grid:new(
|
grid = Raygui.Grid:new(
|
||||||
Rect:new( 400, 400, 256, 256 ),
|
Rect:new( 400, 400, 256, 256 ),
|
||||||
"Grid",
|
"Grid",
|
||||||
32,
|
32,
|
||||||
2
|
2
|
||||||
) )
|
)
|
||||||
windowbox = raygui:add( raygui.WindowBox:new(
|
windowbox = Raygui.WindowBox:new(
|
||||||
Rect:new( 720, 250, 256, 256 ),
|
Rect:new( 720, 250, 256, 256 ),
|
||||||
"WindowBox",
|
"WindowBox",
|
||||||
function( self ) self.visible = false end
|
-- Close callback.
|
||||||
) )
|
function( self ) self.visible = false end,
|
||||||
local groupbox = raygui:add( raygui.GroupBox:new(
|
-- Grab callback.
|
||||||
|
function( self ) Raygui.set2Top( self ) end
|
||||||
|
)
|
||||||
|
local groupbox = Raygui.GroupBox:new(
|
||||||
Rect:new( 400, 700, 256, 256 ),
|
Rect:new( 400, 700, 256, 256 ),
|
||||||
"GroupBox"
|
"GroupBox"
|
||||||
) )
|
)
|
||||||
local line = raygui:add( raygui.Line:new(
|
local line = Raygui.Line:new(
|
||||||
Rect:new( 400, 32, 256, 16 ),
|
Rect:new( 400, 32, 256, 16 ),
|
||||||
"Line"
|
"Line"
|
||||||
) )
|
)
|
||||||
local panel = raygui:add( raygui.Panel:new(
|
local panel = Raygui.Panel:new(
|
||||||
Rect:new( 400, 64, 256, 128 ),
|
Rect:new( 400, 64, 256, 128 ),
|
||||||
"Panel"
|
"Panel",
|
||||||
) )
|
-- Grab callback.
|
||||||
local scrollpanel = raygui:add( raygui.ScrollPanel:new(
|
function( self ) Raygui.set2Top( self ) end
|
||||||
|
)
|
||||||
|
local scrollpanel = Raygui.ScrollPanel:new(
|
||||||
Rect:new( 800, 64, 256, 256 ),
|
Rect:new( 800, 64, 256, 256 ),
|
||||||
"ScrollPanel",
|
"ScrollPanel",
|
||||||
Rect:new( 0, 0, 256, 600 ),
|
Rect:new( 0, 0, 256, 600 ),
|
||||||
Vec2:new( 0, 0 )
|
Vec2:new( 0, 0 ),
|
||||||
) )
|
-- Callback.
|
||||||
local listview = raygui:add( raygui.ListView:new(
|
nil,
|
||||||
|
-- Grab callback.
|
||||||
|
function( self ) Raygui.set2Top( self ) end
|
||||||
|
)
|
||||||
|
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\nDog\nHorse\nCow\nPig\nEagle\nLion",
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
function( self ) print( self:getItem( self.active ) ) end
|
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 ),
|
Rect:new( 1300, 64, 128, 80 ),
|
||||||
"Cat\nDog\nHorse\nCow\nPig\nEagle\nLion",
|
"Cat\nDog\nHorse\nCow\nPig\nEagle\nLion",
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
function( self ) print( self:getItem( self.active ) ) end
|
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 ),
|
Rect:new( 1100, 150, 300, 128 ),
|
||||||
"Title",
|
"Title",
|
||||||
"Message",
|
"Message",
|
||||||
@@ -180,14 +187,16 @@ function RL.init()
|
|||||||
print( "You pressed "..self:getItem( self.buttonIndex ) )
|
print( "You pressed "..self:getItem( self.buttonIndex ) )
|
||||||
|
|
||||||
if self.buttonIndex == 1 then
|
if self.buttonIndex == 1 then
|
||||||
raygui:set2Back( windowbox )
|
Raygui.set2Back( windowbox )
|
||||||
elseif self.buttonIndex == 2 then
|
elseif self.buttonIndex == 2 then
|
||||||
raygui:set2Top( windowbox )
|
Raygui.set2Top( windowbox )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end,
|
||||||
) )
|
-- Grab callback.
|
||||||
local textinputbox = raygui:add( raygui.TextInputBox:new(
|
function( self ) Raygui.set2Top( self ) end
|
||||||
|
)
|
||||||
|
local textinputbox = Raygui.TextInputBox:new(
|
||||||
Rect:new( 1100, 300, 300, 128 ),
|
Rect:new( 1100, 300, 300, 128 ),
|
||||||
"Title",
|
"Title",
|
||||||
"Message",
|
"Message",
|
||||||
@@ -199,40 +208,42 @@ function RL.init()
|
|||||||
if 0 < self.buttonIndex then
|
if 0 < self.buttonIndex then
|
||||||
print( "You pressed "..self:getItem( self.buttonIndex ) )
|
print( "You pressed "..self:getItem( self.buttonIndex ) )
|
||||||
end
|
end
|
||||||
end
|
end,
|
||||||
) )
|
-- Grab callback.
|
||||||
local colorpicker = raygui:add( raygui.ColorPicker:new(
|
function( self ) Raygui.set2Top( self ) end
|
||||||
|
)
|
||||||
|
local colorpicker = Raygui.ColorPicker:new(
|
||||||
Rect:new( 1500, 32, 128, 128 ),
|
Rect:new( 1500, 32, 128, 128 ),
|
||||||
"Color Picker",
|
"Color Picker",
|
||||||
Color:new()
|
Color:new()
|
||||||
) )
|
)
|
||||||
local colorpanel = raygui:add( raygui.ColorPanel:new(
|
local colorpanel = Raygui.ColorPanel:new(
|
||||||
Rect:new( 1700, 32, 128, 128 ),
|
Rect:new( 1700, 32, 128, 128 ),
|
||||||
"Color Panel",
|
"Color Panel",
|
||||||
Color:new()
|
Color:new()
|
||||||
) )
|
)
|
||||||
local colorbaralpha = raygui:add( raygui.ColorBarAlpha:new(
|
local colorbaralpha = Raygui.ColorBarAlpha:new(
|
||||||
Rect:new( 1700, 180, 128, 20 ),
|
Rect:new( 1700, 180, 128, 20 ),
|
||||||
"Color Panel",
|
"Color Panel",
|
||||||
1.0
|
1.0
|
||||||
) )
|
)
|
||||||
local colorbarhue = raygui:add( raygui.ColorBarHue:new(
|
local colorbarhue = Raygui.ColorBarHue:new(
|
||||||
Rect:new( 1840, 32, 20, 128 ),
|
Rect:new( 1840, 32, 20, 128 ),
|
||||||
"Color Panel",
|
"Color Panel",
|
||||||
1.0
|
1.0
|
||||||
) )
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
function RL.process( delta )
|
function RL.process( delta )
|
||||||
if RL.IsKeyPressed( RL.KEY_R ) then
|
if RL.IsKeyPressed( RL.KEY_R ) then
|
||||||
raygui:set2Top( windowbox )
|
Raygui.set2Top( windowbox )
|
||||||
end
|
end
|
||||||
|
|
||||||
if RL.IsKeyPressed( RL.KEY_F ) then
|
if RL.IsKeyPressed( RL.KEY_F ) then
|
||||||
raygui:set2Back( windowbox )
|
Raygui.set2Back( windowbox )
|
||||||
end
|
end
|
||||||
|
|
||||||
raygui:process()
|
Raygui.process()
|
||||||
end
|
end
|
||||||
|
|
||||||
function RL.draw()
|
function RL.draw()
|
||||||
@@ -250,5 +261,5 @@ function RL.draw()
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
raygui:draw()
|
Raygui.draw()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -47,31 +47,29 @@ end
|
|||||||
|
|
||||||
-- Raygui.
|
-- Raygui.
|
||||||
|
|
||||||
Raygui = {}
|
Raygui = {
|
||||||
Raygui.__index = Raygui
|
RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT = 24,
|
||||||
|
|
||||||
function Raygui:new()
|
elements = {},
|
||||||
local object = setmetatable( {}, Raygui )
|
focused = 0,
|
||||||
|
dragging = nil,
|
||||||
|
grabPos = Vec2:new(),
|
||||||
|
}
|
||||||
|
|
||||||
object.elements = {}
|
function Raygui.process()
|
||||||
object.focused = 0
|
-- If dragging, don't process element masking.
|
||||||
|
if Raygui.dragging ~= nil then
|
||||||
|
Raygui.drag( Raygui.dragging )
|
||||||
|
|
||||||
return object
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
function Raygui:add( element )
|
for i = #Raygui.elements, 1, -1 do
|
||||||
table.insert( self.elements, element )
|
local element = Raygui.elements[i]
|
||||||
|
|
||||||
return element
|
|
||||||
end
|
|
||||||
|
|
||||||
function Raygui:process()
|
|
||||||
for i = #self.elements, 1, -1 do
|
|
||||||
local element = self.elements[i]
|
|
||||||
|
|
||||||
if element.visible and element.process ~= nil then
|
if element.visible and element.process ~= nil then
|
||||||
if element:process() then
|
if element:process() then
|
||||||
self.focused = i
|
Raygui.focused = i
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -79,11 +77,40 @@ function Raygui:process()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Raygui:draw()
|
function Raygui.drag( element )
|
||||||
RL.GuiLock()
|
local mousePos = Vec2:new( RL.GetMousePosition() )
|
||||||
|
local mouseOver = RL.CheckCollisionPointRec( mousePos, element.bounds )
|
||||||
|
|
||||||
for i, element in ipairs( self.elements ) do
|
if element.draggable and element ~= Raygui.dragging and RL.IsMouseButtonPressed( RL.MOUSE_BUTTON_LEFT )
|
||||||
if i == self.focused then
|
and mouseOver and mousePos.y - element.bounds.y <= Raygui.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT then
|
||||||
|
Raygui.grabPos = mousePos - Vec2:new( element.bounds.x, element.bounds.y )
|
||||||
|
|
||||||
|
if element.grabCallback ~= nil then
|
||||||
|
element.grabCallback( element )
|
||||||
|
end
|
||||||
|
Raygui.dragging = element
|
||||||
|
end
|
||||||
|
|
||||||
|
if element == Raygui.dragging then
|
||||||
|
if not RL.IsMouseButtonDown( RL.MOUSE_BUTTON_LEFT ) then
|
||||||
|
Raygui.dragging = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
element:setPosition( mousePos - Raygui.grabPos )
|
||||||
|
|
||||||
|
if element.dragCallback ~= nil then
|
||||||
|
element.dragCallback( element )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return mouseOver
|
||||||
|
end
|
||||||
|
|
||||||
|
function Raygui.draw()
|
||||||
|
RL.GuiLock()
|
||||||
|
|
||||||
|
for i, element in ipairs( Raygui.elements ) do
|
||||||
|
if i == Raygui.focused then
|
||||||
RL.GuiUnlock()
|
RL.GuiUnlock()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -93,20 +120,20 @@ function Raygui:draw()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Raygui:set2Top( element )
|
function Raygui.set2Top( element )
|
||||||
for i, curElement in ipairs( self.elements ) do
|
for i, curElement in ipairs( Raygui.elements ) do
|
||||||
if element == curElement then
|
if element == curElement then
|
||||||
Util.tableMove( self.elements, i, 1, #self.elements )
|
Util.tableMove( Raygui.elements, i, 1, #Raygui.elements )
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Raygui:set2Back( element )
|
function Raygui.set2Back( element )
|
||||||
for i, curElement in ipairs( self.elements ) do
|
for i, curElement in ipairs( Raygui.elements ) do
|
||||||
if element == curElement then
|
if element == curElement then
|
||||||
Util.tableMove( self.elements, i, 1, 1 )
|
Util.tableMove( Raygui.elements, i, 1, 1 )
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -119,23 +146,43 @@ end
|
|||||||
|
|
||||||
-- WindowBox.
|
-- WindowBox.
|
||||||
|
|
||||||
|
--- Window Box control, shows a window that can be closed
|
||||||
|
---@class WindowBox
|
||||||
|
---@field bounds table Rect
|
||||||
|
---@field text string
|
||||||
|
---@field callback function|nil
|
||||||
|
---@field grabCallback function|nil
|
||||||
|
---@field dragCallback function|nil
|
||||||
|
---@field visible boolean
|
||||||
|
---@field draggable boolean
|
||||||
WindowBox = {}
|
WindowBox = {}
|
||||||
WindowBox.__index = WindowBox
|
WindowBox.__index = WindowBox
|
||||||
|
|
||||||
function WindowBox:new( bounds, text, callback )
|
---@param bounds table Rect
|
||||||
|
---@param text string
|
||||||
|
---@param callback function|nil
|
||||||
|
---@param grabCallback function|nil
|
||||||
|
---@param dragCallback function|nil
|
||||||
|
---@return table object
|
||||||
|
function WindowBox:new( bounds, text, callback, grabCallback, dragCallback )
|
||||||
local object = setmetatable( {}, WindowBox )
|
local object = setmetatable( {}, WindowBox )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
object.text = text
|
object.text = text
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.grabCallback = grabCallback
|
||||||
|
object.dragCallback = dragCallback
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
object.draggable = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
function WindowBox:process()
|
function WindowBox:process()
|
||||||
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
return Raygui.drag( self )
|
||||||
end
|
end
|
||||||
|
|
||||||
function WindowBox:draw()
|
function WindowBox:draw()
|
||||||
@@ -151,9 +198,16 @@ end
|
|||||||
|
|
||||||
-- GroupBox.
|
-- GroupBox.
|
||||||
|
|
||||||
|
--- Group Box control with text name
|
||||||
|
---@class GroupBox
|
||||||
|
---@field bounds table Rect
|
||||||
|
---@field text string
|
||||||
|
---@field visible boolean
|
||||||
GroupBox = {}
|
GroupBox = {}
|
||||||
GroupBox.__index = GroupBox
|
GroupBox.__index = GroupBox
|
||||||
|
|
||||||
|
---@param bounds table Rect
|
||||||
|
---@param text string
|
||||||
function GroupBox:new( bounds, text )
|
function GroupBox:new( bounds, text )
|
||||||
local object = setmetatable( {}, GroupBox )
|
local object = setmetatable( {}, GroupBox )
|
||||||
|
|
||||||
@@ -162,6 +216,8 @@ function GroupBox:new( bounds, text )
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -180,6 +236,7 @@ end
|
|||||||
|
|
||||||
-- Line.
|
-- Line.
|
||||||
|
|
||||||
|
--- Line separator control, could contain text
|
||||||
Line = {}
|
Line = {}
|
||||||
Line.__index = Line
|
Line.__index = Line
|
||||||
|
|
||||||
@@ -191,6 +248,8 @@ function Line:new( bounds, text )
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -209,22 +268,28 @@ end
|
|||||||
|
|
||||||
-- Panel.
|
-- Panel.
|
||||||
|
|
||||||
|
--- Panel control, useful to group controls
|
||||||
Panel = {}
|
Panel = {}
|
||||||
Panel.__index = Panel
|
Panel.__index = Panel
|
||||||
|
|
||||||
function Panel:new( bounds, text )
|
function Panel:new( bounds, text, grabCallback, dragCallback )
|
||||||
local object = setmetatable( {}, Panel )
|
local object = setmetatable( {}, Panel )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
object.text = text
|
object.text = text
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
object.draggable = true
|
||||||
|
object.grabCallback = grabCallback
|
||||||
|
object.dragCallback = dragCallback
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
function Panel:process()
|
function Panel:process()
|
||||||
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
return Raygui.drag( self )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Panel:draw()
|
function Panel:draw()
|
||||||
@@ -238,10 +303,11 @@ end
|
|||||||
|
|
||||||
-- ScrollPanel.
|
-- ScrollPanel.
|
||||||
|
|
||||||
|
--- Scroll Panel control
|
||||||
ScrollPanel = {}
|
ScrollPanel = {}
|
||||||
ScrollPanel.__index = ScrollPanel
|
ScrollPanel.__index = ScrollPanel
|
||||||
|
|
||||||
function ScrollPanel:new( bounds, text, content, scroll, callback )
|
function ScrollPanel:new( bounds, text, content, scroll, callback, grabCallback, dragCallback )
|
||||||
local object = setmetatable( {}, ScrollPanel )
|
local object = setmetatable( {}, ScrollPanel )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
@@ -250,14 +316,19 @@ function ScrollPanel:new( bounds, text, content, scroll, callback )
|
|||||||
object.scroll = scroll:clone()
|
object.scroll = scroll:clone()
|
||||||
object.view = Rect:new()
|
object.view = Rect:new()
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.grabCallback = grabCallback
|
||||||
|
object.dragCallback = dragCallback
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
object.draggable = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
function ScrollPanel:process()
|
function ScrollPanel:process()
|
||||||
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
return Raygui.drag( self )
|
||||||
end
|
end
|
||||||
|
|
||||||
function ScrollPanel:draw()
|
function ScrollPanel:draw()
|
||||||
@@ -284,6 +355,7 @@ end
|
|||||||
|
|
||||||
-- Label.
|
-- Label.
|
||||||
|
|
||||||
|
--- Label control, shows text
|
||||||
Label = {}
|
Label = {}
|
||||||
Label.__index = Label
|
Label.__index = Label
|
||||||
|
|
||||||
@@ -295,6 +367,8 @@ function Label:new( bounds, text )
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -313,6 +387,7 @@ end
|
|||||||
|
|
||||||
-- Button.
|
-- Button.
|
||||||
|
|
||||||
|
--- Button control
|
||||||
Button = {}
|
Button = {}
|
||||||
Button.__index = Button
|
Button.__index = Button
|
||||||
|
|
||||||
@@ -326,6 +401,8 @@ function Button:new( bounds, text, callback )
|
|||||||
object.clicked = false
|
object.clicked = false
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -348,6 +425,7 @@ end
|
|||||||
|
|
||||||
-- LabelButton.
|
-- LabelButton.
|
||||||
|
|
||||||
|
--- Label button control
|
||||||
LabelButton = {}
|
LabelButton = {}
|
||||||
LabelButton.__index = LabelButton
|
LabelButton.__index = LabelButton
|
||||||
|
|
||||||
@@ -361,6 +439,8 @@ function LabelButton:new( bounds, text, callback )
|
|||||||
object.clicked = false
|
object.clicked = false
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -383,6 +463,7 @@ end
|
|||||||
|
|
||||||
-- Toggle.
|
-- Toggle.
|
||||||
|
|
||||||
|
--- Toggle Button control
|
||||||
Toggle = {}
|
Toggle = {}
|
||||||
Toggle.__index = Toggle
|
Toggle.__index = Toggle
|
||||||
|
|
||||||
@@ -396,6 +477,8 @@ function Toggle:new( bounds, text, active, callback )
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -420,6 +503,7 @@ end
|
|||||||
|
|
||||||
-- ToggleGroup.
|
-- ToggleGroup.
|
||||||
|
|
||||||
|
--- Toggle Group control
|
||||||
ToggleGroup = {}
|
ToggleGroup = {}
|
||||||
ToggleGroup.__index = ToggleGroup
|
ToggleGroup.__index = ToggleGroup
|
||||||
|
|
||||||
@@ -435,6 +519,8 @@ function ToggleGroup:new( bounds, text, active, callback )
|
|||||||
object.focusBounds = {}
|
object.focusBounds = {}
|
||||||
object:updateFocusBounds()
|
object:updateFocusBounds()
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -520,6 +606,8 @@ function CheckBox:new( bounds, text, checked, callback )
|
|||||||
object.focusBounds = bounds:clone()
|
object.focusBounds = bounds:clone()
|
||||||
object:updateFocusBounds()
|
object:updateFocusBounds()
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -585,6 +673,7 @@ end
|
|||||||
|
|
||||||
-- ComboBox.
|
-- ComboBox.
|
||||||
|
|
||||||
|
--- Combo Box control
|
||||||
ComboBox = {}
|
ComboBox = {}
|
||||||
ComboBox.__index = ComboBox
|
ComboBox.__index = ComboBox
|
||||||
|
|
||||||
@@ -598,6 +687,8 @@ function ComboBox:new( bounds, text, active, callback )
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -622,6 +713,7 @@ end
|
|||||||
|
|
||||||
-- DropdownBox.
|
-- DropdownBox.
|
||||||
|
|
||||||
|
--- Dropdown Box control
|
||||||
DropdownBox = {}
|
DropdownBox = {}
|
||||||
DropdownBox.__index = DropdownBox
|
DropdownBox.__index = DropdownBox
|
||||||
|
|
||||||
@@ -638,6 +730,8 @@ function DropdownBox:new( bounds, text, active, editMode, callback )
|
|||||||
object.editModeBounds = bounds:clone()
|
object.editModeBounds = bounds:clone()
|
||||||
object:updateFocusBounds()
|
object:updateFocusBounds()
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -691,6 +785,7 @@ end
|
|||||||
|
|
||||||
-- Spinner.
|
-- Spinner.
|
||||||
|
|
||||||
|
--- Spinner control
|
||||||
Spinner = {}
|
Spinner = {}
|
||||||
Spinner.__index = Spinner
|
Spinner.__index = Spinner
|
||||||
|
|
||||||
@@ -707,6 +802,8 @@ function Spinner:new( bounds, text, value, minValue, maxValue, editMode, callbac
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -736,6 +833,7 @@ end
|
|||||||
|
|
||||||
-- ValueBox.
|
-- ValueBox.
|
||||||
|
|
||||||
|
--- Value Box control
|
||||||
ValueBox = {}
|
ValueBox = {}
|
||||||
ValueBox.__index = ValueBox
|
ValueBox.__index = ValueBox
|
||||||
|
|
||||||
@@ -752,6 +850,8 @@ function ValueBox:new( bounds, text, value, minValue, maxValue, editMode, callba
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -781,6 +881,7 @@ end
|
|||||||
|
|
||||||
-- TextBox.
|
-- TextBox.
|
||||||
|
|
||||||
|
--- Text Box control
|
||||||
TextBox = {}
|
TextBox = {}
|
||||||
TextBox.__index = TextBox
|
TextBox.__index = TextBox
|
||||||
|
|
||||||
@@ -796,6 +897,8 @@ function TextBox:new( bounds, text, textSize, editMode, callback )
|
|||||||
object.scissorMode = false
|
object.scissorMode = false
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -832,6 +935,7 @@ end
|
|||||||
|
|
||||||
-- TextBoxMulti.
|
-- TextBoxMulti.
|
||||||
|
|
||||||
|
-- Text Box control with multiple lines
|
||||||
TextBoxMulti = {}
|
TextBoxMulti = {}
|
||||||
TextBoxMulti.__index = TextBoxMulti
|
TextBoxMulti.__index = TextBoxMulti
|
||||||
|
|
||||||
@@ -846,6 +950,8 @@ function TextBoxMulti:new( bounds, text, textSize, editMode, callback )
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -874,6 +980,7 @@ end
|
|||||||
|
|
||||||
-- Slider.
|
-- Slider.
|
||||||
|
|
||||||
|
--- Slider control
|
||||||
Slider = {}
|
Slider = {}
|
||||||
Slider.__index = Slider
|
Slider.__index = Slider
|
||||||
|
|
||||||
@@ -890,6 +997,8 @@ function Slider:new( bounds, textLeft, textRight, value, minValue, maxValue, cal
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -914,6 +1023,7 @@ end
|
|||||||
|
|
||||||
-- SliderBar.
|
-- SliderBar.
|
||||||
|
|
||||||
|
--- Slider Bar control
|
||||||
SliderBar = {}
|
SliderBar = {}
|
||||||
SliderBar.__index = SliderBar
|
SliderBar.__index = SliderBar
|
||||||
|
|
||||||
@@ -930,6 +1040,8 @@ function SliderBar:new( bounds, textLeft, textRight, value, minValue, maxValue,
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -954,6 +1066,7 @@ end
|
|||||||
|
|
||||||
-- ProgressBar.
|
-- ProgressBar.
|
||||||
|
|
||||||
|
--- Progress Bar control, shows current progress value
|
||||||
ProgressBar = {}
|
ProgressBar = {}
|
||||||
ProgressBar.__index = ProgressBar
|
ProgressBar.__index = ProgressBar
|
||||||
|
|
||||||
@@ -970,6 +1083,8 @@ function ProgressBar:new( bounds, textLeft, textRight, value, minValue, maxValue
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -994,6 +1109,7 @@ end
|
|||||||
|
|
||||||
-- StatusBar.
|
-- StatusBar.
|
||||||
|
|
||||||
|
--- Status Bar control, shows info text
|
||||||
StatusBar = {}
|
StatusBar = {}
|
||||||
StatusBar.__index = StatusBar
|
StatusBar.__index = StatusBar
|
||||||
|
|
||||||
@@ -1005,6 +1121,8 @@ function StatusBar:new( bounds, text )
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1023,6 +1141,7 @@ end
|
|||||||
|
|
||||||
-- DummyRec.
|
-- DummyRec.
|
||||||
|
|
||||||
|
--- Dummy control for placeholders
|
||||||
DummyRec = {}
|
DummyRec = {}
|
||||||
DummyRec.__index = DummyRec
|
DummyRec.__index = DummyRec
|
||||||
|
|
||||||
@@ -1034,6 +1153,8 @@ function DummyRec:new( bounds, text )
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1052,6 +1173,7 @@ end
|
|||||||
|
|
||||||
-- Grid.
|
-- Grid.
|
||||||
|
|
||||||
|
--- Grid control
|
||||||
Grid = {}
|
Grid = {}
|
||||||
Grid.__index = Grid
|
Grid.__index = Grid
|
||||||
|
|
||||||
@@ -1067,6 +1189,8 @@ function Grid:new( bounds, text, spacing, subdivs, callback )
|
|||||||
object.cell = Vec2:new()
|
object.cell = Vec2:new()
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1095,6 +1219,7 @@ end
|
|||||||
|
|
||||||
-- ListView.
|
-- ListView.
|
||||||
|
|
||||||
|
--- List View control
|
||||||
ListView = {}
|
ListView = {}
|
||||||
ListView.__index = ListView
|
ListView.__index = ListView
|
||||||
|
|
||||||
@@ -1108,6 +1233,8 @@ function ListView:new( bounds, text, scrollIndex, active, callback )
|
|||||||
object.callback = callback
|
object.callback = callback
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1136,6 +1263,7 @@ end
|
|||||||
|
|
||||||
-- ListViewEx.
|
-- ListViewEx.
|
||||||
|
|
||||||
|
--- List View with extended parameters
|
||||||
ListViewEx = {}
|
ListViewEx = {}
|
||||||
ListViewEx.__index = ListViewEx
|
ListViewEx.__index = ListViewEx
|
||||||
|
|
||||||
@@ -1150,6 +1278,8 @@ function ListViewEx:new( bounds, text, focus, scrollIndex, active, callback )
|
|||||||
object.callback = callback
|
object.callback = callback
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1178,10 +1308,11 @@ end
|
|||||||
|
|
||||||
-- MessageBox.
|
-- MessageBox.
|
||||||
|
|
||||||
|
--- Message Box control, displays a message
|
||||||
MessageBox = {}
|
MessageBox = {}
|
||||||
MessageBox.__index = MessageBox
|
MessageBox.__index = MessageBox
|
||||||
|
|
||||||
function MessageBox:new( bounds, title, message, buttons, callback )
|
function MessageBox:new( bounds, title, message, buttons, callback, grabCallback, dragCallback )
|
||||||
local object = setmetatable( {}, MessageBox )
|
local object = setmetatable( {}, MessageBox )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
@@ -1189,9 +1320,14 @@ function MessageBox:new( bounds, title, message, buttons, callback )
|
|||||||
object.message = message
|
object.message = message
|
||||||
object.buttons = buttons
|
object.buttons = buttons
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.grabCallback = grabCallback
|
||||||
|
object.dragCallback = dragCallback
|
||||||
|
|
||||||
object.buttonIndex = -1
|
object.buttonIndex = -1
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
object.draggable = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
@@ -1201,7 +1337,7 @@ function MessageBox:getItem( id )
|
|||||||
end
|
end
|
||||||
|
|
||||||
function MessageBox:process()
|
function MessageBox:process()
|
||||||
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
return Raygui.drag( self )
|
||||||
end
|
end
|
||||||
|
|
||||||
function MessageBox:draw()
|
function MessageBox:draw()
|
||||||
@@ -1219,10 +1355,11 @@ end
|
|||||||
|
|
||||||
-- TextInputBox.
|
-- TextInputBox.
|
||||||
|
|
||||||
|
--- Text Input Box control, ask for text, supports secret
|
||||||
TextInputBox = {}
|
TextInputBox = {}
|
||||||
TextInputBox.__index = TextInputBox
|
TextInputBox.__index = TextInputBox
|
||||||
|
|
||||||
function TextInputBox:new( bounds, title, message, buttons, text, textMaxSize, secretViewActive, callback )
|
function TextInputBox:new( bounds, title, message, buttons, text, textMaxSize, secretViewActive, callback, grabCallback, dragCallback )
|
||||||
local object = setmetatable( {}, TextInputBox )
|
local object = setmetatable( {}, TextInputBox )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
@@ -1233,9 +1370,14 @@ function TextInputBox:new( bounds, title, message, buttons, text, textMaxSize, s
|
|||||||
object.textMaxSize = textMaxSize
|
object.textMaxSize = textMaxSize
|
||||||
object.secretViewActive = secretViewActive
|
object.secretViewActive = secretViewActive
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.grabCallback = grabCallback
|
||||||
|
object.dragCallback = dragCallback
|
||||||
|
|
||||||
object.buttonIndex = -1
|
object.buttonIndex = -1
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
object.draggable = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
@@ -1245,7 +1387,7 @@ function TextInputBox:getItem( id )
|
|||||||
end
|
end
|
||||||
|
|
||||||
function TextInputBox:process()
|
function TextInputBox:process()
|
||||||
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
return Raygui.drag( self )
|
||||||
end
|
end
|
||||||
|
|
||||||
function TextInputBox:draw()
|
function TextInputBox:draw()
|
||||||
@@ -1263,6 +1405,7 @@ end
|
|||||||
|
|
||||||
-- ColorPicker.
|
-- ColorPicker.
|
||||||
|
|
||||||
|
--- Color Picker control ( multiple color controls )
|
||||||
ColorPicker = {}
|
ColorPicker = {}
|
||||||
ColorPicker.__index = ColorPicker
|
ColorPicker.__index = ColorPicker
|
||||||
|
|
||||||
@@ -1276,6 +1419,8 @@ function ColorPicker:new( bounds, text, color, callback )
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1301,6 +1446,7 @@ end
|
|||||||
|
|
||||||
-- ColorPanel.
|
-- ColorPanel.
|
||||||
|
|
||||||
|
--- Color Panel control
|
||||||
ColorPanel = {}
|
ColorPanel = {}
|
||||||
ColorPanel.__index = ColorPanel
|
ColorPanel.__index = ColorPanel
|
||||||
|
|
||||||
@@ -1314,6 +1460,8 @@ function ColorPanel:new( bounds, text, color, callback )
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1339,6 +1487,7 @@ end
|
|||||||
|
|
||||||
-- ColorBarAlpha.
|
-- ColorBarAlpha.
|
||||||
|
|
||||||
|
--- Color Bar Alpha control
|
||||||
ColorBarAlpha = {}
|
ColorBarAlpha = {}
|
||||||
ColorBarAlpha.__index = ColorBarAlpha
|
ColorBarAlpha.__index = ColorBarAlpha
|
||||||
|
|
||||||
@@ -1352,6 +1501,8 @@ function ColorBarAlpha:new( bounds, text, alpha, callback )
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1375,6 +1526,7 @@ end
|
|||||||
|
|
||||||
-- ColorBarHue.
|
-- ColorBarHue.
|
||||||
|
|
||||||
|
--- Color Bar Hue control
|
||||||
ColorBarHue = {}
|
ColorBarHue = {}
|
||||||
ColorBarHue.__index = ColorBarHue
|
ColorBarHue.__index = ColorBarHue
|
||||||
|
|
||||||
@@ -1388,6 +1540,8 @@ function ColorBarHue:new( bounds, text, value, callback )
|
|||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user