Raygui wrapper lib finished.
This commit is contained in:
@@ -9,6 +9,7 @@ KEY CHANGES:
|
|||||||
- REVISED: How Lua argumets are handled. Now uluaGet*Index functions can take stack index(positive only).
|
- REVISED: How Lua argumets are handled. Now uluaGet*Index functions can take stack index(positive only).
|
||||||
Also using positive stack indexing.
|
Also using positive stack indexing.
|
||||||
- ADDED: Camera3D Lua lib.
|
- ADDED: Camera3D Lua lib.
|
||||||
|
- ADDED: Raygui wrapper lib.
|
||||||
|
|
||||||
Detailed changes:
|
Detailed changes:
|
||||||
- FIXED: uluaGetRay was looking for integers instead of tables.
|
- FIXED: uluaGetRay was looking for integers instead of tables.
|
||||||
@@ -51,6 +52,7 @@ Detailed changes:
|
|||||||
- ADDED: GetCamera3DProjectionMatrix
|
- ADDED: GetCamera3DProjectionMatrix
|
||||||
- ADDED: glBlitFramebuffer
|
- ADDED: glBlitFramebuffer
|
||||||
- ADDED: GuiGetFont
|
- ADDED: GuiGetFont
|
||||||
|
- FIXED: GuiScrollPanel
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
Release: ReiLua version 0.4.0 Using Raylib 4.2
|
Release: ReiLua version 0.4.0 Using Raylib 4.2
|
||||||
|
|||||||
1
devnotes
1
devnotes
@@ -5,6 +5,7 @@ Current {
|
|||||||
|
|
||||||
Backlog {
|
Backlog {
|
||||||
* IsWaveReady and other Is* ready functions.
|
* 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
|
* rlgl
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ Raygui = require( "raygui" )
|
|||||||
local raygui = Raygui:new()
|
local raygui = Raygui:new()
|
||||||
|
|
||||||
local grid = {}
|
local grid = {}
|
||||||
|
local windowbox = {}
|
||||||
|
local winOpen = true
|
||||||
|
|
||||||
function RL.init()
|
function RL.init()
|
||||||
local monitor = 0
|
local monitor = 0
|
||||||
@@ -130,9 +132,106 @@ function RL.init()
|
|||||||
32,
|
32,
|
||||||
2
|
2
|
||||||
) )
|
) )
|
||||||
|
windowbox = raygui:add( raygui.WindowBox:new(
|
||||||
|
Rect:new( 720, 250, 256, 256 ),
|
||||||
|
"WindowBox",
|
||||||
|
function( self ) self.visible = false end
|
||||||
|
) )
|
||||||
|
local groupbox = raygui:add( raygui.GroupBox:new(
|
||||||
|
Rect:new( 400, 700, 256, 256 ),
|
||||||
|
"GroupBox"
|
||||||
|
) )
|
||||||
|
local line = raygui:add( raygui.Line:new(
|
||||||
|
Rect:new( 400, 32, 256, 16 ),
|
||||||
|
"Line"
|
||||||
|
) )
|
||||||
|
local panel = raygui:add( raygui.Panel:new(
|
||||||
|
Rect:new( 400, 64, 256, 128 ),
|
||||||
|
"Panel"
|
||||||
|
) )
|
||||||
|
local scrollpanel = raygui:add( 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(
|
||||||
|
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(
|
||||||
|
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(
|
||||||
|
Rect:new( 1100, 150, 300, 128 ),
|
||||||
|
"Title",
|
||||||
|
"Message",
|
||||||
|
"Cancel\nOk",
|
||||||
|
function( self )
|
||||||
|
if 0 < self.buttonIndex then
|
||||||
|
print( "You pressed "..self:getItem( self.buttonIndex ) )
|
||||||
|
|
||||||
|
if self.buttonIndex == 1 then
|
||||||
|
raygui:set2Back( windowbox )
|
||||||
|
elseif self.buttonIndex == 2 then
|
||||||
|
raygui:set2Top( windowbox )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
) )
|
||||||
|
local textinputbox = raygui:add( raygui.TextInputBox:new(
|
||||||
|
Rect:new( 1100, 300, 300, 128 ),
|
||||||
|
"Title",
|
||||||
|
"Message",
|
||||||
|
"Cancel\nOk",
|
||||||
|
"Text",
|
||||||
|
8,
|
||||||
|
0,
|
||||||
|
function( self )
|
||||||
|
if 0 < self.buttonIndex then
|
||||||
|
print( "You pressed "..self:getItem( self.buttonIndex ) )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
) )
|
||||||
|
local colorpicker = raygui:add( raygui.ColorPicker:new(
|
||||||
|
Rect:new( 1500, 32, 128, 128 ),
|
||||||
|
"Color Picker",
|
||||||
|
Color:new()
|
||||||
|
) )
|
||||||
|
local colorpanel = raygui:add( raygui.ColorPanel:new(
|
||||||
|
Rect:new( 1700, 32, 128, 128 ),
|
||||||
|
"Color Panel",
|
||||||
|
Color:new()
|
||||||
|
) )
|
||||||
|
local colorbaralpha = raygui:add( raygui.ColorBarAlpha:new(
|
||||||
|
Rect:new( 1700, 180, 128, 20 ),
|
||||||
|
"Color Panel",
|
||||||
|
1.0
|
||||||
|
) )
|
||||||
|
local colorbarhue = raygui:add( raygui.ColorBarHue:new(
|
||||||
|
Rect:new( 1840, 32, 20, 128 ),
|
||||||
|
"Color Panel",
|
||||||
|
1.0
|
||||||
|
) )
|
||||||
end
|
end
|
||||||
|
|
||||||
function RL.process( delta )
|
function RL.process( delta )
|
||||||
|
if RL.IsKeyPressed( RL.KEY_R ) then
|
||||||
|
raygui:set2Top( windowbox )
|
||||||
|
end
|
||||||
|
|
||||||
|
if RL.IsKeyPressed( RL.KEY_F ) then
|
||||||
|
raygui:set2Back( windowbox )
|
||||||
|
end
|
||||||
|
|
||||||
raygui:process()
|
raygui:process()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -28,18 +28,9 @@ Color.meta = {
|
|||||||
-- __idiv = function( v, value )
|
-- __idiv = function( v, value )
|
||||||
-- return Vector2:new( v.x // value, v.y // value )
|
-- return Vector2:new( v.x // value, v.y // value )
|
||||||
-- end,
|
-- end,
|
||||||
-- __len = function( v )
|
__eq = function( c1, c2 )
|
||||||
-- local len = 0
|
return c1.r == c2.r and c1.g == c2.g and c1.b == c2.b
|
||||||
|
end,
|
||||||
-- for _, _ in pairs( v ) do
|
|
||||||
-- len = len + 1
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- return len
|
|
||||||
-- end,
|
|
||||||
-- __eq = function( v1, v2 )
|
|
||||||
-- return v1.x == v2.x and v1.y == v2.y
|
|
||||||
-- end,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Color:new( r, g, b, a )
|
function Color:new( r, g, b, a )
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
Util = require( "utillib" )
|
Util = require( "utillib" )
|
||||||
Rect = require( "rectangle" )
|
Rect = require( "rectangle" )
|
||||||
Vec2 = require( "vector2" )
|
Vec2 = require( "vector2" )
|
||||||
-- Color = require( "color" )
|
Color = require( "color" )
|
||||||
|
|
||||||
---@param text string
|
---@param text string
|
||||||
---@return integer count, table rowItemCounts
|
---@return integer count, table rowItemCounts
|
||||||
@@ -69,7 +69,7 @@ function Raygui:process()
|
|||||||
for i = #self.elements, 1, -1 do
|
for i = #self.elements, 1, -1 do
|
||||||
local element = self.elements[i]
|
local element = self.elements[i]
|
||||||
|
|
||||||
if element.process ~= nil then
|
if element.visible and element.process ~= nil then
|
||||||
if element:process() then
|
if element:process() then
|
||||||
self.focused = i
|
self.focused = i
|
||||||
|
|
||||||
@@ -87,12 +87,201 @@ function Raygui:draw()
|
|||||||
RL.GuiUnlock()
|
RL.GuiUnlock()
|
||||||
end
|
end
|
||||||
|
|
||||||
if element.draw ~= nil then
|
if element.visible and element.draw ~= nil then
|
||||||
element:draw()
|
element:draw()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Raygui:set2Top( element )
|
||||||
|
for i, curElement in ipairs( self.elements ) do
|
||||||
|
if element == curElement then
|
||||||
|
Util.tableMove( self.elements, i, 1, #self.elements )
|
||||||
|
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Raygui:set2Back( element )
|
||||||
|
for i, curElement in ipairs( self.elements ) do
|
||||||
|
if element == curElement then
|
||||||
|
Util.tableMove( self.elements, i, 1, 1 )
|
||||||
|
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Container/separator controls, useful for controls organization
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- WindowBox.
|
||||||
|
|
||||||
|
WindowBox = {}
|
||||||
|
WindowBox.__index = WindowBox
|
||||||
|
|
||||||
|
function WindowBox:new( bounds, text, callback )
|
||||||
|
local object = setmetatable( {}, WindowBox )
|
||||||
|
|
||||||
|
object.bounds = bounds:clone()
|
||||||
|
object.text = text
|
||||||
|
object.callback = callback
|
||||||
|
|
||||||
|
object.visible = true
|
||||||
|
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
function WindowBox:process()
|
||||||
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
|
end
|
||||||
|
|
||||||
|
function WindowBox:draw()
|
||||||
|
if RL.GuiWindowBox( self.bounds, self.text ) and self.callback ~= nil then
|
||||||
|
self.callback( self )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function WindowBox:setPosition( pos )
|
||||||
|
self.bounds.x = pos.x
|
||||||
|
self.bounds.y = pos.y
|
||||||
|
end
|
||||||
|
|
||||||
|
-- GroupBox.
|
||||||
|
|
||||||
|
GroupBox = {}
|
||||||
|
GroupBox.__index = GroupBox
|
||||||
|
|
||||||
|
function GroupBox:new( bounds, text )
|
||||||
|
local object = setmetatable( {}, GroupBox )
|
||||||
|
|
||||||
|
object.bounds = bounds:clone()
|
||||||
|
object.text = text
|
||||||
|
|
||||||
|
object.visible = true
|
||||||
|
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
function GroupBox:process()
|
||||||
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
|
end
|
||||||
|
|
||||||
|
function GroupBox:draw()
|
||||||
|
RL.GuiGroupBox( self.bounds, self.text )
|
||||||
|
end
|
||||||
|
|
||||||
|
function GroupBox:setPosition( pos )
|
||||||
|
self.bounds.x = pos.x
|
||||||
|
self.bounds.y = pos.y
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Line.
|
||||||
|
|
||||||
|
Line = {}
|
||||||
|
Line.__index = Line
|
||||||
|
|
||||||
|
function Line:new( bounds, text )
|
||||||
|
local object = setmetatable( {}, Line )
|
||||||
|
|
||||||
|
object.bounds = bounds:clone()
|
||||||
|
object.text = text
|
||||||
|
|
||||||
|
object.visible = true
|
||||||
|
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
function Line:process()
|
||||||
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
|
end
|
||||||
|
|
||||||
|
function Line:draw()
|
||||||
|
RL.GuiLine( self.bounds, self.text )
|
||||||
|
end
|
||||||
|
|
||||||
|
function Line:setPosition( pos )
|
||||||
|
self.bounds.x = pos.x
|
||||||
|
self.bounds.y = pos.y
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Panel.
|
||||||
|
|
||||||
|
Panel = {}
|
||||||
|
Panel.__index = Panel
|
||||||
|
|
||||||
|
function Panel:new( bounds, text )
|
||||||
|
local object = setmetatable( {}, Panel )
|
||||||
|
|
||||||
|
object.bounds = bounds:clone()
|
||||||
|
object.text = text
|
||||||
|
|
||||||
|
object.visible = true
|
||||||
|
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
function Panel:process()
|
||||||
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
|
end
|
||||||
|
|
||||||
|
function Panel:draw()
|
||||||
|
RL.GuiPanel( self.bounds, self.text )
|
||||||
|
end
|
||||||
|
|
||||||
|
function Panel:setPosition( pos )
|
||||||
|
self.bounds.x = pos.x
|
||||||
|
self.bounds.y = pos.y
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ScrollPanel.
|
||||||
|
|
||||||
|
ScrollPanel = {}
|
||||||
|
ScrollPanel.__index = ScrollPanel
|
||||||
|
|
||||||
|
function ScrollPanel:new( bounds, text, content, scroll, callback )
|
||||||
|
local object = setmetatable( {}, ScrollPanel )
|
||||||
|
|
||||||
|
object.bounds = bounds:clone()
|
||||||
|
object.text = text
|
||||||
|
object.content = content:clone()
|
||||||
|
object.scroll = scroll:clone()
|
||||||
|
object.view = Rect:new()
|
||||||
|
object.callback = callback
|
||||||
|
|
||||||
|
object.visible = true
|
||||||
|
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
function ScrollPanel:process()
|
||||||
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
|
end
|
||||||
|
|
||||||
|
function ScrollPanel:draw()
|
||||||
|
local oldScroll = self.scroll:clone()
|
||||||
|
|
||||||
|
local view, scroll = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll )
|
||||||
|
|
||||||
|
self.view = Rect:new( view )
|
||||||
|
self.scroll = Vec2:new( scroll )
|
||||||
|
|
||||||
|
if self.scroll ~= oldScroll and self.callback ~= nil then
|
||||||
|
self.callback( self )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ScrollPanel:setPosition( pos )
|
||||||
|
self.bounds.x = pos.x
|
||||||
|
self.bounds.y = pos.y
|
||||||
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Basic controls set
|
||||||
|
]]--
|
||||||
|
|
||||||
-- Label.
|
-- Label.
|
||||||
|
|
||||||
Label = {}
|
Label = {}
|
||||||
@@ -104,11 +293,9 @@ function Label:new( bounds, text )
|
|||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
object.text = text
|
object.text = text
|
||||||
|
|
||||||
return object
|
object.visible = true
|
||||||
end
|
|
||||||
|
|
||||||
function Label:setText( text )
|
return object
|
||||||
self.text = text
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Label:process()
|
function Label:process()
|
||||||
@@ -137,14 +324,11 @@ function Button:new( bounds, text, callback )
|
|||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
|
||||||
object.clicked = false
|
object.clicked = false
|
||||||
|
object.visible = true
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
function Button:setText( text )
|
|
||||||
self.text = text
|
|
||||||
end
|
|
||||||
|
|
||||||
function Button:process()
|
function Button:process()
|
||||||
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
end
|
end
|
||||||
@@ -175,14 +359,11 @@ function LabelButton:new( bounds, text, callback )
|
|||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
|
||||||
object.clicked = false
|
object.clicked = false
|
||||||
|
object.visible = true
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
function LabelButton:setText( text )
|
|
||||||
self.text = text
|
|
||||||
end
|
|
||||||
|
|
||||||
function LabelButton:process()
|
function LabelButton:process()
|
||||||
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
end
|
end
|
||||||
@@ -213,11 +394,9 @@ function Toggle:new( bounds, text, active, callback )
|
|||||||
object.active = active
|
object.active = active
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
|
||||||
return object
|
object.visible = true
|
||||||
end
|
|
||||||
|
|
||||||
function Toggle:setText( text )
|
return object
|
||||||
self.text = text
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Toggle:process()
|
function Toggle:process()
|
||||||
@@ -252,6 +431,7 @@ function ToggleGroup:new( bounds, text, active, callback )
|
|||||||
object.active = active
|
object.active = active
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
|
||||||
|
object.visible = true
|
||||||
object.focusBounds = {}
|
object.focusBounds = {}
|
||||||
object:updateFocusBounds()
|
object:updateFocusBounds()
|
||||||
|
|
||||||
@@ -336,6 +516,7 @@ function CheckBox:new( bounds, text, checked, callback )
|
|||||||
object.checked = checked
|
object.checked = checked
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
|
||||||
|
object.visible = true
|
||||||
object.focusBounds = bounds:clone()
|
object.focusBounds = bounds:clone()
|
||||||
object:updateFocusBounds()
|
object:updateFocusBounds()
|
||||||
|
|
||||||
@@ -415,11 +596,9 @@ function ComboBox:new( bounds, text, active, callback )
|
|||||||
object.active = active
|
object.active = active
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
|
||||||
return object
|
object.visible = true
|
||||||
end
|
|
||||||
|
|
||||||
function ComboBox:setText( text )
|
return object
|
||||||
self.text = text
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function ComboBox:process()
|
function ComboBox:process()
|
||||||
@@ -455,6 +634,7 @@ function DropdownBox:new( bounds, text, active, editMode, callback )
|
|||||||
object.editMode = editMode
|
object.editMode = editMode
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
|
||||||
|
object.visible = true
|
||||||
object.editModeBounds = bounds:clone()
|
object.editModeBounds = bounds:clone()
|
||||||
object:updateFocusBounds()
|
object:updateFocusBounds()
|
||||||
|
|
||||||
@@ -525,11 +705,9 @@ function Spinner:new( bounds, text, value, minValue, maxValue, editMode, callbac
|
|||||||
object.editMode = editMode
|
object.editMode = editMode
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
|
||||||
return object
|
object.visible = true
|
||||||
end
|
|
||||||
|
|
||||||
function Spinner:setText( text )
|
return object
|
||||||
self.text = text
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Spinner:process()
|
function Spinner:process()
|
||||||
@@ -572,11 +750,9 @@ function ValueBox:new( bounds, text, value, minValue, maxValue, editMode, callba
|
|||||||
object.editMode = editMode
|
object.editMode = editMode
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
|
||||||
return object
|
object.visible = true
|
||||||
end
|
|
||||||
|
|
||||||
function ValueBox:setText( text )
|
return object
|
||||||
self.text = text
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function ValueBox:process()
|
function ValueBox:process()
|
||||||
@@ -618,14 +794,11 @@ function TextBox:new( bounds, text, textSize, editMode, callback )
|
|||||||
object.callback = callback
|
object.callback = callback
|
||||||
-- Option for preventing text to be drawn outside bounds.
|
-- Option for preventing text to be drawn outside bounds.
|
||||||
object.scissorMode = false
|
object.scissorMode = false
|
||||||
|
object.visible = true
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
function TextBox:setText( text )
|
|
||||||
self.text = text
|
|
||||||
end
|
|
||||||
|
|
||||||
function TextBox:process()
|
function TextBox:process()
|
||||||
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
end
|
end
|
||||||
@@ -671,11 +844,9 @@ function TextBoxMulti:new( bounds, text, textSize, editMode, callback )
|
|||||||
object.editMode = editMode
|
object.editMode = editMode
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
|
||||||
return object
|
object.visible = true
|
||||||
end
|
|
||||||
|
|
||||||
function TextBoxMulti:setText( text )
|
return object
|
||||||
self.text = text
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function TextBoxMulti:process()
|
function TextBoxMulti:process()
|
||||||
@@ -717,11 +888,9 @@ function Slider:new( bounds, textLeft, textRight, value, minValue, maxValue, cal
|
|||||||
object.maxValue = maxValue
|
object.maxValue = maxValue
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
|
||||||
return object
|
object.visible = true
|
||||||
end
|
|
||||||
|
|
||||||
function Slider:setText( text )
|
return object
|
||||||
self.text = text
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Slider:process()
|
function Slider:process()
|
||||||
@@ -759,11 +928,9 @@ function SliderBar:new( bounds, textLeft, textRight, value, minValue, maxValue,
|
|||||||
object.maxValue = maxValue
|
object.maxValue = maxValue
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
|
||||||
return object
|
object.visible = true
|
||||||
end
|
|
||||||
|
|
||||||
function SliderBar:setText( text )
|
return object
|
||||||
self.text = text
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function SliderBar:process()
|
function SliderBar:process()
|
||||||
@@ -801,11 +968,9 @@ function ProgressBar:new( bounds, textLeft, textRight, value, minValue, maxValue
|
|||||||
object.maxValue = maxValue
|
object.maxValue = maxValue
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
|
||||||
return object
|
object.visible = true
|
||||||
end
|
|
||||||
|
|
||||||
function ProgressBar:setText( text )
|
return object
|
||||||
self.text = text
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function ProgressBar:process()
|
function ProgressBar:process()
|
||||||
@@ -838,11 +1003,9 @@ function StatusBar:new( bounds, text )
|
|||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
object.text = text
|
object.text = text
|
||||||
|
|
||||||
return object
|
object.visible = true
|
||||||
end
|
|
||||||
|
|
||||||
function StatusBar:setText( text )
|
return object
|
||||||
self.text = text
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function StatusBar:process()
|
function StatusBar:process()
|
||||||
@@ -869,11 +1032,9 @@ function DummyRec:new( bounds, text )
|
|||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
object.text = text
|
object.text = text
|
||||||
|
|
||||||
return object
|
object.visible = true
|
||||||
end
|
|
||||||
|
|
||||||
function DummyRec:setText( text )
|
return object
|
||||||
self.text = text
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function DummyRec:process()
|
function DummyRec:process()
|
||||||
@@ -904,14 +1065,11 @@ function Grid:new( bounds, text, spacing, subdivs, callback )
|
|||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
|
||||||
object.cell = Vec2:new()
|
object.cell = Vec2:new()
|
||||||
|
object.visible = true
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
function Grid:setText( text )
|
|
||||||
self.text = text
|
|
||||||
end
|
|
||||||
|
|
||||||
function Grid:process()
|
function Grid:process()
|
||||||
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
end
|
end
|
||||||
@@ -931,8 +1089,334 @@ function Grid:setPosition( pos )
|
|||||||
self.bounds.y = pos.y
|
self.bounds.y = pos.y
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--[[
|
||||||
|
Advance controls set
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- ListView.
|
||||||
|
|
||||||
|
ListView = {}
|
||||||
|
ListView.__index = ListView
|
||||||
|
|
||||||
|
function ListView:new( bounds, text, scrollIndex, active, callback )
|
||||||
|
local object = setmetatable( {}, ListView )
|
||||||
|
|
||||||
|
object.bounds = bounds:clone()
|
||||||
|
object.text = text
|
||||||
|
object.scrollIndex = scrollIndex
|
||||||
|
object.active = active
|
||||||
|
object.callback = callback
|
||||||
|
object.visible = true
|
||||||
|
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
function ListView:getItem( id )
|
||||||
|
return getItems( self.text )[ id + 1 ]
|
||||||
|
end
|
||||||
|
|
||||||
|
function ListView:process()
|
||||||
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
|
end
|
||||||
|
|
||||||
|
function ListView:draw()
|
||||||
|
local oldActive = self.active
|
||||||
|
|
||||||
|
self.active, self.scrollIndex = RL.GuiListView( self.bounds, self.text, self.scrollIndex, self.active )
|
||||||
|
|
||||||
|
if oldActive ~= self.active and self.callback ~= nil then
|
||||||
|
self.callback( self )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ListView:setPosition( pos )
|
||||||
|
self.bounds.x = pos.x
|
||||||
|
self.bounds.y = pos.y
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ListViewEx.
|
||||||
|
|
||||||
|
ListViewEx = {}
|
||||||
|
ListViewEx.__index = ListViewEx
|
||||||
|
|
||||||
|
function ListViewEx:new( bounds, text, focus, scrollIndex, active, callback )
|
||||||
|
local object = setmetatable( {}, ListViewEx )
|
||||||
|
|
||||||
|
object.bounds = bounds:clone()
|
||||||
|
object.text = text
|
||||||
|
object.focus = focus
|
||||||
|
object.scrollIndex = scrollIndex
|
||||||
|
object.active = active
|
||||||
|
object.callback = callback
|
||||||
|
object.visible = true
|
||||||
|
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
function ListViewEx:getItem( id )
|
||||||
|
return getItems( self.text )[ id + 1 ]
|
||||||
|
end
|
||||||
|
|
||||||
|
function ListViewEx:process()
|
||||||
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
|
end
|
||||||
|
|
||||||
|
function ListViewEx:draw()
|
||||||
|
local oldActive = self.active
|
||||||
|
|
||||||
|
self.active, self.scrollIndex, self.focus = RL.GuiListViewEx( self.bounds, self.text, self.focus, self.scrollIndex, self.active )
|
||||||
|
|
||||||
|
if oldActive ~= self.active and self.callback ~= nil then
|
||||||
|
self.callback( self )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ListViewEx:setPosition( pos )
|
||||||
|
self.bounds.x = pos.x
|
||||||
|
self.bounds.y = pos.y
|
||||||
|
end
|
||||||
|
|
||||||
|
-- MessageBox.
|
||||||
|
|
||||||
|
MessageBox = {}
|
||||||
|
MessageBox.__index = MessageBox
|
||||||
|
|
||||||
|
function MessageBox:new( bounds, title, message, buttons, callback )
|
||||||
|
local object = setmetatable( {}, MessageBox )
|
||||||
|
|
||||||
|
object.bounds = bounds:clone()
|
||||||
|
object.title = title
|
||||||
|
object.message = message
|
||||||
|
object.buttons = buttons
|
||||||
|
object.callback = callback
|
||||||
|
|
||||||
|
object.buttonIndex = -1
|
||||||
|
object.visible = true
|
||||||
|
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
function MessageBox:getItem( id )
|
||||||
|
return getItems( self.buttons )[ id ]
|
||||||
|
end
|
||||||
|
|
||||||
|
function MessageBox:process()
|
||||||
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
|
end
|
||||||
|
|
||||||
|
function MessageBox:draw()
|
||||||
|
self.buttonIndex = RL.GuiMessageBox( self.bounds, self.title, self.message, self.buttons )
|
||||||
|
|
||||||
|
if 0 <= self.buttonIndex and self.callback ~= nil then
|
||||||
|
self.callback( self )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MessageBox:setPosition( pos )
|
||||||
|
self.bounds.x = pos.x
|
||||||
|
self.bounds.y = pos.y
|
||||||
|
end
|
||||||
|
|
||||||
|
-- TextInputBox.
|
||||||
|
|
||||||
|
TextInputBox = {}
|
||||||
|
TextInputBox.__index = TextInputBox
|
||||||
|
|
||||||
|
function TextInputBox:new( bounds, title, message, buttons, text, textMaxSize, secretViewActive, callback )
|
||||||
|
local object = setmetatable( {}, TextInputBox )
|
||||||
|
|
||||||
|
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.buttonIndex = -1
|
||||||
|
object.visible = true
|
||||||
|
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
function TextInputBox:getItem( id )
|
||||||
|
return getItems( self.buttons )[ id ]
|
||||||
|
end
|
||||||
|
|
||||||
|
function TextInputBox:process()
|
||||||
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
|
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 then
|
||||||
|
self.callback( self )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function TextInputBox:setPosition( pos )
|
||||||
|
self.bounds.x = pos.x
|
||||||
|
self.bounds.y = pos.y
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ColorPicker.
|
||||||
|
|
||||||
|
ColorPicker = {}
|
||||||
|
ColorPicker.__index = ColorPicker
|
||||||
|
|
||||||
|
function ColorPicker:new( bounds, text, color, callback )
|
||||||
|
local object = setmetatable( {}, ColorPicker )
|
||||||
|
|
||||||
|
object.bounds = bounds:clone()
|
||||||
|
object.text = text
|
||||||
|
object.color = color
|
||||||
|
object.callback = callback
|
||||||
|
|
||||||
|
object.visible = true
|
||||||
|
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
function ColorPicker:process()
|
||||||
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
|
end
|
||||||
|
|
||||||
|
function ColorPicker:draw()
|
||||||
|
local oldColor = self.color:clone()
|
||||||
|
local color = RL.GuiColorPicker( self.bounds, self.text, self.color )
|
||||||
|
|
||||||
|
self.color = Color:new( color )
|
||||||
|
|
||||||
|
if oldColor ~= self.color and self.callback ~= nil then
|
||||||
|
self.callback( self )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ColorPicker:setPosition( pos )
|
||||||
|
self.bounds.x = pos.x
|
||||||
|
self.bounds.y = pos.y
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ColorPanel.
|
||||||
|
|
||||||
|
ColorPanel = {}
|
||||||
|
ColorPanel.__index = ColorPanel
|
||||||
|
|
||||||
|
function ColorPanel:new( bounds, text, color, callback )
|
||||||
|
local object = setmetatable( {}, ColorPanel )
|
||||||
|
|
||||||
|
object.bounds = bounds:clone()
|
||||||
|
object.text = text
|
||||||
|
object.color = color
|
||||||
|
object.callback = callback
|
||||||
|
|
||||||
|
object.visible = true
|
||||||
|
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
function ColorPanel:process()
|
||||||
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
|
end
|
||||||
|
|
||||||
|
function ColorPanel:draw()
|
||||||
|
local oldColor = self.color:clone()
|
||||||
|
local color = RL.GuiColorPanel( self.bounds, self.text, self.color )
|
||||||
|
|
||||||
|
self.color = Color:new( color )
|
||||||
|
|
||||||
|
if oldColor ~= self.color and self.callback ~= nil then
|
||||||
|
self.callback( self )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ColorPanel:setPosition( pos )
|
||||||
|
self.bounds.x = pos.x
|
||||||
|
self.bounds.y = pos.y
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ColorBarAlpha.
|
||||||
|
|
||||||
|
ColorBarAlpha = {}
|
||||||
|
ColorBarAlpha.__index = ColorBarAlpha
|
||||||
|
|
||||||
|
function ColorBarAlpha:new( bounds, text, alpha, callback )
|
||||||
|
local object = setmetatable( {}, ColorBarAlpha )
|
||||||
|
|
||||||
|
object.bounds = bounds:clone()
|
||||||
|
object.text = text
|
||||||
|
object.alpha = alpha
|
||||||
|
object.callback = callback
|
||||||
|
|
||||||
|
object.visible = true
|
||||||
|
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
function ColorBarAlpha:process()
|
||||||
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
|
end
|
||||||
|
|
||||||
|
function ColorBarAlpha:draw()
|
||||||
|
local oldAlpha = self.alpha
|
||||||
|
self.alpha = RL.GuiColorBarAlpha( self.bounds, self.text, self.alpha )
|
||||||
|
|
||||||
|
if self.alpha ~= oldAlpha and self.callback ~= nil then
|
||||||
|
self.callback( self )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ColorBarAlpha:setPosition( pos )
|
||||||
|
self.bounds.x = pos.x
|
||||||
|
self.bounds.y = pos.y
|
||||||
|
end
|
||||||
|
|
||||||
|
-- ColorBarHue.
|
||||||
|
|
||||||
|
ColorBarHue = {}
|
||||||
|
ColorBarHue.__index = ColorBarHue
|
||||||
|
|
||||||
|
function ColorBarHue:new( bounds, text, value, callback )
|
||||||
|
local object = setmetatable( {}, ColorBarHue )
|
||||||
|
|
||||||
|
object.bounds = bounds:clone()
|
||||||
|
object.text = text
|
||||||
|
object.value = value
|
||||||
|
object.callback = callback
|
||||||
|
|
||||||
|
object.visible = true
|
||||||
|
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
function ColorBarHue:process()
|
||||||
|
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
|
||||||
|
end
|
||||||
|
|
||||||
|
function ColorBarHue:draw()
|
||||||
|
local oldValue = self.value
|
||||||
|
self.value = RL.GuiColorBarHue( self.bounds, self.text, self.value )
|
||||||
|
|
||||||
|
if self.value ~= oldValue and self.callback ~= nil then
|
||||||
|
self.callback( self )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ColorBarHue:setPosition( pos )
|
||||||
|
self.bounds.x = pos.x
|
||||||
|
self.bounds.y = pos.y
|
||||||
|
end
|
||||||
|
|
||||||
--Assingments.
|
--Assingments.
|
||||||
|
|
||||||
|
Raygui.WindowBox = WindowBox
|
||||||
|
Raygui.GroupBox = GroupBox
|
||||||
|
Raygui.Line = Line
|
||||||
|
Raygui.Panel = Panel
|
||||||
|
Raygui.ScrollPanel = ScrollPanel
|
||||||
|
|
||||||
Raygui.Label = Label
|
Raygui.Label = Label
|
||||||
Raygui.Button = Button
|
Raygui.Button = Button
|
||||||
Raygui.LabelButton = LabelButton
|
Raygui.LabelButton = LabelButton
|
||||||
@@ -952,4 +1436,13 @@ Raygui.StatusBar = StatusBar
|
|||||||
Raygui.DummyRec = DummyRec
|
Raygui.DummyRec = DummyRec
|
||||||
Raygui.Grid = Grid
|
Raygui.Grid = Grid
|
||||||
|
|
||||||
|
Raygui.ListView = ListView
|
||||||
|
Raygui.ListViewEx = ListViewEx
|
||||||
|
Raygui.MessageBox = MessageBox
|
||||||
|
Raygui.TextInputBox = TextInputBox
|
||||||
|
Raygui.ColorPicker = ColorPicker
|
||||||
|
Raygui.ColorPanel = ColorPanel
|
||||||
|
Raygui.ColorBarAlpha = ColorBarAlpha
|
||||||
|
Raygui.ColorBarHue = ColorBarHue
|
||||||
|
|
||||||
return Raygui
|
return Raygui
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ Scroll Panel control
|
|||||||
- Success return Rectangle, Vector2
|
- Success return Rectangle, Vector2
|
||||||
*/
|
*/
|
||||||
int lguiGuiScrollPanel( lua_State *L ) {
|
int lguiGuiScrollPanel( lua_State *L ) {
|
||||||
if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
|
if ( !lua_istable( L, 1 ) || !lua_isstring( L, 2 ) || !lua_istable( L, 3 ) || !lua_istable( L, 4 ) ) {
|
||||||
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GuiScrollPanel( Rectangle bounds, string text, Rectangle content, Vector2 scroll )" );
|
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.GuiScrollPanel( Rectangle bounds, string text, Rectangle content, Vector2 scroll )" );
|
||||||
lua_pushboolean( L, false );
|
lua_pushboolean( L, false );
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user