Changed naming of gui functions set2Top and set2Back to setToTop and setToBack.

This commit is contained in:
jussi
2024-06-26 22:28:13 +03:00
parent c96306bcc3
commit e45564ea3f
15 changed files with 94 additions and 77 deletions

View File

@@ -19,7 +19,7 @@ function Calculator:new( pos )
bounds = Rect:new( 0, 0, object.windowRect.width, object.HANDLE_HIGHT ),
padding = 10,
onClicked = function()
object:set2Top()
object:setToTop()
object.dragPos = Vec2:newT( RL.GetMousePosition() ) - Vec2:new( object.handle.bounds.x, object.handle.bounds.y )
Gui.heldCallback = function() object:drag() end
end,
@@ -186,16 +186,16 @@ function Calculator:setVisible( visible )
end
end
function Calculator:set2Top()
self.panel:set2Top()
function Calculator:setToTop()
self.panel:setToTop()
for _, button in ipairs( self.buttons ) do
button:set2Top()
button:setToTop()
end
self.handle:set2Top()
self.closeButton:set2Top()
self.display:set2Top()
self.handle:setToTop()
self.closeButton:setToTop()
self.display:setToTop()
end
function Calculator:addValue( value )

View File

@@ -19,7 +19,7 @@ function FileExplorer:new( pos )
bounds = Rect:new( 0, 0, object.windowRect.width, object.HANDLE_HIGHT ),
padding = 10,
onClicked = function()
object:set2Top()
object:setToTop()
object.dragPos = Vec2:newT( RL.GetMousePosition() ) - Vec2:new( object.handle.bounds.x, object.handle.bounds.y )
Gui.heldCallback = function() object:drag() end
end,
@@ -305,15 +305,15 @@ function FileExplorer:setVisible( visible )
self.files:update()
end
function FileExplorer:set2Top()
self.panel:set2Top()
self.handle:set2Top()
self.closeButton:set2Top()
self.pathBox:set2Top()
self.backButton:set2Top()
self.files:set2Top()
self.fileName:set2Top()
self.openButton:set2Top()
function FileExplorer:setToTop()
self.panel:setToTop()
self.handle:setToTop()
self.closeButton:setToTop()
self.pathBox:setToTop()
self.backButton:setToTop()
self.files:setToTop()
self.fileName:setToTop()
self.openButton:setToTop()
end
return FileExplorer

View File

@@ -21,6 +21,8 @@ local guiTabBarActive = 0
local colorPickerHSV = { 0, 0, 0 }
local colorPanelHSV = { 0, 0, 0 }
local value = 0
function RL.init()
local monitor = 0
local mPos = RL.GetMonitorPosition( monitor )
@@ -121,4 +123,6 @@ function RL.draw()
_, colorPickerHSV = RL.GuiColorPickerHSV( { 1024, 20, 150, 150 }, "GuiColorPuckerHSV", colorPickerHSV )
_, colorPanelHSV = RL.GuiColorPanelHSV( { 1230, 20, 150, 150 }, "GuiColorPuckerHSV", colorPanelHSV )
value = RL.GuiScrollBar( { 0, 0, 10, 200 }, value, 0, 100 )
end

View File

@@ -18,7 +18,7 @@ function Calculator:new( pos )
"Calculator",
{ -- Callbacks.
close = function() object:setVisible( false ) end,
grab = function() object:set2Top() end,
grab = function() object:setToTop() end,
drag = function( this ) object:setPosition( Vec2:new( this.bounds.x, this.bounds.y ) ) end
}
)
@@ -137,12 +137,12 @@ function Calculator:setPosition( pos )
end
end
function Calculator:set2Top()
Gui:set2Top( self.window )
Gui:set2Top( self.display )
function Calculator:setToTop()
Gui:setToTop( self.window )
Gui:setToTop( self.display )
for _, button in ipairs( self.buttons ) do
Gui:set2Top( button )
Gui:setToTop( button )
end
end

View File

@@ -39,7 +39,7 @@ function FileBrowser:new( pos )
"File Browser",
{ -- callbacks.
close = function() object:setVisible( false ) end,
grab = function() object:set2Top() end,
grab = function() object:setToTop() end,
drag = function( this ) object:setPosition( Vec2:new( this.bounds.x, this.bounds.y ) ) end
}
)
@@ -363,11 +363,11 @@ function FileBrowser:setPosition( pos )
end
end
function FileBrowser:set2Top()
Gui:set2Top( self.window )
function FileBrowser:setToTop()
Gui:setToTop( self.window )
for _, control in ipairs( self.controls ) do
Gui:set2Top( control )
Gui:setToTop( control )
end
end

View File

@@ -75,7 +75,7 @@ local function addPropertyList()
Rect:new( 20, 20, 256, 328 ),
"Property List",
{ -- Callbacks.
grab = function( self ) Gui:set2Top( self ) end,
grab = function( self ) Gui:setToTop( self ) end,
},
{ -- Styles.
properties = {
@@ -272,7 +272,7 @@ local function addTreeView()
"Tree View",
{ -- Callbacks.
select = function( controls ) selected( controls ) end,
grab = function( self ) Gui:set2Top( self ) end,
grab = function( self ) Gui:setToTop( self ) end,
},
{ -- Styles.
properties = {

View File

@@ -87,7 +87,7 @@ function PropertyList:updateControl( control )
control.text = setGroupText( control.text:sub( 6 ), control.active ) -- Sub skips icon.
end
self.gui:set2Back( control )
self.gui:setToBack( control )
end
function PropertyList:updateContent()

View File

@@ -208,7 +208,7 @@ function RL.init()
"WindowBox",
{ -- Callbacks.
close = function( self ) self.visible = false end,
grab = function( self ) Gui:set2Top( self ) end,
grab = function( self ) Gui:setToTop( self ) end,
},
{ -- Styles.
properties = {
@@ -230,7 +230,7 @@ function RL.init()
Rect:new( 400, 64, 256, 128 ),
"Panel",
{ -- Callbacks.
grab = function( self ) Gui:set2Top( self ) end
grab = function( self ) Gui:setToTop( self ) end
},
{ -- Styles.
properties = {
@@ -255,7 +255,7 @@ function RL.init()
Vec2:new( 0, 0 ),
{ -- Callbacks.
scroll = function( self ) print( self.scroll ) end,
grab = function( self ) Gui:set2Top( self ) end
grab = function( self ) Gui:setToTop( self ) end
}
)
local listview = Gui:ListView(
@@ -300,7 +300,7 @@ function RL.init()
end
end
end,
grab = function( self ) Gui:set2Top( self ) end
grab = function( self ) Gui:setToTop( self ) end
}
)
local textinputbox = Gui:TextInputBox(
@@ -317,7 +317,7 @@ function RL.init()
print( "You pressed "..self:getItem( self.buttonIndex ) )
end
end,
grab = function( self ) Gui:set2Top( self ) end
grab = function( self ) Gui:setToTop( self ) end
}
)
local colorpicker = Gui:ColorPicker(

View File

@@ -95,11 +95,11 @@ function Gui.delete( cell )
end
end
function Gui.set2Top( cell )
function Gui.setToTop( cell )
Util.tableMove( Gui._cells, Gui.getId( cell ), 1, #Gui._cells )
end
function Gui.set2Back( cell )
function Gui.setToBack( cell )
Util.tableMove( Gui._cells, Gui.getId( cell ), 1, 1 )
end
@@ -518,12 +518,12 @@ function Element:delete()
Gui.delete( self )
end
function Element:set2Top()
Gui.set2Top( self )
function Element:setToTop()
Gui.setToTop( self )
end
function Element:set2Back()
Gui.set2Back( self )
function Element:setToBack()
Gui.setToBack( self )
end
-- Container.
@@ -820,34 +820,34 @@ function Container:clear()
self.cells = {}
end
function Container:set2Top()
Gui.set2Top( self )
function Container:setToTop()
Gui.setToTop( self )
for _, cell in ipairs( self.cells ) do
cell:set2Top()
cell:setToTop()
end
if self._VScrollbar ~= nil then
Gui.set2Top( self._VScrollbar )
Gui.setToTop( self._VScrollbar )
end
if self._HScrollbar ~= nil then
Gui.set2Top( self._HScrollbar )
Gui.setToTop( self._HScrollbar )
end
end
function Container:set2Back()
function Container:setToBack()
if self._VScrollbar ~= nil then
Gui.set2Back( self._VScrollbar )
Gui.setToBack( self._VScrollbar )
end
if self._HScrollbar ~= nil then
Gui.set2Back( self._HScrollbar )
Gui.setToBack( self._HScrollbar )
end
for _, cell in ipairs( self.cells ) do
cell:set2Back()
cell:setToBack()
end
Gui.set2Back( self )
Gui.setToBack( self )
end
function Container:draw()

View File

@@ -1922,11 +1922,10 @@ function Raygui:checkScrolling()
end
function Raygui:clickedInBounds( bounds )
print( self._mousePressPos, bounds )
return RL.CheckCollisionPointRec( self._mousePressPos, bounds )
end
function Raygui:set2Top( control )
function Raygui:setToTop( control )
for i, curControl in ipairs( self.controls ) do
if control == curControl then
Util.tableMove( self.controls, i, 1, #self.controls )
@@ -1936,7 +1935,7 @@ function Raygui:set2Top( control )
end
end
function Raygui:set2Back( control )
function Raygui:setToBack( control )
for i, curControl in ipairs( self.controls ) do
if control == curControl then
Util.tableMove( self.controls, i, 1, 1 )

View File

@@ -3,6 +3,7 @@ local spacing = 1
local rect = { 100, 64, 200, 200 }
local wordwrap = true
local linkColor = RL.BLUE
local limitHeight = true
local mouseCharId = 0
local textOffset = { 0, 0 }
@@ -34,21 +35,21 @@ function RL.draw()
mouseCharId, textOffset = RL.DrawTextBoxedEx(
RL.GetFontDefault(),
"You can change the size of the box by pressing right mouse and toggle the wordwrap by pressing space. First we will write some text before the hyperlink to show that it is indeed is as powerful feature as adverticed.",
"\tYou can change the size of the box by pressing right mouse and toggle the wordwrap by pressing space. First we will write some text before the hyperlink to show that it is indeed is as powerful feature as adverticed.",
rect,
textSize, spacing, wordwrap, RL.RED, { 0, 0 }
textSize, spacing, wordwrap, RL.RED, limitHeight, { 0, 0 }
)
mouseCharId, textOffset = RL.DrawTextBoxedEx(
RL.GetFontDefault(),
" Hyperlink.",
rect,
textSize, spacing, wordwrap, linkColor, textOffset
textSize, spacing, wordwrap, linkColor, limitHeight, textOffset
)
RL.DrawTextBoxedEx(
RL.GetFontDefault(),
" Then we demonstrate this further by writin more text after the link. Isn't this just amazing! Don't forget to press left mouse to print text to your console when hovering mouse over the hyperlink.",
rect,
textSize, spacing, wordwrap, RL.RED, textOffset
textSize, spacing, wordwrap, RL.RED, limitHeight, textOffset
)
if 0 < mouseCharId then
@@ -57,4 +58,3 @@ function RL.draw()
linkColor = RL.BLUE
end
end