diff options
| author | jussi | 2024-10-02 14:06:50 +0300 |
|---|---|---|
| committer | jussi | 2024-10-02 14:06:50 +0300 |
| commit | 02c7dd9ca80e522b987ebce34143f2eef1b95b64 (patch) | |
| tree | 56ebba19705bcc47a1b0f44f2b0a241cf7da3791 /examples/raygui_extensions/property_list.lua | |
| parent | 30c7a5eda27ef0e424bf7948e3cd37a1cf5a52ef (diff) | |
| download | reilua-enhanced-02c7dd9ca80e522b987ebce34143f2eef1b95b64.tar.gz reilua-enhanced-02c7dd9ca80e522b987ebce34143f2eef1b95b64.tar.bz2 reilua-enhanced-02c7dd9ca80e522b987ebce34143f2eef1b95b64.zip | |
Raygui update.
Diffstat (limited to 'examples/raygui_extensions/property_list.lua')
| -rw-r--r-- | examples/raygui_extensions/property_list.lua | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/examples/raygui_extensions/property_list.lua b/examples/raygui_extensions/property_list.lua index c65e598..d4c5126 100644 --- a/examples/raygui_extensions/property_list.lua +++ b/examples/raygui_extensions/property_list.lua @@ -2,18 +2,18 @@ local PropertyList = {} PropertyList.__index = PropertyList function PropertyList:new( bounds, text, callbacks, styles, tooltip ) - local object = setmetatable( {}, self ) + local object = setmetatable( {}, self ) object._gui = nil object.padding = 4 -- Content edges. object.spacing = 4 -- Between controls. object.contentPadding = Vector2:new( 0, 0 ) -- Extra padding for content rect. - object.bounds = bounds:clone() - object.text = text - object.scroll = Vector2:new( 0, 0 ) + object.bounds = bounds:clone() + object.text = text + object.scroll = Vector2:new( 0, 0 ) object.view = Rectangle:new( 0, 0, 0, 0 ) - object.callbacks = callbacks -- scroll, grab, drag. + object.callbacks = callbacks -- scroll, grab, drag. object.styles = styles object.tooltip = tooltip @@ -31,7 +31,6 @@ function PropertyList:new( bounds, text, callbacks, styles, tooltip ) object:setSize( Vector2:new( object.bounds.width, object.bounds.height ) ) - object._forceCheckScroll = false object._posY = 0 -- In control list update. object:updateMouseOffset() @@ -103,7 +102,7 @@ function PropertyList:updateContent() self.content.width + self.padding + self.contentPadding.y, self.content.height + self.padding + self.contentPadding.x ) - self._forceCheckScroll = true + self:updateMouseOffset() end -- Leave control bounds size to 0 to use default. Optional group for parameter 2. @@ -162,29 +161,25 @@ function PropertyList:addGroup( name, active, group ) return control end -function PropertyList:update() +function PropertyList:update( delta ) if not self.view:checkCollisionPoint( RL.GetMousePosition() ) then self.gui.locked = true else self.gui.locked = false end - self.gui:update() + self.gui:update( delta ) - return self._gui:drag( self ) + return self._gui:drag( self ) end function PropertyList:draw() - local result, scroll, view = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll, self.view ) + local oldScroll = Vector2:tempV( self.scroll ) + local _, scroll, view = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll, self.view ) self.view:setT( view ) self.scroll:setT( scroll ) - if 0 < result or self._forceCheckScroll then - if not self._forceCheckScroll then - self._gui:checkScrolling() - end - self._forceCheckScroll = false - + if self.scroll ~= oldScroll then self:updateMouseOffset() self.gui.view:set( -self.scroll.x, -self.scroll.y, self.view.width, self.view.height ) @@ -238,8 +233,8 @@ function PropertyList:setSize( size ) self.defaultControlSize = Vector2:new( self.content.width, self.defaultControlHeight ) local _, _, view = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll, self.view ) - self.view = Rectangle:newT( view ) + self.gui.view = Rectangle:new( 0, 0, self.view.width, self.view.height ) self:updateContent() |
