summaryrefslogtreecommitdiff
path: root/examples/raygui_extensions
diff options
context:
space:
mode:
authorjussi2024-02-21 23:25:17 +0200
committerjussi2024-02-21 23:25:17 +0200
commit178196b0ffb8e2358ce9b0be5e1570a10136eb45 (patch)
tree45d657547c10c01dc230dbf5dc9f30281cad621a /examples/raygui_extensions
parent836c9d1d0005c32714c89b3adecbb232472b494a (diff)
downloadreilua-enhanced-178196b0ffb8e2358ce9b0be5e1570a10136eb45.tar.gz
reilua-enhanced-178196b0ffb8e2358ce9b0be5e1570a10136eb45.tar.bz2
reilua-enhanced-178196b0ffb8e2358ce9b0be5e1570a10136eb45.zip
Raygui lib tooltip.
Diffstat (limited to 'examples/raygui_extensions')
-rw-r--r--examples/raygui_extensions/main.lua63
-rw-r--r--examples/raygui_extensions/property_list.lua7
-rw-r--r--examples/raygui_extensions/sprite_button.lua8
3 files changed, 61 insertions, 17 deletions
diff --git a/examples/raygui_extensions/main.lua b/examples/raygui_extensions/main.lua
index d7c43cb..e3f559d 100644
--- a/examples/raygui_extensions/main.lua
+++ b/examples/raygui_extensions/main.lua
@@ -42,7 +42,8 @@ local function addButton( bounds, text, callback )
{ RL.LABEL, RL.TEXT_COLOR_PRESSED, RL.ColorToInt( { 84/2, 59/2, 22/2 } ) },
{ RL.LABEL, RL.TEXT_COLOR_FOCUSED, RL.ColorToInt( RL.GREEN ) },
},
- }
+ },
+ text
)
end
@@ -103,14 +104,26 @@ local function addPropertyList()
cat.dest.x,
32,
false,
- function( self ) self.value = getTextValue( self.text ) self.text = tostring( self.value ) cat.dest.x = self.value end
+ function( self )
+ self.value = getTextValue( self.text )
+ self.text = tostring( self.value )
+ cat.dest.x = self.value
+ end,
+ nil,
+ "Position X"
), transformGroup, true )
PropertyList:addControl( PropertyList.gui:TextBox(
Rect:new( 74, 0, 64, 22 ),
cat.dest.y,
32,
false,
- function( self ) self.value = getTextValue( self.text ) self.text = tostring( self.value ) cat.dest.y = self.value end
+ function( self )
+ self.value = getTextValue( self.text )
+ self.text = tostring( self.value )
+ cat.dest.y = self.value
+ end,
+ nil,
+ "Position Y"
), transformGroup )
-- Origin.
PropertyList:addControl( PropertyList.gui:Label(
@@ -122,18 +135,29 @@ local function addPropertyList()
cat.dest.x,
32,
false,
- function( self ) self.value = getTextValue( self.text ) self.text = tostring( self.value ) cat.origin.x = self.value end
+ function( self )
+ self.value = getTextValue( self.text )
+ self.text = tostring( self.value )
+ cat.origin.x = self.value
+ end,
+ nil,
+ "Origin X"
), transformGroup, true )
PropertyList:addControl( PropertyList.gui:TextBox(
Rect:new( 74, 0, 64, 22 ),
cat.dest.y,
32,
false,
- function( self ) self.value = getTextValue( self.text ) self.text = tostring( self.value ) cat.origin.y = self.value end
+ function( self )
+ self.value = getTextValue( self.text )
+ self.text = tostring( self.value )
+ cat.origin.y = self.value
+ end,
+ nil,
+ "Origin Y"
), transformGroup )
-- Rotation.
PropertyList:addControl( PropertyList.gui:Slider(
- -- Rect:new( 112, 0, PropertyList.defaultControlSize.x - 150, 22 ),
Rect:new( 60, 0, PropertyList.defaultControlSize.x - 150, 22 ),
"Rotation",
"0",
@@ -144,14 +168,18 @@ local function addPropertyList()
self.value = Util.round( self.value )
cat.rotation = self.value
self.textRight = self.value
- end
+ end,
+ nil,
+ "Rotation angle"
), transformGroup )
-- Flipped.
PropertyList:addControl( PropertyList.gui:CheckBox(
Rect:new( 0, 0, 20, 20 ),
"Flipped",
cat.flipped,
- function( self ) cat.flipped = self.checked end
+ function( self ) cat.flipped = self.checked end,
+ nil,
+ "Flips the image"
), transformGroup )
-- Visibility.
@@ -196,7 +224,6 @@ local function addPropertyList()
for i = 1, 5 do
PropertyList:addControl( PropertyList.gui:CheckBox(
- -- Rect:new( 0, 0, 20, 20 ),
Rect:new( 128, 0, 20, 20 ),
i.."_Visible",
false,
@@ -246,9 +273,23 @@ function RL.draw()
if cat.visible then
if cat.flipped then
- RL.DrawTexturePro( cat.texture, { cat.source.x, cat.source.y, -cat.source.width, cat.source.height }, cat.dest, cat.origin, cat.rotation, cat.tint )
+ RL.DrawTexturePro(
+ cat.texture,
+ { cat.source.x, cat.source.y, -cat.source.width, cat.source.height },
+ cat.dest,
+ cat.origin,
+ cat.rotation,
+ cat.tint
+ )
else
- RL.DrawTexturePro( cat.texture, cat.source, cat.dest, cat.origin, cat.rotation, cat.tint )
+ RL.DrawTexturePro(
+ cat.texture,
+ cat.source,
+ cat.dest,
+ cat.origin,
+ cat.rotation,
+ cat.tint
+ )
end
end
Gui:draw()
diff --git a/examples/raygui_extensions/property_list.lua b/examples/raygui_extensions/property_list.lua
index d8d2622..c7b0d30 100644
--- a/examples/raygui_extensions/property_list.lua
+++ b/examples/raygui_extensions/property_list.lua
@@ -3,7 +3,7 @@ PropertyList.__index = PropertyList
local RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT = 24
-function PropertyList:new( bounds, text, callback, grabCallback, dragCallback, styles )
+function PropertyList:new( bounds, text, callback, grabCallback, dragCallback, styles, tooltip )
local object = setmetatable( {}, self )
object._parent = nil
@@ -26,6 +26,7 @@ function PropertyList:new( bounds, text, callback, grabCallback, dragCallback, s
object.grabCallback = grabCallback
object.dragCallback = dragCallback
object.styles = styles
+ object.tooltip = tooltip
object.gui = Raygui:new() -- Contains full independent gui system.
object.controls = {}
@@ -218,8 +219,8 @@ function PropertyList:setPosition( pos )
end
function PropertyList:register( gui )
- function gui:PropertyList( bounds, text, callback, grabCallback, dragCallback, styles )
- return self:addControl( PropertyList:new( bounds, text, callback, grabCallback, dragCallback, styles ) )
+ function gui:PropertyList( bounds, text, callback, grabCallback, dragCallback, styles, tooltip )
+ return self:addControl( PropertyList:new( bounds, text, callback, grabCallback, dragCallback, styles, tooltip ) )
end
end
diff --git a/examples/raygui_extensions/sprite_button.lua b/examples/raygui_extensions/sprite_button.lua
index 401c1a9..11bdf51 100644
--- a/examples/raygui_extensions/sprite_button.lua
+++ b/examples/raygui_extensions/sprite_button.lua
@@ -1,7 +1,7 @@
local SpriteButton = {}
SpriteButton.__index = SpriteButton
-function SpriteButton:new( bounds, text, texture, nPatchNormal, nPatchPressed, callback, styles )
+function SpriteButton:new( bounds, text, texture, nPatchNormal, nPatchPressed, callback, styles, tooltip )
local object = setmetatable( {}, self )
object._parent = nil
@@ -12,6 +12,7 @@ function SpriteButton:new( bounds, text, texture, nPatchNormal, nPatchPressed, c
object.nPatchPressed = nPatchPressed
object.callback = callback
object.styles = styles
+ object.tooltip = tooltip
object.visible = true
object.disabled = false
@@ -20,6 +21,7 @@ function SpriteButton:new( bounds, text, texture, nPatchNormal, nPatchPressed, c
end
function SpriteButton:update()
+ -- print( self.tooltip )
return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end
@@ -43,8 +45,8 @@ function SpriteButton:setPosition( pos )
end
function SpriteButton:register( gui )
- function gui:SpriteButton( bounds, text, texture, nPatchNormal, nPatchPressed, callback, styles )
- return self:addControl( SpriteButton:new( bounds, text, texture, nPatchNormal, nPatchPressed, callback, styles ) )
+ function gui:SpriteButton( bounds, text, texture, nPatchNormal, nPatchPressed, callback, styles, tooltip )
+ return self:addControl( SpriteButton:new( bounds, text, texture, nPatchNormal, nPatchPressed, callback, styles, tooltip ) )
end
end