(lbs []string, col bool)
| 52 | } |
| 53 | |
| 54 | func (tg *SimMatGrid) SizeLabel(lbs []string, col bool) (minBlank, ngps int, sz math32.Vector2) { |
| 55 | mx := 0 |
| 56 | mxi := 0 |
| 57 | minBlank = len(lbs) |
| 58 | if minBlank == 0 { |
| 59 | return |
| 60 | } |
| 61 | curblk := 0 |
| 62 | ngps = 0 |
| 63 | for i, lb := range lbs { |
| 64 | l := len(lb) |
| 65 | if l == 0 { |
| 66 | curblk++ |
| 67 | } else { |
| 68 | if curblk > 0 { |
| 69 | ngps++ |
| 70 | } |
| 71 | if i > 0 { |
| 72 | minBlank = min(minBlank, curblk) |
| 73 | } |
| 74 | curblk = 0 |
| 75 | if l > mx { |
| 76 | mx = l |
| 77 | mxi = i |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | minBlank = min(minBlank, curblk) |
| 82 | tr := paint.Text{} |
| 83 | fr := tg.Styles.FontRender() |
| 84 | if col { |
| 85 | tr.SetStringRot90(lbs[mxi], fr, &tg.Styles.UnitContext, &tg.Styles.Text, true, 0) |
| 86 | } else { |
| 87 | tr.SetString(lbs[mxi], fr, &tg.Styles.UnitContext, &tg.Styles.Text, true, 0, 0) |
| 88 | } |
| 89 | tsz := tg.Geom.Size.Actual.Content |
| 90 | if !col { |
| 91 | tr.LayoutStdLR(&tg.Styles.Text, fr, &tg.Styles.UnitContext, tsz) |
| 92 | } |
| 93 | return minBlank, ngps, tr.BBox.Size() |
| 94 | } |
| 95 | |
| 96 | func (tg *SimMatGrid) MinSize() math32.Vector2 { |
| 97 | tg.rowMinBlank, tg.rowNGps, tg.rowMaxSz = tg.SizeLabel(tg.SimMat.Rows, false) |
no test coverage detected