Closed togfoxy closed 3 years ago
Perhaps X and Y is being passed incorrectly?
local function DrawTextFormatted(Text)
local StatHandle = Stats.Begin('DrawTextFormatted', StatsCategory)
print(Text.Text, Text.X, Text.Y, Text.W, Text.Align)
love.graphics.setFont(Text.Font)
love.graphics.setColor(Text.Color)
love.graphics.printf(Text.Text, Text.X, Text.Y, Text.W, Text.Align)
Stats.End(StatHandle)
end
Did a workaround with
Slab.BeginLayout('mylayout', {AlignX = 'center'})
Is this intended behaviour?
Hi @togfoxy, yes Slab.BeginLayout is the intended behavior for aligning controls to a specific layout. Be sure to call Slab.EndLayout when you are finished with controls that need to be affected by this layout.
If you feel the layout system is confusing or limited, feel free to let me know. This feature is really early and will be updated frequently as more developers use this system. I am also currently working on a 'Panel' control which should give developers another way of organizing their controls.
I guess the original comment was that I can't align text with textf unless the provided text is long enough to wrap. I'll do some more testing.
Regarding layout, it was very intuitive and worked first time. :)
Slab.Textf("some text",{Align = 'center'})
will center correctly if SOME TEXT expands across more than one line (i.e. wraps). Using 'Align' on a short string should center that text on that one line based on the window width instead of left aligning against the left margin.