summaryrefslogtreecommitdiff
path: root/examples/raygui_extensions/sprite_button.lua
diff options
context:
space:
mode:
authorjussi2024-10-02 14:06:50 +0300
committerjussi2024-10-02 14:06:50 +0300
commit02c7dd9ca80e522b987ebce34143f2eef1b95b64 (patch)
tree56ebba19705bcc47a1b0f44f2b0a241cf7da3791 /examples/raygui_extensions/sprite_button.lua
parent30c7a5eda27ef0e424bf7948e3cd37a1cf5a52ef (diff)
downloadreilua-enhanced-02c7dd9ca80e522b987ebce34143f2eef1b95b64.tar.gz
reilua-enhanced-02c7dd9ca80e522b987ebce34143f2eef1b95b64.tar.bz2
reilua-enhanced-02c7dd9ca80e522b987ebce34143f2eef1b95b64.zip
Raygui update.
Diffstat (limited to 'examples/raygui_extensions/sprite_button.lua')
-rw-r--r--examples/raygui_extensions/sprite_button.lua27
1 files changed, 17 insertions, 10 deletions
diff --git a/examples/raygui_extensions/sprite_button.lua b/examples/raygui_extensions/sprite_button.lua
index 8a3027b..201e617 100644
--- a/examples/raygui_extensions/sprite_button.lua
+++ b/examples/raygui_extensions/sprite_button.lua
@@ -2,15 +2,15 @@ local SpriteButton = {}
SpriteButton.__index = SpriteButton
function SpriteButton:new( bounds, text, texture, nPatchNormal, nPatchPressed, callbacks, styles, tooltip )
- local object = setmetatable( {}, self )
+ local object = setmetatable( {}, self )
object._gui = nil
- object.bounds = bounds:clone()
- object.text = text
+ object.bounds = bounds:clone()
+ object.text = text
object.buttonTexture = texture
object.nPatchNormal = nPatchNormal
object.nPatchPressed = nPatchPressed
- object.callbacks = callbacks -- pressed.
+ object.callbacks = callbacks -- pressed.
object.styles = styles
object.tooltip = tooltip
@@ -21,21 +21,28 @@ function SpriteButton:new( bounds, text, texture, nPatchNormal, nPatchPressed, c
end
function SpriteButton:update()
- return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
+ return RL.CheckCollisionPointRec( RL.GetMousePosition(), self.bounds )
end
function SpriteButton:draw()
- if RL.IsMouseButtonDown( RL.MOUSE_BUTTON_LEFT ) and self:update() and not RL.GuiIsLocked() and not self._gui.scrolling then
- RL.DrawTextureNPatchRepeat( self.buttonTexture, self.nPatchPressed, self.bounds, { 0, 0 }, 0.0, RL.WHITE )
+ if RL.IsMouseButtonDown( RL.MOUSE_BUTTON_LEFT ) and self:update() and not RL.GuiIsLocked()
+ and not RL.GuiGetSliderDragging() then
+ RL.DrawTextureNPatchRepeat(
+ self.buttonTexture, self.nPatchPressed, self.bounds,
+ { 0, 0 }, 0.0, RL.GetColor( RL.GuiGetStyle( RL.BUTTON, RL.BASE_COLOR_PRESSED ) )
+ )
else
- RL.DrawTextureNPatchRepeat( self.buttonTexture, self.nPatchNormal, self.bounds, { 0, 0 }, 0.0, RL.WHITE )
+ RL.DrawTextureNPatchRepeat(
+ self.buttonTexture, self.nPatchNormal, self.bounds,
+ { 0, 0 }, 0.0, RL.GetColor( RL.GuiGetStyle( RL.BUTTON, RL.BASE_COLOR_NORMAL ) )
+ )
end
local result = RL.GuiLabelButton( self.bounds, self.text )
- if result == 1 and self.callbacks.pressed ~= nil and self._gui:clickedInBounds( self.bounds ) then
+ if result == 1 and self.callbacks.pressed ~= nil and self._gui:clickedInBounds( self.bounds ) then
self.callbacks.pressed( self )
- end
+ end
end
function SpriteButton:setPosition( pos )