configTextAlloc is used for determining how much space the text takes, using given size (typically Alloc). In this case, alignment factors are turned off, because they otherwise can absorb much more space, which should instead be controlled by the base Align X,Y factors.
(sz math32.Vector2)
| 305 | // because they otherwise can absorb much more space, which should |
| 306 | // instead be controlled by the base Align X,Y factors. |
| 307 | func (tx *Text) configTextAlloc(sz math32.Vector2) math32.Vector2 { |
| 308 | // todo: last arg is CSSAgg. Can synthesize that some other way? |
| 309 | fs := tx.Styles.FontRender() |
| 310 | txs := &tx.Styles.Text |
| 311 | align, alignV := txs.Align, txs.AlignV |
| 312 | txs.Align, txs.AlignV = styles.Start, styles.Start |
| 313 | tx.paintText.SetHTML(tx.Text, fs, txs, &tx.Styles.UnitContext, nil) |
| 314 | tx.paintText.Layout(txs, fs, &tx.Styles.UnitContext, sz) |
| 315 | rsz := tx.paintText.BBox.Size().Ceil() |
| 316 | txs.Align, txs.AlignV = align, alignV |
| 317 | tx.paintText.Layout(txs, fs, &tx.Styles.UnitContext, rsz) |
| 318 | return rsz |
| 319 | } |
| 320 | |
| 321 | func (tx *Text) SizeUp() { |
| 322 | tx.WidgetBase.SizeUp() // sets Actual size based on styles |