My train of thought for my code:
Code: Select all
MyLabel.AutoNewLine = False;
MyLabel.Size[0] = MathLib::Min(MyLabel.ComputeWidth(MyLabel.Value), 80.);
// Thinking that Autonewline only works on a given size, so I calculate my needed size first
MyLabel.AutoNewLine = True;
// Turn it back on, so it can wrap lines and calculate the LineCount
declare Integer LineCount = MyLabel.ValueLineCount;
// It doesn't seem to care about newlines
declare Text[] Helper = TextLib::Split("\n", MyLabel.Value);
LineCount += Helper.count - 1;
MyLabel.Size[1] = LineCount * 4.;

Oh and another problem I encountered: ComputeWidth seems to calculate the last line's width, not the longest line's.


My complete extract of code for interested readers:Code: Select all
_Toast_Label.Value = TextLib::Trim(_Toast_Queue[0]); _Toast_Label.AutoNewLine = False; _Toast_Label.Size[0] = TextLib::Min(80., _Toast_Label.ComputeWidth(_Toast_Label.Value)); _Toast_Label.AutoNewLine = True; declare Integer LineCount = _Toast_Label.ValueLineCount; declare Text[] Helper = TextLib::Split("\n", _Toast_Label.Value); LineCount += Helper.count - 1; _Toast_Label.Size[1] = LineCount * 4.; _Toast_Label.Show(); _Toast_Background.Size = _Toast_Label.Size + <6., 4.>; log(LineCount); // The call for the image above logs 1 _Toast_Background.Show();