Reigui property_list and tree_view use scrissor mode.
This commit is contained in:
2
API.md
2
API.md
@@ -9606,7 +9606,7 @@ Value Box control, updates input text with numbers
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
> result, text = RL.GuiTextBox( Rectangle bounds, string text, int textSize, bool editMode )
|
> result, text = RL.GuiTextBox( Rectangle bounds, string text, int bufferSize, bool editMode )
|
||||||
|
|
||||||
Text Box control, updates input text
|
Text Box control, updates input text
|
||||||
|
|
||||||
|
|||||||
@@ -6526,11 +6526,11 @@ function RL.GuiValueBox( bounds, text, value, minValue, maxValue, editMode ) end
|
|||||||
---- Success return int, string
|
---- Success return int, string
|
||||||
---@param bounds table
|
---@param bounds table
|
||||||
---@param text string
|
---@param text string
|
||||||
---@param textSize integer
|
---@param bufferSize integer
|
||||||
---@param editMode boolean
|
---@param editMode boolean
|
||||||
---@return any result
|
---@return any result
|
||||||
---@return any text
|
---@return any text
|
||||||
function RL.GuiTextBox( bounds, text, textSize, editMode ) end
|
function RL.GuiTextBox( bounds, text, bufferSize, editMode ) end
|
||||||
|
|
||||||
---Slider control, returns selected value
|
---Slider control, returns selected value
|
||||||
---- Success return int, float, Rectangle, Rectangle
|
---- Success return int, float, Rectangle, Rectangle
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ local function addPropertyList()
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
RL.GuiSetStyle( RL.SPINNER, RL.TEXT_ALIGNMENT, RL.TEXT_ALIGN_LEFT )
|
RL.GuiSetStyle( RL.SPINNER, RL.TEXT_ALIGNMENT, RL.TEXT_ALIGN_LEFT )
|
||||||
|
PropertyList.contentPadding.x = PropertyList.bounds.height -- Room for dropdown.
|
||||||
|
|
||||||
PropertyList:addControl( PropertyList.gui:Line(
|
PropertyList:addControl( PropertyList.gui:Line(
|
||||||
Rectangle:new( 0, 0, 0, 0 ),
|
Rectangle:new( 0, 0, 0, 0 ),
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ function PropertyList:new( bounds, text, callbacks, styles, tooltip )
|
|||||||
|
|
||||||
object.padding = 4 -- Content edges.
|
object.padding = 4 -- Content edges.
|
||||||
object.spacing = 4 -- Between controls.
|
object.spacing = 4 -- Between controls.
|
||||||
|
object.contentPadding = Vector2:new( 0, 0 ) -- Extra padding for content rect.
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
object.text = text
|
object.text = text
|
||||||
@@ -18,10 +19,9 @@ function PropertyList:new( bounds, text, callbacks, styles, tooltip )
|
|||||||
|
|
||||||
object.gui = Raygui:new() -- Contains full independent gui system.
|
object.gui = Raygui:new() -- Contains full independent gui system.
|
||||||
object.controls = {}
|
object.controls = {}
|
||||||
|
object.content = Rectangle:new()
|
||||||
|
|
||||||
-- Set in setSize.
|
-- Set in setSize.
|
||||||
object.framebufferSize = nil
|
|
||||||
object.framebuffer = nil
|
|
||||||
object.defaultControlSize = nil
|
object.defaultControlSize = nil
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
@@ -98,10 +98,11 @@ function PropertyList:updateContent()
|
|||||||
for _, control in ipairs( self.controls ) do
|
for _, control in ipairs( self.controls ) do
|
||||||
self:updateControl( control )
|
self:updateControl( control )
|
||||||
end
|
end
|
||||||
self.content.x = 0
|
self.content:set(
|
||||||
self.content.y = 0
|
0, 0,
|
||||||
self.content.height = self.content.height + self.padding + self.view.height - self.defaultControlSize.y - self.spacing
|
self.content.width + self.padding + self.contentPadding.y,
|
||||||
self.content.width = self.content.width + self.padding
|
self.content.height + self.padding + self.contentPadding.x
|
||||||
|
)
|
||||||
self._forceCheckScroll = true
|
self._forceCheckScroll = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -170,22 +171,15 @@ function PropertyList:update()
|
|||||||
|
|
||||||
self.gui:update()
|
self.gui:update()
|
||||||
|
|
||||||
RL.BeginTextureMode( self.framebuffer )
|
|
||||||
RL.ClearBackground( RL.BLANK )
|
|
||||||
RL.rlTranslatef( { self.scroll.x, self.scroll.y, 0 } )
|
|
||||||
self.gui:draw()
|
|
||||||
RL.EndTextureMode()
|
|
||||||
|
|
||||||
return self._gui:drag( self )
|
return self._gui:drag( self )
|
||||||
end
|
end
|
||||||
|
|
||||||
function PropertyList:draw()
|
function PropertyList:draw()
|
||||||
local oldScroll = self.scroll:clone()
|
local result, 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 )
|
|
||||||
self.view:setT( view )
|
self.view:setT( view )
|
||||||
self.scroll:setT( scroll )
|
self.scroll:setT( scroll )
|
||||||
|
|
||||||
if self.scroll ~= oldScroll or self._forceCheckScroll then
|
if 0 < result or self._forceCheckScroll then
|
||||||
if not self._forceCheckScroll then
|
if not self._forceCheckScroll then
|
||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
end
|
end
|
||||||
@@ -198,15 +192,15 @@ function PropertyList:draw()
|
|||||||
self.callbacks.scroll( self )
|
self.callbacks.scroll( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- Lock if this gui not focused.
|
||||||
|
self.gui.locked = not ( self._gui.controls[ self._gui.focused ] == self ) or self._gui.locked
|
||||||
|
|
||||||
RL.DrawTexturePro(
|
RL.BeginScissorMode( self.view )
|
||||||
RL.GetRenderTextureTexture( self.framebuffer ),
|
RL.rlPushMatrix()
|
||||||
{ 0, self.framebufferSize.y - self.view.height, self.view.width, -self.view.height },
|
RL.rlTranslatef( { RL.Round( self.view.x + self.scroll.x ), RL.Round( self.view.y + self.scroll.y ), 0 } )
|
||||||
{ math.floor( self.view.x ), math.floor( self.view.y ), self.view.width, self.view.height },
|
self.gui:draw()
|
||||||
{ 0, 0 },
|
RL.rlPopMatrix()
|
||||||
0.0,
|
RL.EndScissorMode()
|
||||||
RL.WHITE
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function PropertyList:updateMouseOffset()
|
function PropertyList:updateMouseOffset()
|
||||||
@@ -219,8 +213,8 @@ function PropertyList:updateMouseOffset()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function PropertyList:setPosition( pos )
|
function PropertyList:setPosition( pos )
|
||||||
self.bounds.x = pos.x
|
self.bounds.x = RL.Round( pos.x )
|
||||||
self.bounds.y = pos.y
|
self.bounds.y = RL.Round( pos.y )
|
||||||
|
|
||||||
if self.visible then
|
if self.visible then
|
||||||
self:draw() -- Update self.view.
|
self:draw() -- Update self.view.
|
||||||
@@ -244,15 +238,9 @@ function PropertyList:setSize( size )
|
|||||||
self.defaultControlSize = Vector2:new( self.content.width, self.defaultControlHeight )
|
self.defaultControlSize = Vector2:new( self.content.width, self.defaultControlHeight )
|
||||||
|
|
||||||
local _, _, view = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll, self.view )
|
local _, _, view = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll, self.view )
|
||||||
|
|
||||||
self.view = Rectangle:newT( view )
|
self.view = Rectangle:newT( view )
|
||||||
|
|
||||||
self.gui.view = Rectangle:new( 0, 0, self.view.width, self.view.height )
|
self.gui.view = Rectangle:new( 0, 0, self.view.width, self.view.height )
|
||||||
self.framebufferSize = Vector2:new( self.bounds.width, self.bounds.height - self.gui.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT )
|
|
||||||
|
|
||||||
if self.framebuffer ~= nil and not RL.IsGCUnloadEnabled() then
|
|
||||||
RL.UnloadRenderTexture( self.framebuffer )
|
|
||||||
end
|
|
||||||
self.framebuffer = RL.LoadRenderTexture( self.framebufferSize )
|
|
||||||
|
|
||||||
self:updateContent()
|
self:updateContent()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ function TreeView:new( bounds, text, callbacks, styles, tooltip )
|
|||||||
object.controls = {}
|
object.controls = {}
|
||||||
|
|
||||||
-- Set in setSize.
|
-- Set in setSize.
|
||||||
object.framebufferSize = nil
|
-- object.framebufferSize = nil
|
||||||
object.framebuffer = nil
|
-- object.framebuffer = nil
|
||||||
object.defaultControlSize = nil
|
object.defaultControlSize = nil
|
||||||
|
|
||||||
object.visible = true
|
object.visible = true
|
||||||
@@ -120,10 +120,11 @@ function TreeView:updateContent()
|
|||||||
control._childId = i
|
control._childId = i
|
||||||
self:updateControl( control )
|
self:updateControl( control )
|
||||||
end
|
end
|
||||||
self.content.x = 0
|
self.content:set(
|
||||||
self.content.y = 0
|
0, 0,
|
||||||
self.content.height = self.content.height + self.padding
|
self.content.width + self.padding,
|
||||||
self.content.width = self.content.width + self.padding
|
self.content.height + self.padding
|
||||||
|
)
|
||||||
self._forceCheckScroll = true
|
self._forceCheckScroll = true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -269,8 +270,7 @@ function TreeView:itemSelect( item )
|
|||||||
end
|
end
|
||||||
|
|
||||||
function TreeView:update()
|
function TreeView:update()
|
||||||
local mousePos = Vector2:newT( RL.GetMousePosition() )
|
local mousePos = Vector2:tempT( RL.GetMousePosition() )
|
||||||
local guiMousePos = mousePos + self.gui.mouseOffset
|
|
||||||
local mouseInView = self.view:checkCollisionPoint( mousePos )
|
local mouseInView = self.view:checkCollisionPoint( mousePos )
|
||||||
|
|
||||||
if not mouseInView then
|
if not mouseInView then
|
||||||
@@ -281,6 +281,28 @@ function TreeView:update()
|
|||||||
|
|
||||||
self.gui:update()
|
self.gui:update()
|
||||||
|
|
||||||
|
return self._gui:drag( self )
|
||||||
|
end
|
||||||
|
|
||||||
|
function TreeView:draw()
|
||||||
|
local result, 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
|
||||||
|
|
||||||
|
self:updateMouseOffset()
|
||||||
|
self.gui.view:set( -self.scroll.x, -self.scroll.y, self.view.width, self.view.height )
|
||||||
|
end
|
||||||
|
|
||||||
|
local mousePos = Vector2:tempT( RL.GetMousePosition() )
|
||||||
|
local guiMousePos = mousePos + self.gui.mouseOffset
|
||||||
|
local mouseInView = self.view:checkCollisionPoint( mousePos )
|
||||||
|
|
||||||
local mouseInClickedItem = false
|
local mouseInClickedItem = false
|
||||||
|
|
||||||
if RL.IsMouseButtonPressed( RL.MOUSE_BUTTON_LEFT ) then
|
if RL.IsMouseButtonPressed( RL.MOUSE_BUTTON_LEFT ) then
|
||||||
@@ -295,10 +317,13 @@ function TreeView:update()
|
|||||||
mouseInClickedItem = self._clickedItem.bounds:checkCollisionPoint( guiMousePos )
|
mouseInClickedItem = self._clickedItem.bounds:checkCollisionPoint( guiMousePos )
|
||||||
end
|
end
|
||||||
|
|
||||||
RL.BeginTextureMode( self.framebuffer )
|
-- Lock if this gui not focused.
|
||||||
RL.ClearBackground( RL.BLANK )
|
self.gui.locked = not ( self._gui.controls[ self._gui.focused ] == self ) or self._gui.locked
|
||||||
RL.rlTranslatef( { self.scroll.x, self.scroll.y, 0 } )
|
|
||||||
|
RL.BeginScissorMode( self.view )
|
||||||
|
RL.rlPushMatrix()
|
||||||
|
RL.rlTranslatef( { RL.Round( self.view.x + self.scroll.x ), RL.Round( self.view.y + self.scroll.y ), 0 } )
|
||||||
|
|
||||||
self.gui:draw()
|
self.gui:draw()
|
||||||
|
|
||||||
if self.allowMove and RL.IsMouseButtonDown( RL.MOUSE_BUTTON_LEFT ) and self._clickedItem ~= nil
|
if self.allowMove and RL.IsMouseButtonDown( RL.MOUSE_BUTTON_LEFT ) and self._clickedItem ~= nil
|
||||||
@@ -328,35 +353,9 @@ function TreeView:update()
|
|||||||
self._clickedItem = nil
|
self._clickedItem = nil
|
||||||
self._movingItem = self.MOVE_ITEM_NONE
|
self._movingItem = self.MOVE_ITEM_NONE
|
||||||
end
|
end
|
||||||
RL.EndTextureMode()
|
|
||||||
|
|
||||||
return self._gui:drag( self )
|
RL.rlPopMatrix()
|
||||||
end
|
RL.EndScissorMode()
|
||||||
|
|
||||||
function TreeView:draw()
|
|
||||||
local oldScroll = self.scroll:clone()
|
|
||||||
local _, scroll, view = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll, self.view )
|
|
||||||
self.view:setT( view )
|
|
||||||
self.scroll:setT( scroll )
|
|
||||||
|
|
||||||
if self.scroll ~= oldScroll or self._forceCheckScroll then
|
|
||||||
if not self._forceCheckScroll then
|
|
||||||
self._gui:checkScrolling()
|
|
||||||
end
|
|
||||||
self._forceCheckScroll = false
|
|
||||||
|
|
||||||
self:updateMouseOffset()
|
|
||||||
self.gui.view:set( -self.scroll.x, -self.scroll.y, self.view.width, self.view.height )
|
|
||||||
end
|
|
||||||
|
|
||||||
RL.DrawTexturePro(
|
|
||||||
RL.GetRenderTextureTexture( self.framebuffer ),
|
|
||||||
{ 0, self.framebufferSize.y - self.view.height, self.view.width, -self.view.height },
|
|
||||||
{ math.floor( self.view.x ), math.floor( self.view.y ), self.view.width, self.view.height },
|
|
||||||
{ 0, 0 },
|
|
||||||
0.0,
|
|
||||||
RL.WHITE
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function TreeView:updateMouseOffset()
|
function TreeView:updateMouseOffset()
|
||||||
@@ -386,15 +385,9 @@ function TreeView:setSize( size )
|
|||||||
self.defaultControlSize = Vector2:new( self.content.width, self.defaultControlHeight )
|
self.defaultControlSize = Vector2:new( self.content.width, self.defaultControlHeight )
|
||||||
|
|
||||||
local _, _, view = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll, self.view )
|
local _, _, view = RL.GuiScrollPanel( self.bounds, self.text, self.content, self.scroll, self.view )
|
||||||
|
|
||||||
self.view = Rectangle:newT( view )
|
self.view = Rectangle:newT( view )
|
||||||
|
|
||||||
self.gui.view = Rectangle:new( 0, 0, self.view.width, self.view.height )
|
self.gui.view = Rectangle:new( 0, 0, self.view.width, self.view.height )
|
||||||
self.framebufferSize = Vector2:new( self.bounds.width, self.bounds.height - self.gui.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT )
|
|
||||||
|
|
||||||
if self.framebuffer ~= nil and not RL.IsGCUnloadEnabled() then
|
|
||||||
RL.UnloadRenderTexture( self.framebuffer )
|
|
||||||
end
|
|
||||||
self.framebuffer = RL.LoadRenderTexture( self.framebufferSize )
|
|
||||||
|
|
||||||
self:updateContent()
|
self:updateContent()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ function WindowBox:draw()
|
|||||||
|
|
||||||
if result == 1 then
|
if result == 1 then
|
||||||
-- //TODO Could add self._gui:clickedInBounds( closeButtonBounds )
|
-- //TODO Could add self._gui:clickedInBounds( closeButtonBounds )
|
||||||
if self.callbacks.close ~= nil then
|
if self.callbacks.close then
|
||||||
self.callbacks.close( self )
|
self.callbacks.close( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -230,13 +230,13 @@ function GuiTabBar:draw()
|
|||||||
if self._gui:clickedInBounds( self.bounds ) then
|
if self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.active = active
|
self.active = active
|
||||||
|
|
||||||
if self.callbacks.select ~= nil then
|
if self.callbacks.select then
|
||||||
self.callbacks.select( self )
|
self.callbacks.select( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if 0 <= result and self.callbacks.close ~= nil and self._gui:clickedInBounds( self.bounds ) then
|
if 0 <= result and self.callbacks.close and self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.callbacks.close( self, result )
|
self.callbacks.close( self, result )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -284,7 +284,7 @@ function ScrollPanel:draw()
|
|||||||
if 0 < result then
|
if 0 < result then
|
||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
|
|
||||||
if self.callbacks.scroll ~= nil then
|
if self.callbacks.scroll then
|
||||||
self.callbacks.scroll( self )
|
self.callbacks.scroll( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -361,7 +361,7 @@ end
|
|||||||
function Button:draw()
|
function Button:draw()
|
||||||
local result = RL.GuiButton( self.bounds, self.text )
|
local result = RL.GuiButton( 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 and self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.callbacks.pressed( self )
|
self.callbacks.pressed( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -400,7 +400,7 @@ end
|
|||||||
function LabelButton:draw()
|
function LabelButton:draw()
|
||||||
local result = RL.GuiLabelButton( self.bounds, self.text )
|
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 and self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.callbacks.pressed( self )
|
self.callbacks.pressed( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -443,7 +443,7 @@ function Toggle:draw()
|
|||||||
if 0 < result and self._gui:clickedInBounds( self.bounds ) then
|
if 0 < result and self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.active = active
|
self.active = active
|
||||||
|
|
||||||
if self.callbacks.pressed ~= nil then
|
if self.callbacks.pressed then
|
||||||
self.callbacks.pressed( self )
|
self.callbacks.pressed( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -541,7 +541,7 @@ function ToggleGroup:draw()
|
|||||||
if inBounds then
|
if inBounds then
|
||||||
self.active = active
|
self.active = active
|
||||||
|
|
||||||
if self.callbacks.select ~= nil then
|
if self.callbacks.select then
|
||||||
self.callbacks.select( self )
|
self.callbacks.select( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -596,7 +596,7 @@ function CheckBox:draw()
|
|||||||
if self._gui:clickedInBounds( self.focusBounds ) then
|
if self._gui:clickedInBounds( self.focusBounds ) then
|
||||||
self.checked = checked
|
self.checked = checked
|
||||||
|
|
||||||
if self.callbacks.pressed ~= nil then
|
if self.callbacks.pressed then
|
||||||
self.callbacks.pressed( self )
|
self.callbacks.pressed( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -644,7 +644,7 @@ function ComboBox:draw()
|
|||||||
if self._gui:clickedInBounds( self.bounds ) then
|
if self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.active = active
|
self.active = active
|
||||||
|
|
||||||
if self.callbacks.select ~= nil then
|
if self.callbacks.select then
|
||||||
self.callbacks.select( self )
|
self.callbacks.select( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -711,10 +711,14 @@ function DropdownBox:draw()
|
|||||||
|
|
||||||
if result == 1 then
|
if result == 1 then
|
||||||
self.editMode = not self.editMode
|
self.editMode = not self.editMode
|
||||||
|
self:updateEditModeBounds()
|
||||||
|
|
||||||
if not self.editMode and self.callbacks.select ~= nil then
|
if not self.editMode and self.callbacks.select then
|
||||||
self.callbacks.select( self )
|
self.callbacks.select( self )
|
||||||
end
|
end
|
||||||
|
if self.callbacks.pressed then
|
||||||
|
self.callbacks.pressed( self )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -775,7 +779,7 @@ function Spinner:draw()
|
|||||||
if self._gui:clickedInBounds( self.bounds ) then
|
if self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
if self.callbacks.edit ~= nil then
|
if self.callbacks.edit then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.edit( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -842,7 +846,7 @@ function ValueBox:draw()
|
|||||||
self._gui:editMode( self )
|
self._gui:editMode( self )
|
||||||
self.editMode = not self.editMode
|
self.editMode = not self.editMode
|
||||||
end
|
end
|
||||||
if self.value ~= oldValue and self.callbacks.edit ~= nil then
|
if self.value ~= oldValue and self.callbacks.edit then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.edit( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -860,13 +864,13 @@ end
|
|||||||
local TextBox = {}
|
local TextBox = {}
|
||||||
TextBox.__index = TextBox
|
TextBox.__index = TextBox
|
||||||
|
|
||||||
function TextBox:new( bounds, text, textSize, editMode, callbacks, styles, tooltip )
|
function TextBox:new( bounds, text, bufferSize, editMode, callbacks, styles, tooltip )
|
||||||
local object = setmetatable( {}, self )
|
local object = setmetatable( {}, self )
|
||||||
object._gui = nil
|
object._gui = nil
|
||||||
|
|
||||||
object.bounds = bounds:clone()
|
object.bounds = bounds:clone()
|
||||||
object.text = text
|
object.text = text
|
||||||
object.textSize = textSize
|
object.bufferSize = bufferSize
|
||||||
object.editMode = editMode
|
object.editMode = editMode
|
||||||
object.callbacks = callbacks -- edit.
|
object.callbacks = callbacks -- edit.
|
||||||
-- Option for preventing text to be drawn outside bounds.
|
-- Option for preventing text to be drawn outside bounds.
|
||||||
@@ -890,7 +894,7 @@ function TextBox:draw()
|
|||||||
RL.BeginScissorMode( self.bounds )
|
RL.BeginScissorMode( self.bounds )
|
||||||
end
|
end
|
||||||
|
|
||||||
result, self.text = RL.GuiTextBox( self.bounds, self.text, self.textSize, self.editMode )
|
result, self.text = RL.GuiTextBox( self.bounds, self.text, self.bufferSize, self.editMode )
|
||||||
|
|
||||||
if self.scissorMode then
|
if self.scissorMode then
|
||||||
RL.EndScissorMode()
|
RL.EndScissorMode()
|
||||||
@@ -899,7 +903,7 @@ function TextBox:draw()
|
|||||||
self._gui:editMode( self )
|
self._gui:editMode( self )
|
||||||
self.editMode = not self.editMode
|
self.editMode = not self.editMode
|
||||||
|
|
||||||
if not self.editMode and self.callbacks.edit ~= nil then
|
if not self.editMode and self.callbacks.edit then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.edit( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -957,7 +961,7 @@ function Slider:draw()
|
|||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
if self.callbacks.edit ~= nil then
|
if self.callbacks.edit then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.edit( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1018,7 +1022,7 @@ function SliderBar:draw()
|
|||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
if self.callbacks.edit ~= nil then
|
if self.callbacks.edit then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.edit( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1078,7 +1082,7 @@ function ProgressBar:draw()
|
|||||||
if self._gui:clickedInBounds( self.bounds ) then
|
if self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
if self.callbacks.edit ~= nil then
|
if self.callbacks.edit then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.edit( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1193,7 +1197,7 @@ function Grid:draw()
|
|||||||
local result, mouseCell = RL.GuiGrid( self.bounds, self.text, self.spacing, self.subdivs, self.mouseCell )
|
local result, mouseCell = RL.GuiGrid( self.bounds, self.text, self.spacing, self.subdivs, self.mouseCell )
|
||||||
self.mouseCell:setT( mouseCell )
|
self.mouseCell:setT( mouseCell )
|
||||||
|
|
||||||
if 0 < result and self.callbacks.cellChange ~= nil then
|
if 0 < result and self.callbacks.cellChange then
|
||||||
self.callbacks.cellChange( self )
|
self.callbacks.cellChange( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1247,7 +1251,7 @@ function ListView:draw()
|
|||||||
if self.scrollIndex ~= oldScrollIndex then
|
if self.scrollIndex ~= oldScrollIndex then
|
||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
end
|
end
|
||||||
if 0 < result and self.callbacks.select ~= nil then
|
if 0 < result and self.callbacks.select then
|
||||||
self.callbacks.select( self )
|
self.callbacks.select( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1298,7 +1302,7 @@ function ListViewEx:draw()
|
|||||||
if self.scrollIndex ~= oldScrollIndex then
|
if self.scrollIndex ~= oldScrollIndex then
|
||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
end
|
end
|
||||||
if 0 < result and self.callbacks.select ~= nil then
|
if 0 < result and self.callbacks.select then
|
||||||
self.callbacks.select( self )
|
self.callbacks.select( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1345,7 +1349,7 @@ end
|
|||||||
function MessageBox:draw()
|
function MessageBox:draw()
|
||||||
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 0 <= self.buttonIndex and self.callbacks.pressed ~= nil and self._gui:clickedInBounds( self.bounds ) then
|
if 0 <= self.buttonIndex and self.callbacks.pressed and self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.callbacks.pressed( self )
|
self.callbacks.pressed( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1395,7 +1399,7 @@ end
|
|||||||
function TextInputBox:draw()
|
function TextInputBox:draw()
|
||||||
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 0 <= self.buttonIndex and self.callbacks.pressed ~= nil and self._gui:clickedInBounds( self.bounds ) then
|
if 0 <= self.buttonIndex and self.callbacks.pressed and self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.callbacks.pressed( self )
|
self.callbacks.pressed( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1455,7 +1459,7 @@ function ColorPicker:draw()
|
|||||||
end
|
end
|
||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
|
|
||||||
if self.callbacks.edit ~= nil then
|
if self.callbacks.edit then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.edit( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1501,7 +1505,7 @@ function ColorPanel:draw()
|
|||||||
if self._gui:clickedInBounds( self.bounds ) then
|
if self._gui:clickedInBounds( self.bounds ) then
|
||||||
self.color:setT( color )
|
self.color:setT( color )
|
||||||
|
|
||||||
if self.callbacks.edit ~= nil then
|
if self.callbacks.edit then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.edit( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1548,7 +1552,7 @@ function ColorBarAlpha:draw()
|
|||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
self.alpha = alpha
|
self.alpha = alpha
|
||||||
|
|
||||||
if self.callbacks.edit ~= nil then
|
if self.callbacks.edit then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.edit( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1595,7 +1599,7 @@ function ColorBarHue:draw()
|
|||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
if self.callbacks.edit ~= nil then
|
if self.callbacks.edit then
|
||||||
self.callbacks.edit( self )
|
self.callbacks.edit( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1644,7 +1648,7 @@ function GuiScrollBar:draw()
|
|||||||
self._gui:checkScrolling()
|
self._gui:checkScrolling()
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
if self.callbacks.scroll ~= nil then
|
if self.callbacks.scroll then
|
||||||
self.callbacks.scroll( self )
|
self.callbacks.scroll( self )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1767,7 +1771,7 @@ function Raygui:drag( control )
|
|||||||
and mouseOver and mousePos.y - control.bounds.y <= self.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT then
|
and mouseOver and mousePos.y - control.bounds.y <= self.RAYGUI_WINDOWBOX_STATUSBAR_HEIGHT then
|
||||||
self.grabPos = mousePos - Vector2:temp( control.bounds.x, control.bounds.y )
|
self.grabPos = mousePos - Vector2:temp( control.bounds.x, control.bounds.y )
|
||||||
|
|
||||||
if control.callbacks.grab ~= nil then
|
if control.callbacks.grab then
|
||||||
control.callbacks.grab( control )
|
control.callbacks.grab( control )
|
||||||
end
|
end
|
||||||
self.dragging = control
|
self.dragging = control
|
||||||
@@ -1779,7 +1783,7 @@ function Raygui:drag( control )
|
|||||||
end
|
end
|
||||||
control:setPosition( mousePos - self.grabPos )
|
control:setPosition( mousePos - self.grabPos )
|
||||||
|
|
||||||
if control.callbacks.drag ~= nil then
|
if control.callbacks.drag then
|
||||||
control.callbacks.drag( control )
|
control.callbacks.drag( control )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1917,6 +1921,12 @@ function Raygui:remove( control )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Raygui:clear()
|
||||||
|
for _, control in ipairs( self.controls ) do
|
||||||
|
table.remove( control )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Raygui:editMode( control )
|
function Raygui:editMode( control )
|
||||||
if self.textEditControl ~= nil and not control.editMode then
|
if self.textEditControl ~= nil and not control.editMode then
|
||||||
self.textEditControl.editMode = false
|
self.textEditControl.editMode = false
|
||||||
@@ -2163,14 +2173,14 @@ end
|
|||||||
|
|
||||||
---@param bounds Rectangle
|
---@param bounds Rectangle
|
||||||
---@param text string
|
---@param text string
|
||||||
---@param textSize integer
|
---@param bufferSize integer
|
||||||
---@param editMode boolean
|
---@param editMode boolean
|
||||||
---@param callbacks table edit.
|
---@param callbacks table edit.
|
||||||
---@param styles table|nil
|
---@param styles table|nil
|
||||||
---@param tooltip string|nil
|
---@param tooltip string|nil
|
||||||
---@return table TextBox
|
---@return table TextBox
|
||||||
function Raygui:TextBox( bounds, text, textSize, editMode, callbacks, styles, tooltip )
|
function Raygui:TextBox( bounds, text, bufferSize, editMode, callbacks, styles, tooltip )
|
||||||
return self:addControl( TextBox:new( bounds, text, textSize, editMode, callbacks, styles, tooltip ) )
|
return self:addControl( TextBox:new( bounds, text, bufferSize, editMode, callbacks, styles, tooltip ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param bounds Rectangle
|
---@param bounds Rectangle
|
||||||
|
|||||||
@@ -705,7 +705,7 @@ int lguiGuiValueBox( lua_State* L ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
> result, text = RL.GuiTextBox( Rectangle bounds, string text, int textSize, bool editMode )
|
> result, text = RL.GuiTextBox( Rectangle bounds, string text, int bufferSize, bool editMode )
|
||||||
|
|
||||||
Text Box control, updates input text
|
Text Box control, updates input text
|
||||||
|
|
||||||
@@ -713,12 +713,12 @@ Text Box control, updates input text
|
|||||||
*/
|
*/
|
||||||
int lguiGuiTextBox( lua_State* L ) {
|
int lguiGuiTextBox( lua_State* L ) {
|
||||||
Rectangle bounds = uluaGetRectangle( L, 1 );
|
Rectangle bounds = uluaGetRectangle( L, 1 );
|
||||||
int textSize = luaL_checkinteger( L, 3 );
|
int bufferSize = luaL_checkinteger( L, 3 );
|
||||||
char text[ textSize + 1 ];
|
char text[ bufferSize + 1 ];
|
||||||
strcpy( text, luaL_checkstring( L, 2 ) );
|
strcpy( text, luaL_checkstring( L, 2 ) );
|
||||||
bool editMode = uluaGetBoolean( L, 4 );
|
bool editMode = uluaGetBoolean( L, 4 );
|
||||||
|
|
||||||
lua_pushinteger( L, GuiTextBox( bounds, text, textSize, editMode ) );
|
lua_pushinteger( L, GuiTextBox( bounds, text, bufferSize, editMode ) );
|
||||||
lua_pushstring( L, text );
|
lua_pushstring( L, text );
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user