Raygui wrapper library is now object based.
This commit is contained in:
@@ -17,6 +17,7 @@ KEY CHANGES:
|
||||
- ADDED: Platform specific API documentation generation.
|
||||
- ADDED: Platform web.
|
||||
- ADDED: Raygui textures with SetShapesTexture.
|
||||
- CHANGE: Raygui wrapper library is now object based. Possible to have multiple separated gui systems.
|
||||
|
||||
DETAILED CHANGES:
|
||||
- REMOVED: DrawLineBezierQuad, DrawLineBezierCubic.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Calculator = {}
|
||||
local Calculator = {}
|
||||
Calculator.__index = Calculator
|
||||
|
||||
Calculator.OPERATIONS = {
|
||||
@@ -13,7 +13,7 @@ Calculator.OPERATIONS = {
|
||||
function Calculator:new( pos )
|
||||
local object = setmetatable( {}, Calculator )
|
||||
|
||||
object.window = Raygui.WindowBox:new(
|
||||
object.window = Gui:WindowBox(
|
||||
Rect:new( pos.x, pos.y, 188, 216 ),
|
||||
"Calculator",
|
||||
-- Close callback.
|
||||
@@ -23,7 +23,7 @@ function Calculator:new( pos )
|
||||
-- Drag callback.
|
||||
function( self ) object:setPosition( Vec2:new( self.bounds.x, self.bounds.y ) ) end
|
||||
)
|
||||
object.display = Raygui.Label:new(
|
||||
object.display = Gui:Label(
|
||||
Rect:new( 0, 0, 180, 20 ),
|
||||
""
|
||||
)
|
||||
@@ -54,7 +54,7 @@ function Calculator:new( pos )
|
||||
local buttonSpacing = 6
|
||||
|
||||
for i, button in ipairs( buttons ) do
|
||||
table.insert( object.buttons, Raygui.Button:new(
|
||||
table.insert( object.buttons, Gui:Button(
|
||||
buttonRect:clone(),
|
||||
button[1],
|
||||
button[2]
|
||||
@@ -139,11 +139,11 @@ function Calculator:setPosition( pos )
|
||||
end
|
||||
|
||||
function Calculator:set2Top()
|
||||
Raygui.set2Top( self.window )
|
||||
Raygui.set2Top( self.display )
|
||||
Gui:set2Top( self.window )
|
||||
Gui:set2Top( self.display )
|
||||
|
||||
for _, button in ipairs( self.buttons ) do
|
||||
Raygui.set2Top( button )
|
||||
Gui:set2Top( button )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ Color = require( "color" )
|
||||
Raygui = require( "raygui" )
|
||||
Calculator = require( "calculator" )
|
||||
|
||||
Gui = Raygui:new()
|
||||
|
||||
local calculator = nil
|
||||
local calculator2 = nil
|
||||
|
||||
@@ -32,11 +34,11 @@ function RL.init()
|
||||
end
|
||||
|
||||
function RL.process( delta )
|
||||
Raygui:process()
|
||||
Gui:process()
|
||||
end
|
||||
|
||||
function RL.draw()
|
||||
RL.ClearBackground( RL.DARKBLUE )
|
||||
|
||||
Raygui:draw()
|
||||
Gui:draw()
|
||||
end
|
||||
|
||||
@@ -6,6 +6,8 @@ Vec2 = require( "vector2" )
|
||||
Color = require( "color" )
|
||||
Raygui = require( "raygui" )
|
||||
|
||||
Gui = Raygui:new()
|
||||
|
||||
local grid = {}
|
||||
local windowbox = {}
|
||||
local tabBar = {}
|
||||
@@ -17,7 +19,7 @@ local function closeTab( self, id )
|
||||
local newText = ""
|
||||
|
||||
if #splits == 1 then
|
||||
Raygui.remove( tabBar )
|
||||
Gui:remove( tabBar )
|
||||
end
|
||||
table.remove( splits, id + 1 )
|
||||
|
||||
@@ -50,24 +52,24 @@ function RL.init()
|
||||
RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_COLOR_FOCUSED, RL.ColorToInt( RL.ORANGE ) )
|
||||
RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_COLOR_PRESSED, RL.ColorToInt( RL.GREEN ) )
|
||||
|
||||
local label = Raygui.Label:new(
|
||||
local label = Gui:Label(
|
||||
Rect:new( 16, 16, 64, 32 ),
|
||||
"Cat"
|
||||
)
|
||||
local toggleGroup = Raygui.ToggleGroup:new(
|
||||
local toggleGroup = Gui:ToggleGroup(
|
||||
Rect:new( 68, 16, 64, 32 ),
|
||||
"Cat\nDog",
|
||||
0,
|
||||
function( self ) print( self:getItem( self.active ) ) end
|
||||
)
|
||||
local button = Raygui.Button:new(
|
||||
local button = Gui:Button(
|
||||
Rect:new( 245, 188, 64, 32 ),
|
||||
"Dog",
|
||||
function() toggleGroup:setText( "Dog;Cat\nEagle" ) end,
|
||||
texture,
|
||||
textureRect
|
||||
)
|
||||
local checkbox = Raygui.CheckBox:new(
|
||||
local checkbox = Gui:CheckBox(
|
||||
Rect:new( 64, 128, 20, 20 ),
|
||||
"Dog",
|
||||
false,
|
||||
@@ -75,19 +77,19 @@ function RL.init()
|
||||
texture,
|
||||
textureRect
|
||||
)
|
||||
local combobox = Raygui.ComboBox:new(
|
||||
local combobox = Gui:ComboBox(
|
||||
Rect:new( 64, 256, 128, 32 ),
|
||||
"Dog\nCow\nDonkey",
|
||||
0
|
||||
)
|
||||
local dropdownbox = Raygui.DropdownBox:new(
|
||||
local dropdownbox = Gui:DropdownBox(
|
||||
Rect:new( 256, 128, 128, 32 ),
|
||||
"Dog\nGiraffe\nLion\nHorse",
|
||||
0,
|
||||
false,
|
||||
function( self ) print( self:getItem( self.active ) ) end
|
||||
)
|
||||
local spinner = Raygui.Spinner:new(
|
||||
local spinner = Gui:Spinner(
|
||||
Rect:new( 464, 256, 128, 32 ),
|
||||
"Health",
|
||||
0,
|
||||
@@ -96,7 +98,7 @@ function RL.init()
|
||||
false,
|
||||
function( self ) print( "Spinner value changed to "..self.value ) end
|
||||
)
|
||||
local valuebox = Raygui.ValueBox:new(
|
||||
local valuebox = Gui:ValueBox(
|
||||
Rect:new( 464, 316, 128, 32 ),
|
||||
"Health",
|
||||
0,
|
||||
@@ -105,21 +107,21 @@ function RL.init()
|
||||
false,
|
||||
function( self ) print( "ValueBox value changed to "..self.value ) end
|
||||
)
|
||||
local textbox = Raygui.TextBox:new(
|
||||
local textbox = Gui:TextBox(
|
||||
Rect:new( 32, 316, 256, 32 ),
|
||||
"Name",
|
||||
32,
|
||||
false,
|
||||
function( self ) print( "Set text "..self.text ) end
|
||||
)
|
||||
local textbox2 = Raygui.TextBox:new(
|
||||
local textbox2 = Gui:TextBox(
|
||||
Rect:new( 32, 380, 256, 32 ),
|
||||
"Name",
|
||||
32,
|
||||
false,
|
||||
function( self ) print( "Set text "..self.text ) end
|
||||
)
|
||||
local slider = Raygui.Slider:new(
|
||||
local slider = Gui:Slider(
|
||||
Rect:new( 50, 500, 256, 32 ),
|
||||
"min",
|
||||
"max",
|
||||
@@ -130,7 +132,7 @@ function RL.init()
|
||||
texture,
|
||||
textureRect
|
||||
)
|
||||
local sliderbar = Raygui.SliderBar:new(
|
||||
local sliderbar = Gui:SliderBar(
|
||||
Rect:new( 50, 550, 256, 32 ),
|
||||
"min",
|
||||
"max",
|
||||
@@ -138,9 +140,8 @@ function RL.init()
|
||||
0,
|
||||
100,
|
||||
function( self ) print( "Changed value "..self.value ) end
|
||||
|
||||
)
|
||||
local progressbar = Raygui.ProgressBar:new(
|
||||
local progressbar = Gui:ProgressBar(
|
||||
Rect:new( 50, 600, 256, 32 ),
|
||||
"min",
|
||||
"max",
|
||||
@@ -149,56 +150,56 @@ function RL.init()
|
||||
100,
|
||||
function( self ) print( "Changed value "..self.value ) end
|
||||
)
|
||||
local statusbar = Raygui.StatusBar:new(
|
||||
local statusbar = Gui:StatusBar(
|
||||
Rect:new( 50, 650, 256, 32 ),
|
||||
"StatusBar"
|
||||
)
|
||||
local dummyrec = Raygui.DummyRec:new(
|
||||
local dummyrec = Gui:DummyRec(
|
||||
Rect:new( 50, 700, 256, 32 ),
|
||||
"DummyRec"
|
||||
)
|
||||
grid = Raygui.Grid:new(
|
||||
grid = Gui:Grid(
|
||||
Rect:new( 400, 400, 256, 256 ),
|
||||
"Grid",
|
||||
32,
|
||||
2
|
||||
)
|
||||
windowbox = Raygui.WindowBox:new(
|
||||
windowbox = Gui:WindowBox(
|
||||
Rect:new( 720, 250, 256, 256 ),
|
||||
"WindowBox",
|
||||
-- Close callback.
|
||||
function( self ) self.visible = false end,
|
||||
-- Grab callback.
|
||||
function( self ) Raygui.set2Top( self ) end,
|
||||
function( self ) Gui:set2Top( self ) end,
|
||||
nil,
|
||||
texture,
|
||||
textureRect
|
||||
)
|
||||
local groupbox = Raygui.GroupBox:new(
|
||||
local groupbox = Gui:GroupBox(
|
||||
Rect:new( 400, 700, 256, 256 ),
|
||||
"GroupBox"
|
||||
)
|
||||
local line = Raygui.Line:new(
|
||||
local line = Gui:Line(
|
||||
Rect:new( 400, 32, 256, 16 ),
|
||||
"Line"
|
||||
)
|
||||
local panel = Raygui.Panel:new(
|
||||
local panel = Gui:Panel(
|
||||
Rect:new( 400, 64, 256, 128 ),
|
||||
"Panel",
|
||||
-- Grab callback.
|
||||
function( self ) Raygui.set2Top( self ) end
|
||||
function( self ) Gui:set2Top( self ) end
|
||||
)
|
||||
tabBar = Raygui.GuiTabBar:new(
|
||||
tabBar = Gui:GuiTabBar(
|
||||
Rect:new( 700, 520, 700, 32 ),
|
||||
"Cat;Dog;Horse;Cow",
|
||||
0,
|
||||
-- function( self ) Raygui.set2Top( self ) end
|
||||
-- function( self ) Gui:set2Top( self ) end
|
||||
nil,
|
||||
closeTab,
|
||||
texture,
|
||||
textureRect
|
||||
)
|
||||
local scrollpanel = Raygui.ScrollPanel:new(
|
||||
local scrollpanel = Gui:ScrollPanel(
|
||||
Rect:new( 800, 64, 256, 256 ),
|
||||
"ScrollPanel",
|
||||
Rect:new( 0, 0, 256, 600 ),
|
||||
@@ -206,19 +207,17 @@ function RL.init()
|
||||
-- Callback.
|
||||
nil,
|
||||
-- Grab callback.
|
||||
function( self ) Raygui.set2Top( self ) end
|
||||
function( self ) Gui:set2Top( self ) end
|
||||
)
|
||||
local listview = Raygui.ListView:new(
|
||||
Rect:new( 1100, 64, 128, 80 ),
|
||||
local listview = Gui:ListView(
|
||||
Rect:new( 1100, 64, 128, 128 ),
|
||||
"Cat;Dog;Horse;Cow;Pig;Eagle;Lion",
|
||||
0,
|
||||
0,
|
||||
function( self ) print( self:getItem( self.active ) ) end,
|
||||
texture,
|
||||
textureRect
|
||||
function( self ) print( self:getItem( self.active ) ) end
|
||||
)
|
||||
local listviewex = Raygui.ListViewEx:new(
|
||||
Rect:new( 1300, 64, 128, 80 ),
|
||||
local listviewex = Gui:ListViewEx(
|
||||
Rect:new( 1300, 64, 128, 128 ),
|
||||
"Cat;Dog;Horse;Cow;Pig;Eagle;Lion",
|
||||
0,
|
||||
0,
|
||||
@@ -227,7 +226,7 @@ function RL.init()
|
||||
texture,
|
||||
textureRect
|
||||
)
|
||||
local messagebox = Raygui.MessageBox:new(
|
||||
local messagebox = Gui:MessageBox(
|
||||
Rect:new( 1100, 150, 300, 128 ),
|
||||
"Title",
|
||||
"Message",
|
||||
@@ -237,16 +236,16 @@ function RL.init()
|
||||
print( "You pressed "..self:getItem( self.buttonIndex ) )
|
||||
|
||||
if self.buttonIndex == 1 then
|
||||
Raygui.set2Back( windowbox )
|
||||
Gui:set2Back( windowbox )
|
||||
elseif self.buttonIndex == 2 then
|
||||
Raygui.set2Top( windowbox )
|
||||
Gui:set2Top( windowbox )
|
||||
end
|
||||
end
|
||||
end,
|
||||
-- Grab callback.
|
||||
function( self ) Raygui.set2Top( self ) end
|
||||
function( self ) Gui:set2Top( self ) end
|
||||
)
|
||||
local textinputbox = Raygui.TextInputBox:new(
|
||||
local textinputbox = Gui:TextInputBox(
|
||||
Rect:new( 1100, 300, 300, 128 ),
|
||||
"Title",
|
||||
"Message",
|
||||
@@ -260,24 +259,24 @@ function RL.init()
|
||||
end
|
||||
end,
|
||||
-- Grab callback.
|
||||
function( self ) Raygui.set2Top( self ) end
|
||||
function( self ) Gui:set2Top( self ) end
|
||||
)
|
||||
local colorpicker = Raygui.ColorPicker:new(
|
||||
local colorpicker = Gui:ColorPicker(
|
||||
Rect:new( 1500, 32, 128, 128 ),
|
||||
"Color Picker",
|
||||
Color:new()
|
||||
)
|
||||
local colorpanel = Raygui.ColorPanel:new(
|
||||
local colorpanel = Gui:ColorPanel(
|
||||
Rect:new( 1700, 32, 128, 128 ),
|
||||
"Color Panel",
|
||||
Color:new()
|
||||
)
|
||||
local colorbaralpha = Raygui.ColorBarAlpha:new(
|
||||
local colorbaralpha = Gui:ColorBarAlpha(
|
||||
Rect:new( 1700, 180, 128, 20 ),
|
||||
"Color Panel",
|
||||
1.0
|
||||
)
|
||||
local colorbarhue = Raygui.ColorBarHue:new(
|
||||
local colorbarhue = Gui:ColorBarHue(
|
||||
Rect:new( 1840, 32, 20, 128 ),
|
||||
"Color Panel",
|
||||
1.0
|
||||
@@ -285,7 +284,7 @@ function RL.init()
|
||||
end
|
||||
|
||||
function RL.process( delta )
|
||||
Raygui.process()
|
||||
Gui:process()
|
||||
end
|
||||
|
||||
function RL.draw()
|
||||
@@ -302,6 +301,5 @@ function RL.draw()
|
||||
RL.GREEN
|
||||
)
|
||||
end
|
||||
|
||||
Raygui.draw()
|
||||
Gui:draw()
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ end
|
||||
|
||||
local Vector3 = require( "vector3" )
|
||||
|
||||
Color = {}
|
||||
local Color = {}
|
||||
Color.meta = {
|
||||
__index = Color,
|
||||
__tostring = function( c )
|
||||
|
||||
@@ -1,19 +1,9 @@
|
||||
Util = require( "utillib" )
|
||||
Rect = require( "rectangle" )
|
||||
Vec2 = require( "vector2" )
|
||||
Color = require( "color" )
|
||||
local Util = require( "utillib" )
|
||||
local Rect = require( "rectangle" )
|
||||
local Vec2 = require( "vector2" )
|
||||
local Color = require( "color" )
|
||||
|
||||
--[[
|
||||
To add repeat inputs to the keys pressed buffer, you could add GLFW_REPEAT in railib rcore.c in function "KeyCallback" by changing:
|
||||
|
||||
if ((CORE.Input.Keyboard.keyPressedQueueCount < MAX_KEY_PRESSED_QUEUE) && (action == GLFW_PRESS))
|
||||
To
|
||||
if ((CORE.Input.Keyboard.keyPressedQueueCount < MAX_KEY_PRESSED_QUEUE) && (action == GLFW_PRESS || action == GLFW_REPEAT))
|
||||
|
||||
Now GLFW_REPEAT can be read by "RL.GetKeyPressed".
|
||||
]]
|
||||
|
||||
Gui = {
|
||||
local Gui = {
|
||||
ALING = {
|
||||
NONE = 0,
|
||||
LEFT = 1,
|
||||
|
||||
@@ -22,7 +22,7 @@ local function deepCopy( orig )
|
||||
return copy
|
||||
end
|
||||
|
||||
Matrix = {}
|
||||
local Matrix = {}
|
||||
Matrix.meta = {
|
||||
__index = Matrix,
|
||||
__tostring = function( m )
|
||||
|
||||
@@ -6,7 +6,7 @@ end
|
||||
local Vector3 = require( "vector3" )
|
||||
local Matrix = require( "matrix" )
|
||||
|
||||
Quaternion = {}
|
||||
local Quaternion = {}
|
||||
Quaternion.meta = {
|
||||
__index = Quaternion,
|
||||
__tostring = function( q )
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,8 +5,7 @@ end
|
||||
|
||||
local Vector2 = require( "vector2" )
|
||||
|
||||
Rectangle = {}
|
||||
|
||||
local Rectangle = {}
|
||||
Rectangle.meta = {
|
||||
__index = Rectangle,
|
||||
__tostring = function( r )
|
||||
|
||||
@@ -3,7 +3,7 @@ if table.unpack == nil then
|
||||
table.unpack = unpack
|
||||
end
|
||||
|
||||
Vector2 = {}
|
||||
local Vector2 = {}
|
||||
Vector2.meta = {
|
||||
__index = Vector2,
|
||||
__tostring = function( v )
|
||||
|
||||
@@ -5,7 +5,7 @@ end
|
||||
|
||||
local Vector2 = require( "vector2" )
|
||||
|
||||
Vector3 = {}
|
||||
local Vector3 = {}
|
||||
Vector3.meta = {
|
||||
__index = Vector3,
|
||||
__tostring = function( v )
|
||||
|
||||
Reference in New Issue
Block a user