Raygui textures with SetShapesTexture.
This commit is contained in:
12
API.md
12
API.md
@@ -5880,6 +5880,14 @@ Draw text (Custom sprite font) within an image (Destination)
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
> texture = RL.GetTextureDefault()
|
||||||
|
|
||||||
|
Get default texture. Return as lightuserdata
|
||||||
|
|
||||||
|
- Success return Texture
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
> texture = RL.LoadTexture( string fileName )
|
> texture = RL.LoadTexture( string fileName )
|
||||||
|
|
||||||
Load texture from file into GPU memory ( VRAM )
|
Load texture from file into GPU memory ( VRAM )
|
||||||
@@ -6201,10 +6209,12 @@ Get pixel data size in bytes for certain format
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
> RL.GetFontDefault()
|
> font = RL.GetFontDefault()
|
||||||
|
|
||||||
Get the default Font. Return as lightuserdata
|
Get the default Font. Return as lightuserdata
|
||||||
|
|
||||||
|
- Success return Font
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
> font = RL.LoadFont( string fileName )
|
> font = RL.LoadFont( string fileName )
|
||||||
|
|||||||
@@ -3314,6 +3314,11 @@ function RL.ImageDrawTextEx( dst, font, text, position, fontSize, spacing, tint
|
|||||||
|
|
||||||
-- Textures - Texture loading functions
|
-- Textures - Texture loading functions
|
||||||
|
|
||||||
|
---Get default texture. Return as lightuserdata
|
||||||
|
---- Success return Texture
|
||||||
|
---@return any texture
|
||||||
|
function RL.GetTextureDefault() end
|
||||||
|
|
||||||
---Load texture from file into GPU memory ( VRAM )
|
---Load texture from file into GPU memory ( VRAM )
|
||||||
---- Failure return nil
|
---- Failure return nil
|
||||||
---- Success return Texture
|
---- Success return Texture
|
||||||
@@ -3590,7 +3595,8 @@ function RL.GetPixelDataSize( width, height, format ) end
|
|||||||
-- Text - Font loading/unloading functions
|
-- Text - Font loading/unloading functions
|
||||||
|
|
||||||
---Get the default Font. Return as lightuserdata
|
---Get the default Font. Return as lightuserdata
|
||||||
---@return any RL.GetFontDefault
|
---- Success return Font
|
||||||
|
---@return any font
|
||||||
function RL.GetFontDefault() end
|
function RL.GetFontDefault() end
|
||||||
|
|
||||||
---Load font from file into GPU memory (VRAM)
|
---Load font from file into GPU memory (VRAM)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ KEY CHANGES:
|
|||||||
- ADDED: Experimental GLFW Pen Touch events. Needs glfw PR https://github.com/glfw/glfw/pull/1445.
|
- ADDED: Experimental GLFW Pen Touch events. Needs glfw PR https://github.com/glfw/glfw/pull/1445.
|
||||||
- ADDED: Platform specific API documentation generation.
|
- ADDED: Platform specific API documentation generation.
|
||||||
- ADDED: Platform web.
|
- ADDED: Platform web.
|
||||||
|
- ADDED: Raygui textures with SetShapesTexture.
|
||||||
|
|
||||||
DETAILED CHANGES:
|
DETAILED CHANGES:
|
||||||
- REMOVED: DrawLineBezierQuad, DrawLineBezierCubic.
|
- REMOVED: DrawLineBezierQuad, DrawLineBezierCubic.
|
||||||
@@ -32,6 +33,7 @@ DETAILED CHANGES:
|
|||||||
- CHANGE: Term globals changed to defines in documentation.
|
- CHANGE: Term globals changed to defines in documentation.
|
||||||
- CHANGE: Event documentation is now described in c files.
|
- CHANGE: Event documentation is now described in c files.
|
||||||
- ADDED: ExportBufferAsCode.
|
- ADDED: ExportBufferAsCode.
|
||||||
|
- ADDED: GetTextureDefault.
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
Release: ReiLua version 0.6.0 Using Raylib 4.5
|
Release: ReiLua version 0.6.0 Using Raylib 4.5
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ Raygui = require( "raygui" )
|
|||||||
local grid = {}
|
local grid = {}
|
||||||
local windowbox = {}
|
local windowbox = {}
|
||||||
local tabBar = {}
|
local tabBar = {}
|
||||||
|
local texture = RL.LoadTexture( RL.GetBasePath().."../resources/images/gradient.png" )
|
||||||
|
local textureRect = Rect:new( 0, 0, RL.GetTextureSize( texture )[1], RL.GetTextureSize( texture )[2] )
|
||||||
|
|
||||||
local function closeTab( self, id )
|
local function closeTab( self, id )
|
||||||
local splits = Util.split( tabBar.text, ";" )
|
local splits = Util.split( tabBar.text, ";" )
|
||||||
@@ -44,6 +46,10 @@ 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 )
|
||||||
|
|
||||||
|
RL.GuiSetStyle( RL.DEFAULT, RL.TEXT_COLOR_NORMAL, RL.ColorToInt( RL.RED ) )
|
||||||
|
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 = Raygui.Label:new(
|
||||||
Rect:new( 16, 16, 64, 32 ),
|
Rect:new( 16, 16, 64, 32 ),
|
||||||
"Cat"
|
"Cat"
|
||||||
@@ -57,12 +63,17 @@ function RL.init()
|
|||||||
local button = 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,
|
||||||
|
texture,
|
||||||
|
textureRect
|
||||||
)
|
)
|
||||||
local checkbox = Raygui.CheckBox:new(
|
local checkbox = Raygui.CheckBox:new(
|
||||||
Rect:new( 64, 128, 20, 20 ),
|
Rect:new( 64, 128, 20, 20 ),
|
||||||
"Dog",
|
"Dog",
|
||||||
false
|
false,
|
||||||
|
nil,
|
||||||
|
texture,
|
||||||
|
textureRect
|
||||||
)
|
)
|
||||||
local combobox = Raygui.ComboBox:new(
|
local combobox = Raygui.ComboBox:new(
|
||||||
Rect:new( 64, 256, 128, 32 ),
|
Rect:new( 64, 256, 128, 32 ),
|
||||||
@@ -115,7 +126,9 @@ function RL.init()
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
100,
|
100,
|
||||||
function( self ) print( "Changed value "..self.value ) end
|
function( self ) print( "Changed value "..self.value ) end,
|
||||||
|
texture,
|
||||||
|
textureRect
|
||||||
)
|
)
|
||||||
local sliderbar = Raygui.SliderBar:new(
|
local sliderbar = Raygui.SliderBar:new(
|
||||||
Rect:new( 50, 550, 256, 32 ),
|
Rect:new( 50, 550, 256, 32 ),
|
||||||
@@ -125,6 +138,7 @@ 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.ProgressBar:new(
|
local progressbar = Raygui.ProgressBar:new(
|
||||||
Rect:new( 50, 600, 256, 32 ),
|
Rect:new( 50, 600, 256, 32 ),
|
||||||
@@ -155,7 +169,10 @@ function RL.init()
|
|||||||
-- Close callback.
|
-- Close callback.
|
||||||
function( self ) self.visible = false end,
|
function( self ) self.visible = false end,
|
||||||
-- Grab callback.
|
-- Grab callback.
|
||||||
function( self ) Raygui.set2Top( self ) end
|
function( self ) Raygui.set2Top( self ) end,
|
||||||
|
nil,
|
||||||
|
texture,
|
||||||
|
textureRect
|
||||||
)
|
)
|
||||||
local groupbox = Raygui.GroupBox:new(
|
local groupbox = Raygui.GroupBox:new(
|
||||||
Rect:new( 400, 700, 256, 256 ),
|
Rect:new( 400, 700, 256, 256 ),
|
||||||
@@ -177,7 +194,9 @@ function RL.init()
|
|||||||
0,
|
0,
|
||||||
-- function( self ) Raygui.set2Top( self ) end
|
-- function( self ) Raygui.set2Top( self ) end
|
||||||
nil,
|
nil,
|
||||||
closeTab
|
closeTab,
|
||||||
|
texture,
|
||||||
|
textureRect
|
||||||
)
|
)
|
||||||
local scrollpanel = Raygui.ScrollPanel:new(
|
local scrollpanel = Raygui.ScrollPanel:new(
|
||||||
Rect:new( 800, 64, 256, 256 ),
|
Rect:new( 800, 64, 256, 256 ),
|
||||||
@@ -194,7 +213,9 @@ function RL.init()
|
|||||||
"Cat;Dog;Horse;Cow;Pig;Eagle;Lion",
|
"Cat;Dog;Horse;Cow;Pig;Eagle;Lion",
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
function( self ) print( self:getItem( self.active ) ) end
|
function( self ) print( self:getItem( self.active ) ) end,
|
||||||
|
texture,
|
||||||
|
textureRect
|
||||||
)
|
)
|
||||||
local listviewex = Raygui.ListViewEx:new(
|
local listviewex = Raygui.ListViewEx:new(
|
||||||
Rect:new( 1300, 64, 128, 80 ),
|
Rect:new( 1300, 64, 128, 80 ),
|
||||||
@@ -202,7 +223,9 @@ function RL.init()
|
|||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
function( self ) print( self:getItem( self.active ) ) end
|
function( self ) print( self:getItem( self.active ) ) end,
|
||||||
|
texture,
|
||||||
|
textureRect
|
||||||
)
|
)
|
||||||
local messagebox = Raygui.MessageBox:new(
|
local messagebox = Raygui.MessageBox:new(
|
||||||
Rect:new( 1100, 150, 300, 128 ),
|
Rect:new( 1100, 150, 300, 128 ),
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ grass.png Jussi Viitala CC0
|
|||||||
snake.png Jussi Viitala CC0
|
snake.png Jussi Viitala CC0
|
||||||
ui_border.png Jussi Viitala CC0
|
ui_border.png Jussi Viitala CC0
|
||||||
ui_bgr.png Jussi Viitala CC0
|
ui_bgr.png Jussi Viitala CC0
|
||||||
|
gradient.png Jussi Viitala CC0
|
||||||
check-mark.png Delapouite Creative Commons 3.0 https://game-icons.net Resized
|
check-mark.png Delapouite Creative Commons 3.0 https://game-icons.net Resized
|
||||||
circle.png Delapouite Creative Commons 3.0 https://game-icons.net Resized
|
circle.png Delapouite Creative Commons 3.0 https://game-icons.net Resized
|
||||||
plain-circle.png Delapouite Creative Commons 3.0 https://game-icons.net Resized
|
plain-circle.png Delapouite Creative Commons 3.0 https://game-icons.net Resized
|
||||||
|
|||||||
BIN
examples/resources/images/gradient.png
Normal file
BIN
examples/resources/images/gradient.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
@@ -56,6 +56,8 @@ local Raygui = {
|
|||||||
grabPos = Vec2:new(),
|
grabPos = Vec2:new(),
|
||||||
scrolling = false,
|
scrolling = false,
|
||||||
textEdit = false,
|
textEdit = false,
|
||||||
|
defaultTexture = RL.GetTextureDefault(),
|
||||||
|
defaultRect = Rect:new( 0, 0, 1, 1 )
|
||||||
}
|
}
|
||||||
|
|
||||||
function Raygui.process()
|
function Raygui.process()
|
||||||
@@ -180,25 +182,10 @@ 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
|
||||||
|
|
||||||
---@param bounds table Rect
|
function WindowBox:new( bounds, text, callback, grabCallback, dragCallback, texture, textureRect )
|
||||||
---@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()
|
||||||
@@ -206,6 +193,8 @@ function WindowBox:new( bounds, text, callback, grabCallback, dragCallback )
|
|||||||
object.callback = callback
|
object.callback = callback
|
||||||
object.grabCallback = grabCallback
|
object.grabCallback = grabCallback
|
||||||
object.dragCallback = dragCallback
|
object.dragCallback = dragCallback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
object.draggable = true
|
object.draggable = true
|
||||||
@@ -220,8 +209,16 @@ function WindowBox:process()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function WindowBox:draw()
|
function WindowBox:draw()
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
local result = RL.GuiWindowBox( self.bounds, self.text )
|
local result = RL.GuiWindowBox( self.bounds, self.text )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
|
|
||||||
if result == 1 and self.callback ~= nil then
|
if result == 1 and self.callback ~= nil then
|
||||||
self.callback( self )
|
self.callback( self )
|
||||||
end
|
end
|
||||||
@@ -234,16 +231,9 @@ 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 )
|
||||||
|
|
||||||
@@ -308,16 +298,18 @@ end
|
|||||||
Panel = {}
|
Panel = {}
|
||||||
Panel.__index = Panel
|
Panel.__index = Panel
|
||||||
|
|
||||||
function Panel:new( bounds, text, grabCallback, dragCallback )
|
function Panel:new( bounds, text, grabCallback, dragCallback, texture, textureRect )
|
||||||
local object = setmetatable( {}, Panel )
|
local object = setmetatable( {}, Panel )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
object.text = text
|
object.text = text
|
||||||
|
object.grabCallback = grabCallback
|
||||||
|
object.dragCallback = dragCallback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
object.draggable = true
|
object.draggable = true
|
||||||
object.grabCallback = grabCallback
|
|
||||||
object.dragCallback = dragCallback
|
|
||||||
|
|
||||||
table.insert( Raygui.elements, object )
|
table.insert( Raygui.elements, object )
|
||||||
|
|
||||||
@@ -329,7 +321,15 @@ function Panel:process()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Panel:draw()
|
function Panel:draw()
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
RL.GuiPanel( self.bounds, self.text )
|
RL.GuiPanel( self.bounds, self.text )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Panel:setPosition( pos )
|
function Panel:setPosition( pos )
|
||||||
@@ -343,12 +343,14 @@ end
|
|||||||
GuiTabBar = {}
|
GuiTabBar = {}
|
||||||
GuiTabBar.__index = GuiTabBar
|
GuiTabBar.__index = GuiTabBar
|
||||||
|
|
||||||
function GuiTabBar:new( bounds, text, active, callback, closeCallback )
|
function GuiTabBar:new( bounds, text, active, callback, closeCallback, texture, textureRect )
|
||||||
local object = setmetatable( {}, GuiTabBar )
|
local object = setmetatable( {}, GuiTabBar )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
object.text = text
|
object.text = text
|
||||||
object.active = active
|
object.active = active
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
@@ -367,8 +369,16 @@ function GuiTabBar:draw()
|
|||||||
local oldActive = self.active
|
local oldActive = self.active
|
||||||
local result = -1
|
local result = -1
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
result, self.active = RL.GuiTabBar( self.bounds, self.text, self.active )
|
result, self.active = RL.GuiTabBar( self.bounds, self.text, self.active )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
|
|
||||||
if self.active ~= oldActive and self.callback ~= nil then
|
if self.active ~= oldActive and self.callback ~= nil then
|
||||||
self.callback( self )
|
self.callback( self )
|
||||||
end
|
end
|
||||||
@@ -389,7 +399,7 @@ end
|
|||||||
ScrollPanel = {}
|
ScrollPanel = {}
|
||||||
ScrollPanel.__index = ScrollPanel
|
ScrollPanel.__index = ScrollPanel
|
||||||
|
|
||||||
function ScrollPanel:new( bounds, text, content, scroll, callback, grabCallback, dragCallback )
|
function ScrollPanel:new( bounds, text, content, scroll, callback, grabCallback, dragCallback, texture, textureRect )
|
||||||
local object = setmetatable( {}, ScrollPanel )
|
local object = setmetatable( {}, ScrollPanel )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
@@ -400,6 +410,8 @@ function ScrollPanel:new( bounds, text, content, scroll, callback, grabCallback,
|
|||||||
object.callback = callback
|
object.callback = callback
|
||||||
object.grabCallback = grabCallback
|
object.grabCallback = grabCallback
|
||||||
object.dragCallback = dragCallback
|
object.dragCallback = dragCallback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
object.draggable = true
|
object.draggable = true
|
||||||
@@ -415,8 +427,17 @@ end
|
|||||||
|
|
||||||
function ScrollPanel:draw()
|
function ScrollPanel:draw()
|
||||||
local oldScroll = self.scroll:clone()
|
local oldScroll = self.scroll:clone()
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
local _, scroll, view = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll, self.view )
|
local _, scroll, view = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll, self.view )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
|
|
||||||
self.view = Rect:new( view )
|
self.view = Rect:new( view )
|
||||||
self.scroll = Vec2:new( scroll )
|
self.scroll = Vec2:new( scroll )
|
||||||
|
|
||||||
@@ -476,12 +497,14 @@ end
|
|||||||
Button = {}
|
Button = {}
|
||||||
Button.__index = Button
|
Button.__index = Button
|
||||||
|
|
||||||
function Button:new( bounds, text, callback )
|
function Button:new( bounds, text, callback, texture, textureRect )
|
||||||
local object = setmetatable( {}, Button )
|
local object = setmetatable( {}, Button )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
object.text = text
|
object.text = text
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
@@ -495,8 +518,16 @@ function Button:process()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Button:draw()
|
function Button:draw()
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
local result = RL.GuiButton( self.bounds, self.text )
|
local result = RL.GuiButton( self.bounds, self.text )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
|
|
||||||
if result == 1 and self.callback ~= nil then
|
if result == 1 and self.callback ~= nil then
|
||||||
self.callback( self )
|
self.callback( self )
|
||||||
end
|
end
|
||||||
@@ -550,13 +581,15 @@ end
|
|||||||
Toggle = {}
|
Toggle = {}
|
||||||
Toggle.__index = Toggle
|
Toggle.__index = Toggle
|
||||||
|
|
||||||
function Toggle:new( bounds, text, active, callback )
|
function Toggle:new( bounds, text, active, callback, texture, textureRect )
|
||||||
local object = setmetatable( {}, Toggle )
|
local object = setmetatable( {}, Toggle )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
object.text = text
|
object.text = text
|
||||||
object.active = active
|
object.active = active
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
@@ -572,8 +605,16 @@ end
|
|||||||
function Toggle:draw()
|
function Toggle:draw()
|
||||||
local oldActive = self.active
|
local oldActive = self.active
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
_, self.active = RL.GuiToggle( self.bounds, self.text, self.active )
|
_, self.active = RL.GuiToggle( self.bounds, self.text, self.active )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
|
|
||||||
if self.active ~= oldActive and self.callback ~= nil then
|
if self.active ~= oldActive and self.callback ~= nil then
|
||||||
self.callback( self )
|
self.callback( self )
|
||||||
end
|
end
|
||||||
@@ -590,13 +631,15 @@ end
|
|||||||
ToggleGroup = {}
|
ToggleGroup = {}
|
||||||
ToggleGroup.__index = ToggleGroup
|
ToggleGroup.__index = ToggleGroup
|
||||||
|
|
||||||
function ToggleGroup:new( bounds, text, active, callback )
|
function ToggleGroup:new( bounds, text, active, callback, texture, textureRect )
|
||||||
local object = setmetatable( {}, ToggleGroup )
|
local object = setmetatable( {}, ToggleGroup )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
object.text = text
|
object.text = text
|
||||||
object.active = active
|
object.active = active
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
object.focusBounds = {}
|
object.focusBounds = {}
|
||||||
@@ -653,8 +696,15 @@ end
|
|||||||
function ToggleGroup:draw()
|
function ToggleGroup:draw()
|
||||||
local oldActive = self.active
|
local oldActive = self.active
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
_, self.active = RL.GuiToggleGroup( self.bounds, self.text, self.active )
|
_, self.active = RL.GuiToggleGroup( self.bounds, self.text, self.active )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
if self.active ~= oldActive and self.callback ~= nil then
|
if self.active ~= oldActive and self.callback ~= nil then
|
||||||
self.callback( self )
|
self.callback( self )
|
||||||
end
|
end
|
||||||
@@ -673,13 +723,15 @@ end
|
|||||||
CheckBox = {}
|
CheckBox = {}
|
||||||
CheckBox.__index = CheckBox
|
CheckBox.__index = CheckBox
|
||||||
|
|
||||||
function CheckBox:new( bounds, text, checked, callback )
|
function CheckBox:new( bounds, text, checked, callback, texture, textureRect )
|
||||||
local object = setmetatable( {}, CheckBox )
|
local object = setmetatable( {}, CheckBox )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
object.text = text
|
object.text = text
|
||||||
object.checked = checked
|
object.checked = checked
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
object.focusBounds = bounds:clone()
|
object.focusBounds = bounds:clone()
|
||||||
@@ -734,12 +786,18 @@ end
|
|||||||
function CheckBox:draw()
|
function CheckBox:draw()
|
||||||
local oldChecked = self.checked
|
local oldChecked = self.checked
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
_, self.checked = RL.GuiCheckBox( self.bounds, self.text, self.checked )
|
_, self.checked = RL.GuiCheckBox( self.bounds, self.text, self.checked )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
if self.checked ~= oldChecked and self.callback ~= nil then
|
if self.checked ~= oldChecked and self.callback ~= nil then
|
||||||
self.callback( self )
|
self.callback( self )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- RL.DrawRectangleLines( self.focusBounds, RL.RED )
|
-- RL.DrawRectangleLines( self.focusBounds, RL.RED )
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -756,13 +814,15 @@ end
|
|||||||
ComboBox = {}
|
ComboBox = {}
|
||||||
ComboBox.__index = ComboBox
|
ComboBox.__index = ComboBox
|
||||||
|
|
||||||
function ComboBox:new( bounds, text, active, callback )
|
function ComboBox:new( bounds, text, active, callback, texture, textureRect )
|
||||||
local object = setmetatable( {}, ComboBox )
|
local object = setmetatable( {}, ComboBox )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
object.text = text
|
object.text = text
|
||||||
object.active = active
|
object.active = active
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
@@ -778,8 +838,15 @@ end
|
|||||||
function ComboBox:draw()
|
function ComboBox:draw()
|
||||||
local oldActive = self.active
|
local oldActive = self.active
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
_, self.active = RL.GuiComboBox( self.bounds, self.text, self.active )
|
_, self.active = RL.GuiComboBox( self.bounds, self.text, self.active )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
if self.active ~= oldActive and self.callback ~= nil then
|
if self.active ~= oldActive and self.callback ~= nil then
|
||||||
self.callback( self )
|
self.callback( self )
|
||||||
end
|
end
|
||||||
@@ -796,7 +863,7 @@ end
|
|||||||
DropdownBox = {}
|
DropdownBox = {}
|
||||||
DropdownBox.__index = DropdownBox
|
DropdownBox.__index = DropdownBox
|
||||||
|
|
||||||
function DropdownBox:new( bounds, text, active, editMode, callback )
|
function DropdownBox:new( bounds, text, active, editMode, callback, texture, textureRect )
|
||||||
local object = setmetatable( {}, DropdownBox )
|
local object = setmetatable( {}, DropdownBox )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
@@ -804,6 +871,8 @@ function DropdownBox:new( bounds, text, active, editMode, callback )
|
|||||||
object.active = active
|
object.active = active
|
||||||
object.editMode = editMode
|
object.editMode = editMode
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
object.editModeBounds = bounds:clone()
|
object.editModeBounds = bounds:clone()
|
||||||
@@ -846,8 +915,15 @@ end
|
|||||||
function DropdownBox:draw()
|
function DropdownBox:draw()
|
||||||
local result = 0
|
local result = 0
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
result, self.active = RL.GuiDropdownBox( self.bounds, self.text, self.active, self.editMode )
|
result, self.active = RL.GuiDropdownBox( self.bounds, self.text, self.active, self.editMode )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
if result == 1 then
|
if result == 1 then
|
||||||
self.editMode = not self.editMode
|
self.editMode = not self.editMode
|
||||||
|
|
||||||
@@ -868,7 +944,7 @@ end
|
|||||||
Spinner = {}
|
Spinner = {}
|
||||||
Spinner.__index = Spinner
|
Spinner.__index = Spinner
|
||||||
|
|
||||||
function Spinner:new( bounds, text, value, minValue, maxValue, editMode, callback )
|
function Spinner:new( bounds, text, value, minValue, maxValue, editMode, callback, texture, textureRect )
|
||||||
local object = setmetatable( {}, Spinner )
|
local object = setmetatable( {}, Spinner )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
@@ -878,6 +954,8 @@ function Spinner:new( bounds, text, value, minValue, maxValue, editMode, callbac
|
|||||||
object.maxValue = maxValue
|
object.maxValue = maxValue
|
||||||
object.editMode = editMode
|
object.editMode = editMode
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
@@ -894,13 +972,19 @@ function Spinner:draw()
|
|||||||
local result = 0
|
local result = 0
|
||||||
local oldValue = self.value
|
local oldValue = self.value
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
result, self.value = RL.GuiSpinner( self.bounds, self.text, self.value, self.minValue, self.maxValue, self.editMode )
|
result, self.value = RL.GuiSpinner( self.bounds, self.text, self.value, self.minValue, self.maxValue, self.editMode )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
if result == 1 then
|
if result == 1 then
|
||||||
Raygui.editMode( self.editMode )
|
Raygui.editMode( self.editMode )
|
||||||
self.editMode = not self.editMode
|
self.editMode = not self.editMode
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.value ~= oldValue and self.callback ~= nil then
|
if self.value ~= oldValue and self.callback ~= nil then
|
||||||
self.callback( self )
|
self.callback( self )
|
||||||
end
|
end
|
||||||
@@ -917,7 +1001,7 @@ end
|
|||||||
ValueBox = {}
|
ValueBox = {}
|
||||||
ValueBox.__index = ValueBox
|
ValueBox.__index = ValueBox
|
||||||
|
|
||||||
function ValueBox:new( bounds, text, value, minValue, maxValue, editMode, callback )
|
function ValueBox:new( bounds, text, value, minValue, maxValue, editMode, callback, texture, textureRect )
|
||||||
local object = setmetatable( {}, ValueBox )
|
local object = setmetatable( {}, ValueBox )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
@@ -927,6 +1011,8 @@ function ValueBox:new( bounds, text, value, minValue, maxValue, editMode, callba
|
|||||||
object.maxValue = maxValue
|
object.maxValue = maxValue
|
||||||
object.editMode = editMode
|
object.editMode = editMode
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
@@ -943,13 +1029,19 @@ function ValueBox:draw()
|
|||||||
local result = 0
|
local result = 0
|
||||||
local oldValue = self.value
|
local oldValue = self.value
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
result, self.value = RL.GuiValueBox( self.bounds, self.text, self.value, self.minValue, self.maxValue, self.editMode )
|
result, self.value = RL.GuiValueBox( self.bounds, self.text, self.value, self.minValue, self.maxValue, self.editMode )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
if result == 1 then
|
if result == 1 then
|
||||||
Raygui.editMode( self.editMode )
|
Raygui.editMode( self.editMode )
|
||||||
self.editMode = not self.editMode
|
self.editMode = not self.editMode
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.value ~= oldValue and self.callback ~= nil then
|
if self.value ~= oldValue and self.callback ~= nil then
|
||||||
self.callback( self )
|
self.callback( self )
|
||||||
end
|
end
|
||||||
@@ -966,7 +1058,7 @@ end
|
|||||||
TextBox = {}
|
TextBox = {}
|
||||||
TextBox.__index = TextBox
|
TextBox.__index = TextBox
|
||||||
|
|
||||||
function TextBox:new( bounds, text, textSize, editMode, callback )
|
function TextBox:new( bounds, text, textSize, editMode, callback, texture, textureRect )
|
||||||
local object = setmetatable( {}, TextBox )
|
local object = setmetatable( {}, TextBox )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
@@ -974,6 +1066,8 @@ function TextBox:new( bounds, text, textSize, editMode, callback )
|
|||||||
object.textSize = textSize
|
object.textSize = textSize
|
||||||
object.editMode = editMode
|
object.editMode = editMode
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
-- 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
|
object.visible = true
|
||||||
@@ -993,13 +1087,18 @@ function TextBox:draw()
|
|||||||
if self.scissorMode then
|
if self.scissorMode then
|
||||||
RL.BeginScissorMode( self.bounds )
|
RL.BeginScissorMode( self.bounds )
|
||||||
end
|
end
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
result, self.text = RL.GuiTextBox( self.bounds, self.text, self.textSize, self.editMode )
|
result, self.text = RL.GuiTextBox( self.bounds, self.text, self.textSize, self.editMode )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
if self.scissorMode then
|
if self.scissorMode then
|
||||||
RL.EndScissorMode()
|
RL.EndScissorMode()
|
||||||
end
|
end
|
||||||
|
|
||||||
if result == 1 then
|
if result == 1 then
|
||||||
Raygui.editMode( self.editMode )
|
Raygui.editMode( self.editMode )
|
||||||
self.editMode = not self.editMode
|
self.editMode = not self.editMode
|
||||||
@@ -1021,7 +1120,7 @@ end
|
|||||||
Slider = {}
|
Slider = {}
|
||||||
Slider.__index = Slider
|
Slider.__index = Slider
|
||||||
|
|
||||||
function Slider:new( bounds, textLeft, textRight, value, minValue, maxValue, callback )
|
function Slider:new( bounds, textLeft, textRight, value, minValue, maxValue, callback, texture, textureRect )
|
||||||
local object = setmetatable( {}, Slider )
|
local object = setmetatable( {}, Slider )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
@@ -1031,6 +1130,8 @@ function Slider:new( bounds, textLeft, textRight, value, minValue, maxValue, cal
|
|||||||
object.minValue = minValue
|
object.minValue = minValue
|
||||||
object.maxValue = maxValue
|
object.maxValue = maxValue
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
@@ -1046,8 +1147,15 @@ end
|
|||||||
function Slider:draw()
|
function Slider:draw()
|
||||||
local oldValue = self.value
|
local oldValue = self.value
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
_, self.value = RL.GuiSlider( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue )
|
_, self.value = RL.GuiSlider( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
if self.value ~= oldValue then
|
if self.value ~= oldValue then
|
||||||
Raygui.scrolling = true
|
Raygui.scrolling = true
|
||||||
|
|
||||||
@@ -1068,7 +1176,7 @@ end
|
|||||||
SliderBar = {}
|
SliderBar = {}
|
||||||
SliderBar.__index = SliderBar
|
SliderBar.__index = SliderBar
|
||||||
|
|
||||||
function SliderBar:new( bounds, textLeft, textRight, value, minValue, maxValue, callback )
|
function SliderBar:new( bounds, textLeft, textRight, value, minValue, maxValue, callback, texture, textureRect )
|
||||||
local object = setmetatable( {}, SliderBar )
|
local object = setmetatable( {}, SliderBar )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
@@ -1078,6 +1186,8 @@ function SliderBar:new( bounds, textLeft, textRight, value, minValue, maxValue,
|
|||||||
object.minValue = minValue
|
object.minValue = minValue
|
||||||
object.maxValue = maxValue
|
object.maxValue = maxValue
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
@@ -1093,8 +1203,15 @@ end
|
|||||||
function SliderBar:draw()
|
function SliderBar:draw()
|
||||||
local oldValue = self.value
|
local oldValue = self.value
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
_, self.value = RL.GuiSliderBar( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue )
|
_, self.value = RL.GuiSliderBar( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
if self.value ~= oldValue then
|
if self.value ~= oldValue then
|
||||||
Raygui.scrolling = true
|
Raygui.scrolling = true
|
||||||
|
|
||||||
@@ -1115,7 +1232,7 @@ end
|
|||||||
ProgressBar = {}
|
ProgressBar = {}
|
||||||
ProgressBar.__index = ProgressBar
|
ProgressBar.__index = ProgressBar
|
||||||
|
|
||||||
function ProgressBar:new( bounds, textLeft, textRight, value, minValue, maxValue, callback )
|
function ProgressBar:new( bounds, textLeft, textRight, value, minValue, maxValue, callback, texture, textureRect )
|
||||||
local object = setmetatable( {}, ProgressBar )
|
local object = setmetatable( {}, ProgressBar )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
@@ -1125,6 +1242,8 @@ function ProgressBar:new( bounds, textLeft, textRight, value, minValue, maxValue
|
|||||||
object.minValue = minValue
|
object.minValue = minValue
|
||||||
object.maxValue = maxValue
|
object.maxValue = maxValue
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
@@ -1140,8 +1259,15 @@ end
|
|||||||
function ProgressBar:draw()
|
function ProgressBar:draw()
|
||||||
local oldValue = self.value
|
local oldValue = self.value
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
_, self.value = RL.GuiProgressBar( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue )
|
_, self.value = RL.GuiProgressBar( self.bounds, self.textLeft, self.textRight, self.value, self.minValue, self.maxValue )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
if self.value ~= oldValue then
|
if self.value ~= oldValue then
|
||||||
self.callback( self )
|
self.callback( self )
|
||||||
end
|
end
|
||||||
@@ -1158,11 +1284,13 @@ end
|
|||||||
StatusBar = {}
|
StatusBar = {}
|
||||||
StatusBar.__index = StatusBar
|
StatusBar.__index = StatusBar
|
||||||
|
|
||||||
function StatusBar:new( bounds, text )
|
function StatusBar:new( bounds, text, texture, textureRect )
|
||||||
local object = setmetatable( {}, StatusBar )
|
local object = setmetatable( {}, StatusBar )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
object.text = text
|
object.text = text
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
@@ -1176,7 +1304,15 @@ function StatusBar:process()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function StatusBar:draw()
|
function StatusBar:draw()
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
RL.GuiStatusBar( self.bounds, self.text )
|
RL.GuiStatusBar( self.bounds, self.text )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function StatusBar:setPosition( pos )
|
function StatusBar:setPosition( pos )
|
||||||
@@ -1190,11 +1326,13 @@ end
|
|||||||
DummyRec = {}
|
DummyRec = {}
|
||||||
DummyRec.__index = DummyRec
|
DummyRec.__index = DummyRec
|
||||||
|
|
||||||
function DummyRec:new( bounds, text )
|
function DummyRec:new( bounds, text, texture, textureRect )
|
||||||
local object = setmetatable( {}, DummyRec )
|
local object = setmetatable( {}, DummyRec )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
object.text = text
|
object.text = text
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
@@ -1208,7 +1346,15 @@ function DummyRec:process()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function DummyRec:draw()
|
function DummyRec:draw()
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
RL.GuiDummyRec( self.bounds, self.text )
|
RL.GuiDummyRec( self.bounds, self.text )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function DummyRec:setPosition( pos )
|
function DummyRec:setPosition( pos )
|
||||||
@@ -1270,7 +1416,7 @@ end
|
|||||||
ListView = {}
|
ListView = {}
|
||||||
ListView.__index = ListView
|
ListView.__index = ListView
|
||||||
|
|
||||||
function ListView:new( bounds, text, scrollIndex, active, callback )
|
function ListView:new( bounds, text, scrollIndex, active, callback, texture, textureRect )
|
||||||
local object = setmetatable( {}, ListView )
|
local object = setmetatable( {}, ListView )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
@@ -1278,6 +1424,9 @@ function ListView:new( bounds, text, scrollIndex, active, callback )
|
|||||||
object.scrollIndex = scrollIndex
|
object.scrollIndex = scrollIndex
|
||||||
object.active = active
|
object.active = active
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
table.insert( Raygui.elements, object )
|
table.insert( Raygui.elements, object )
|
||||||
@@ -1297,8 +1446,15 @@ function ListView:draw()
|
|||||||
local oldActive = self.active
|
local oldActive = self.active
|
||||||
local oldScrollIndex = self.scrollIndex
|
local oldScrollIndex = self.scrollIndex
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
_, self.scrollIndex, self.active = RL.GuiListView( self.bounds, self.text, self.scrollIndex, self.active )
|
_, self.scrollIndex, self.active = RL.GuiListView( self.bounds, self.text, self.scrollIndex, self.active )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
if self.scrollIndex ~= oldScrollIndex then
|
if self.scrollIndex ~= oldScrollIndex then
|
||||||
Raygui.scrolling = true
|
Raygui.scrolling = true
|
||||||
end
|
end
|
||||||
@@ -1318,7 +1474,7 @@ end
|
|||||||
ListViewEx = {}
|
ListViewEx = {}
|
||||||
ListViewEx.__index = ListViewEx
|
ListViewEx.__index = ListViewEx
|
||||||
|
|
||||||
function ListViewEx:new( bounds, text, scrollIndex, active, focus, callback )
|
function ListViewEx:new( bounds, text, scrollIndex, active, focus, callback, texture, textureRect )
|
||||||
local object = setmetatable( {}, ListViewEx )
|
local object = setmetatable( {}, ListViewEx )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
@@ -1327,6 +1483,9 @@ function ListViewEx:new( bounds, text, scrollIndex, active, focus, callback )
|
|||||||
object.active = active
|
object.active = active
|
||||||
object.focus = focus
|
object.focus = focus
|
||||||
object.callback = callback
|
object.callback = callback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
|
|
||||||
table.insert( Raygui.elements, object )
|
table.insert( Raygui.elements, object )
|
||||||
@@ -1346,8 +1505,15 @@ function ListViewEx:draw()
|
|||||||
local oldActive = self.active
|
local oldActive = self.active
|
||||||
local oldScrollIndex = self.scrollIndex
|
local oldScrollIndex = self.scrollIndex
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
_, self.scrollIndex, self.active, self.focus = RL.GuiListViewEx( self.bounds, self.text, self.scrollIndex, self.active, self.focus )
|
_, self.scrollIndex, self.active, self.focus = RL.GuiListViewEx( self.bounds, self.text, self.scrollIndex, self.active, self.focus )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
if self.scrollIndex ~= oldScrollIndex then
|
if self.scrollIndex ~= oldScrollIndex then
|
||||||
Raygui.scrolling = true
|
Raygui.scrolling = true
|
||||||
end
|
end
|
||||||
@@ -1367,7 +1533,7 @@ end
|
|||||||
MessageBox = {}
|
MessageBox = {}
|
||||||
MessageBox.__index = MessageBox
|
MessageBox.__index = MessageBox
|
||||||
|
|
||||||
function MessageBox:new( bounds, title, message, buttons, callback, grabCallback, dragCallback )
|
function MessageBox:new( bounds, title, message, buttons, callback, grabCallback, dragCallback, texture, textureRect )
|
||||||
local object = setmetatable( {}, MessageBox )
|
local object = setmetatable( {}, MessageBox )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
@@ -1377,6 +1543,8 @@ function MessageBox:new( bounds, title, message, buttons, callback, grabCallback
|
|||||||
object.callback = callback
|
object.callback = callback
|
||||||
object.grabCallback = grabCallback
|
object.grabCallback = grabCallback
|
||||||
object.dragCallback = dragCallback
|
object.dragCallback = dragCallback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.buttonIndex = -1
|
object.buttonIndex = -1
|
||||||
object.visible = true
|
object.visible = true
|
||||||
@@ -1396,8 +1564,15 @@ function MessageBox:process()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function MessageBox:draw()
|
function MessageBox:draw()
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
self.buttonIndex = RL.GuiMessageBox( self.bounds, self.title, self.message, self.buttons )
|
self.buttonIndex = RL.GuiMessageBox( self.bounds, self.title, self.message, self.buttons )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
if 0 <= self.buttonIndex and self.callback ~= nil then
|
if 0 <= self.buttonIndex and self.callback ~= nil then
|
||||||
self.callback( self )
|
self.callback( self )
|
||||||
end
|
end
|
||||||
@@ -1414,7 +1589,7 @@ end
|
|||||||
TextInputBox = {}
|
TextInputBox = {}
|
||||||
TextInputBox.__index = TextInputBox
|
TextInputBox.__index = TextInputBox
|
||||||
|
|
||||||
function TextInputBox:new( bounds, title, message, buttons, text, textMaxSize, secretViewActive, callback, grabCallback, dragCallback )
|
function TextInputBox:new( bounds, title, message, buttons, text, textMaxSize, secretViewActive, callback, grabCallback, dragCallback, texture, textureRect )
|
||||||
local object = setmetatable( {}, TextInputBox )
|
local object = setmetatable( {}, TextInputBox )
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
@@ -1427,6 +1602,8 @@ function TextInputBox:new( bounds, title, message, buttons, text, textMaxSize, s
|
|||||||
object.callback = callback
|
object.callback = callback
|
||||||
object.grabCallback = grabCallback
|
object.grabCallback = grabCallback
|
||||||
object.dragCallback = dragCallback
|
object.dragCallback = dragCallback
|
||||||
|
object.texture = texture
|
||||||
|
object.textureRect = textureRect
|
||||||
|
|
||||||
object.buttonIndex = -1
|
object.buttonIndex = -1
|
||||||
object.visible = true
|
object.visible = true
|
||||||
@@ -1446,8 +1623,15 @@ function TextInputBox:process()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function TextInputBox:draw()
|
function TextInputBox:draw()
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( self.texture, self.textureRect )
|
||||||
|
end
|
||||||
|
|
||||||
self.buttonIndex, self.text, self.secretViewActive = RL.GuiTextInputBox( self.bounds, self.title, self.message, self.buttons, self.text, self.textMaxSize, self.secretViewActive )
|
self.buttonIndex, self.text, self.secretViewActive = RL.GuiTextInputBox( self.bounds, self.title, self.message, self.buttons, self.text, self.textMaxSize, self.secretViewActive )
|
||||||
|
|
||||||
|
if self.texture ~= nil then
|
||||||
|
RL.SetShapesTexture( Raygui.defaultTexture, Raygui.defaultRect )
|
||||||
|
end
|
||||||
if 0 <= self.buttonIndex and self.callback ~= nil then
|
if 0 <= self.buttonIndex and self.callback ~= nil then
|
||||||
self.callback( self )
|
self.callback( self )
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -25,4 +25,6 @@ end
|
|||||||
function RL.draw()
|
function RL.draw()
|
||||||
RL.ClearBackground( RL.RAYWHITE )
|
RL.ClearBackground( RL.RAYWHITE )
|
||||||
RL.DrawText( text, textPos, 20, textColor )
|
RL.DrawText( text, textPos, 20, textColor )
|
||||||
|
|
||||||
|
RL.DrawCircle( { 300, 300 }, 180, RL.BLACK )
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ typedef struct {
|
|||||||
int logLevelInvalid;
|
int logLevelInvalid;
|
||||||
Font defaultFont;
|
Font defaultFont;
|
||||||
Material defaultMaterial;
|
Material defaultMaterial;
|
||||||
|
Texture defaultTexture;
|
||||||
int *RLGLcurrentShaderLocs;
|
int *RLGLcurrentShaderLocs;
|
||||||
/* Events. */
|
/* Events. */
|
||||||
#ifdef PLATFORM_DESKTOP
|
#ifdef PLATFORM_DESKTOP
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ int ltexturesImageDrawRectangleLines( lua_State *L );
|
|||||||
int ltexturesImageDraw( lua_State *L );
|
int ltexturesImageDraw( lua_State *L );
|
||||||
int ltexturesImageDrawTextEx( lua_State *L );
|
int ltexturesImageDrawTextEx( lua_State *L );
|
||||||
/* Texture loading functions. */
|
/* Texture loading functions. */
|
||||||
|
int ltexturesGetTextureDefault( lua_State *L );
|
||||||
int ltexturesLoadTexture( lua_State *L );
|
int ltexturesLoadTexture( lua_State *L );
|
||||||
int ltexturesLoadTextureFromImage( lua_State *L );
|
int ltexturesLoadTextureFromImage( lua_State *L );
|
||||||
int ltexturesLoadTextureCubemap( lua_State *L );
|
int ltexturesLoadTextureCubemap( lua_State *L );
|
||||||
|
|||||||
@@ -1508,6 +1508,7 @@ void luaRegister() {
|
|||||||
assingGlobalFunction( "ImageDraw", ltexturesImageDraw );
|
assingGlobalFunction( "ImageDraw", ltexturesImageDraw );
|
||||||
assingGlobalFunction( "ImageDrawTextEx", ltexturesImageDrawTextEx );
|
assingGlobalFunction( "ImageDrawTextEx", ltexturesImageDrawTextEx );
|
||||||
/* Texture loading functions. */
|
/* Texture loading functions. */
|
||||||
|
assingGlobalFunction( "GetTextureDefault", ltexturesGetTextureDefault );
|
||||||
assingGlobalFunction( "LoadTexture", ltexturesLoadTexture );
|
assingGlobalFunction( "LoadTexture", ltexturesLoadTexture );
|
||||||
assingGlobalFunction( "LoadTextureFromImage", ltexturesLoadTextureFromImage );
|
assingGlobalFunction( "LoadTextureFromImage", ltexturesLoadTextureFromImage );
|
||||||
assingGlobalFunction( "LoadTextureCubemap", ltexturesLoadTextureCubemap );
|
assingGlobalFunction( "LoadTextureCubemap", ltexturesLoadTextureCubemap );
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ bool stateInit( int argn, const char **argc, const char *exePath ) {
|
|||||||
}
|
}
|
||||||
state->defaultFont = GetFontDefault();
|
state->defaultFont = GetFontDefault();
|
||||||
state->defaultMaterial = LoadMaterialDefault();
|
state->defaultMaterial = LoadMaterialDefault();
|
||||||
|
state->defaultTexture = (Texture){ 1, 1, 1, 1, 7 };
|
||||||
state->RLGLcurrentShaderLocs = malloc( RL_MAX_SHADER_LOCATIONS * sizeof( int ) );
|
state->RLGLcurrentShaderLocs = malloc( RL_MAX_SHADER_LOCATIONS * sizeof( int ) );
|
||||||
int *defaultShaderLocs = rlGetShaderLocsDefault();
|
int *defaultShaderLocs = rlGetShaderLocsDefault();
|
||||||
|
|
||||||
|
|||||||
@@ -162,9 +162,11 @@ bool wordWrap, Color *tints, int tintCount, Color *backTints, int backTintCount
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
> RL.GetFontDefault()
|
> font = RL.GetFontDefault()
|
||||||
|
|
||||||
Get the default Font. Return as lightuserdata
|
Get the default Font. Return as lightuserdata
|
||||||
|
|
||||||
|
- Success return Font
|
||||||
*/
|
*/
|
||||||
int ltextGetFontDefault( lua_State *L ) {
|
int ltextGetFontDefault( lua_State *L ) {
|
||||||
lua_pushlightuserdata( L, &state->defaultFont );
|
lua_pushlightuserdata( L, &state->defaultFont );
|
||||||
|
|||||||
@@ -1035,6 +1035,19 @@ int ltexturesImageDrawTextEx( lua_State *L ) {
|
|||||||
## Textures - Texture loading functions
|
## Textures - Texture loading functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
> texture = RL.GetTextureDefault()
|
||||||
|
|
||||||
|
Get default texture. Return as lightuserdata
|
||||||
|
|
||||||
|
- Success return Texture
|
||||||
|
*/
|
||||||
|
int ltexturesGetTextureDefault( lua_State *L ) {
|
||||||
|
lua_pushlightuserdata( L, &state->defaultTexture );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
> texture = RL.LoadTexture( string fileName )
|
> texture = RL.LoadTexture( string fileName )
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user