Open nebula-codes opened 7 months ago
Idk if it is what autoWidth is supposed to do, but if so it didn't do that
TextLabel is meant to be a lightweight implementation of of text, whereas the Text class it much more feature rich but also heavier in resources. Autowidth in TextLabel merely sets the width equal to the text fed into it. If you have any other questions, feel free to open more issues.
I can understand it being lighter, but is centering text really considered heavy? Its just styling, not functionality
It would be a nice addition to be able to center the text within a label so that we can make a header with centered text in 1 shot instead of stacking a rectangle with a label on top centered to the screen.
Unless I am missing something about it, but for now I am centering with the following code:
local function drawHeader(frame, text, color) local textWidth = #text local frameWidth = frame:width() local xPos = math.floor((frameWidth - textWidth) / 2) local header = gui.TextLabel(frame, xPos, 1, text, 0xffffff) -- 0xffffff is white header:width(width) header:backgroundColor(color) end
And just having a rectangle under it at full width with the same background color.