Raygui lib tooltip.
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user