Changed naming of gui functions set2Top and set2Back to setToTop and setToBack.
This commit is contained in:
6
API.md
6
API.md
@@ -6858,13 +6858,15 @@ Draw multiple character (codepoint)
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
> RL.DrawTextBoxed(Font font, string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint )
|
> mouseCharId, textOffset = RL.DrawTextBoxed(Font font, string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, bool limitHeight )
|
||||||
|
|
||||||
Draw text using font inside rectangle limits.
|
Draw text using font inside rectangle limits.
|
||||||
|
|
||||||
|
- Success return int, Vector2
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
> mouseCharId, textOffset = RL.DrawTextBoxedEx( Font font, string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, Vector2 textOffset )
|
> mouseCharId, textOffset = RL.DrawTextBoxedEx( Font font, string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, bool limitHeight, Vector2 textOffset )
|
||||||
|
|
||||||
Draw text using font inside rectangle limits. Return character id from mouse position (default 0).
|
Draw text using font inside rectangle limits. Return character id from mouse position (default 0).
|
||||||
textOffset can be used to set start position inside rectangle. Usefull to pass from previous
|
textOffset can be used to set start position inside rectangle. Usefull to pass from previous
|
||||||
|
|||||||
@@ -4045,6 +4045,7 @@ function RL.DrawTextCodepoint( font, codepoint, position, fontSize, tint ) end
|
|||||||
function RL.DrawTextCodepoints( font, codepoints, position, fontSize, spacing, tint ) end
|
function RL.DrawTextCodepoints( font, codepoints, position, fontSize, spacing, tint ) end
|
||||||
|
|
||||||
---Draw text using font inside rectangle limits.
|
---Draw text using font inside rectangle limits.
|
||||||
|
---- Success return int, Vector2
|
||||||
---@param font any
|
---@param font any
|
||||||
---@param text string
|
---@param text string
|
||||||
---@param rec table
|
---@param rec table
|
||||||
@@ -4052,8 +4053,10 @@ function RL.DrawTextCodepoints( font, codepoints, position, fontSize, spacing,
|
|||||||
---@param spacing number
|
---@param spacing number
|
||||||
---@param wordWrap boolean
|
---@param wordWrap boolean
|
||||||
---@param tint table
|
---@param tint table
|
||||||
---@return any RL.DrawTextBoxed
|
---@param limitHeight boolean
|
||||||
function RL.DrawTextBoxed( font, text, rec, fontSize, spacing, wordWrap, tint ) end
|
---@return any mouseCharId
|
||||||
|
---@return any textOffset
|
||||||
|
function RL.DrawTextBoxed( font, text, rec, fontSize, spacing, wordWrap, tint, limitHeight ) end
|
||||||
|
|
||||||
---Draw text using font inside rectangle limits. Return character id from mouse position (default 0).
|
---Draw text using font inside rectangle limits. Return character id from mouse position (default 0).
|
||||||
---textOffset can be used to set start position inside rectangle. Usefull to pass from previous
|
---textOffset can be used to set start position inside rectangle. Usefull to pass from previous
|
||||||
@@ -4066,10 +4069,11 @@ function RL.DrawTextBoxed( font, text, rec, fontSize, spacing, wordWrap, tint )
|
|||||||
---@param spacing number
|
---@param spacing number
|
||||||
---@param wordWrap boolean
|
---@param wordWrap boolean
|
||||||
---@param tint table
|
---@param tint table
|
||||||
|
---@param limitHeight boolean
|
||||||
---@param textOffset table
|
---@param textOffset table
|
||||||
---@return any mouseCharId
|
---@return any mouseCharId
|
||||||
---@return any textOffset
|
---@return any textOffset
|
||||||
function RL.DrawTextBoxedEx( font, text, rec, fontSize, spacing, wordWrap, tint, textOffset ) end
|
function RL.DrawTextBoxedEx( font, text, rec, fontSize, spacing, wordWrap, tint, limitHeight, textOffset ) end
|
||||||
|
|
||||||
-- Text - Text font info functions
|
-- Text - Text font info functions
|
||||||
|
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ DETAILED CHANGES:
|
|||||||
- ADDED: GetTextLineSpacing.
|
- ADDED: GetTextLineSpacing.
|
||||||
- REMOVED: DrawTextBoxedTinted. DrawTextBoxedEx can do same much more efficiently.
|
- REMOVED: DrawTextBoxedTinted. DrawTextBoxedEx can do same much more efficiently.
|
||||||
- ADDED: DrawTextBoxedEx.
|
- ADDED: DrawTextBoxedEx.
|
||||||
|
- CHANGE: Naming of gui functions set2Top and set2Back to setToTop and setToBack.
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0
|
Release: ReiLua version 0.7.0 Using Raylib 5.0 and Forked Raygui 4.0
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ function Calculator:new( pos )
|
|||||||
bounds = Rect:new( 0, 0, object.windowRect.width, object.HANDLE_HIGHT ),
|
bounds = Rect:new( 0, 0, object.windowRect.width, object.HANDLE_HIGHT ),
|
||||||
padding = 10,
|
padding = 10,
|
||||||
onClicked = function()
|
onClicked = function()
|
||||||
object:set2Top()
|
object:setToTop()
|
||||||
object.dragPos = Vec2:newT( RL.GetMousePosition() ) - Vec2:new( object.handle.bounds.x, object.handle.bounds.y )
|
object.dragPos = Vec2:newT( RL.GetMousePosition() ) - Vec2:new( object.handle.bounds.x, object.handle.bounds.y )
|
||||||
Gui.heldCallback = function() object:drag() end
|
Gui.heldCallback = function() object:drag() end
|
||||||
end,
|
end,
|
||||||
@@ -186,16 +186,16 @@ function Calculator:setVisible( visible )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Calculator:set2Top()
|
function Calculator:setToTop()
|
||||||
self.panel:set2Top()
|
self.panel:setToTop()
|
||||||
|
|
||||||
for _, button in ipairs( self.buttons ) do
|
for _, button in ipairs( self.buttons ) do
|
||||||
button:set2Top()
|
button:setToTop()
|
||||||
end
|
end
|
||||||
|
|
||||||
self.handle:set2Top()
|
self.handle:setToTop()
|
||||||
self.closeButton:set2Top()
|
self.closeButton:setToTop()
|
||||||
self.display:set2Top()
|
self.display:setToTop()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Calculator:addValue( value )
|
function Calculator:addValue( value )
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ function FileExplorer:new( pos )
|
|||||||
bounds = Rect:new( 0, 0, object.windowRect.width, object.HANDLE_HIGHT ),
|
bounds = Rect:new( 0, 0, object.windowRect.width, object.HANDLE_HIGHT ),
|
||||||
padding = 10,
|
padding = 10,
|
||||||
onClicked = function()
|
onClicked = function()
|
||||||
object:set2Top()
|
object:setToTop()
|
||||||
object.dragPos = Vec2:newT( RL.GetMousePosition() ) - Vec2:new( object.handle.bounds.x, object.handle.bounds.y )
|
object.dragPos = Vec2:newT( RL.GetMousePosition() ) - Vec2:new( object.handle.bounds.x, object.handle.bounds.y )
|
||||||
Gui.heldCallback = function() object:drag() end
|
Gui.heldCallback = function() object:drag() end
|
||||||
end,
|
end,
|
||||||
@@ -305,15 +305,15 @@ function FileExplorer:setVisible( visible )
|
|||||||
self.files:update()
|
self.files:update()
|
||||||
end
|
end
|
||||||
|
|
||||||
function FileExplorer:set2Top()
|
function FileExplorer:setToTop()
|
||||||
self.panel:set2Top()
|
self.panel:setToTop()
|
||||||
self.handle:set2Top()
|
self.handle:setToTop()
|
||||||
self.closeButton:set2Top()
|
self.closeButton:setToTop()
|
||||||
self.pathBox:set2Top()
|
self.pathBox:setToTop()
|
||||||
self.backButton:set2Top()
|
self.backButton:setToTop()
|
||||||
self.files:set2Top()
|
self.files:setToTop()
|
||||||
self.fileName:set2Top()
|
self.fileName:setToTop()
|
||||||
self.openButton:set2Top()
|
self.openButton:setToTop()
|
||||||
end
|
end
|
||||||
|
|
||||||
return FileExplorer
|
return FileExplorer
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ local guiTabBarActive = 0
|
|||||||
local colorPickerHSV = { 0, 0, 0 }
|
local colorPickerHSV = { 0, 0, 0 }
|
||||||
local colorPanelHSV = { 0, 0, 0 }
|
local colorPanelHSV = { 0, 0, 0 }
|
||||||
|
|
||||||
|
local value = 0
|
||||||
|
|
||||||
function RL.init()
|
function RL.init()
|
||||||
local monitor = 0
|
local monitor = 0
|
||||||
local mPos = RL.GetMonitorPosition( monitor )
|
local mPos = RL.GetMonitorPosition( monitor )
|
||||||
@@ -121,4 +123,6 @@ function RL.draw()
|
|||||||
|
|
||||||
_, colorPickerHSV = RL.GuiColorPickerHSV( { 1024, 20, 150, 150 }, "GuiColorPuckerHSV", colorPickerHSV )
|
_, colorPickerHSV = RL.GuiColorPickerHSV( { 1024, 20, 150, 150 }, "GuiColorPuckerHSV", colorPickerHSV )
|
||||||
_, colorPanelHSV = RL.GuiColorPanelHSV( { 1230, 20, 150, 150 }, "GuiColorPuckerHSV", colorPanelHSV )
|
_, colorPanelHSV = RL.GuiColorPanelHSV( { 1230, 20, 150, 150 }, "GuiColorPuckerHSV", colorPanelHSV )
|
||||||
|
|
||||||
|
value = RL.GuiScrollBar( { 0, 0, 10, 200 }, value, 0, 100 )
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ function Calculator:new( pos )
|
|||||||
"Calculator",
|
"Calculator",
|
||||||
{ -- Callbacks.
|
{ -- Callbacks.
|
||||||
close = function() object:setVisible( false ) end,
|
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
|
drag = function( this ) object:setPosition( Vec2:new( this.bounds.x, this.bounds.y ) ) end
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -137,12 +137,12 @@ function Calculator:setPosition( pos )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Calculator:set2Top()
|
function Calculator:setToTop()
|
||||||
Gui:set2Top( self.window )
|
Gui:setToTop( self.window )
|
||||||
Gui:set2Top( self.display )
|
Gui:setToTop( self.display )
|
||||||
|
|
||||||
for _, button in ipairs( self.buttons ) do
|
for _, button in ipairs( self.buttons ) do
|
||||||
Gui:set2Top( button )
|
Gui:setToTop( button )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ function FileBrowser:new( pos )
|
|||||||
"File Browser",
|
"File Browser",
|
||||||
{ -- callbacks.
|
{ -- callbacks.
|
||||||
close = function() object:setVisible( false ) end,
|
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
|
drag = function( this ) object:setPosition( Vec2:new( this.bounds.x, this.bounds.y ) ) end
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -363,11 +363,11 @@ function FileBrowser:setPosition( pos )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function FileBrowser:set2Top()
|
function FileBrowser:setToTop()
|
||||||
Gui:set2Top( self.window )
|
Gui:setToTop( self.window )
|
||||||
|
|
||||||
for _, control in ipairs( self.controls ) do
|
for _, control in ipairs( self.controls ) do
|
||||||
Gui:set2Top( control )
|
Gui:setToTop( control )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ local function addPropertyList()
|
|||||||
Rect:new( 20, 20, 256, 328 ),
|
Rect:new( 20, 20, 256, 328 ),
|
||||||
"Property List",
|
"Property List",
|
||||||
{ -- Callbacks.
|
{ -- Callbacks.
|
||||||
grab = function( self ) Gui:set2Top( self ) end,
|
grab = function( self ) Gui:setToTop( self ) end,
|
||||||
},
|
},
|
||||||
{ -- Styles.
|
{ -- Styles.
|
||||||
properties = {
|
properties = {
|
||||||
@@ -272,7 +272,7 @@ local function addTreeView()
|
|||||||
"Tree View",
|
"Tree View",
|
||||||
{ -- Callbacks.
|
{ -- Callbacks.
|
||||||
select = function( controls ) selected( controls ) end,
|
select = function( controls ) selected( controls ) end,
|
||||||
grab = function( self ) Gui:set2Top( self ) end,
|
grab = function( self ) Gui:setToTop( self ) end,
|
||||||
},
|
},
|
||||||
{ -- Styles.
|
{ -- Styles.
|
||||||
properties = {
|
properties = {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ function PropertyList:updateControl( control )
|
|||||||
|
|
||||||
control.text = setGroupText( control.text:sub( 6 ), control.active ) -- Sub skips icon.
|
control.text = setGroupText( control.text:sub( 6 ), control.active ) -- Sub skips icon.
|
||||||
end
|
end
|
||||||
self.gui:set2Back( control )
|
self.gui:setToBack( control )
|
||||||
end
|
end
|
||||||
|
|
||||||
function PropertyList:updateContent()
|
function PropertyList:updateContent()
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ function RL.init()
|
|||||||
"WindowBox",
|
"WindowBox",
|
||||||
{ -- Callbacks.
|
{ -- Callbacks.
|
||||||
close = function( self ) self.visible = false end,
|
close = function( self ) self.visible = false end,
|
||||||
grab = function( self ) Gui:set2Top( self ) end,
|
grab = function( self ) Gui:setToTop( self ) end,
|
||||||
},
|
},
|
||||||
{ -- Styles.
|
{ -- Styles.
|
||||||
properties = {
|
properties = {
|
||||||
@@ -230,7 +230,7 @@ function RL.init()
|
|||||||
Rect:new( 400, 64, 256, 128 ),
|
Rect:new( 400, 64, 256, 128 ),
|
||||||
"Panel",
|
"Panel",
|
||||||
{ -- Callbacks.
|
{ -- Callbacks.
|
||||||
grab = function( self ) Gui:set2Top( self ) end
|
grab = function( self ) Gui:setToTop( self ) end
|
||||||
},
|
},
|
||||||
{ -- Styles.
|
{ -- Styles.
|
||||||
properties = {
|
properties = {
|
||||||
@@ -255,7 +255,7 @@ function RL.init()
|
|||||||
Vec2:new( 0, 0 ),
|
Vec2:new( 0, 0 ),
|
||||||
{ -- Callbacks.
|
{ -- Callbacks.
|
||||||
scroll = function( self ) print( self.scroll ) end,
|
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(
|
local listview = Gui:ListView(
|
||||||
@@ -300,7 +300,7 @@ function RL.init()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
grab = function( self ) Gui:set2Top( self ) end
|
grab = function( self ) Gui:setToTop( self ) end
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
local textinputbox = Gui:TextInputBox(
|
local textinputbox = Gui:TextInputBox(
|
||||||
@@ -317,7 +317,7 @@ function RL.init()
|
|||||||
print( "You pressed "..self:getItem( self.buttonIndex ) )
|
print( "You pressed "..self:getItem( self.buttonIndex ) )
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
grab = function( self ) Gui:set2Top( self ) end
|
grab = function( self ) Gui:setToTop( self ) end
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
local colorpicker = Gui:ColorPicker(
|
local colorpicker = Gui:ColorPicker(
|
||||||
|
|||||||
@@ -95,11 +95,11 @@ function Gui.delete( cell )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Gui.set2Top( cell )
|
function Gui.setToTop( cell )
|
||||||
Util.tableMove( Gui._cells, Gui.getId( cell ), 1, #Gui._cells )
|
Util.tableMove( Gui._cells, Gui.getId( cell ), 1, #Gui._cells )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Gui.set2Back( cell )
|
function Gui.setToBack( cell )
|
||||||
Util.tableMove( Gui._cells, Gui.getId( cell ), 1, 1 )
|
Util.tableMove( Gui._cells, Gui.getId( cell ), 1, 1 )
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -518,12 +518,12 @@ function Element:delete()
|
|||||||
Gui.delete( self )
|
Gui.delete( self )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Element:set2Top()
|
function Element:setToTop()
|
||||||
Gui.set2Top( self )
|
Gui.setToTop( self )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Element:set2Back()
|
function Element:setToBack()
|
||||||
Gui.set2Back( self )
|
Gui.setToBack( self )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Container.
|
-- Container.
|
||||||
@@ -820,34 +820,34 @@ function Container:clear()
|
|||||||
self.cells = {}
|
self.cells = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
function Container:set2Top()
|
function Container:setToTop()
|
||||||
Gui.set2Top( self )
|
Gui.setToTop( self )
|
||||||
|
|
||||||
for _, cell in ipairs( self.cells ) do
|
for _, cell in ipairs( self.cells ) do
|
||||||
cell:set2Top()
|
cell:setToTop()
|
||||||
end
|
end
|
||||||
|
|
||||||
if self._VScrollbar ~= nil then
|
if self._VScrollbar ~= nil then
|
||||||
Gui.set2Top( self._VScrollbar )
|
Gui.setToTop( self._VScrollbar )
|
||||||
end
|
end
|
||||||
if self._HScrollbar ~= nil then
|
if self._HScrollbar ~= nil then
|
||||||
Gui.set2Top( self._HScrollbar )
|
Gui.setToTop( self._HScrollbar )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Container:set2Back()
|
function Container:setToBack()
|
||||||
if self._VScrollbar ~= nil then
|
if self._VScrollbar ~= nil then
|
||||||
Gui.set2Back( self._VScrollbar )
|
Gui.setToBack( self._VScrollbar )
|
||||||
end
|
end
|
||||||
if self._HScrollbar ~= nil then
|
if self._HScrollbar ~= nil then
|
||||||
Gui.set2Back( self._HScrollbar )
|
Gui.setToBack( self._HScrollbar )
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, cell in ipairs( self.cells ) do
|
for _, cell in ipairs( self.cells ) do
|
||||||
cell:set2Back()
|
cell:setToBack()
|
||||||
end
|
end
|
||||||
|
|
||||||
Gui.set2Back( self )
|
Gui.setToBack( self )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Container:draw()
|
function Container:draw()
|
||||||
|
|||||||
@@ -1922,11 +1922,10 @@ function Raygui:checkScrolling()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Raygui:clickedInBounds( bounds )
|
function Raygui:clickedInBounds( bounds )
|
||||||
print( self._mousePressPos, bounds )
|
|
||||||
return RL.CheckCollisionPointRec( self._mousePressPos, bounds )
|
return RL.CheckCollisionPointRec( self._mousePressPos, bounds )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Raygui:set2Top( control )
|
function Raygui:setToTop( control )
|
||||||
for i, curControl in ipairs( self.controls ) do
|
for i, curControl in ipairs( self.controls ) do
|
||||||
if control == curControl then
|
if control == curControl then
|
||||||
Util.tableMove( self.controls, i, 1, #self.controls )
|
Util.tableMove( self.controls, i, 1, #self.controls )
|
||||||
@@ -1936,7 +1935,7 @@ function Raygui:set2Top( control )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Raygui:set2Back( control )
|
function Raygui:setToBack( control )
|
||||||
for i, curControl in ipairs( self.controls ) do
|
for i, curControl in ipairs( self.controls ) do
|
||||||
if control == curControl then
|
if control == curControl then
|
||||||
Util.tableMove( self.controls, i, 1, 1 )
|
Util.tableMove( self.controls, i, 1, 1 )
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ local spacing = 1
|
|||||||
local rect = { 100, 64, 200, 200 }
|
local rect = { 100, 64, 200, 200 }
|
||||||
local wordwrap = true
|
local wordwrap = true
|
||||||
local linkColor = RL.BLUE
|
local linkColor = RL.BLUE
|
||||||
|
local limitHeight = true
|
||||||
local mouseCharId = 0
|
local mouseCharId = 0
|
||||||
local textOffset = { 0, 0 }
|
local textOffset = { 0, 0 }
|
||||||
|
|
||||||
@@ -34,21 +35,21 @@ function RL.draw()
|
|||||||
|
|
||||||
mouseCharId, textOffset = RL.DrawTextBoxedEx(
|
mouseCharId, textOffset = RL.DrawTextBoxedEx(
|
||||||
RL.GetFontDefault(),
|
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,
|
rect,
|
||||||
textSize, spacing, wordwrap, RL.RED, { 0, 0 }
|
textSize, spacing, wordwrap, RL.RED, limitHeight, { 0, 0 }
|
||||||
)
|
)
|
||||||
mouseCharId, textOffset = RL.DrawTextBoxedEx(
|
mouseCharId, textOffset = RL.DrawTextBoxedEx(
|
||||||
RL.GetFontDefault(),
|
RL.GetFontDefault(),
|
||||||
" Hyperlink.",
|
" Hyperlink.",
|
||||||
rect,
|
rect,
|
||||||
textSize, spacing, wordwrap, linkColor, textOffset
|
textSize, spacing, wordwrap, linkColor, limitHeight, textOffset
|
||||||
)
|
)
|
||||||
RL.DrawTextBoxedEx(
|
RL.DrawTextBoxedEx(
|
||||||
RL.GetFontDefault(),
|
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.",
|
" 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,
|
rect,
|
||||||
textSize, spacing, wordwrap, RL.RED, textOffset
|
textSize, spacing, wordwrap, RL.RED, limitHeight, textOffset
|
||||||
)
|
)
|
||||||
|
|
||||||
if 0 < mouseCharId then
|
if 0 < mouseCharId then
|
||||||
@@ -57,4 +58,3 @@ function RL.draw()
|
|||||||
linkColor = RL.BLUE
|
linkColor = RL.BLUE
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
35
src/text.c
35
src/text.c
@@ -25,10 +25,11 @@ static float measureWord( Font font, char* text, float fontSize, float spacing )
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int DrawTextBoxed( Font font, char* text, Rectangle rec, float fontSize,
|
static int DrawTextBoxed( Font font, char* text, Rectangle rec, float fontSize,
|
||||||
float spacing, bool wordWrap, Color tint, Vector2* textOffset, bool getMouseChar ) {
|
float spacing, bool wordWrap, Color tint, bool limitHeight, Vector2* textOffset ) {
|
||||||
|
const int tabSize = 4; /* How many spaces. */
|
||||||
int lineSpacing = state->lineSpacing;
|
int lineSpacing = state->lineSpacing;
|
||||||
|
|
||||||
if ( rec.width <= 0 || rec.height <= ( textOffset->y + lineSpacing ) ) {
|
if ( rec.width <= 0 || ( rec.height <= limitHeight ? ( textOffset->y + lineSpacing ) : 0 ) ) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,20 +74,21 @@ float spacing, bool wordWrap, Color tint, Vector2* textOffset, bool getMouseChar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( rec.height < ( textOffset->y + lineSpacing ) ) {
|
if ( limitHeight && ( rec.height < ( textOffset->y + lineSpacing ) ) ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( codepoint != '\n' && !( textOffset->x == 0 && codepoint == ' ' ) && codepointWidth < rec.width ) {
|
if ( codepoint != '\n' && codepoint != '\t' && !( textOffset->x == 0 && codepoint == ' ' ) && codepointWidth < rec.width ) {
|
||||||
DrawTextCodepoint( font, codepoint, (Vector2){ rec.x + textOffset->x, rec.y + textOffset->y }, fontSize, tint );
|
DrawTextCodepoint( font, codepoint, (Vector2){ round( rec.x + textOffset->x ), round( rec.y + textOffset->y ) }, fontSize, tint );
|
||||||
|
|
||||||
if ( getMouseChar && CheckCollisionPointRec( mousePos, (Rectangle){ rec.x + textOffset->x - 1, rec.y + textOffset->y, codepointWidth, (float)font.baseSize * scaleFactor } ) ) {
|
if ( CheckCollisionPointRec( mousePos, (Rectangle){ rec.x + textOffset->x - 1, rec.y + textOffset->y, codepointWidth, (float)font.baseSize * scaleFactor } ) ) {
|
||||||
mouseChar = i + 1;
|
mouseChar = i + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
textOffset->x += codepointWidth;
|
textOffset->x += codepointWidth;
|
||||||
}
|
}
|
||||||
|
else if ( codepoint == '\t' ) {
|
||||||
|
textOffset->x += (float)font.recs[ GetGlyphIndex( font, ' ' ) ].width * tabSize * scaleFactor + spacing;
|
||||||
|
}
|
||||||
i += codepointByteCount;
|
i += codepointByteCount;
|
||||||
}
|
}
|
||||||
return mouseChar;
|
return mouseChar;
|
||||||
@@ -516,9 +518,11 @@ int ltextDrawTextCodepoints( lua_State* L ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
> RL.DrawTextBoxed(Font font, string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint )
|
> mouseCharId, textOffset = RL.DrawTextBoxed(Font font, string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, bool limitHeight )
|
||||||
|
|
||||||
Draw text using font inside rectangle limits.
|
Draw text using font inside rectangle limits.
|
||||||
|
|
||||||
|
- Success return int, Vector2
|
||||||
*/
|
*/
|
||||||
int ltextDrawTextBoxed( lua_State* L ) {
|
int ltextDrawTextBoxed( lua_State* L ) {
|
||||||
Font* font = uluaGetFont( L, 1 );
|
Font* font = uluaGetFont( L, 1 );
|
||||||
@@ -528,15 +532,17 @@ int ltextDrawTextBoxed( lua_State* L ) {
|
|||||||
float spacing = luaL_checknumber( L, 5 );
|
float spacing = luaL_checknumber( L, 5 );
|
||||||
bool wordWrap = uluaGetBoolean( L, 6 );
|
bool wordWrap = uluaGetBoolean( L, 6 );
|
||||||
Color tint = uluaGetColor( L, 7 );
|
Color tint = uluaGetColor( L, 7 );
|
||||||
|
bool limitHeight = uluaGetBoolean( L, 8 );
|
||||||
Vector2 textOffset = { 0, 0 };
|
Vector2 textOffset = { 0, 0 };
|
||||||
|
|
||||||
DrawTextBoxed( *font, text, rec, fontSize, spacing, wordWrap, tint, &textOffset, false );
|
lua_pushinteger( L, DrawTextBoxed( *font, text, rec, fontSize, spacing, wordWrap, tint, limitHeight, &textOffset ) );
|
||||||
|
uluaPushVector2( L, textOffset );
|
||||||
|
|
||||||
return 0;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
> mouseCharId, textOffset = RL.DrawTextBoxedEx( Font font, string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, Vector2 textOffset )
|
> mouseCharId, textOffset = RL.DrawTextBoxedEx( Font font, string text, Rectangle rec, float fontSize, float spacing, bool wordWrap, Color tint, bool limitHeight, Vector2 textOffset )
|
||||||
|
|
||||||
Draw text using font inside rectangle limits. Return character id from mouse position (default 0).
|
Draw text using font inside rectangle limits. Return character id from mouse position (default 0).
|
||||||
textOffset can be used to set start position inside rectangle. Usefull to pass from previous
|
textOffset can be used to set start position inside rectangle. Usefull to pass from previous
|
||||||
@@ -552,9 +558,10 @@ int ltextDrawTextBoxedEx( lua_State* L ) {
|
|||||||
float spacing = luaL_checknumber( L, 5 );
|
float spacing = luaL_checknumber( L, 5 );
|
||||||
bool wordWrap = uluaGetBoolean( L, 6 );
|
bool wordWrap = uluaGetBoolean( L, 6 );
|
||||||
Color tint = uluaGetColor( L, 7 );
|
Color tint = uluaGetColor( L, 7 );
|
||||||
Vector2 textOffset = uluaGetVector2( L, 8 );
|
bool limitHeight = uluaGetBoolean( L, 8 );
|
||||||
|
Vector2 textOffset = uluaGetVector2( L, 9 );
|
||||||
|
|
||||||
lua_pushinteger( L, DrawTextBoxed( *font, text, rec, fontSize, spacing, wordWrap, tint, &textOffset, true ) );
|
lua_pushinteger( L, DrawTextBoxed( *font, text, rec, fontSize, spacing, wordWrap, tint, limitHeight, &textOffset ) );
|
||||||
uluaPushVector2( L, textOffset );
|
uluaPushVector2( L, textOffset );
|
||||||
|
|
||||||
return 2;
|
return 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user