Skip to content

Commit

Permalink
[SlabTest]
Browse files Browse the repository at this point in the history
Added example of multi-line tooltip.

[Tooltip]
#15
Support for multi-line tooltips.
  • Loading branch information
coding-jackalope committed Apr 6, 2020
1 parent ffaef87 commit 87231b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Internal/UI/Text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ function Text.BeginFormatted(Label, Options)
Options.W = Options.W == nil and WinW or Options.W
Options.Align = Options.Align == nil and 'left' or Options.Align

if Window.IsAutoSize() then
Options.W = love.graphics.getWidth()
end

local Width, Wrapped = Style.Font:getWrap(Label, Options.W)
local H = #Wrapped * Style.Font:getHeight()

Expand Down
2 changes: 1 addition & 1 deletion Internal/UI/Tooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function Tooltip.Begin(Tip)
ResetWindowSize = ResetSize,
CanObstruct = false
})
Text.Begin(Tip, {Color = TextColor})
Text.BeginFormatted(Tip, {Color = TextColor})
OffsetY = Window.GetHeight()
Window.End()
LayoutManager.End()
Expand Down
4 changes: 4 additions & 0 deletions SlabTest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1747,6 +1747,10 @@ local function DrawTooltip()
Slab.BeginTree('DrawTooltip_Tree_Child', {Label = "Child", Tooltip = "This is the child tree item.", IsLeaf = true})
Slab.EndTree()
end

Slab.NewLine()

Slab.Button("MultiLine Tooltip", {Tooltip = "This is a multi-line tooltip.\nThis is the second line."})
end

local DrawStats_SetPosition = false
Expand Down

0 comments on commit 87231b8

Please sign in to comment.